From cebf2478808aca31c465437f1e8f2c30667366b0 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 28 May 2024 17:12:47 +0800 Subject: [PATCH] internal/ethapi: fix panic in accesslist creation (#23225) --- core/types/transaction.go | 4 ++++ internal/ethapi/api.go | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 904f62ae2731..867c57b3ccc2 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -861,3 +861,7 @@ 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 +} diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 74defd2a748a..59fbea76146c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -2057,12 +2057,19 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH } // Copy the original db so we don't modify it statedb := db.Copy() + // Set the accesslist to the last al + args.AccessList = &accessList + msg, err := args.ToMessage(b, block.Number(), b.RPCGasCap(), header.BaseFee) + if err != nil { + return nil, 0, nil, err + } + feeCapacity := state.GetTRC21FeeCapacityFromState(statedb) var balanceTokenFee *big.Int if value, ok := feeCapacity[to]; ok { balanceTokenFee = value } - msg := types.NewMessage(args.from(), args.To, uint64(*args.Nonce), args.Value.ToInt(), uint64(*args.Gas), args.GasPrice.ToInt(), big.NewInt(0), big.NewInt(0), args.data(), accessList, false, balanceTokenFee, header.Number) + msg.SetBalanceTokenFee(balanceTokenFee) // Apply the transaction with the access list tracer tracer := vm.NewAccessListTracer(accessList, args.from(), to, precompiles)