From 1e7e94cc116c3472bf3edcb95efeeac93eca6b6f Mon Sep 17 00:00:00 2001 From: Stefan Iliev <46542846+StefanIliev545@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:41:51 +0300 Subject: [PATCH] Added stopwatches in important functions. (#1581) Co-authored-by: StefanIliev545 --- go/enclave/enclave.go | 3 +++ go/enclave/evm/evm_facade.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index b4ea2ba6e4..3206629e93 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -1006,6 +1006,8 @@ func (e *enclaveImpl) EstimateGas(encryptedParams common.EncryptedParamsEstimate return nil, responses.ToInternalError(fmt.Errorf("requested EstimateGas with the enclave stopping")) } + defer core.LogMethodDuration(e.logger, measure.NewStopwatch(), "enclave.go:EstimateGas()") + // decode the received request into a []interface paramList, err := e.decodeRequest(encryptedParams) if err != nil { @@ -1396,6 +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") 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 b35e0e9e79..08550c5f8a 100644 --- a/go/enclave/evm/evm_facade.go +++ b/go/enclave/evm/evm_facade.go @@ -16,6 +16,8 @@ import ( "github.com/obscuronet/go-obscuro/go/common/errutil" "github.com/obscuronet/go-obscuro/go/common/gethencoding" "github.com/obscuronet/go-obscuro/go/common/log" + "github.com/obscuronet/go-obscuro/go/common/measure" + "github.com/obscuronet/go-obscuro/go/enclave/core" "github.com/obscuronet/go-obscuro/go/enclave/crypto" "github.com/obscuronet/go-obscuro/go/enclave/storage" @@ -162,6 +164,8 @@ func ExecuteObsCall( noBaseFee = false } + core.LogMethodDuration(logger, measure.NewStopwatch(), "evm_facade.go:ObsCall()") + chain, vmCfg, gp := initParams(storage, noBaseFee, nil) ethHeader, err := gethencoding.CreateEthHeaderForBatch(header, secret(storage)) if err != nil {