From 1ba67f049a3f000fcecdac64463f6b1eef055dae Mon Sep 17 00:00:00 2001 From: Konstantin Munichev Date: Tue, 5 Mar 2024 22:45:32 +0100 Subject: [PATCH] Ethermint with better EVM logs --- x/evm/keeper/msg_server.go | 2 ++ x/evm/keeper/state_transition.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 0a96b48917..f1c3acc9b1 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -56,6 +56,8 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t labels = append(labels, telemetry.NewLabel("execution", "call")) } + k.Logger(ctx).Info("incoming", "tx", msg.Hash) + response, err := k.ApplyTransaction(ctx, msg) if err != nil { return nil, errorsmod.Wrap(err, "failed to apply transaction") diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 9b330213d3..668937bbb1 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -179,10 +179,18 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, msgEth *types.MsgEthereumTx) // pass true to commit the StateDB res, err := k.ApplyMessageWithConfig(tmpCtx, msg, nil, true, cfg, txConfig) + if err != nil { + k.Logger(ctx).Error("error", "err", err) + } if err != nil { return nil, errorsmod.Wrap(err, "failed to apply ethereum core message") } + if res.VmError != "" { + k.Logger(ctx).Error("vmerror", "vmerr", res.VmError) + } + k.Logger(ctx).Info("tx hash", "hash", res.Hash) + logs := types.LogsToEthereum(res.Logs) // Compute block bloom filter @@ -376,7 +384,6 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, stateDB.SetNonce(sender.Address(), msg.Nonce()+1) } else { ret, leftoverGas, vmErr = evm.Call(sender, *msg.To(), msg.Data(), leftoverGas, msg.Value()) - k.Logger(ctx).Error("raw error", "error", vmErr) } refundQuotient := params.RefundQuotient @@ -424,11 +431,6 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, logs := types.NewLogsFromEth(stateDB.Logs()) - k.Logger(ctx).Info("tx hash", "hash", txConfig.TxHash.Hex()) - for _, l := range logs { - k.Logger(ctx).Info("logs", "log", l) - } - return &types.MsgEthereumTxResponse{ GasUsed: gasUsed, VmError: vmError,