diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go index 44da333b49..4e7fdbc376 100644 --- a/plugin/evm/export_tx.go +++ b/plugin/evm/export_tx.go @@ -7,9 +7,9 @@ import ( "context" "errors" "fmt" + "github.com/ava-labs/coreth/core/vm" "math/big" - "github.com/ava-labs/coreth/core/state" "github.com/ava-labs/coreth/params" "github.com/ava-labs/avalanchego/chains/atomic" @@ -369,7 +369,7 @@ func (vm *VM) newExportTx( } // EVMStateTransfer executes the state update from the atomic export transaction -func (utx *UnsignedExportTx) EVMStateTransfer(ctx *snow.Context, state *state.StateDB) error { +func (utx *UnsignedExportTx) EVMStateTransfer(ctx *snow.Context, state vm.StateDB) error { addrs := map[[20]byte]uint64{} for _, from := range utx.Ins { if from.AssetID == ctx.AVAXAssetID { @@ -378,6 +378,8 @@ func (utx *UnsignedExportTx) EVMStateTransfer(ctx *snow.Context, state *state.St // denomination before export. amount := new(big.Int).Mul( new(big.Int).SetUint64(from.Amount), x2cRate) + addrBalance := state.GetBalance(from.Address) + log.Info("get address balance", "address", from.Address.String(), "balance", addrBalance.String(), "assetID", from.AssetID.String()) if state.GetBalance(from.Address).Cmp(amount) < 0 { return errInsufficientFunds } @@ -385,6 +387,8 @@ func (utx *UnsignedExportTx) EVMStateTransfer(ctx *snow.Context, state *state.St } else { log.Debug("crosschain", "dest", utx.DestinationChain, "addr", from.Address, "amount", from.Amount, "assetID", from.AssetID) amount := new(big.Int).SetUint64(from.Amount) + addrBalance := state.GetBalanceMultiCoin(from.Address, common.Hash(from.AssetID)) + log.Info("get address balance multi coin", "address", from.Address.String(), "balance", addrBalance.String(), "assetID", from.AssetID.String()) if state.GetBalanceMultiCoin(from.Address, common.Hash(from.AssetID)).Cmp(amount) < 0 { return errInsufficientFunds } diff --git a/plugin/evm/import_tx.go b/plugin/evm/import_tx.go index ee2eff0590..cd5d493368 100644 --- a/plugin/evm/import_tx.go +++ b/plugin/evm/import_tx.go @@ -7,10 +7,10 @@ import ( "context" "errors" "fmt" + "github.com/ava-labs/coreth/core/vm" "math/big" "slices" - "github.com/ava-labs/coreth/core/state" "github.com/ava-labs/coreth/params" "github.com/ava-labs/avalanchego/chains/atomic" @@ -428,7 +428,7 @@ func (vm *VM) newImportTxWithUTXOs( // EVMStateTransfer performs the state transfer to increase the balances of // accounts accordingly with the imported EVMOutputs -func (utx *UnsignedImportTx) EVMStateTransfer(ctx *snow.Context, state *state.StateDB) error { +func (utx *UnsignedImportTx) EVMStateTransfer(ctx *snow.Context, state vm.StateDB) error { for _, to := range utx.Outs { if to.AssetID == ctx.AVAXAssetID { log.Debug("crosschain", "src", utx.SourceChain, "addr", to.Address, "amount", to.Amount, "assetID", "AVAX") diff --git a/plugin/evm/test_tx.go b/plugin/evm/test_tx.go index c057c874ad..96d8cd2b88 100644 --- a/plugin/evm/test_tx.go +++ b/plugin/evm/test_tx.go @@ -4,6 +4,7 @@ package evm import ( + "github.com/ava-labs/coreth/core/vm" "math/big" "math/rand" @@ -16,7 +17,6 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/coreth/core/state" "github.com/ava-labs/coreth/params" ) @@ -71,7 +71,7 @@ func (t *TestUnsignedTx) SemanticVerify(vm *VM, stx *Tx, parent *Block, baseFee } // EVMStateTransfer implements the UnsignedAtomicTx interface -func (t *TestUnsignedTx) EVMStateTransfer(ctx *snow.Context, state *state.StateDB) error { +func (t *TestUnsignedTx) EVMStateTransfer(ctx *snow.Context, state vm.StateDB) error { return t.EVMStateTransferV } diff --git a/plugin/evm/tx.go b/plugin/evm/tx.go index 5c8497a3a3..0dd6ce62cd 100644 --- a/plugin/evm/tx.go +++ b/plugin/evm/tx.go @@ -7,12 +7,12 @@ import ( "bytes" "errors" "fmt" + "github.com/ava-labs/coreth/core/vm" "math/big" "sort" "github.com/ethereum/go-ethereum/common" - "github.com/ava-labs/coreth/core/state" "github.com/ava-labs/coreth/params" "github.com/ava-labs/avalanchego/chains/atomic" @@ -130,7 +130,7 @@ type UnsignedAtomicTx interface { // The set of atomic requests must be returned in a consistent order. AtomicOps() (ids.ID, *atomic.Requests, error) - EVMStateTransfer(ctx *snow.Context, state *state.StateDB) error + EVMStateTransfer(ctx *snow.Context, state vm.StateDB) error } // Tx is a signed transaction