diff --git a/src/polyfills/rpc-issues.ts b/src/polyfills/rpc-issues.ts index 4e72d113..599766ba 100644 --- a/src/polyfills/rpc-issues.ts +++ b/src/polyfills/rpc-issues.ts @@ -13,6 +13,7 @@ RpcClient.prototype.call = async function ( params?: any[], options?: CallOptions, ): Promise { + const time = Date.now() processingStats.rpcCalls++ const response = await (this as any)._call(method, params, options) if (method === 'debug_traceBlockByHash') { @@ -20,9 +21,11 @@ RpcClient.prototype.call = async function ( } // fs.writeFileSync(`rpcResponse${count}-in.json`, JSON.stringify({ method, params, options }, null, 2)) // fs.writeFileSync(`rpcResponse${count++}.json`, JSON.stringify(response, null, 2)) + processingStats.rpcCallTime += Date.now() - time return response } RpcClient.prototype.batchCall = async function (batch: RpcCall[], options?: CallOptions): Promise { + const time = Date.now() processingStats.rpcCalls += batch.length const response = await (this as any)._batchCall(batch, options) for (let i = 0; i < batch.length; i++) { @@ -32,6 +35,7 @@ RpcClient.prototype.batchCall = async function (batch: RpcCall[], optio } // fs.writeFileSync(`rpcResponse$${count}-in.json`, JSON.stringify({ batch, options }, null, 2)) // fs.writeFileSync(`rpcResponse$${count++}.json`, JSON.stringify(response, null, 2)) + processingStats.rpcCallTime += Date.now() - time return response } diff --git a/src/utils/blockFrequencyUpdater.ts b/src/utils/blockFrequencyUpdater.ts index f7a97d79..f769cf7a 100644 --- a/src/utils/blockFrequencyUpdater.ts +++ b/src/utils/blockFrequencyUpdater.ts @@ -49,7 +49,7 @@ export const blockFrequencyTracker = (params: { from: number }) => { (ctx._chain.client as any).url.includes('tenderly') || // Normal logic down below. block.header.height % frequency === 0 || - block.header.height % 100000 || // For validation generation we need something reliable and unchanging. + block.header.height % 100000 === 0 || // For validation generation we need something reliable and unchanging. isAerodromeImportantBlock(ctx, block) ) } diff --git a/src/utils/processing-stats.ts b/src/utils/processing-stats.ts index d821fcf9..0ddd7ac3 100644 --- a/src/utils/processing-stats.ts +++ b/src/utils/processing-stats.ts @@ -2,12 +2,14 @@ import { Context } from '@processor' export const processingStats = { rpcCalls: 0, + rpcCallTime: 0, } export const printStats = (ctx: Context) => { if (process.env.DEBUG_PERF === 'true') { ctx.log.info({ ...processingStats, + averageRpcCallTime: processingStats.rpcCallTime / processingStats.rpcCalls, blockCount: ctx.blocks.length, blockCountWithContent: ctx.blocksWithContent.length, frequencyBlockCount: ctx.frequencyBlocks.length, @@ -17,4 +19,5 @@ export const printStats = (ctx: Context) => { }) } processingStats.rpcCalls = 0 + processingStats.rpcCallTime = 0 }