mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
ensure AccessList calls setFeeDefaults so that fee fields are filled with proper values. modify setFeeDefaults to take a historical header value (doesn't work if EIP-1559 is disabled. everything other than AccessLists, which were introduced after/same-time (?) as 1559, calls setFeeDefaults with current block header.
This commit is contained in:
parent
599fdedadc
commit
78897ffaf0
3 changed files with 10 additions and 7 deletions
|
|
@ -1627,15 +1627,19 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
|||
return nil, 0, nil, err
|
||||
}
|
||||
|
||||
// fill in missing fields based on the state at the specified block
|
||||
// Ensure any missing fields are filled, extract the recipient and input data
|
||||
if err = args.setFeeDefaults(ctx, b, header); err != nil {
|
||||
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)
|
||||
if err := args.CallDefaults(b.RPCGasCap(), blockCtx.BaseFee, b.ChainConfig().ChainID); err != nil {
|
||||
return types.AccessList{}, 0, nil, err
|
||||
if err = args.CallDefaults(b.RPCGasCap(), blockCtx.BaseFee, b.ChainConfig().ChainID); err != nil {
|
||||
return nil, 0, nil, err
|
||||
}
|
||||
|
||||
var to common.Address
|
||||
if args.To != nil {
|
||||
to = *args.To
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGas
|
|||
if err := args.setBlobTxSidecar(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := args.setFeeDefaults(ctx, b); err != nil {
|
||||
if err := args.setFeeDefaults(ctx, b, b.CurrentHeader()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -183,8 +183,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGas
|
|||
}
|
||||
|
||||
// setFeeDefaults fills in default fee values for unspecified tx fields.
|
||||
func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) error {
|
||||
head := b.CurrentHeader()
|
||||
func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head *types.Header) error {
|
||||
// Sanity check the EIP-4844 fee parameters.
|
||||
if args.BlobFeeCap != nil && args.BlobFeeCap.ToInt().Sign() == 0 {
|
||||
return errors.New("maxFeePerBlobGas, if specified, must be non-zero")
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ func TestSetFeeDefaults(t *testing.T) {
|
|||
t.Fatalf("failed to set fork: %v", err)
|
||||
}
|
||||
got := test.in
|
||||
err := got.setFeeDefaults(ctx, b)
|
||||
err := got.setFeeDefaults(ctx, b, b.CurrentHeader())
|
||||
if err != nil {
|
||||
if test.err == nil {
|
||||
t.Fatalf("test %d (%s): unexpected error: %s", i, test.name, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue