diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index 268cc246bb..9b053f69bd 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -264,18 +264,15 @@ func (sim *simulator) sanitizeCall(call *TransactionArgs, state *state.StateDB, nonce := state.GetNonce(call.from()) call.Nonce = (*hexutil.Uint64)(&nonce) } - var gas uint64 - if call.Gas != nil { - gas = uint64(*call.Gas) - } - if *gasUsed+gas > blockContext.GasLimit { - return &blockGasLimitReachedError{fmt.Sprintf("block gas limit reached: %d >= %d", gasUsed, blockContext.GasLimit)} - } // Let the call run wild unless explicitly specified. if call.Gas == nil { remaining := blockContext.GasLimit - *gasUsed call.Gas = (*hexutil.Uint64)(&remaining) } + if *gasUsed+uint64(*call.Gas) > blockContext.GasLimit { + return &blockGasLimitReachedError{fmt.Sprintf("block gas limit reached: %d >= %d", gasUsed, blockContext.GasLimit)} + } + if err := call.CallDefaults(sim.gp.Gas(), header.BaseFee, sim.chainConfig.ChainID); err != nil { return err } diff --git a/internal/ethapi/simulate_test.go b/internal/ethapi/simulate_test.go index d80380a8e0..e8a1f08cfd 100644 --- a/internal/ethapi/simulate_test.go +++ b/internal/ethapi/simulate_test.go @@ -88,8 +88,8 @@ func TestSimulateSanitizeBlockOrder(t *testing.T) { if b.BlockOverrides.Time == nil { t.Fatalf("testcase %d: block time not set", i) } - if (uint64)(*b.BlockOverrides.Time) != tc.expected[bi].timestamp { - t.Errorf("testcase %d: block timestamp mismatch. Want %d, have %d", i, tc.expected[bi].timestamp, (uint64)(*b.BlockOverrides.Time)) + if uint64(*b.BlockOverrides.Time) != tc.expected[bi].timestamp { + t.Errorf("testcase %d: block timestamp mismatch. Want %d, have %d", i, tc.expected[bi].timestamp, uint64(*b.BlockOverrides.Time)) } have := b.BlockOverrides.Number.ToInt().Uint64() if have != tc.expected[bi].number {