check error from CallDefaults. if tx nonce was not provided, fill it from the db

This commit is contained in:
Jared Wasinger 2024-10-08 16:30:00 +07:00
parent 5fce58e5b2
commit 6d3b00013a

View file

@ -1627,8 +1627,14 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
return nil, 0, nil, err return nil, 0, nil, err
} }
if args.Nonce == nil {
nonce := hexutil.Uint64(db.GetNonce(args.from()))
args.Nonce = &nonce
}
blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil) blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil)
args.CallDefaults(b.RPCGasCap(), blockCtx.BaseFee, b.ChainConfig().ChainID) if err := args.CallDefaults(b.RPCGasCap(), blockCtx.BaseFee, b.ChainConfig().ChainID); err != nil {
return types.AccessList{}, 0, nil, err
}
var to common.Address var to common.Address
if args.To != nil { if args.To != nil {
@ -1636,6 +1642,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
} else { } else {
to = crypto.CreateAddress(args.from(), uint64(*args.Nonce)) to = crypto.CreateAddress(args.from(), uint64(*args.Nonce))
} }
fmt.Printf("nonce %d\nto %x\n", *args.Nonce, to)
isPostMerge := header.Difficulty.Sign() == 0 isPostMerge := header.Difficulty.Sign() == 0
// Retrieve the precompiles since they don't need to be added to the access list // Retrieve the precompiles since they don't need to be added to the access list
precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, isPostMerge, header.Time)) precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, isPostMerge, header.Time))