Skip to content

Commit

Permalink
add an unchanging block frequency so that validations have a more sta…
Browse files Browse the repository at this point in the history
…ble environment
  • Loading branch information
apexearth committed Dec 20, 2024
1 parent 2a6b180 commit d76f632
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/polyfills/rpc-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ RpcClient.prototype.call = async function <T = any>(
params?: any[],
options?: CallOptions<T>,
): Promise<T> {
const time = Date.now()
processingStats.rpcCalls++
const response = await (this as any)._call(method, params, options)
if (method === 'debug_traceBlockByHash') {
fixSelfDestructs(response)
}
// 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 <T = any>(batch: RpcCall[], options?: CallOptions<T>): Promise<T[]> {
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++) {
Expand All @@ -32,6 +35,7 @@ RpcClient.prototype.batchCall = async function <T = any>(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
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/blockFrequencyUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
Expand Down
3 changes: 3 additions & 0 deletions src/utils/processing-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -17,4 +19,5 @@ export const printStats = (ctx: Context) => {
})
}
processingStats.rpcCalls = 0
processingStats.rpcCallTime = 0
}

0 comments on commit d76f632

Please sign in to comment.