Skip to content
Merged
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
6 changes: 5 additions & 1 deletion yarn-project/circuit-types/src/interfaces/proving-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ export const makeProvingJobId = (epochNumber: number, type: ProvingRequestType,

export const getEpochFromProvingJobId = (id: ProvingJobId) => {
const components = id.split(':');
return +components[0];
const epochNumber = components.length < 1 ? Number.NaN : parseInt(components[0], 10);
if (!Number.isSafeInteger(epochNumber) || epochNumber < 0) {
throw new Error(`Proving Job ID ${id} does not contain valid epoch`);
}
return epochNumber;
};

export type ProvingJob = z.infer<typeof ProvingJob>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ProvingRequestType,
type PublicInputsAndRecursiveProof,
type ServerCircuitProver,
makeProvingJobId,
} from '@aztec/circuit-types';
import {
type AVM_PROOF_LENGTH_IN_FIELDS,
Expand Down Expand Up @@ -564,6 +565,6 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {

private generateId(type: ProvingRequestType, inputs: { toBuffer(): Buffer }, epochNumber = 0) {
const inputsHash = sha256(inputs.toBuffer());
return `${epochNumber}:${ProvingRequestType[type]}:${inputsHash.toString('hex')}`;
return makeProvingJobId(epochNumber, type, inputsHash.toString('hex'));
}
}