Skip to content

Commit

Permalink
feat: add proving retries
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed May 2, 2024
1 parent 5b133f2 commit 9d334a0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions yarn-project/prover-client/src/prover-pool/memory-proving-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ type ProvingJobWithResolvers<T extends ProvingRequest = ProvingRequest> = {
id: string;
request: T;
signal?: AbortSignal;
retries: number;
} & PromiseWithResolvers<ProvingRequestResult<T['type']>>;

const MAX_RETRIES = 3;

export class MemoryProvingQueue implements CircuitProver, ProvingJobSource {
private jobId = 0;
private log = createDebugLogger('aztec:prover-client:prover-pool:queue');
Expand Down Expand Up @@ -95,7 +98,18 @@ export class MemoryProvingQueue implements CircuitProver, ProvingJobSource {
return Promise.resolve();
}

job.reject(err);
if (job.retries < MAX_RETRIES) {
job.retries++;
this.log.warn(
`Job id=${job.id} type=${ProvingRequestType[job.request.type]} failed with error: ${err}. Retry ${
job.retries
}/${MAX_RETRIES}`,
);
this.queue.put(job);
} else {
this.log.error(`Job id=${job.id} type=${ProvingRequestType[job.request.type]} failed with error: ${err}`);
job.reject(err);
}
return Promise.resolve();
}

Expand All @@ -111,13 +125,16 @@ export class MemoryProvingQueue implements CircuitProver, ProvingJobSource {
promise,
resolve,
reject,
retries: 0,
};

if (signal) {
signal.addEventListener('abort', () => reject(new AbortedError('Operation has been aborted')));
}

this.log.info(`Adding ${ProvingRequestType[request.type]} proving job to queue`);
this.log.info(
`Adding id=${item.id} type=${ProvingRequestType[request.type]} proving job to queue depth=${this.queue.length()}`,
);
// TODO (alexg) remove the `any`
if (!this.queue.put(item as any)) {
throw new Error();
Expand Down

0 comments on commit 9d334a0

Please sign in to comment.