Skip to content

Commit 7c0737b

Browse files
committed
Use execution result's MaxGasConsumed for gas estimation
1 parent 5727891 commit 7c0737b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

models/events_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ func newTransaction(nonce uint64, txIndex uint16) (Transaction, *types.Result, f
578578
TxType: tx.Type(),
579579
GasConsumed: 1,
580580
CumulativeGasUsed: 1,
581-
GasRefund: 0,
581+
MaxGasConsumed: 1,
582582
DeployedContractAddress: &types.Address{0x5, 0x6, 0x7},
583583
ReturnedData: []byte{0x55},
584584
Logs: []*gethTypes.Log{{

services/requester/requester.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ func (e *EVM) EstimateGas(
376376
failingGasLimit = result.GasConsumed - 1
377377

378378
// There's a fairly high chance for the transaction to execute successfully
379-
// with gasLimit set to the first execution's GasConsumed + GasRefund.
379+
// with gasLimit set to the first execution's MaxGasConsumed + CallStipend.
380380
// Explicitly check that gas amount and use as a limit for the binary search.
381-
optimisticGasLimit := (result.GasConsumed + result.GasRefund + gethParams.CallStipend) * 64 / 63
381+
optimisticGasLimit := (result.MaxGasConsumed + gethParams.CallStipend) * 64 / 63
382382
if optimisticGasLimit < passingGasLimit {
383383
result, err := dryRun(optimisticGasLimit)
384384
if err != nil {

0 commit comments

Comments
 (0)