diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index c46ba672e54b..c4223e487391 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -477,7 +477,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call XDPoSChain.Cal feeCapacity := state.GetTRC21FeeCapacityFromState(statedb) if msg.To != nil { if value, ok := feeCapacity[*msg.To]; ok { - msg.CallMsg.BalanceTokenFee = value + msg.BalanceTokenFee = value } } diff --git a/core/state_transition.go b/core/state_transition.go index 7281ce9cd872..901980409d6e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -131,7 +131,7 @@ type Message struct { GasTipCap *big.Int Data []byte AccessList types.AccessList - balanceTokenFee *big.Int + BalanceTokenFee *big.Int // When SkipAccountCheckss is true, the message nonce is not checked against the // account nonce in state. It also disables checking that the sender is an EOA. @@ -152,7 +152,7 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, balanceFee, blo Data: tx.Data(), AccessList: tx.AccessList(), SkipAccountChecks: false, - balanceTokenFee: balanceFee, + BalanceTokenFee: balanceFee, // } // // If baseFee provided, set gasPrice to effectiveGasPrice. // if baseFee != nil { @@ -245,7 +245,7 @@ func (st *StateTransition) from() vm.AccountRef { } func (st *StateTransition) balanceTokenFee() *big.Int { - return st.msg.BalanceTokenFee() + return st.msg.BalanceTokenFee } func (st *StateTransition) to() vm.AccountRef { diff --git a/core/token_validator.go b/core/token_validator.go index 434314d70471..0d8988a73414 100644 --- a/core/token_validator.go +++ b/core/token_validator.go @@ -119,7 +119,7 @@ func CallContractWithState(call ethereum.CallMsg, chain consensus.ChainContext, feeCapacity := state.GetTRC21FeeCapacityFromState(statedb) if msg.To != nil { if value, ok := feeCapacity[*msg.To]; ok { - msg.CallMsg.BalanceTokenFee = value + msg.BalanceTokenFee = value } } txContext := NewEVMTxContext(msg) diff --git a/core/types/transaction.go b/core/types/transaction.go index c07159e3db8d..355a466c6a92 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -771,15 +771,6 @@ func (t *TransactionsByPriceAndNonce) Pop() { heap.Pop(&t.heads) } -func (m *Message) SetBalanceTokenFeeForCall() { - m.balanceTokenFee = new(big.Int).SetUint64(m.gasLimit) - m.balanceTokenFee.Mul(m.balanceTokenFee, m.gasPrice) -} - -func (m *Message) SetBalanceTokenFee(balanceTokenFee *big.Int) { - m.balanceTokenFee = balanceTokenFee -} - // copyAddressPtr copies an address. func copyAddressPtr(a *common.Address) *common.Address { if a == nil { diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 98d747b8995d..35ae8e03c5c2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1370,7 +1370,8 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash if err != nil { return nil, err } - msg.SetBalanceTokenFeeForCall() + msg.BalanceTokenFee = new(big.Int).SetUint64(msg.GasLimit) + msg.BalanceTokenFee.Mul(msg.BalanceTokenFee, msg.GasPrice) // Get a new instance of the EVM. evm, vmError, err := b.GetEVM(ctx, msg, statedb, XDCxState, header, &vm.Config{NoBaseFee: true}) @@ -2086,7 +2087,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH if value, ok := feeCapacity[to]; ok { balanceTokenFee = value } - msg.SetBalanceTokenFee(balanceTokenFee) + msg.BalanceTokenFee = balanceTokenFee // Apply the transaction with the access list tracer tracer := vm.NewAccessListTracer(accessList, args.from(), to, precompiles) diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index 7e7f2499948b..a6d2d6ed0880 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -344,7 +344,7 @@ func (b *backendMock) GetTd(common.Hash) *big.Int { return nil } -func (b *backendMock) GetEVM(context.Context, core.Message, *state.StateDB, *tradingstate.TradingStateDB, *types.Header, *vm.Config) (*vm.EVM, func() error, error) { +func (b *backendMock) GetEVM(context.Context, *core.Message, *state.StateDB, *tradingstate.TradingStateDB, *types.Header, *vm.Config) (*vm.EVM, func() error, error) { return nil, nil, nil } diff --git a/les/odr_test.go b/les/odr_test.go index 96c0fcbc10fb..82623bb17460 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -137,6 +137,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai GasTipCap: new(big.Int), Data: data, SkipAccountChecks: true, + BalanceTokenFee: balanceTokenFee, // msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, balanceTokenFee, header.Number)} } context := core.NewEVMBlockContext(header, bc, nil) @@ -169,6 +170,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai GasTipCap: new(big.Int), Data: data, SkipAccountChecks: true, + BalanceTokenFee: balanceTokenFee, } context := core.NewEVMBlockContext(header, lc, nil) txContext := core.NewEVMTxContext(msg) diff --git a/light/odr_test.go b/light/odr_test.go index 9d2058a5af6f..f992c86d19ca 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -190,6 +190,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain GasTipCap: new(big.Int), Data: data, SkipAccountChecks: true, + BalanceTokenFee: balanceTokenFee, } txContext := core.NewEVMTxContext(msg) context := core.NewEVMBlockContext(header, chain, nil)