Skip to content

Commit eeaaeb2

Browse files
committed
internal/ethapi: distinguish Call and Transaction nobasefee check
Signed-off-by: jsvisa <delweng@gmail.com>
1 parent 7de748d commit eeaaeb2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

internal/ethapi/api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ func (context *ChainContext) GetHeader(hash common.Hash, number uint64) *types.H
10241024
return header
10251025
}
10261026

1027-
func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, overrides *StateOverride, blockOverrides *BlockOverrides, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error) {
1027+
func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, overrides *StateOverride, blockOverrides *BlockOverrides, timeout time.Duration, globalGasCap uint64, noBaseFee bool) (*core.ExecutionResult, error) {
10281028
if err := overrides.Apply(state); err != nil {
10291029
return nil, err
10301030
}
@@ -1049,7 +1049,7 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
10491049
if blockOverrides != nil {
10501050
blockOverrides.Apply(&blockCtx)
10511051
}
1052-
evm, vmError := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true}, &blockCtx)
1052+
evm, vmError := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: noBaseFee}, &blockCtx)
10531053

10541054
// Wait for the context to be done and cancel the evm. Even if the
10551055
// EVM has finished, cancelling may be done (repeatedly)
@@ -1083,7 +1083,7 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
10831083
return nil, err
10841084
}
10851085

1086-
return doCall(ctx, b, args, state, header, overrides, blockOverrides, timeout, globalGasCap)
1086+
return doCall(ctx, b, args, state, header, overrides, blockOverrides, timeout, globalGasCap, true)
10871087
}
10881088

10891089
func newRevertError(result *core.ExecutionResult) *revertError {
@@ -1134,7 +1134,7 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO
11341134
return result.Return(), result.Err
11351135
}
11361136

1137-
func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error) {
1137+
func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64, noBaseFee bool) (hexutil.Uint64, error) {
11381138
// Binary search the gas requirement, as it may be higher than the amount used
11391139
var (
11401140
lo uint64 = params.TxGas - 1
@@ -1208,7 +1208,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
12081208
executable := func(gas uint64, state *state.StateDB, header *types.Header) (bool, *core.ExecutionResult, error) {
12091209
args.Gas = (*hexutil.Uint64)(&gas)
12101210

1211-
result, err := doCall(ctx, b, args, state, header, nil, nil, 0, gasCap)
1211+
result, err := doCall(ctx, b, args, state, header, nil, nil, 0, gasCap, noBaseFee)
12121212
if err != nil {
12131213
if errors.Is(err, core.ErrIntrinsicGas) {
12141214
return true, nil, nil // Special case, raise gas limit
@@ -1266,7 +1266,7 @@ func (s *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, b
12661266
if blockNrOrHash != nil {
12671267
bNrOrHash = *blockNrOrHash
12681268
}
1269-
return DoEstimateGas(ctx, s.b, args, bNrOrHash, s.b.RPCGasCap())
1269+
return DoEstimateGas(ctx, s.b, args, bNrOrHash, s.b.RPCGasCap(), false)
12701270
}
12711271

12721272
// RPCMarshalHeader converts the given header to the RPC output .

internal/ethapi/transaction_args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
111111
AccessList: args.AccessList,
112112
}
113113
pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
114-
estimated, err := DoEstimateGas(ctx, b, callArgs, pendingBlockNr, b.RPCGasCap())
114+
estimated, err := DoEstimateGas(ctx, b, callArgs, pendingBlockNr, b.RPCGasCap(), false)
115115
if err != nil {
116116
return err
117117
}

0 commit comments

Comments
 (0)