Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new RpcDataIngestSettings for controlling split size #354

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion evm/evm-processor/src/ds-rpc/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ export interface EvmRpcDataSourceOptions {
debugTraceTimeout?: string
log?: Logger
validationFlags?: RpcValidationFlags
maxBlocksPerIteration?: number
}

export class EvmRpcDataSource implements HotDataSource<Block, DataRequest> {
private rpc: Rpc
private finalityConfirmation: number
private headPollInterval: number
private newHeadTimeout: number
private maxBlocksPerIteration: number
private preferTraceApi?: boolean
private useDebugApiForStateDiffs?: boolean
private debugTraceTimeout?: string
Expand All @@ -66,6 +68,7 @@ export class EvmRpcDataSource implements HotDataSource<Block, DataRequest> {
this.preferTraceApi = options.preferTraceApi
this.useDebugApiForStateDiffs = options.useDebugApiForStateDiffs
this.debugTraceTimeout = options.debugTraceTimeout
this.maxBlocksPerIteration = Math.max(options.maxBlocksPerIteration || 10, 1)
}

async getFinalizedHeight(): Promise<number> {
Expand All @@ -85,7 +88,7 @@ export class EvmRpcDataSource implements HotDataSource<Block, DataRequest> {
getFinalizedHeight: () => this.getFinalizedHeight(),
getSplit: req => this._getColdSplit(req),
requests: mapRangeRequestList(requests, req => this.toMappingRequest(req)),
splitSize: 10,
splitSize: this.maxBlocksPerIteration,
concurrency: Math.min(5, this.rpc.client.getConcurrency()),
stopOnHead,
headPollInterval: this.headPollInterval
Expand Down
6 changes: 6 additions & 0 deletions evm/evm-processor/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export interface RpcDataIngestionSettings {
* Flags to switch off the data consistency checks
*/
validationFlags?: RpcValidationFlags

/**
* The maximum number of blocks to process at a time
*/
maxBlocksPerIteration?: number
}


Expand Down Expand Up @@ -473,6 +478,7 @@ export class EvmBatchProcessor<F extends FieldSelection = {}> {
headPollInterval: this.rpcIngestSettings?.headPollInterval,
newHeadTimeout: this.rpcIngestSettings?.newHeadTimeout,
validationFlags: this.rpcIngestSettings?.validationFlags,
maxBlocksPerIteration: this.rpcIngestSettings?.maxBlocksPerIteration,
log: this.getLogger().child('rpc', {rpcUrl: this.getChainRpcClient().url})
})
}
Expand Down