Skip to content

Commit

Permalink
Update statedb usage in app
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Jan 8, 2024
1 parent ef887b2 commit a184788
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions app/ante/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
ethermint "github.com/evmos/ethermint/types"
"github.com/evmos/ethermint/x/evm/keeper"
"github.com/evmos/ethermint/x/evm/statedb"
"github.com/evmos/ethermint/x/evm/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (avd EthAccountVerificationDecorator) AnteHandle(
if acct == nil {
acc := avd.ak.NewAccountWithAddress(ctx, from)
avd.ak.SetAccount(ctx, acc)
acct = statedb.NewEmptyAccount()
acct = types.NewEmptyAccount()
} else if acct.IsContract() {
return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType,
"the sender is not EOA: address %s, codeHash <%s>", fromAddr, acct.CodeHash)
Expand Down Expand Up @@ -302,7 +303,7 @@ func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
BaseFee: baseFee,
}

stateDB := statedb.New(ctx, ctd.evmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())))
stateDB := statedb.New(ctx, ctd.evmKeeper, types.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash().Bytes())))
evm := ctd.evmKeeper.NewEVM(ctx, coreMsg, cfg, evmtypes.NewNoOpTracer(), stateDB)

// check that caller has enough balance to cover asset transfer for **topmost** call
Expand Down
8 changes: 4 additions & 4 deletions app/ante/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/evmos/ethermint/server/config"
"github.com/evmos/ethermint/tests"
ethermint "github.com/evmos/ethermint/types"
"github.com/evmos/ethermint/x/evm/statedb"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/evmos/ethermint/x/evm/vm"

ethtypes "github.com/ethereum/go-ethereum/core/types"
)
Expand All @@ -26,7 +26,7 @@ func (suite AnteTestSuite) TestNewEthAccountVerificationDecorator() {
tx := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), 1000, big.NewInt(1), nil, nil, nil, nil)
tx.From = addr.Hex()

var vmdb *statedb.StateDB
var vmdb vm.StateDB

testCases := []struct {
name string
Expand Down Expand Up @@ -192,7 +192,7 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() {
dynamicFeeTx.From = addr.Hex()
dynamicFeeTxPriority := int64(1)

var vmdb *statedb.StateDB
var vmdb vm.StateDB

testCases := []struct {
name string
Expand Down Expand Up @@ -352,7 +352,7 @@ func (suite AnteTestSuite) TestCanTransferDecorator() {
err := tx.Sign(suite.ethSigner, tests.NewSigner(privKey))
suite.Require().NoError(err)

var vmdb *statedb.StateDB
var vmdb vm.StateDB

testCases := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion app/ante/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type DynamicFeeEVMKeeper interface {

// EVMKeeper defines the expected keeper interface used on the Eth AnteHandler
type EVMKeeper interface {
statedb.Keeper
evm.StateDBKeeper
DynamicFeeEVMKeeper

NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) evm.EVM
Expand Down
4 changes: 2 additions & 2 deletions app/ante/sigs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math/big"

"github.com/evmos/ethermint/tests"
"github.com/evmos/ethermint/x/evm/statedb"
"github.com/evmos/ethermint/x/evm/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
)

Expand All @@ -15,7 +15,7 @@ func (suite AnteTestSuite) TestSignatures() {
addr, privKey := tests.NewAddrKey()
to := tests.GenerateAddress()

acc := statedb.NewEmptyAccount()
acc := types.NewEmptyAccount()
acc.Nonce = 1
acc.Balance = big.NewInt(10000000000)

Expand Down
5 changes: 3 additions & 2 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/evmos/ethermint/tests"
"github.com/evmos/ethermint/x/evm/statedb"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/evmos/ethermint/x/evm/vm"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand All @@ -73,8 +74,8 @@ type AnteTestSuite struct {

const TestGasLimit uint64 = 100000

func (suite *AnteTestSuite) StateDB() *statedb.StateDB {
return statedb.New(suite.ctx, suite.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes())))
func (suite *AnteTestSuite) StateDB() vm.StateDB {
return statedb.New(suite.ctx, suite.app.EvmKeeper, evmtypes.NewEmptyTxConfig(common.BytesToHash(suite.ctx.HeaderHash().Bytes())))
}

func (suite *AnteTestSuite) SetupTest() {
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ import (
ethermint "github.com/evmos/ethermint/types"
"github.com/evmos/ethermint/x/evm"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
"github.com/evmos/ethermint/x/evm/statedb"
evmtypes "github.com/evmos/ethermint/x/evm/types"
legacyevmtypes "github.com/evmos/ethermint/x/evm/types/legacy"
"github.com/evmos/ethermint/x/evm/vm/geth"
Expand Down Expand Up @@ -422,7 +423,7 @@ func NewEthermintApp(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
nil, geth.NewEVM, tracer, evmSs,
nil, geth.NewEVM, statedb.New, tracer, evmSs,
)

// Create IBC Keeper
Expand Down

0 comments on commit a184788

Please sign in to comment.