From 90ab439a39d101d752cc5c209af221753eb4600b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 14 Jul 2021 08:50:33 -0400 Subject: [PATCH 1/2] update logging --- module/go.sum | 2 -- module/x/gravity/abci.go | 3 ++- .../x/gravity/keeper/ethereum_event_vote.go | 3 ++- module/x/gravity/keeper/keeper.go | 23 ++++++++----------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/module/go.sum b/module/go.sum index 76a945a60..4cb6b63a9 100644 --- a/module/go.sum +++ b/module/go.sum @@ -131,8 +131,6 @@ github.com/cosmos/cosmos-sdk v0.42.4-0.20210623214207-eb0fc466c99b/go.mod h1:xiL github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= -github.com/peggyjv/gravity-bridge/module v0.0.0-20210322173118-25d77b5f9b46 h1:XXCzKCfiWWnn6sjNISC/pv+GbfEd03bCpu0IXCnS9TA= -github.com/peggyjv/gravity-bridge/module v0.0.0-20210322173118-25d77b5f9b46/go.mod h1:jEI1pLV70xW9prKdBnKroKWIpYXjcVyn4BQQcwXHs40= github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE= github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I= github.com/cosmos/iavl v0.15.3 h1:xE9r6HW8GeKeoYJN4zefpljZ1oukVScP/7M8oj6SUts= diff --git a/module/x/gravity/abci.go b/module/x/gravity/abci.go index bbdf517b4..09a774e82 100644 --- a/module/x/gravity/abci.go +++ b/module/x/gravity/abci.go @@ -68,7 +68,8 @@ func createSignerSetTxs(ctx sdk.Context, k keeper.Keeper) { powerDiff := types.EthereumSigners(k.CurrentSignerSet(ctx)).PowerDiff(latestSignerSetTx.Signers) shouldCreate := (lastUnbondingHeight == blockHeight) || (powerDiff > 0.05) - ctx.Logger().Info("considering signer set tx creation", + k.Logger(ctx).Info( + "considering signer set tx creation", "blockHeight", blockHeight, "lastUnbondingHeight", lastUnbondingHeight, "latestSignerSetTx.Nonce", latestSignerSetTx.Nonce, diff --git a/module/x/gravity/keeper/ethereum_event_vote.go b/module/x/gravity/keeper/ethereum_event_vote.go index 13ecf9eb1..2fd2c80ca 100644 --- a/module/x/gravity/keeper/ethereum_event_vote.go +++ b/module/x/gravity/keeper/ethereum_event_vote.go @@ -122,7 +122,8 @@ func (k Keeper) processEthereumEvent(ctx sdk.Context, event types.EthereumEvent) // If the attestation fails, something has gone wrong and we can't recover it. Log and move on // The attestation will still be marked "Observed", and validators can still be slashed for not // having voted for it. - k.logger(ctx).Error("ethereum event vote record failed", + k.Logger(ctx).Error( + "ethereum event vote record failed", "cause", err.Error(), "event type", fmt.Sprintf("%T", event), "id", types.MakeEthereumEventVoteRecordKey(event.GetEventNonce(), event.Hash()), diff --git a/module/x/gravity/keeper/keeper.go b/module/x/gravity/keeper/keeper.go index 5b96e8fda..73998158f 100644 --- a/module/x/gravity/keeper/keeper.go +++ b/module/x/gravity/keeper/keeper.go @@ -8,17 +8,14 @@ import ( "sort" "strconv" - "github.com/cosmos/cosmos-sdk/types/query" - - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - - "github.com/ethereum/go-ethereum/common" - "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" "github.com/tendermint/tendermint/libs/log" "github.com/peggyjv/gravity-bridge/module/x/gravity/types" @@ -61,6 +58,10 @@ func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey, paramSpace para return k } +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + ///////////////////////////// // SignerSetTxNonce // ///////////////////////////// @@ -217,13 +218,13 @@ func (k Keeper) getEthereumAddressesByOrchestrator(ctx sdk.Context, orch sdk.Acc return } - // CreateSignerSetTx gets the current signer set from the staking keeper, increments the nonce, // creates the signer set tx object, emits an event and sets the signer set in state func (k Keeper) CreateSignerSetTx(ctx sdk.Context) *types.SignerSetTx { nonce := k.incrementLatestSignerSetTxNonce(ctx) currSignerSet := k.CurrentSignerSet(ctx) newSignerSetTx := types.NewSignerSetTx(nonce, uint64(ctx.BlockHeight()), currSignerSet) + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeMultisigUpdateRequest, @@ -234,7 +235,8 @@ func (k Keeper) CreateSignerSetTx(ctx sdk.Context) *types.SignerSetTx { ), ) k.SetOutgoingTx(ctx, newSignerSetTx) - ctx.Logger().Info("SignerSetTx created", + k.Logger(ctx).Info( + "SignerSetTx created", "nonce", newSignerSetTx.Nonce, "height", newSignerSetTx.Height, "signers", len(newSignerSetTx.Signers), @@ -333,11 +335,6 @@ func (k Keeper) getGravityID(ctx sdk.Context) string { return a } -// logger returns a module-specific logger. -func (k Keeper) logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} - // getDelegateKeys iterates both the EthAddress and Orchestrator address indexes to produce // a vector of MsgDelegateKeys entries containing all the delgate keys for state // export / import. This may seem at first glance to be excessively complicated, why not combine From 7872f3541958acb49cf7d1623fd041b1b92c52d9 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 14 Jul 2021 10:06:44 -0400 Subject: [PATCH 2/2] reset go.sum --- module/go.sum | 2 ++ 1 file changed, 2 insertions(+) diff --git a/module/go.sum b/module/go.sum index 4cb6b63a9..76a945a60 100644 --- a/module/go.sum +++ b/module/go.sum @@ -131,6 +131,8 @@ github.com/cosmos/cosmos-sdk v0.42.4-0.20210623214207-eb0fc466c99b/go.mod h1:xiL github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= +github.com/peggyjv/gravity-bridge/module v0.0.0-20210322173118-25d77b5f9b46 h1:XXCzKCfiWWnn6sjNISC/pv+GbfEd03bCpu0IXCnS9TA= +github.com/peggyjv/gravity-bridge/module v0.0.0-20210322173118-25d77b5f9b46/go.mod h1:jEI1pLV70xW9prKdBnKroKWIpYXjcVyn4BQQcwXHs40= github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE= github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I= github.com/cosmos/iavl v0.15.3 h1:xE9r6HW8GeKeoYJN4zefpljZ1oukVScP/7M8oj6SUts=