diff --git a/packages/beacon-node/src/chain/bls/multithread/index.ts b/packages/beacon-node/src/chain/bls/multithread/index.ts index 0ead7505351f..680ca6da9b43 100644 --- a/packages/beacon-node/src/chain/bls/multithread/index.ts +++ b/packages/beacon-node/src/chain/bls/multithread/index.ts @@ -21,6 +21,7 @@ import {chunkifyMaximizeChunkSize} from "./utils.js"; import {defaultPoolSize} from "./poolSize.js"; import { JobQueueItem, + JobQueueItemSameMessage, JobQueueItemType, jobItemSameMessageToMultiSet, jobItemSigSets, @@ -394,16 +395,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier { job.reject(e as Error); } else { // there could be an invalid pubkey/signature, retry each individually - // Create new jobs for each pubkey set, and Promise.all all the results - for (const j of jobItemSameMessageToMultiSet(job)) { - if (j.opts.priority) { - this.jobs.unshift(j); - } else { - this.jobs.push(j); - } - } - this.metrics?.blsThreadPool.sameMessageRetryJobs.inc(1); - this.metrics?.blsThreadPool.sameMessageRetrySets.inc(job.sets.length); + this.retryJobItemSameMessage(job); } continue; } @@ -465,16 +457,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier { job.resolve(job.sets.map(() => true)); } else { // Retry each individually - // Create new jobs for each pubkey set, and Promise.all all the results - for (const j of jobItemSameMessageToMultiSet(job)) { - if (j.opts.priority) { - this.jobs.unshift(j); - } else { - this.jobs.push(j); - } - } - this.metrics?.blsThreadPool.sameMessageRetryJobs.inc(1); - this.metrics?.blsThreadPool.sameMessageRetrySets.inc(job.sets.length); + this.retryJobItemSameMessage(job); } successCount += 1; } @@ -545,6 +528,19 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier { } }; + private retryJobItemSameMessage(job: JobQueueItemSameMessage): void { + // Create new jobs for each pubkey set, and Promise.all all the results + for (const j of jobItemSameMessageToMultiSet(job)) { + if (j.opts.priority) { + this.jobs.unshift(j); + } else { + this.jobs.push(j); + } + } + this.metrics?.blsThreadPool.sameMessageRetryJobs.inc(1); + this.metrics?.blsThreadPool.sameMessageRetrySets.inc(job.sets.length); + } + /** For testing */ private async waitTillInitialized(): Promise { await Promise.all(