@aztec/prover-client 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -2
- package/dest/light/lightweight_checkpoint_builder.d.ts +22 -6
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +112 -28
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +2 -1
- package/dest/mocks/test_context.d.ts +6 -2
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +31 -11
- package/dest/orchestrator/block-building-helpers.d.ts +5 -5
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +4 -4
- package/dest/orchestrator/block-proving-state.d.ts +4 -1
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +7 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts +24 -4
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +47 -5
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +107 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +151 -0
- package/dest/orchestrator/epoch-proving-context.d.ts +51 -0
- package/dest/orchestrator/epoch-proving-context.d.ts.map +1 -0
- package/dest/orchestrator/epoch-proving-context.js +81 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +7 -6
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +37 -1
- package/dest/orchestrator/index.d.ts +4 -1
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -0
- package/dest/orchestrator/orchestrator.d.ts +30 -25
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +549 -255
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -6
- package/dest/orchestrator/proving-scheduler.d.ts +72 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +117 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +83 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +182 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts +62 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-scheduler.js +73 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-state.js +185 -0
- package/dest/orchestrator/tx-proving-state.d.ts +5 -4
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +6 -6
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/prover-client.d.ts +66 -7
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +64 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +7 -5
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +16 -22
- package/dest/proving_broker/config.d.ts +12 -64
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +22 -5
- package/dest/proving_broker/index.d.ts +2 -1
- package/dest/proving_broker/index.d.ts.map +1 -1
- package/dest/proving_broker/index.js +1 -0
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- package/dest/proving_broker/proving_broker.d.ts +8 -5
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +69 -21
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +391 -3
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +22 -35
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +6 -3
- package/dest/proving_broker/rpc.d.ts +6 -2
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +87 -23
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +5 -5
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +3 -3
- package/package.json +19 -21
- package/src/config.ts +18 -2
- package/src/light/lightweight_checkpoint_builder.ts +159 -37
- package/src/mocks/fixtures.ts +2 -1
- package/src/mocks/test_context.ts +24 -11
- package/src/orchestrator/block-building-helpers.ts +4 -4
- package/src/orchestrator/block-proving-state.ts +9 -0
- package/src/orchestrator/checkpoint-proving-state.ts +65 -6
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
- package/src/orchestrator/epoch-proving-context.ts +101 -0
- package/src/orchestrator/epoch-proving-state.ts +59 -9
- package/src/orchestrator/index.ts +8 -0
- package/src/orchestrator/orchestrator.ts +165 -293
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/proving-scheduler.ts +156 -0
- package/src/orchestrator/top-tree-orchestrator.ts +314 -0
- package/src/orchestrator/top-tree-proving-scheduler.ts +154 -0
- package/src/orchestrator/top-tree-proving-state.ts +220 -0
- package/src/orchestrator/tx-proving-state.ts +8 -11
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +157 -24
- package/src/proving_broker/broker_prover_facade.ts +25 -26
- package/src/proving_broker/config.ts +25 -2
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +65 -16
- package/src/proving_broker/proving_broker_database/persisted.ts +17 -3
- package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
- package/src/proving_broker/proving_job_controller.ts +9 -3
- package/src/proving_broker/rpc.ts +46 -20
- package/src/test/mock_prover.ts +1 -8
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -108
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -137
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type { BatchedBlob, BatchedBlobAccumulator, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import type { NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
3
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
5
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
+
import {
|
|
8
|
+
CheckpointMergeRollupPrivateInputs,
|
|
9
|
+
CheckpointPaddingRollupPrivateInputs,
|
|
10
|
+
CheckpointRollupPublicInputs,
|
|
11
|
+
RootRollupPrivateInputs,
|
|
12
|
+
type RootRollupPublicInputs,
|
|
13
|
+
} from '@aztec/stdlib/rollup';
|
|
14
|
+
|
|
15
|
+
import { toProofData } from './block-building-helpers.js';
|
|
16
|
+
import type { ProofState } from './block-proving-state.js';
|
|
17
|
+
|
|
18
|
+
enum TOP_TREE_LIFECYCLE {
|
|
19
|
+
CREATED,
|
|
20
|
+
RESOLVED,
|
|
21
|
+
REJECTED,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Lean top-tree-only state. Owns the merge tree of checkpoint root proofs, the
|
|
26
|
+
* single-checkpoint padding proof slot, the final root rollup proof, and the blob
|
|
27
|
+
* accumulator endpoints needed to finalise the epoch's batched blob proof.
|
|
28
|
+
*
|
|
29
|
+
* Constructed with `totalNumCheckpoints` and `finalBlobBatchingChallenges` upfront —
|
|
30
|
+
* by the time the top tree starts, all checkpoints are known and the challenges are
|
|
31
|
+
* derivable from their blob fields.
|
|
32
|
+
*/
|
|
33
|
+
export class TopTreeProvingState {
|
|
34
|
+
private checkpointProofs: UnbalancedTreeStore<
|
|
35
|
+
ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
36
|
+
>;
|
|
37
|
+
private checkpointPaddingProof:
|
|
38
|
+
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
39
|
+
| undefined;
|
|
40
|
+
private rootRollupProof: ProofState<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
|
|
41
|
+
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
42
|
+
private finalBatchedBlob: BatchedBlob | undefined;
|
|
43
|
+
private lifecycle = TOP_TREE_LIFECYCLE.CREATED;
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
public readonly epochNumber: EpochNumber,
|
|
47
|
+
public readonly totalNumCheckpoints: number,
|
|
48
|
+
public readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
49
|
+
public readonly startBlobAccumulator: BatchedBlobAccumulator,
|
|
50
|
+
private readonly completionCallback: () => void,
|
|
51
|
+
private readonly rejectionCallback: (reason: string) => void,
|
|
52
|
+
) {
|
|
53
|
+
if (totalNumCheckpoints < 1) {
|
|
54
|
+
throw new Error(`TopTreeProvingState requires at least one checkpoint; got ${totalNumCheckpoints}.`);
|
|
55
|
+
}
|
|
56
|
+
this.checkpointProofs = new UnbalancedTreeStore(totalNumCheckpoints);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// --- checkpoint root rollup ---
|
|
60
|
+
|
|
61
|
+
public setCheckpointRootRollupProof(
|
|
62
|
+
checkpointIndex: number,
|
|
63
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
64
|
+
CheckpointRollupPublicInputs,
|
|
65
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
66
|
+
>,
|
|
67
|
+
): TreeNodeLocation {
|
|
68
|
+
return this.checkpointProofs.setLeaf(checkpointIndex, { provingOutput });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// --- checkpoint merge rollup ---
|
|
72
|
+
|
|
73
|
+
public tryStartProvingCheckpointMerge(location: TreeNodeLocation) {
|
|
74
|
+
if (this.checkpointProofs.getNode(location)?.isProving) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
this.checkpointProofs.setNode(location, { isProving: true });
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public setCheckpointMergeRollupProof(
|
|
82
|
+
location: TreeNodeLocation,
|
|
83
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
84
|
+
CheckpointRollupPublicInputs,
|
|
85
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
86
|
+
>,
|
|
87
|
+
) {
|
|
88
|
+
this.checkpointProofs.setNode(location, { provingOutput });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public isReadyForCheckpointMerge(location: TreeNodeLocation) {
|
|
92
|
+
return !!this.checkpointProofs.getSibling(location)?.provingOutput;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public getParentLocation(location: TreeNodeLocation) {
|
|
96
|
+
return this.checkpointProofs.getParentLocation(location);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
100
|
+
const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
101
|
+
if (!left || !right) {
|
|
102
|
+
throw new Error('At least one child is not ready for the checkpoint merge rollup.');
|
|
103
|
+
}
|
|
104
|
+
return new CheckpointMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// --- padding (single-checkpoint case) ---
|
|
108
|
+
|
|
109
|
+
public tryStartProvingPaddingCheckpoint() {
|
|
110
|
+
if (this.checkpointPaddingProof?.isProving) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
this.checkpointPaddingProof = { isProving: true };
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public setCheckpointPaddingProof(
|
|
118
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
119
|
+
CheckpointRollupPublicInputs,
|
|
120
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
121
|
+
>,
|
|
122
|
+
) {
|
|
123
|
+
this.checkpointPaddingProof = { provingOutput };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public getPaddingCheckpointInputs() {
|
|
127
|
+
return new CheckpointPaddingRollupPrivateInputs();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// --- root rollup ---
|
|
131
|
+
|
|
132
|
+
public tryStartProvingRootRollup() {
|
|
133
|
+
if (this.rootRollupProof?.isProving) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
this.rootRollupProof = { isProving: true };
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
|
|
141
|
+
this.rootRollupProof = { provingOutput };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public isReadyForRootRollup() {
|
|
145
|
+
const childProofs = this.#getChildProofsForRoot();
|
|
146
|
+
return childProofs.every(p => !!p);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public getRootRollupInputs() {
|
|
150
|
+
const [left, right] = this.#getChildProofsForRoot();
|
|
151
|
+
if (!left || !right) {
|
|
152
|
+
throw new Error('At least one child is not ready for the root rollup.');
|
|
153
|
+
}
|
|
154
|
+
return RootRollupPrivateInputs.from({
|
|
155
|
+
previousRollups: [toProofData(left), toProofData(right)],
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// --- blob accumulator finalisation ---
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Sets the end-of-epoch blob accumulator, computed by the top-tree orchestrator
|
|
163
|
+
* from the surviving checkpoints' blob fields. Required before `finalizeBatchedBlob`.
|
|
164
|
+
*/
|
|
165
|
+
public setEndBlobAccumulator(accumulator: BatchedBlobAccumulator) {
|
|
166
|
+
this.endBlobAccumulator = accumulator;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public async finalizeBatchedBlob() {
|
|
170
|
+
if (!this.endBlobAccumulator) {
|
|
171
|
+
throw new Error('End blob accumulator not set; call setEndBlobAccumulator before finalize.');
|
|
172
|
+
}
|
|
173
|
+
this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true /* verifyProof */);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs; batchedBlobInputs: BatchedBlob } {
|
|
177
|
+
const provingOutput = this.rootRollupProof?.provingOutput;
|
|
178
|
+
if (!provingOutput || !this.finalBatchedBlob) {
|
|
179
|
+
throw new Error('Top-tree proof not ready; root rollup or batched blob missing.');
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
proof: provingOutput.proof.binaryProof,
|
|
183
|
+
publicInputs: provingOutput.inputs,
|
|
184
|
+
batchedBlobInputs: this.finalBatchedBlob,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// --- lifecycle ---
|
|
189
|
+
|
|
190
|
+
public verifyState() {
|
|
191
|
+
return this.lifecycle === TOP_TREE_LIFECYCLE.CREATED;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public resolve() {
|
|
195
|
+
if (!this.verifyState()) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.lifecycle = TOP_TREE_LIFECYCLE.RESOLVED;
|
|
199
|
+
this.completionCallback();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public reject(reason: string) {
|
|
203
|
+
if (!this.verifyState()) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
this.lifecycle = TOP_TREE_LIFECYCLE.REJECTED;
|
|
207
|
+
this.rejectionCallback(reason);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public cancel() {
|
|
211
|
+
this.reject('Top-tree proving cancelled');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#getChildProofsForRoot() {
|
|
215
|
+
const rootLocation = { level: 0, index: 0 };
|
|
216
|
+
return this.totalNumCheckpoints === 1
|
|
217
|
+
? [this.checkpointProofs.getNode(rootLocation)?.provingOutput, this.checkpointPaddingProof?.provingOutput]
|
|
218
|
+
: this.checkpointProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -2,8 +2,8 @@ import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_ROLLUP_HONK_PROO
|
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
4
4
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
5
|
-
import type {
|
|
6
|
-
import { ProofData, ProofDataForFixedVk } from '@aztec/stdlib/proofs';
|
|
5
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { ProofData, ProofDataForFixedVk, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
7
7
|
import {
|
|
8
8
|
type BaseRollupHints,
|
|
9
9
|
PrivateBaseRollupHints,
|
|
@@ -32,7 +32,7 @@ export class TxProvingState {
|
|
|
32
32
|
PublicChonkVerifierPublicInputs,
|
|
33
33
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
34
34
|
>;
|
|
35
|
-
private
|
|
35
|
+
private avmProof?: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>;
|
|
36
36
|
|
|
37
37
|
constructor(
|
|
38
38
|
public readonly processedTx: ProcessedTx,
|
|
@@ -46,7 +46,7 @@ export class TxProvingState {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
public ready() {
|
|
49
|
-
return !this.requireAvmProof || (!!this.
|
|
49
|
+
return !this.requireAvmProof || (!!this.avmProof && !!this.publicChonkVerifier);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
public getAvmInputs(): AvmCircuitInputs {
|
|
@@ -80,8 +80,8 @@ export class TxProvingState {
|
|
|
80
80
|
this.publicChonkVerifier = publicChonkVerifierProofAndVk;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
public setAvmProof(
|
|
84
|
-
this.
|
|
83
|
+
public setAvmProof(avmProof: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>) {
|
|
84
|
+
this.avmProof = avmProof;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
#getPrivateBaseInputs() {
|
|
@@ -105,7 +105,7 @@ export class TxProvingState {
|
|
|
105
105
|
if (!this.publicChonkVerifier) {
|
|
106
106
|
throw new Error('Tx not ready for proving base rollup: public chonk verifier proof undefined');
|
|
107
107
|
}
|
|
108
|
-
if (!this.
|
|
108
|
+
if (!this.avmProof) {
|
|
109
109
|
throw new Error('Tx not ready for proving base rollup: avm proof undefined');
|
|
110
110
|
}
|
|
111
111
|
if (!(this.baseRollupHints instanceof PublicBaseRollupHints)) {
|
|
@@ -114,10 +114,7 @@ export class TxProvingState {
|
|
|
114
114
|
|
|
115
115
|
const publicChonkVerifierProofData = toProofData(this.publicChonkVerifier);
|
|
116
116
|
|
|
117
|
-
const avmProofData = new ProofDataForFixedVk(
|
|
118
|
-
this.processedTx.avmProvingRequest.inputs.publicInputs,
|
|
119
|
-
this.avm.proof,
|
|
120
|
-
);
|
|
117
|
+
const avmProofData = new ProofDataForFixedVk(this.processedTx.avmProvingRequest.inputs.publicInputs, this.avmProof);
|
|
121
118
|
|
|
122
119
|
return new PublicTxBaseRollupPrivateInputs(publicChonkVerifierProofData, avmProofData, this.baseRollupHints);
|
|
123
120
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ForkMerkleTreeOperations,
|
|
3
|
+
ProvingJobBroker,
|
|
4
|
+
ReadonlyWorldStateAccess,
|
|
5
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
2
6
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
3
7
|
|
|
4
8
|
import type { ProverClientConfig } from '../config.js';
|
|
@@ -6,7 +10,7 @@ import { ProverClient } from './prover-client.js';
|
|
|
6
10
|
|
|
7
11
|
export function createProverClient(
|
|
8
12
|
config: ProverClientConfig,
|
|
9
|
-
worldState: ForkMerkleTreeOperations,
|
|
13
|
+
worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
10
14
|
broker: ProvingJobBroker,
|
|
11
15
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
12
16
|
) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
7
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
6
8
|
import {
|
|
7
9
|
type ActualProverConfig,
|
|
@@ -11,44 +13,170 @@ import {
|
|
|
11
13
|
type ProvingJobBroker,
|
|
12
14
|
type ProvingJobConsumer,
|
|
13
15
|
type ProvingJobProducer,
|
|
16
|
+
type ReadonlyWorldStateAccess,
|
|
14
17
|
type ServerCircuitProver,
|
|
15
18
|
tryStop,
|
|
16
19
|
} from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
21
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
17
22
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
18
23
|
|
|
19
24
|
import type { ProverClientConfig } from '../config.js';
|
|
25
|
+
import { CheckpointSubTreeOrchestrator } from '../orchestrator/checkpoint-sub-tree-orchestrator.js';
|
|
26
|
+
import { EpochProvingContext } from '../orchestrator/epoch-proving-context.js';
|
|
20
27
|
import { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
|
|
28
|
+
import { TopTreeOrchestrator } from '../orchestrator/top-tree-orchestrator.js';
|
|
21
29
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
22
30
|
import { InlineProofStore, type ProofStore, createProofStore } from '../proving_broker/proof_store/index.js';
|
|
23
31
|
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
24
32
|
import { ServerEpochProver } from './server-epoch-prover.js';
|
|
25
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The factory surface that `EpochProvingJob` (in `prover-node`) depends on. Implemented
|
|
36
|
+
* by `ProverClient`. Defined here rather than in stdlib because the return types
|
|
37
|
+
* (`CheckpointSubTreeOrchestrator`, `TopTreeOrchestrator`) are concrete classes from
|
|
38
|
+
* this package.
|
|
39
|
+
*
|
|
40
|
+
* A single `BrokerCircuitProverFacade` is owned by `ProverClient` and shared across
|
|
41
|
+
* every orchestrator (every sub-tree and every top-tree across every concurrent epoch
|
|
42
|
+
* job). The broker delivers each completed-job notification exactly once (drained on
|
|
43
|
+
* the first `getCompletedJobs` poll), so multiple facades polling the same broker
|
|
44
|
+
* race and lose notifications
|
|
45
|
+
*
|
|
46
|
+
* The facade's job map cleans up entries on resolve/reject, and the prover-node
|
|
47
|
+
* keeps `ProverClient` alive for its whole lifetime
|
|
48
|
+
*/
|
|
49
|
+
export interface EpochProverFactory {
|
|
50
|
+
getProverId(): EthAddress;
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a per-epoch shared context for the caching of e.g. chonk verifier results
|
|
53
|
+
*/
|
|
54
|
+
createEpochProvingContext(epochNumber: EpochNumber): EpochProvingContext;
|
|
55
|
+
/**
|
|
56
|
+
* Constructs and starts a `CheckpointSubTreeOrchestrator` for a single checkpoint.
|
|
57
|
+
*/
|
|
58
|
+
createCheckpointSubTreeOrchestrator(
|
|
59
|
+
epochContext: EpochProvingContext,
|
|
60
|
+
checkpointConstants: CheckpointConstantData,
|
|
61
|
+
l1ToL2Messages: Fr[],
|
|
62
|
+
totalNumBlocks: number,
|
|
63
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
64
|
+
): Promise<CheckpointSubTreeOrchestrator>;
|
|
65
|
+
createTopTreeOrchestrator(): TopTreeOrchestrator;
|
|
66
|
+
}
|
|
67
|
+
|
|
26
68
|
/** Manages proving of epochs by orchestrating the proving of individual blocks relying on a pool of prover agents. */
|
|
27
|
-
export class ProverClient implements EpochProverManager {
|
|
69
|
+
export class ProverClient implements EpochProverManager, EpochProverFactory {
|
|
28
70
|
private running = false;
|
|
29
71
|
private agents: ProvingAgent[] = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
72
|
+
/**
|
|
73
|
+
* The single broker facade shared by every orchestrator created from this client.
|
|
74
|
+
* Constructed lazily on `start()` and torn down on `stop()` — see the comment on
|
|
75
|
+
* `EpochProverFactory` for why a single shared facade is required.
|
|
76
|
+
*/
|
|
77
|
+
private facade: BrokerCircuitProverFacade | undefined;
|
|
33
78
|
|
|
34
79
|
private constructor(
|
|
35
80
|
private config: ProverClientConfig,
|
|
36
|
-
private worldState: ForkMerkleTreeOperations,
|
|
81
|
+
private worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
37
82
|
private orchestratorClient: ProvingJobProducer,
|
|
83
|
+
private proofStore: ProofStore,
|
|
84
|
+
private failedProofStore: ProofStore | undefined,
|
|
38
85
|
private agentClient?: ProvingJobConsumer,
|
|
39
86
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
40
|
-
private log = createLogger('prover-client:tx-prover'),
|
|
41
|
-
) {
|
|
42
|
-
|
|
43
|
-
|
|
87
|
+
private log: Logger = createLogger('prover-client:tx-prover'),
|
|
88
|
+
) {}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Lazy-init the shared facade. The broker delivers each completed-job notification
|
|
92
|
+
* exactly once (drained on the first `getCompletedJobs` poll), so we cannot start
|
|
93
|
+
* a shared facade alongside the per-call facades that `createEpochProver` builds —
|
|
94
|
+
* they would race for notifications and one side would silently drop them. Starting
|
|
95
|
+
* the shared facade only on first use of one of the new factory methods keeps the
|
|
96
|
+
* legacy `createEpochProver` path race-free.
|
|
97
|
+
*/
|
|
98
|
+
private getFacade(): BrokerCircuitProverFacade {
|
|
99
|
+
if (!this.running) {
|
|
100
|
+
throw new Error('ProverClient is not running; call start() before constructing orchestrators.');
|
|
101
|
+
}
|
|
102
|
+
if (!this.facade) {
|
|
103
|
+
this.facade = new BrokerCircuitProverFacade(
|
|
104
|
+
this.orchestratorClient,
|
|
105
|
+
this.proofStore,
|
|
106
|
+
this.failedProofStore,
|
|
107
|
+
undefined,
|
|
108
|
+
this.log.getBindings(),
|
|
109
|
+
);
|
|
110
|
+
this.facade.start();
|
|
111
|
+
}
|
|
112
|
+
return this.facade;
|
|
44
113
|
}
|
|
45
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Legacy single-class epoch prover. Each call constructs its own
|
|
117
|
+
* `BrokerCircuitProverFacade`; the new factory methods (`createCheckpointSubTreeOrchestrator`,
|
|
118
|
+
* `createTopTreeOrchestrator`, `createEpochProvingContext`) share a single facade
|
|
119
|
+
* owned by `ProverClient`. Both APIs coexist while the prover-node migrates onto
|
|
120
|
+
* the new pair.
|
|
121
|
+
*/
|
|
46
122
|
public createEpochProver(): EpochProver {
|
|
47
|
-
const
|
|
48
|
-
const
|
|
123
|
+
const bindings = this.log.getBindings();
|
|
124
|
+
const facade = new BrokerCircuitProverFacade(
|
|
125
|
+
this.orchestratorClient,
|
|
126
|
+
this.proofStore,
|
|
127
|
+
this.failedProofStore,
|
|
128
|
+
undefined,
|
|
129
|
+
bindings,
|
|
130
|
+
);
|
|
131
|
+
const orchestrator = new ProvingOrchestrator(
|
|
132
|
+
this.worldState,
|
|
133
|
+
facade,
|
|
134
|
+
this.config.proverId,
|
|
135
|
+
this.config.cancelJobsOnStop,
|
|
136
|
+
this.config.enqueueConcurrency,
|
|
137
|
+
this.telemetry,
|
|
138
|
+
bindings,
|
|
139
|
+
);
|
|
49
140
|
return new ServerEpochProver(facade, orchestrator);
|
|
50
141
|
}
|
|
51
142
|
|
|
143
|
+
public createEpochProvingContext(epochNumber: EpochNumber): EpochProvingContext {
|
|
144
|
+
return new EpochProvingContext(this.getFacade(), epochNumber, this.log.getBindings());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public createCheckpointSubTreeOrchestrator(
|
|
148
|
+
epochContext: EpochProvingContext,
|
|
149
|
+
checkpointConstants: CheckpointConstantData,
|
|
150
|
+
l1ToL2Messages: Fr[],
|
|
151
|
+
totalNumBlocks: number,
|
|
152
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
153
|
+
): Promise<CheckpointSubTreeOrchestrator> {
|
|
154
|
+
return CheckpointSubTreeOrchestrator.start(
|
|
155
|
+
this.worldState,
|
|
156
|
+
this.getFacade(),
|
|
157
|
+
this.config.proverId,
|
|
158
|
+
epochContext,
|
|
159
|
+
this.config.cancelJobsOnStop,
|
|
160
|
+
this.config.enqueueConcurrency,
|
|
161
|
+
checkpointConstants,
|
|
162
|
+
l1ToL2Messages,
|
|
163
|
+
totalNumBlocks,
|
|
164
|
+
headerOfLastBlockInPreviousCheckpoint,
|
|
165
|
+
this.telemetry,
|
|
166
|
+
this.log.getBindings(),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public createTopTreeOrchestrator(): TopTreeOrchestrator {
|
|
171
|
+
return new TopTreeOrchestrator(
|
|
172
|
+
this.getFacade(),
|
|
173
|
+
this.config.proverId,
|
|
174
|
+
this.config.enqueueConcurrency,
|
|
175
|
+
this.telemetry,
|
|
176
|
+
this.log.getBindings(),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
52
180
|
public getProverId(): EthAddress {
|
|
53
181
|
return this.config.proverId;
|
|
54
182
|
}
|
|
@@ -88,6 +216,14 @@ export class ProverClient implements EpochProverManager {
|
|
|
88
216
|
}
|
|
89
217
|
this.running = false;
|
|
90
218
|
await this.stopAgents();
|
|
219
|
+
if (this.facade) {
|
|
220
|
+
try {
|
|
221
|
+
await this.facade.stop();
|
|
222
|
+
} catch (err) {
|
|
223
|
+
this.log.error('Error stopping shared broker facade', err);
|
|
224
|
+
}
|
|
225
|
+
this.facade = undefined;
|
|
226
|
+
}
|
|
91
227
|
await tryStop(this.orchestratorClient);
|
|
92
228
|
}
|
|
93
229
|
|
|
@@ -99,11 +235,13 @@ export class ProverClient implements EpochProverManager {
|
|
|
99
235
|
*/
|
|
100
236
|
public static async new(
|
|
101
237
|
config: ProverClientConfig,
|
|
102
|
-
worldState: ForkMerkleTreeOperations,
|
|
238
|
+
worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
103
239
|
broker: ProvingJobBroker,
|
|
104
240
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
105
241
|
) {
|
|
106
|
-
const
|
|
242
|
+
const proofStore = await createProofStore(config.proofStore);
|
|
243
|
+
const failedProofStore = config.failedProofStore ? await createProofStore(config.failedProofStore) : undefined;
|
|
244
|
+
const prover = new ProverClient(config, worldState, broker, proofStore, failedProofStore, broker, telemetry);
|
|
107
245
|
await prover.start();
|
|
108
246
|
return prover;
|
|
109
247
|
}
|
|
@@ -127,17 +265,11 @@ export class ProverClient implements EpochProverManager {
|
|
|
127
265
|
|
|
128
266
|
const proofStore = new InlineProofStore();
|
|
129
267
|
const prover = await buildServerCircuitProver(this.config, this.telemetry);
|
|
268
|
+
const bindings = this.log.getBindings();
|
|
130
269
|
this.agents = times(
|
|
131
270
|
this.config.proverAgentCount,
|
|
132
271
|
() =>
|
|
133
|
-
new ProvingAgent(
|
|
134
|
-
this.agentClient!,
|
|
135
|
-
proofStore,
|
|
136
|
-
prover,
|
|
137
|
-
[],
|
|
138
|
-
this.config.proverAgentPollIntervalMs,
|
|
139
|
-
this.telemetry,
|
|
140
|
-
),
|
|
272
|
+
new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs, bindings),
|
|
141
273
|
);
|
|
142
274
|
|
|
143
275
|
await Promise.all(this.agents.map(agent => agent.start()));
|
|
@@ -149,15 +281,16 @@ export class ProverClient implements EpochProverManager {
|
|
|
149
281
|
}
|
|
150
282
|
|
|
151
283
|
export function buildServerCircuitProver(
|
|
152
|
-
config: ActualProverConfig & ACVMConfig & BBConfig,
|
|
284
|
+
config: Omit<ActualProverConfig, 'enqueueConcurrency'> & ACVMConfig & BBConfig,
|
|
153
285
|
telemetry: TelemetryClient,
|
|
154
286
|
): Promise<ServerCircuitProver> {
|
|
155
287
|
if (config.realProofs) {
|
|
156
288
|
return BBNativeRollupProver.new(config, telemetry);
|
|
157
289
|
}
|
|
158
290
|
|
|
291
|
+
const logger = createLogger('prover-client:acvm-native');
|
|
159
292
|
const simulator = config.acvmBinaryPath
|
|
160
|
-
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath)
|
|
293
|
+
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, logger)
|
|
161
294
|
: undefined;
|
|
162
295
|
|
|
163
296
|
return Promise.resolve(new TestCircuitProver(simulator, config, telemetry));
|
|
@@ -4,14 +4,14 @@ import type {
|
|
|
4
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
5
|
RECURSIVE_PROOF_LENGTH,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
+
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
7
8
|
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
8
|
-
import {
|
|
9
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { chunk } from '@aztec/foundation/collection';
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
10
11
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
11
12
|
import { truncate } from '@aztec/foundation/string';
|
|
12
13
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
13
14
|
import {
|
|
14
|
-
type ProofAndVerificationKey,
|
|
15
15
|
type ProofUri,
|
|
16
16
|
type ProvingJobId,
|
|
17
17
|
type ProvingJobInputsMap,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
makeProvingJobId,
|
|
24
24
|
} from '@aztec/stdlib/interfaces/server';
|
|
25
25
|
import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
26
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
26
|
+
import { ProvingRequestType, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
27
27
|
import type {
|
|
28
28
|
BlockMergeRollupPrivateInputs,
|
|
29
29
|
BlockRollupPublicInputs,
|
|
@@ -47,6 +47,8 @@ import type {
|
|
|
47
47
|
TxRollupPublicInputs,
|
|
48
48
|
} from '@aztec/stdlib/rollup';
|
|
49
49
|
|
|
50
|
+
import { createHash } from 'node:crypto';
|
|
51
|
+
|
|
50
52
|
import { InlineProofStore, type ProofStore } from './proof_store/index.js';
|
|
51
53
|
|
|
52
54
|
// Perform a snapshot sync every 30 seconds
|
|
@@ -69,14 +71,17 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
69
71
|
private runningPromise?: RunningPromise;
|
|
70
72
|
private timeOfLastSnapshotSync = Date.now();
|
|
71
73
|
private jobsToRetrieve: Set<ProvingJobId> = new Set();
|
|
74
|
+
private log: Logger;
|
|
72
75
|
|
|
73
76
|
constructor(
|
|
74
77
|
private broker: ProvingJobProducer,
|
|
75
78
|
private proofStore: ProofStore = new InlineProofStore(),
|
|
76
79
|
private failedProofStore?: ProofStore,
|
|
77
80
|
private pollIntervalMs = 1000,
|
|
78
|
-
|
|
79
|
-
) {
|
|
81
|
+
bindings?: LoggerBindings,
|
|
82
|
+
) {
|
|
83
|
+
this.log = createLogger('prover-client:broker-circuit-prover-facade', bindings);
|
|
84
|
+
}
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* This is a critical section. This function can not be async since it writes
|
|
@@ -223,17 +228,11 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
223
228
|
// We collect all returned notifications and return them
|
|
224
229
|
const allCompleted = new Set<ProvingJobId>();
|
|
225
230
|
try {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
const completed = await this.broker.getCompletedJobs(slice);
|
|
231
|
+
const batches = ids.length > 0 ? chunk(ids, SNAPSHOT_SYNC_CHECK_MAX_REQUEST_SIZE) : [[]];
|
|
232
|
+
await asyncPool(1, batches, async batch => {
|
|
233
|
+
const completed = await this.broker.getCompletedJobs(batch);
|
|
230
234
|
completed.forEach(id => allCompleted.add(id));
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
if (numRequests === 0) {
|
|
234
|
-
const final = await this.broker.getCompletedJobs([]);
|
|
235
|
-
final.forEach(id => allCompleted.add(id));
|
|
236
|
-
}
|
|
235
|
+
});
|
|
237
236
|
} catch (err) {
|
|
238
237
|
this.log.error(`Error thrown when requesting completed job notifications from the broker`, err);
|
|
239
238
|
}
|
|
@@ -349,12 +348,8 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
349
348
|
.map(id => this.jobs.get(id)!)
|
|
350
349
|
.filter(x => x !== undefined);
|
|
351
350
|
const totalJobsToRetrieve = toBeRetrieved.length;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const slice = toBeRetrieved.splice(0, MAX_CONCURRENT_JOB_SETTLED_REQUESTS);
|
|
355
|
-
const results = await Promise.all(slice.map(job => processJob(job!)));
|
|
356
|
-
totalJobsRetrieved += results.filter(x => x).length;
|
|
357
|
-
}
|
|
351
|
+
const results = await asyncPool(MAX_CONCURRENT_JOB_SETTLED_REQUESTS, toBeRetrieved, job => processJob(job));
|
|
352
|
+
const totalJobsRetrieved = results.filter(x => x).length;
|
|
358
353
|
if (totalJobsToRetrieve > 0) {
|
|
359
354
|
this.log.verbose(
|
|
360
355
|
`Successfully retrieved ${totalJobsRetrieved} of ${totalJobsToRetrieve} jobs that should be ready, total ready jobs is now: ${this.jobsToRetrieve.size}`,
|
|
@@ -399,7 +394,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
399
394
|
inputs: AvmCircuitInputs,
|
|
400
395
|
signal?: AbortSignal,
|
|
401
396
|
epochNumber?: EpochNumber,
|
|
402
|
-
): Promise<
|
|
397
|
+
): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
403
398
|
return this.enqueueJob(
|
|
404
399
|
this.generateId(ProvingRequestType.PUBLIC_VM, inputs, epochNumber),
|
|
405
400
|
ProvingRequestType.PUBLIC_VM,
|
|
@@ -657,8 +652,12 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
657
652
|
);
|
|
658
653
|
}
|
|
659
654
|
|
|
660
|
-
private generateId(
|
|
661
|
-
|
|
662
|
-
|
|
655
|
+
private generateId(
|
|
656
|
+
type: ProvingRequestType,
|
|
657
|
+
inputs: { toBuffer(): Buffer },
|
|
658
|
+
epochNumber = EpochNumber.ZERO,
|
|
659
|
+
): ProvingJobId {
|
|
660
|
+
const inputsHash = createHash('sha256').update(inputs.toBuffer()).digest('hex');
|
|
661
|
+
return makeProvingJobId(epochNumber, type, inputsHash);
|
|
663
662
|
}
|
|
664
663
|
}
|