Skip to content

Commit 4a3e15b

Browse files
committed
Added forceProverExists to protect against missing provers for non-sideloaded circuits
1 parent 684b621 commit 4a3e15b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/common/src/compiling/CompileRegistry.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@ export class CompileRegistry {
3030

3131
private artifacts: ArtifactRecord = {};
3232

33-
// TODO Add possibility to force recompilation for non-sideloaded dependencies
33+
private inForceProverBlock = false;
34+
35+
/**
36+
* This function forces compilation even if the artifact itself is in the registry.
37+
* Basically the statement is: The artifact along is not enough, we need to
38+
* actually have the prover compiled.
39+
* This is true for non-sideloaded circuit dependencies.
40+
*/
41+
public async forceProverExists(
42+
f: (registry: CompileRegistry) => Promise<void>
43+
) {
44+
this.inForceProverBlock = true;
45+
await f(this);
46+
this.inForceProverBlock = false;
47+
}
3448

3549
public async compile(target: CompileTarget) {
36-
if (this.artifacts[target.name] === undefined) {
50+
if (this.artifacts[target.name] === undefined || this.inForceProverBlock) {
3751
const artifact = await this.compiler.compileContract(target);
3852
this.artifacts[target.name] = artifact;
3953
return artifact;

packages/protocol/src/prover/block/BlockProver.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,10 @@ export class BlockProver
931931
public async compile(
932932
registry: CompileRegistry
933933
): Promise<Record<string, CompileArtifact> | undefined> {
934-
await this.stateTransitionProver.compile(registry);
935-
await this.runtime.compile(registry);
934+
await registry.forceProverExists(async () => {
935+
await this.stateTransitionProver.compile(registry);
936+
await this.runtime.compile(registry);
937+
});
936938

937939
return await this.zkProgrammable.compile(registry);
938940
}

0 commit comments

Comments
 (0)