From 1110858e417e218cbd9a0c7ca2d0c8506adccbd7 Mon Sep 17 00:00:00 2001 From: StefanIliev545 Date: Thu, 29 Feb 2024 13:22:55 +0200 Subject: [PATCH 1/2] Disabled caching. --- tools/walletextension/cache/cache.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/walletextension/cache/cache.go b/tools/walletextension/cache/cache.go index 74be7c3a7b..e0886abf9e 100644 --- a/tools/walletextension/cache/cache.go +++ b/tools/walletextension/cache/cache.go @@ -25,18 +25,18 @@ type RPCMethodCacheConfig struct { // CacheableRPCMethods is a map of Ethereum JSON-RPC methods that can be cached and their TTL var cacheableRPCMethods = map[string]RPCMethodCacheConfig{ // Ethereum JSON-RPC methods that can be cached long time - "eth_getBlockByNumber": {longCacheTTL, false}, - "eth_getBlockByHash": {longCacheTTL, false}, - "eth_getTransactionByHash": {longCacheTTL, true}, - "eth_chainId": {longCacheTTL, false}, + "eth_getBlockByNumber": {longCacheTTL, false}, + "eth_getBlockByHash": {longCacheTTL, false}, + //"eth_getTransactionByHash": {longCacheTTL, true}, + "eth_chainId": {longCacheTTL, false}, // Ethereum JSON-RPC methods that can be cached short time "eth_blockNumber": {shortCacheTTL, false}, "eth_getCode": {shortCacheTTL, true}, // "eth_getBalance": {longCacheTTL, true},// excluded for test: gen_cor_059 - "eth_getTransactionReceipt": {shortCacheTTL, true}, - "eth_call": {shortCacheTTL, true}, - "eth_gasPrice": {shortCacheTTL, false}, + //"eth_getTransactionReceipt": {shortCacheTTL, true}, + "eth_call": {shortCacheTTL, true}, + "eth_gasPrice": {shortCacheTTL, false}, // "eth_getTransactionCount": {longCacheTTL, true}, // excluded for test: gen_cor_009 "eth_estimateGas": {shortCacheTTL, true}, "eth_feeHistory": {shortCacheTTL, false}, From 195388656a627f8a70dada78f2f516d0c392e52f Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Sat, 2 Mar 2024 12:00:31 +0000 Subject: [PATCH 2/2] 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,