-
Notifications
You must be signed in to change notification settings - Fork 305
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
fix: memory leak in the broker #10567
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ export class CachingBrokerFacade implements ServerCircuitProver { | |
id: ProvingJobId, | ||
type: T, | ||
inputs: ProvingJobInputsMap[T], | ||
epochNumber = 0, | ||
signal?: AbortSignal, | ||
): Promise<ProvingJobResultsMap[T]> { | ||
// first try the cache | ||
|
@@ -95,6 +96,7 @@ export class CachingBrokerFacade implements ServerCircuitProver { | |
id, | ||
type, | ||
inputsUri, | ||
epochNumber, | ||
}); | ||
await this.cache.setProvingJobStatus(id, { status: 'in-queue' }); | ||
} catch (err) { | ||
|
@@ -107,7 +109,7 @@ export class CachingBrokerFacade implements ServerCircuitProver { | |
// notify broker of cancelled job | ||
const abortFn = async () => { | ||
signal?.removeEventListener('abort', abortFn); | ||
await this.broker.removeAndCancelProvingJob(id); | ||
await this.broker.cancelProvingJob(id); | ||
}; | ||
|
||
signal?.addEventListener('abort', abortFn); | ||
|
@@ -147,160 +149,174 @@ export class CachingBrokerFacade implements ServerCircuitProver { | |
} | ||
} finally { | ||
signal?.removeEventListener('abort', abortFn); | ||
// we've saved the result in our cache. We can tell the broker to clear its state | ||
await this.broker.cleanUpProvingJobState(id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I read this correctly. Does this mean the orchestrator effectively tells the broker when to clear state. This feels like it's quite coupled. Would a better approach be for the broker to simply e.g. delete all state for epochs < N - 1 when it is asked to prove something for epoch N. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you that's right. I think your suggestion makes a lot of sense! |
||
} | ||
} | ||
|
||
getAvmProof( | ||
inputs: AvmCircuitInputs, | ||
signal?: AbortSignal, | ||
_blockNumber?: number, | ||
epochNumber?: number, | ||
): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.PUBLIC_VM, inputs), | ||
ProvingRequestType.PUBLIC_VM, | ||
inputs, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getBaseParityProof( | ||
inputs: BaseParityInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.BASE_PARITY, inputs), | ||
ProvingRequestType.BASE_PARITY, | ||
inputs, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getBlockMergeRollupProof( | ||
input: BlockMergeRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.BLOCK_MERGE_ROLLUP, input), | ||
ProvingRequestType.BLOCK_MERGE_ROLLUP, | ||
input, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getBlockRootRollupProof( | ||
input: BlockRootRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.BLOCK_ROOT_ROLLUP, input), | ||
ProvingRequestType.BLOCK_ROOT_ROLLUP, | ||
input, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getEmptyBlockRootRollupProof( | ||
input: EmptyBlockRootRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP, input), | ||
ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP, | ||
input, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getEmptyPrivateKernelProof( | ||
inputs: PrivateKernelEmptyInputData, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.PRIVATE_KERNEL_EMPTY, inputs), | ||
ProvingRequestType.PRIVATE_KERNEL_EMPTY, | ||
inputs, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getMergeRollupProof( | ||
input: MergeRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.MERGE_ROLLUP, input), | ||
ProvingRequestType.MERGE_ROLLUP, | ||
input, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
getPrivateBaseRollupProof( | ||
baseRollupInput: PrivateBaseRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.PRIVATE_BASE_ROLLUP, baseRollupInput), | ||
ProvingRequestType.PRIVATE_BASE_ROLLUP, | ||
baseRollupInput, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getPublicBaseRollupProof( | ||
inputs: PublicBaseRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.PUBLIC_BASE_ROLLUP, inputs), | ||
ProvingRequestType.PUBLIC_BASE_ROLLUP, | ||
inputs, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getRootParityProof( | ||
inputs: RootParityInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.ROOT_PARITY, inputs), | ||
ProvingRequestType.ROOT_PARITY, | ||
inputs, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getRootRollupProof( | ||
input: RootRollupInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.ROOT_ROLLUP, input), | ||
ProvingRequestType.ROOT_ROLLUP, | ||
input, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
||
getTubeProof( | ||
tubeInput: TubeInputs, | ||
signal?: AbortSignal, | ||
_epochNumber?: number, | ||
epochNumber?: number, | ||
): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>> { | ||
return this.enqueueAndWaitForJob( | ||
this.generateId(ProvingRequestType.TUBE_PROOF, tubeInput), | ||
ProvingRequestType.TUBE_PROOF, | ||
tubeInput, | ||
epochNumber, | ||
signal, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me: who's expected to be persisting proving data? I wouldn't want to clean up the broker data if we were counting on it to persist work info across crashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 I misplaced my comment sorry about that #10567 (comment)