Skip to content

Commit

Permalink
internal/ethapi/api: for simulated calls, set gaspool to max value if…
Browse files Browse the repository at this point in the history
… global gascap is 0 (ethereum#30474)

In ethereum#27720, we introduced RPC global gas cap. A value of `0` means an unlimited gas cap. However, this was not the case for simulated calls. This PR fixes the behaviour.
  • Loading branch information
jwasinger authored and zfy0701 committed Dec 3, 2024
1 parent 28194d9 commit e906b3d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,13 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
// Make sure the context is cancelled when the call has completed
// this makes sure resources are cleaned up.
defer cancel()
return applyMessage(ctx, b, args, state, header, timeout, new(core.GasPool).AddGas(globalGasCap), &blockCtx, &vm.Config{NoBaseFee: true}, precompiles, true)
gp := new(core.GasPool)
if globalGasCap == 0 {
gp.AddGas(math.MaxUint64)
} else {
gp.AddGas(globalGasCap)
}
return applyMessage(ctx, b, args, state, header, timeout, gp, &blockCtx, &vm.Config{NoBaseFee: true}, precompiles, true)
}

func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *state.StateDB, header *types.Header, timeout time.Duration, gp *core.GasPool, blockContext *vm.BlockContext, vmConfig *vm.Config, precompiles vm.PrecompiledContracts, skipChecks bool) (*core.ExecutionResult, error) {
Expand Down

0 comments on commit e906b3d

Please sign in to comment.