From 5c517642b1a92c90385850fd18af4bb9b5e61280 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Thu, 19 Dec 2024 13:36:21 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"=E2=9A=97=EF=B8=8F=20Custom=20methods?= =?UTF-8?q?=20caching=20policies"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 26bf5baeb20430890d7332af7237c81dd7f2c36f. --- packages/erpc/Dockerfile | 10 +- packages/erpc/src/storage.ts | 203 ----------------------------------- 2 files changed, 5 insertions(+), 208 deletions(-) diff --git a/packages/erpc/Dockerfile b/packages/erpc/Dockerfile index 640142d..eaee2f5 100644 --- a/packages/erpc/Dockerfile +++ b/packages/erpc/Dockerfile @@ -1,11 +1,11 @@ # Config bundler step FROM oven/bun:latest AS bundler -RUN mkdir -p /tmp/dev +RUN mkdir -p /temp/dev # Bundle everything in a single erpc.js file -COPY . /tmp/dev -RUN cd /tmp/dev && bun install --production -RUN cd /tmp/dev && bun build --outfile ./erpc.js --minify --target node --external "@erpc-cloud/*" src/index.ts +COPY . /temp/dev +RUN cd /temp/dev && bun install --production +RUN cd /temp/dev && bun build --outfile ./erpc.js --minify --target node --external "@erpc-cloud/*" src/index.ts # Final image #FROM erpc-dev AS final @@ -15,7 +15,7 @@ FROM ghcr.io/erpc/erpc@sha256:c2e09378e5b7922428e8363c577fdf063aaf3d060e79ce44f8 RUN apt-get update && apt-get install -y curl # Copy the bundled config -COPY --from=bundler ./tmp/dev/erpc.js /root/erpc.js +COPY --from=bundler ./temp/dev/erpc.js /root/erpc.js # Run the server CMD ["./erpc-server"] \ No newline at end of file diff --git a/packages/erpc/src/storage.ts b/packages/erpc/src/storage.ts index 50be641..79d51f6 100644 --- a/packages/erpc/src/storage.ts +++ b/packages/erpc/src/storage.ts @@ -87,213 +87,10 @@ const cachePolicies = [ // }, ] as const satisfies CachePolicyConfig[]; -/** - * Custom caching methods - * - Added blockHash on the `eth_getLogs` method - */ -const methods = { - // Static methods that return fixed values: - eth_chainId: { - finalized: true, - }, - net_version: { - finalized: true, - }, - - // Realtime methods that change frequently (i.e. on every block): - eth_hashrate: { - realtime: true, - }, - eth_mining: { - realtime: true, - }, - eth_syncing: { - realtime: true, - }, - net_peerCount: { - realtime: true, - }, - eth_gasPrice: { - realtime: true, - }, - eth_maxPriorityFeePerGas: { - realtime: true, - }, - eth_blobBaseFee: { - realtime: true, - }, - eth_blockNumber: { - realtime: true, - }, - erigon_blockNumber: { - realtime: true, - }, - - // Methods with block references in request/response: - // Make sure number is first in the array if hash is also present - eth_getLogs: { - reqRefs: [ - [0, "fromBlock"], - [0, "toBlock"], - [0, "blockHash"], - ], - }, - eth_getBlockByHash: { - reqRefs: [[0]], - respRefs: [["number"], ["hash"]], - }, - eth_getBlockByNumber: { - reqRefs: [[0]], - respRefs: [["number"], ["hash"]], - }, - eth_getTransactionByBlockHashAndIndex: { - reqRefs: [[0]], - respRefs: [["blockNumber"], ["blockHash"]], - }, - eth_getTransactionByBlockNumberAndIndex: { - reqRefs: [[0]], - respRefs: [["blockNumber"], ["blockHash"]], - }, - eth_getUncleByBlockHashAndIndex: { - reqRefs: [[0]], - respRefs: [["number"], ["hash"]], - }, - eth_getUncleByBlockNumberAndIndex: { - reqRefs: [[0]], - respRefs: [["number"], ["hash"]], - }, - eth_getBlockTransactionCountByHash: { - reqRefs: [[0]], - }, - eth_getBlockTransactionCountByNumber: { - reqRefs: [[0]], - }, - eth_getUncleCountByBlockHash: { - reqRefs: [[0]], - }, - eth_getUncleCountByBlockNumber: { - reqRefs: [[0]], - }, - eth_getStorageAt: { - reqRefs: [[2]], - }, - eth_getBalance: { - reqRefs: [[1]], - }, - eth_getTransactionCount: { - reqRefs: [[1]], - }, - eth_getCode: { - reqRefs: [[1]], - }, - eth_call: { - reqRefs: [[1]], - }, - eth_getProof: { - reqRefs: [[2]], - }, - arbtrace_call: { - reqRefs: [[2]], - }, - eth_feeHistory: { - reqRefs: [[1]], - }, - eth_getAccount: { - reqRefs: [[1]], - }, - eth_estimateGas: { - reqRefs: [[1]], - }, - debug_traceCall: { - reqRefs: [[1]], - }, - eth_simulateV1: { - reqRefs: [[1]], - }, - erigon_getBlockByTimestamp: { - reqRefs: [[1]], - }, - arbtrace_callMany: { - reqRefs: [[1]], - }, - eth_getBlockReceipts: { - reqRefs: [[0]], - }, - trace_block: { - reqRefs: [[0]], - }, - debug_traceBlockByNumber: { - reqRefs: [[0]], - }, - trace_replayBlockTransactions: { - reqRefs: [[0]], - }, - debug_storageRangeAt: { - reqRefs: [[0]], - }, - debug_traceBlockByHash: { - reqRefs: [[0]], - }, - debug_getRawBlock: { - reqRefs: [[0]], - }, - debug_getRawHeader: { - reqRefs: [[0]], - }, - debug_getRawReceipts: { - reqRefs: [[0]], - }, - erigon_getHeaderByNumber: { - reqRefs: [[0]], - }, - arbtrace_block: { - reqRefs: [[0]], - }, - arbtrace_replayBlockTransactions: { - reqRefs: [[0]], - }, - - // Special methods that can be cached regardless of block: - // Most often finality of these responses is 'unknown'. - // For these data it is safe to keep the data in cache even after reorg, - // because if client explcitly querying such data (e.g. a specific tx hash receipt) - // they know it might be reorged from a separate process. - // For example this is not safe to do for eth_getBlockByNumber because users - // require the method to always give them current accurate data (even if it's reorged). - // Using "*" as request blockRef means that these data are safe be cached irrevelant of their block. - eth_getTransactionReceipt: { - reqRefs: [["*"]], - respRefs: [["blockNumber"], ["blockHash"]], - }, - eth_getTransactionByHash: { - reqRefs: [["*"]], - respRefs: [["blockNumber"], ["blockHash"]], - }, - arbtrace_replayTransaction: { - reqRefs: [["*"]], - }, - trace_replayTransaction: { - reqRefs: [["*"]], - }, - debug_traceTransaction: { - reqRefs: [["*"]], - }, - trace_rawTransaction: { - reqRefs: [["*"]], - }, - trace_transaction: { - reqRefs: [["*"]], - }, - debug_traceBlock: { - reqRefs: [["*"]], - }, -} as unknown as CacheConfig["methods"]; - /** * Export our final cache config */ export const cacheConfig = { connectors, policies: cachePolicies, - methods, } as const satisfies CacheConfig;