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