internal/ethapi: fix panic in accesslist creation (#23225)

This commit is contained in:
Daniel Liu 2024-05-28 17:12:47 +08:00
parent 7500b0ac95
commit 62a70f0cde
2 changed files with 12 additions and 1 deletions

View file

@ -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
}

View file

@ -2063,12 +2063,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)