From 195388656a627f8a70dada78f2f516d0c392e52f Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Sat, 2 Mar 2024 12:00:31 +0000 Subject: [PATCH] performance fix --- go/enclave/enclave.go | 2 +- go/enclave/rpc/EstimateGas.go | 5 +++-- go/enclave/rpc/rpc_encryption_manager.go | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index 2a48d5b03e..0d47c7c418 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -225,7 +225,7 @@ func NewEnclave( registry, config.GasLocalExecutionCapFlag, ) - rpcEncryptionManager := rpc.NewEncryptionManager(ecies.ImportECDSA(obscuroKey), storage, registry, crossChainProcessors, service, config, gasOracle, storage, chain, logger) + rpcEncryptionManager := rpc.NewEncryptionManager(ecies.ImportECDSA(obscuroKey), storage, registry, crossChainProcessors, service, config, gasOracle, storage, blockProcessor, chain, logger) subscriptionManager := events.NewSubscriptionManager(storage, config.ObscuroChainID, logger) // ensure cached chain state data is up-to-date using the persisted batch data diff --git a/go/enclave/rpc/EstimateGas.go b/go/enclave/rpc/EstimateGas.go index 20708601d0..2b6489d383 100644 --- a/go/enclave/rpc/EstimateGas.go +++ b/go/enclave/rpc/EstimateGas.go @@ -60,7 +60,7 @@ func EstimateGasExecute(builder *CallBuilder[CallParamsWithBlock, hexutil.Uint64 txArgs := builder.Param.callParams blockNumber := builder.Param.block - block, err := rpc.blockResolver.FetchHeadBlock() + block, err := rpc.l1BlockProcessor.GetHead() if err != nil { return err } @@ -72,7 +72,8 @@ func EstimateGasExecute(builder *CallBuilder[CallParamsWithBlock, hexutil.Uint64 return err } - batch, err := rpc.storage.FetchHeadBatch() + headBatchSeq := rpc.registry.HeadBatchSeq() + batch, err := rpc.storage.FetchBatchBySeqNo(headBatchSeq.Uint64()) if err != nil { return err } diff --git a/go/enclave/rpc/rpc_encryption_manager.go b/go/enclave/rpc/rpc_encryption_manager.go index 9fc41c07cc..a974a9389f 100644 --- a/go/enclave/rpc/rpc_encryption_manager.go +++ b/go/enclave/rpc/rpc_encryption_manager.go @@ -26,11 +26,12 @@ type EncryptionManager struct { service nodetype.NodeType gasOracle gas.Oracle blockResolver storage.BlockResolver + l1BlockProcessor components.L1BlockProcessor config *config.EnclaveConfig logger gethlog.Logger } -func NewEncryptionManager(enclavePrivateKeyECIES *ecies.PrivateKey, storage storage.Storage, registry components.BatchRegistry, processors *crosschain.Processors, service nodetype.NodeType, config *config.EnclaveConfig, oracle gas.Oracle, blockResolver storage.BlockResolver, chain l2chain.ObscuroChain, logger gethlog.Logger) *EncryptionManager { +func NewEncryptionManager(enclavePrivateKeyECIES *ecies.PrivateKey, storage storage.Storage, registry components.BatchRegistry, processors *crosschain.Processors, service nodetype.NodeType, config *config.EnclaveConfig, oracle gas.Oracle, blockResolver storage.BlockResolver, l1BlockProcessor components.L1BlockProcessor, chain l2chain.ObscuroChain, logger gethlog.Logger) *EncryptionManager { return &EncryptionManager{ storage: storage, registry: registry, @@ -39,6 +40,7 @@ func NewEncryptionManager(enclavePrivateKeyECIES *ecies.PrivateKey, storage stor chain: chain, config: config, blockResolver: blockResolver, + l1BlockProcessor: l1BlockProcessor, gasOracle: oracle, logger: logger, enclavePrivateKeyECIES: enclavePrivateKeyECIES,