Skip to content

Commit befde4f

Browse files
heijiLeemmsqeAlex | Interchain Labsvladjdkyihuang
authored
feat: Delete EVM instance in AnteHandler (cosmos#352)
* test: adjusts GasTipCap to equal GasFeeCap when it exceeds the maximum fee cap * ensures adequate fees for bank msg send * Optimize CanTransfer AnteHandler * refactor(antehandler): remove stateDB allocation * chore: replace GlobalEVMMempool by passing to JSONRPC on initiate (cosmos#467) * chore: ensure SetGlobalEVMMempool is thread-safe and only set once keep singleton behavior on concurrent initialization * doc * keep reset * pass in mempool * cleanup --------- Co-authored-by: Vlad J <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]> * Problem: eip-2935 is not implemented (cosmos#407) * Problem: eip-2935 is not implemented Solution: - adapt the implementation from geth * change BLOCKHASH opcode to query contract storage * commit statedb * fix panic * temp * just emulate the contract behavior with native code * fix test * fix lint * fix lint * revert unneeded changes * fix test * revert * only set contract storage if it's deployed * fix build * add history serve window parameter * cleanup * fix lint --------- Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]> * fix : EVMKeeper GetBalance missed when version upgrades * add CHANGELOG --------- Co-authored-by: mmsqe <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]> Co-authored-by: yihuang <[email protected]>
1 parent 7451d9b commit befde4f

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### IMPROVEMENTS
1010

11+
- [\#352](https://github.com/cosmos/evm/pull/352) Remove the creation of a Geth EVM instance, stateDB during the AnteHandler balance check.
1112
- [\#467](https://github.com/cosmos/evm/pull/467) Ensure SetGlobalEVMMempool is thread-safe and only sets global mempool instance once.
1213

1314
### FEATURES

ante/evm/07_can_transfer.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ package evm
33
import (
44
"math/big"
55

6-
"github.com/ethereum/go-ethereum/common"
76
"github.com/ethereum/go-ethereum/core"
87

98
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
109
"github.com/cosmos/evm/utils"
11-
"github.com/cosmos/evm/x/vm/statedb"
1210
evmtypes "github.com/cosmos/evm/x/vm/types"
1311

1412
errorsmod "cosmossdk.io/errors"
@@ -34,23 +32,13 @@ func CanTransfer(
3432
)
3533
}
3634

37-
// NOTE: pass in an empty coinbase address and nil tracer as we don't need them for the check below
38-
cfg := &statedb.EVMConfig{
39-
Params: params,
40-
CoinBase: common.Address{},
41-
BaseFee: baseFee,
42-
}
43-
44-
stateDB := statedb.New(ctx, evmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())))
45-
evm := evmKeeper.NewEVM(ctx, msg, cfg, evmtypes.NewNoOpTracer(), stateDB)
46-
4735
// check that caller has enough balance to cover asset transfer for **topmost** call
4836
// NOTE: here the gas consumed is from the context with the infinite gas meter
4937
convertedValue, err := utils.Uint256FromBigInt(msg.Value)
5038
if err != nil {
5139
return err
5240
}
53-
if msg.Value.Sign() > 0 && !evm.Context.CanTransfer(stateDB, msg.From, convertedValue) {
41+
if msg.Value.Sign() > 0 && evmKeeper.GetAccount(ctx, msg.From).Balance.Cmp(convertedValue) < 0 {
5442
return errorsmod.Wrapf(
5543
errortypes.ErrInsufficientFunds,
5644
"failed to transfer %s from address %s using the EVM block context transfer function",

0 commit comments

Comments
 (0)