From dc900b6af96e4461a449bd5ebc2da6e4dcd3df86 Mon Sep 17 00:00:00 2001 From: Stefan Iliev <46542846+StefanIliev545@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:14:54 +0300 Subject: [PATCH] Fix gas estimation (#1582) * Added stopwatches in important functions. * Using defer. --------- Co-authored-by: StefanIliev545 --- go/enclave/enclave.go | 2 +- go/enclave/evm/evm_facade.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index 3206629e93..da711fcb15 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -1398,7 +1398,7 @@ func (e *enclaveImpl) GetPublicTransactionData(pagination *common.QueryPaginatio // Create a helper to check if a gas allowance results in an executable transaction // isGasEnough returns whether the gaslimit should be raised, lowered, or if it was impossible to execute the message func (e *enclaveImpl) isGasEnough(args *gethapi.TransactionArgs, gas uint64, blkNumber *gethrpc.BlockNumber) (bool, *gethcore.ExecutionResult, error) { - core.LogMethodDuration(e.logger, measure.NewStopwatch(), "enclave.go:IsGasEnough") + defer core.LogMethodDuration(e.logger, measure.NewStopwatch(), "enclave.go:IsGasEnough") args.Gas = (*hexutil.Uint64)(&gas) result, err := e.chain.ObsCallAtBlock(args, blkNumber) if err != nil { diff --git a/go/enclave/evm/evm_facade.go b/go/enclave/evm/evm_facade.go index 08550c5f8a..cf0fc976f4 100644 --- a/go/enclave/evm/evm_facade.go +++ b/go/enclave/evm/evm_facade.go @@ -164,7 +164,7 @@ func ExecuteObsCall( noBaseFee = false } - core.LogMethodDuration(logger, measure.NewStopwatch(), "evm_facade.go:ObsCall()") + defer core.LogMethodDuration(logger, measure.NewStopwatch(), "evm_facade.go:ObsCall()") chain, vmCfg, gp := initParams(storage, noBaseFee, nil) ethHeader, err := gethencoding.CreateEthHeaderForBatch(header, secret(storage))