From 8a369f560e1dd80d21c4e11fb2fd05b4e070ee6f Mon Sep 17 00:00:00 2001 From: jwasinger Date: Mon, 23 Sep 2024 18:31:56 +0700 Subject: [PATCH 1/2] internal/ethapi/api: for simulated calls, set gaspool to max value if global gascap is 0 (#30474) In #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. --- internal/ethapi/api.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 72e05decf..944b0ae43 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1287,7 +1287,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) { From 6d4a68159defa42d46433273b41060a2269243a4 Mon Sep 17 00:00:00 2001 From: Sina M <1591639+s1na@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:14:38 +0200 Subject: [PATCH 2/2] internal/ethapi: fix gascap 0 for eth_simulateV1 (#30496) Similar to #30474. --- internal/ethapi/api.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 944b0ae43..a3df00dc7 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1398,13 +1398,17 @@ func (api *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrO if state == nil || err != nil { return nil, err } + gasCap := api.b.RPCGasCap() + if gasCap == 0 { + gasCap = math.MaxUint64 + } sim := &simulator{ b: api.b, state: state, base: base, chainConfig: api.b.ChainConfig(), // Each tx and all the series of txes shouldn't consume more gas than cap - gp: new(core.GasPool).AddGas(api.b.RPCGasCap()), + gp: new(core.GasPool).AddGas(gasCap), traceTransfers: opts.TraceTransfers, validate: opts.Validation, fullTx: opts.ReturnFullTransactions,