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