diff --git a/CHANGELOG.md b/CHANGELOG.md index cf3961a3f..07fb8af5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,11 +79,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1950](https://github.com/NibiruChain/nibiru/pull/1950) - feat(evm): Tx to create FunToken mapping from ERC20, contract embeds, and ERC20 queries. - [#1956](https://github.com/NibiruChain/nibiru/pull/1956) - feat(evm): msg to send bank coin to erc20 - [#1958](https://github.com/NibiruChain/nibiru/pull/1958) - chore(evm): wiped deprecated evm apis: miner, personal -- [#1959](https://github.com/NibiruChain/nibiru/pull/1959) - feat(evm): Add precompile to the EVM that enables trasnfers of ERC20 tokens to "nibi" accounts as regular Ethereum transactions +- [#1959](https://github.com/NibiruChain/nibiru/pull/1959) - feat(evm): Add precompile to the EVM that enables transfers of ERC20 tokens to "nibi" accounts as regular Ethereum transactions - [#1960](https://github.com/NibiruChain/nibiru/pull/1960) - test(network): graceful cleanup for more consistent CI runs - [#1961](https://github.com/NibiruChain/nibiru/pull/1961) - chore(test): reverted funtoken precompile test back to the isolated state - [#1962](https://github.com/NibiruChain/nibiru/pull/1962) - chore(evm): code cleanup, unused code, typos, styles, warnings - [#1963](https://github.com/NibiruChain/nibiru/pull/1963) - feat(evm): Deduct a fee during the creation of a FunToken mapping. Implemented by `deductCreateFunTokenFee` inside of the `eth.evm.v1.MsgCreateFunToken` transaction. +- [#1965](https://github.com/NibiruChain/nibiru/pull/1965) - refactor(evm): remove evm post-processing hooks #### Dapp modules: perp, spot, oracle, etc diff --git a/x/evm/deps.go b/x/evm/deps.go index c02a9ec32..04327db06 100644 --- a/x/evm/deps.go +++ b/x/evm/deps.go @@ -6,8 +6,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - gethcore "github.com/ethereum/go-ethereum/core" - gethcoretypes "github.com/ethereum/go-ethereum/core/types" ) // AccountKeeper defines the expected account keeper interface @@ -51,14 +49,3 @@ type StakingKeeper interface { GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool) GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool) } - -// EvmHooks: Ethereum transaction processing callbacks/hooks. -type EvmHooks interface { - // PostTxProcessing: Called after default tx processing. If the hook errors, - // the tx is reverted. - PostTxProcessing( - ctx sdk.Context, - msg gethcore.Message, - receipt *gethcoretypes.Receipt, - ) error -} diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 3379c6159..53f95861a 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -5,7 +5,6 @@ import ( "math/big" "github.com/ethereum/go-ethereum/core" - gethcore "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" gethparams "github.com/ethereum/go-ethereum/params" @@ -46,7 +45,6 @@ type Keeper struct { // Integer for the Ethereum EIP155 Chain ID // eip155ChainIDInt *big.Int - hooks evm.EvmHooks //nolint:unused precompiles map[gethcommon.Address]vm.PrecompiledContract //nolint:unused // tracer: Configures the output type for a geth `vm.EVMLogger`. Tracer types // include "access_list", "json", "struct", and "markdown". If any other @@ -141,14 +139,3 @@ func (k Keeper) Tracer( ) vm.EVMLogger { return evm.NewTracer(k.tracer, msg, ethCfg, ctx.BlockHeight()) } - -// PostTxProcessing: Called after tx is processed successfully. If it errors, -// the tx will revert. -func (k *Keeper) PostTxProcessing( - ctx sdk.Context, msg core.Message, receipt *gethcore.Receipt, -) error { - if k.hooks == nil { - return nil - } - return k.hooks.PostTxProcessing(ctx, msg, receipt) -} diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 3265f9b8f..a9828feaa 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -118,16 +118,7 @@ func (k *Keeper) ApplyEvmTx( return nil, errors.Wrap(err, "failed to return ethereum transaction as core message") } - // snapshot to contain the tx processing and post-processing in same scope - var commit func() - tmpCtx := ctx - if k.hooks != nil { - // Create a cache context to revert state when tx hooks fails, - // the cache context is only committed when both tx and hooks executed successfully. - // Didn't use `Snapshot` because the context stack has exponential complexity on certain operations, - // thus restricted to be used only inside `ApplyMessage`. - tmpCtx, commit = ctx.CacheContext() - } + tmpCtx, commit := ctx.CacheContext() // pass true to commit the StateDB res, err := k.ApplyEvmMsg(tmpCtx, msg, nil, true, cfg, txConfig) @@ -170,21 +161,8 @@ func (k *Keeper) ApplyEvmTx( if !res.Failed() { receipt.Status = gethcore.ReceiptStatusSuccessful - // Only call hooks if tx executed successfully. - if err = k.PostTxProcessing(tmpCtx, msg, receipt); err != nil { - // If hooks return error, revert the whole tx. - res.VmError = evm.ErrPostTxProcessing.Error() - k.Logger(ctx).Error("tx post processing failed", "error", err) - - // If the tx failed in post-processing hooks, we should clear the logs - res.Logs = nil - } else if commit != nil { - // PostTxProcessing is successful, commit the tmpCtx - commit() - // Since the post-processing can alter the log, we need to update the result - res.Logs = evm.NewLogsFromEth(receipt.Logs) - ctx.EventManager().EmitEvents(tmpCtx.EventManager().Events()) - } + commit() + ctx.EventManager().EmitEvents(tmpCtx.EventManager().Events()) } // refund gas in order to match the Ethereum gas consumption instead of the default SDK one.