From b3b686f032960ef887b8dd599d41a37ef03f612d Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Tue, 6 Feb 2024 14:28:32 +0000 Subject: [PATCH] Add estimate optmisation that geth added --- go/enclave/enclave.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index 0e7b1993bd..64a4ddd652 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -1252,6 +1252,12 @@ func (e *enclaveImpl) DoEstimateGas(args *gethapi.TransactionArgs, blkNumber *ge // Execute the binary search and hone in on an isGasEnough gas limit for lo+1 < hi { mid := (hi + lo) / 2 + if mid > lo*2 { + // Most txs don't need much higher gas limit than their gas used, and most txs don't + // require near the full block limit of gas, so the selection of where to bisect the + // range here is skewed to favor the low side. + mid = lo * 2 + } failed, _, err := e.isGasEnough(args, mid, blkNumber) // If the error is not nil(consensus error), it means the provided message // call or transaction will never be accepted no matter how much gas it is