@aztec/prover-client 5.0.0-private.20260319 → 5.0.0-rc.2
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 +1 -1
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +15 -5
- package/dest/mocks/test_context.d.ts +11 -11
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +25 -28
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +20 -36
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +22 -120
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +161 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/{orchestrator.js → checkpoint-sub-tree-orchestrator.js} +267 -451
- package/dest/orchestrator/chonk-cache.d.ts +39 -0
- package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
- package/dest/orchestrator/chonk-cache.js +80 -0
- package/dest/orchestrator/index.d.ts +4 -2
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -1
- package/dest/orchestrator/proving-scheduler.d.ts +81 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +120 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +88 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +232 -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/prover-client/prover-client.d.ts +61 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +54 -7
- package/dest/proving_broker/broker_prover_facade.d.ts +1 -1
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +10 -16
- package/dest/proving_broker/config.d.ts +8 -72
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +2 -2
- 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/proving_broker.d.ts +2 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +32 -7
- package/dest/proving_broker/proving_broker_database/persisted.js +2 -2
- package/dest/proving_broker/rpc.d.ts +3 -1
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +80 -24
- package/dest/test/epoch_settlement.d.ts +36 -0
- package/dest/test/epoch_settlement.d.ts.map +1 -0
- package/dest/test/epoch_settlement.js +52 -0
- package/dest/test/index.d.ts +2 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/dest/test/mock_prover.d.ts +3 -3
- package/package.json +19 -18
- package/src/config.ts +18 -2
- package/src/light/lightweight_checkpoint_builder.ts +16 -6
- package/src/mocks/test_context.ts +24 -41
- package/src/orchestrator/checkpoint-proving-state.ts +21 -162
- package/src/orchestrator/{orchestrator.ts → checkpoint-sub-tree-orchestrator.ts} +415 -661
- package/src/orchestrator/chonk-cache.ts +99 -0
- package/src/orchestrator/index.ts +8 -1
- package/src/orchestrator/proving-scheduler.ts +160 -0
- package/src/orchestrator/top-tree-orchestrator.ts +384 -0
- package/src/orchestrator/top-tree-proving-state.ts +219 -0
- package/src/prover-client/prover-client.ts +128 -18
- package/src/proving_broker/broker_prover_facade.ts +8 -16
- package/src/proving_broker/config.ts +2 -1
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proving_broker.ts +27 -5
- package/src/proving_broker/proving_broker_database/persisted.ts +2 -2
- package/src/proving_broker/rpc.ts +36 -24
- package/src/test/epoch_settlement.ts +82 -0
- package/src/test/index.ts +1 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +0 -75
- package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
- package/dest/orchestrator/epoch-proving-state.js +0 -269
- package/dest/orchestrator/orchestrator.d.ts +0 -130
- package/dest/orchestrator/orchestrator.d.ts.map +0 -1
- package/dest/prover-client/server-epoch-prover.d.ts +0 -32
- package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
- package/dest/prover-client/server-epoch-prover.js +0 -40
- package/src/orchestrator/epoch-proving-state.ts +0 -380
- package/src/prover-client/server-epoch-prover.ts +0 -69
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { BatchedBlobAccumulator } from '@aztec/blob-lib';
|
|
2
|
+
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, OUT_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
3
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
+
import { BLS12Point } from '@aztec/foundation/curves/bls12';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
|
+
import { MerkleTreeCalculator, shaMerkleHash } from '@aztec/foundation/trees';
|
|
8
|
+
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
9
|
+
import { CheckpointRootRollupHints, CheckpointRootRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
10
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
11
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
12
|
+
import { buildBlobHints, toProofData } from './block-building-helpers.js';
|
|
13
|
+
import { ProvingScheduler } from './proving-scheduler.js';
|
|
14
|
+
import { TopTreeProvingState } from './top-tree-proving-state.js';
|
|
15
|
+
/**
|
|
16
|
+
* Sentinel thrown by `cancel` so callers can distinguish reorg-driven cancellation from
|
|
17
|
+
* a genuine proving failure (and choose to rebuild + retry instead of failing the epoch).
|
|
18
|
+
*/ export class TopTreeCancelledError extends Error {
|
|
19
|
+
constructor(reason = 'Top-tree proving cancelled'){
|
|
20
|
+
super(reason);
|
|
21
|
+
this.name = 'TopTreeCancelledError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Drives proving from checkpoint root rollups through the epoch root rollup. Owns no
|
|
26
|
+
* world-state forks or tx processing — every input is supplied by the caller.
|
|
27
|
+
*
|
|
28
|
+
* Pipelined start: `prove()` does not wait for block-level proving. It pre-computes the
|
|
29
|
+
* out-hash and blob-accumulator hint chains immediately from archiver-derivable data,
|
|
30
|
+
* and each checkpoint's root rollup fires the moment its sub-tree's `blockProofs`
|
|
31
|
+
* promise resolves. Later checkpoints can still be block-level proving in parallel.
|
|
32
|
+
*/ export class TopTreeOrchestrator extends ProvingScheduler {
|
|
33
|
+
prover;
|
|
34
|
+
proverId;
|
|
35
|
+
state;
|
|
36
|
+
cancelled;
|
|
37
|
+
constructor(prover, proverId, deferredJobQueue, _telemetryClient = getTelemetryClient(), bindings){
|
|
38
|
+
super(deferredJobQueue, 'prover-client:top-tree-orchestrator', bindings), this.prover = prover, this.proverId = proverId, this.cancelled = false;
|
|
39
|
+
}
|
|
40
|
+
getProverId() {
|
|
41
|
+
return this.proverId;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Proves the top tree from per-checkpoint data and pending block-proofs promises.
|
|
45
|
+
* Resolves with the final epoch proof, or rejects with `TopTreeCancelledError` if
|
|
46
|
+
* `cancel()` is invoked, or any other error if a circuit fails.
|
|
47
|
+
*/ async prove(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, checkpointData) {
|
|
48
|
+
if (checkpointData.length !== totalNumCheckpoints) {
|
|
49
|
+
throw new Error(`checkpointData length (${checkpointData.length}) does not match totalNumCheckpoints (${totalNumCheckpoints}).`);
|
|
50
|
+
}
|
|
51
|
+
if (this.state) {
|
|
52
|
+
throw new Error('TopTreeOrchestrator.prove called twice; construct a new orchestrator per epoch.');
|
|
53
|
+
}
|
|
54
|
+
// If cancel() was already called before prove() ran (e.g. a removeCheckpoint that
|
|
55
|
+
// landed while the caller was still preparing inputs), short-circuit the whole
|
|
56
|
+
// proving path. Without this, prove() would build its state, the per-checkpoint
|
|
57
|
+
// .then handlers would all bail on `this.cancelled`, and the completion promise
|
|
58
|
+
// would never resolve — prove() would hang forever.
|
|
59
|
+
if (this.cancelled) {
|
|
60
|
+
throw new TopTreeCancelledError();
|
|
61
|
+
}
|
|
62
|
+
const { promise: completionPromise, resolve, reject } = promiseWithResolvers();
|
|
63
|
+
// The completion promise is awaited below. Attach a no-op catch here as well so any
|
|
64
|
+
// spurious unhandled-rejection detection during cancellation (where reject() can fire
|
|
65
|
+
// synchronously before the await microtask installs a handler) is silenced.
|
|
66
|
+
completionPromise.catch(()=>{});
|
|
67
|
+
const startBlobAccumulator = BatchedBlobAccumulator.newWithChallenges(finalBlobBatchingChallenges);
|
|
68
|
+
this.state = new TopTreeProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, startBlobAccumulator, resolve, (reason)=>reject(this.cancelled ? new TopTreeCancelledError(reason) : new Error(reason)));
|
|
69
|
+
// Compute the full out-hash hint chain and per-checkpoint start blob accumulators
|
|
70
|
+
// synchronously from archiver data. No proving required.
|
|
71
|
+
const outHashHints = await this.computeOutHashHints(checkpointData);
|
|
72
|
+
const checkpointStartBlobs = [];
|
|
73
|
+
let runningBlobAccumulator = startBlobAccumulator;
|
|
74
|
+
for (const cd of checkpointData){
|
|
75
|
+
checkpointStartBlobs.push(runningBlobAccumulator);
|
|
76
|
+
runningBlobAccumulator = await runningBlobAccumulator.accumulateFields(cd.blobFields);
|
|
77
|
+
}
|
|
78
|
+
this.state.setEndBlobAccumulator(runningBlobAccumulator);
|
|
79
|
+
// For each checkpoint, await its block proofs promise then enqueue the checkpoint root.
|
|
80
|
+
// Each await runs independently — checkpoints whose sub-trees finish first start their
|
|
81
|
+
// root proofs first, in parallel with later checkpoints' block-level proving.
|
|
82
|
+
for(let i = 0; i < checkpointData.length; i++){
|
|
83
|
+
const cd = checkpointData[i];
|
|
84
|
+
const checkpointIndex = i;
|
|
85
|
+
void cd.blockProofs.then((blockProofs)=>{
|
|
86
|
+
if (this.cancelled || !this.state?.verifyState()) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.enqueueCheckpointRoot(this.state, checkpointIndex, blockProofs, cd, outHashHints[i], checkpointStartBlobs[i]);
|
|
90
|
+
}, (err)=>{
|
|
91
|
+
if (this.cancelled) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.state?.reject(`Sub-tree for checkpoint ${i} failed: ${err}`);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// The error type is stamped atomically at rejection time by the rejectionCallback above
|
|
98
|
+
// (TopTreeCancelledError iff cancel() drove the rejection). Re-deriving it here from the
|
|
99
|
+
// live `cancelled` flag would mask a genuine failure that lost a race with a late cancel
|
|
100
|
+
// (A-1035), so let the original error propagate untouched.
|
|
101
|
+
await completionPromise;
|
|
102
|
+
await this.state.finalizeBatchedBlob();
|
|
103
|
+
return this.state.getEpochProofResult();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Cancels in-flight proving. If `abortJobs` is true, each pending broker job is aborted
|
|
107
|
+
* (used on reorg, when the surviving checkpoint set differs and the in-flight jobs'
|
|
108
|
+
* inputs are no longer valid). On shutdown the caller passes `false` so jobs remain in
|
|
109
|
+
* the broker queue for reuse on restart.
|
|
110
|
+
*/ cancel({ abortJobs }) {
|
|
111
|
+
this.cancelled = true;
|
|
112
|
+
this.resetSchedulerState(abortJobs);
|
|
113
|
+
this.state?.cancel();
|
|
114
|
+
}
|
|
115
|
+
/** Standard shutdown — preserve the broker queue (`abortJobs: false`). */ cancelInternal() {
|
|
116
|
+
this.cancel({
|
|
117
|
+
abortJobs: false
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// --- internal: per-checkpoint enqueue path ---
|
|
121
|
+
enqueueCheckpointRoot(state, checkpointIndex, blockProofs, cd, outHashHint, startBlobAccumulator) {
|
|
122
|
+
void this.buildCheckpointRootInputs(blockProofs, cd, outHashHint, startBlobAccumulator).then((inputs)=>{
|
|
123
|
+
this.deferredProving(state, (signal)=>{
|
|
124
|
+
if (inputs instanceof CheckpointRootSingleBlockRollupPrivateInputs) {
|
|
125
|
+
return this.prover.getCheckpointRootSingleBlockRollupProof(inputs, signal, state.epochNumber);
|
|
126
|
+
}
|
|
127
|
+
return this.prover.getCheckpointRootRollupProof(inputs, signal, state.epochNumber);
|
|
128
|
+
}, (result)=>{
|
|
129
|
+
this.logger.debug(`Completed checkpoint root proof for checkpoint ${checkpointIndex}`);
|
|
130
|
+
const leafLocation = state.setCheckpointRootRollupProof(checkpointIndex, result);
|
|
131
|
+
if (state.totalNumCheckpoints === 1) {
|
|
132
|
+
this.enqueueEpochPadding(state);
|
|
133
|
+
} else {
|
|
134
|
+
this.checkAndEnqueueNextCheckpointMergeRollup(state, leafLocation);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}, // Without this, an input-building failure rejects a discarded promise, state.reject() is
|
|
138
|
+
// never called, and prove() hangs forever on its completion promise (A-1036).
|
|
139
|
+
(err)=>{
|
|
140
|
+
if (this.cancelled) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
state.reject(`Building checkpoint root inputs for checkpoint ${checkpointIndex} failed: ${err}`);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async buildCheckpointRootInputs(blockProofs, cd, outHashHint, startBlobAccumulator) {
|
|
147
|
+
const { blobCommitments, blobsHash } = await buildBlobHints(cd.blobFields);
|
|
148
|
+
const hints = CheckpointRootRollupHints.from({
|
|
149
|
+
previousBlockHeader: cd.previousBlockHeader,
|
|
150
|
+
previousArchiveSiblingPath: cd.previousArchiveSiblingPath,
|
|
151
|
+
previousOutHash: outHashHint.treeSnapshot,
|
|
152
|
+
newOutHashSiblingPath: outHashHint.siblingPath,
|
|
153
|
+
startBlobAccumulator: startBlobAccumulator.toBlobAccumulator(),
|
|
154
|
+
finalBlobChallenges: this.state.finalBlobBatchingChallenges,
|
|
155
|
+
blobFields: padArrayEnd(cd.blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT),
|
|
156
|
+
blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO, BLOBS_PER_CHECKPOINT),
|
|
157
|
+
blobsHash
|
|
158
|
+
});
|
|
159
|
+
const proofDatas = blockProofs.map((p)=>toProofData(p));
|
|
160
|
+
return proofDatas.length === 1 ? new CheckpointRootSingleBlockRollupPrivateInputs(proofDatas[0], hints) : new CheckpointRootRollupPrivateInputs([
|
|
161
|
+
proofDatas[0],
|
|
162
|
+
proofDatas[1]
|
|
163
|
+
], hints);
|
|
164
|
+
}
|
|
165
|
+
// --- internal: top-tree proof orchestration (formerly TopTreeProvingScheduler) ---
|
|
166
|
+
enqueueCheckpointMergeRollup(state, location) {
|
|
167
|
+
if (!state.verifyState() || !state.tryStartProvingCheckpointMerge(location)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const inputs = state.getCheckpointMergeRollupInputs(location);
|
|
171
|
+
this.deferredProving(state, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, state.epochNumber), (result)=>{
|
|
172
|
+
state.setCheckpointMergeRollupProof(location, result);
|
|
173
|
+
this.checkAndEnqueueNextCheckpointMergeRollup(state, location);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
enqueueEpochPadding(state) {
|
|
177
|
+
if (!state.verifyState() || !state.tryStartProvingPaddingCheckpoint()) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const inputs = state.getPaddingCheckpointInputs();
|
|
181
|
+
this.deferredProving(state, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, state.epochNumber), (result)=>{
|
|
182
|
+
state.setCheckpointPaddingProof(result);
|
|
183
|
+
this.checkAndEnqueueRootRollup(state);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
enqueueRootRollup(state) {
|
|
187
|
+
if (!state.verifyState() || !state.tryStartProvingRootRollup()) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const inputs = state.getRootRollupInputs();
|
|
191
|
+
this.deferredProving(state, (signal)=>this.prover.getRootRollupProof(inputs, signal, state.epochNumber), (result)=>{
|
|
192
|
+
this.logger.verbose(`Completed root rollup for epoch ${state.epochNumber}`);
|
|
193
|
+
state.setRootRollupProof(result);
|
|
194
|
+
state.resolve();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
checkAndEnqueueNextCheckpointMergeRollup(state, currentLocation) {
|
|
198
|
+
if (!state.isReadyForCheckpointMerge(currentLocation)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const parentLocation = state.getParentLocation(currentLocation);
|
|
202
|
+
if (parentLocation.level === 0) {
|
|
203
|
+
this.checkAndEnqueueRootRollup(state);
|
|
204
|
+
} else {
|
|
205
|
+
this.enqueueCheckpointMergeRollup(state, parentLocation);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
checkAndEnqueueRootRollup(state) {
|
|
209
|
+
if (!state.isReadyForRootRollup()) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.enqueueRootRollup(state);
|
|
213
|
+
}
|
|
214
|
+
async computeOutHashHints(checkpointData) {
|
|
215
|
+
const treeCalculator = await MerkleTreeCalculator.create(OUT_HASH_TREE_HEIGHT, undefined, (left, right)=>Promise.resolve(shaMerkleHash(left, right)));
|
|
216
|
+
const computeHint = async (leaves)=>{
|
|
217
|
+
const tree = await treeCalculator.computeTree(leaves.map((l)=>l.toBuffer()));
|
|
218
|
+
const nextAvailableLeafIndex = leaves.length;
|
|
219
|
+
return {
|
|
220
|
+
treeSnapshot: new AppendOnlyTreeSnapshot(Fr.fromBuffer(tree.root), nextAvailableLeafIndex),
|
|
221
|
+
siblingPath: tree.getSiblingPath(nextAvailableLeafIndex).map(Fr.fromBuffer)
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
const hints = [];
|
|
225
|
+
const outHashes = [];
|
|
226
|
+
for (const cd of checkpointData){
|
|
227
|
+
hints.push(await computeHint(outHashes));
|
|
228
|
+
outHashes.push(computeCheckpointOutHash(cd.l2ToL1MsgsPerBlock));
|
|
229
|
+
}
|
|
230
|
+
return hints;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { BatchedBlob, BatchedBlobAccumulator, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import type { NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
3
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { type TreeNodeLocation } from '@aztec/foundation/trees';
|
|
5
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
+
import { CheckpointMergeRollupPrivateInputs, CheckpointPaddingRollupPrivateInputs, CheckpointRollupPublicInputs, RootRollupPrivateInputs, type RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
8
|
+
/**
|
|
9
|
+
* Lean top-tree-only state. Owns the merge tree of checkpoint root proofs, the
|
|
10
|
+
* single-checkpoint padding proof slot, the final root rollup proof, and the blob
|
|
11
|
+
* accumulator endpoints needed to finalise the epoch's batched blob proof.
|
|
12
|
+
*
|
|
13
|
+
* Constructed with `totalNumCheckpoints` and `finalBlobBatchingChallenges` upfront —
|
|
14
|
+
* by the time the top tree starts, all checkpoints are known and the challenges are
|
|
15
|
+
* derivable from their blob fields.
|
|
16
|
+
*/
|
|
17
|
+
export declare class TopTreeProvingState {
|
|
18
|
+
#private;
|
|
19
|
+
readonly epochNumber: EpochNumber;
|
|
20
|
+
readonly totalNumCheckpoints: number;
|
|
21
|
+
readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges;
|
|
22
|
+
readonly startBlobAccumulator: BatchedBlobAccumulator;
|
|
23
|
+
private readonly completionCallback;
|
|
24
|
+
private readonly rejectionCallback;
|
|
25
|
+
private checkpointProofs;
|
|
26
|
+
private checkpointPaddingProof;
|
|
27
|
+
private rootRollupProof;
|
|
28
|
+
private endBlobAccumulator;
|
|
29
|
+
private finalBatchedBlob;
|
|
30
|
+
private lifecycle;
|
|
31
|
+
constructor(epochNumber: EpochNumber, totalNumCheckpoints: number, finalBlobBatchingChallenges: FinalBlobBatchingChallenges, startBlobAccumulator: BatchedBlobAccumulator, completionCallback: () => void, rejectionCallback: (reason: string) => void);
|
|
32
|
+
setCheckpointRootRollupProof(checkpointIndex: number, provingOutput: PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): TreeNodeLocation;
|
|
33
|
+
tryStartProvingCheckpointMerge(location: TreeNodeLocation): boolean;
|
|
34
|
+
setCheckpointMergeRollupProof(location: TreeNodeLocation, provingOutput: PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): void;
|
|
35
|
+
isReadyForCheckpointMerge(location: TreeNodeLocation): boolean;
|
|
36
|
+
getParentLocation(location: TreeNodeLocation): TreeNodeLocation;
|
|
37
|
+
getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation): CheckpointMergeRollupPrivateInputs;
|
|
38
|
+
tryStartProvingPaddingCheckpoint(): boolean;
|
|
39
|
+
setCheckpointPaddingProof(provingOutput: PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): void;
|
|
40
|
+
getPaddingCheckpointInputs(): CheckpointPaddingRollupPrivateInputs;
|
|
41
|
+
tryStartProvingRootRollup(): boolean;
|
|
42
|
+
setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>): void;
|
|
43
|
+
isReadyForRootRollup(): boolean;
|
|
44
|
+
getRootRollupInputs(): RootRollupPrivateInputs;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the end-of-epoch blob accumulator, computed by the top-tree orchestrator
|
|
47
|
+
* from the surviving checkpoints' blob fields. Required before `finalizeBatchedBlob`.
|
|
48
|
+
*/
|
|
49
|
+
setEndBlobAccumulator(accumulator: BatchedBlobAccumulator): void;
|
|
50
|
+
finalizeBatchedBlob(): Promise<void>;
|
|
51
|
+
getEpochProofResult(): {
|
|
52
|
+
proof: Proof;
|
|
53
|
+
publicInputs: RootRollupPublicInputs;
|
|
54
|
+
batchedBlobInputs: BatchedBlob;
|
|
55
|
+
};
|
|
56
|
+
verifyState(): boolean;
|
|
57
|
+
resolve(): void;
|
|
58
|
+
reject(reason: string): void;
|
|
59
|
+
cancel(): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9wLXRyZWUtcHJvdmluZy1zdGF0ZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29yY2hlc3RyYXRvci90b3AtdHJlZS1wcm92aW5nLXN0YXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxzQkFBc0IsRUFBRSwyQkFBMkIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ3hHLE9BQU8sS0FBSyxFQUFpQyx5Q0FBeUMsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ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AW,YAEjB;IAEM,OAAO,SAMb;IAEM,MAAM,CAAC,MAAM,EAAE,MAAM,QAM3B;IAEM,MAAM,SAEZ;CAQF"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
2
|
+
import { CheckpointMergeRollupPrivateInputs, CheckpointPaddingRollupPrivateInputs, RootRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
3
|
+
import { toProofData } from './block-building-helpers.js';
|
|
4
|
+
var TOP_TREE_LIFECYCLE = /*#__PURE__*/ function(TOP_TREE_LIFECYCLE) {
|
|
5
|
+
TOP_TREE_LIFECYCLE[TOP_TREE_LIFECYCLE["CREATED"] = 0] = "CREATED";
|
|
6
|
+
TOP_TREE_LIFECYCLE[TOP_TREE_LIFECYCLE["RESOLVED"] = 1] = "RESOLVED";
|
|
7
|
+
TOP_TREE_LIFECYCLE[TOP_TREE_LIFECYCLE["REJECTED"] = 2] = "REJECTED";
|
|
8
|
+
return TOP_TREE_LIFECYCLE;
|
|
9
|
+
}(TOP_TREE_LIFECYCLE || {});
|
|
10
|
+
/**
|
|
11
|
+
* Lean top-tree-only state. Owns the merge tree of checkpoint root proofs, the
|
|
12
|
+
* single-checkpoint padding proof slot, the final root rollup proof, and the blob
|
|
13
|
+
* accumulator endpoints needed to finalise the epoch's batched blob proof.
|
|
14
|
+
*
|
|
15
|
+
* Constructed with `totalNumCheckpoints` and `finalBlobBatchingChallenges` upfront —
|
|
16
|
+
* by the time the top tree starts, all checkpoints are known and the challenges are
|
|
17
|
+
* derivable from their blob fields.
|
|
18
|
+
*/ export class TopTreeProvingState {
|
|
19
|
+
epochNumber;
|
|
20
|
+
totalNumCheckpoints;
|
|
21
|
+
finalBlobBatchingChallenges;
|
|
22
|
+
startBlobAccumulator;
|
|
23
|
+
completionCallback;
|
|
24
|
+
rejectionCallback;
|
|
25
|
+
checkpointProofs;
|
|
26
|
+
checkpointPaddingProof;
|
|
27
|
+
rootRollupProof;
|
|
28
|
+
endBlobAccumulator;
|
|
29
|
+
finalBatchedBlob;
|
|
30
|
+
lifecycle;
|
|
31
|
+
constructor(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, startBlobAccumulator, completionCallback, rejectionCallback){
|
|
32
|
+
this.epochNumber = epochNumber;
|
|
33
|
+
this.totalNumCheckpoints = totalNumCheckpoints;
|
|
34
|
+
this.finalBlobBatchingChallenges = finalBlobBatchingChallenges;
|
|
35
|
+
this.startBlobAccumulator = startBlobAccumulator;
|
|
36
|
+
this.completionCallback = completionCallback;
|
|
37
|
+
this.rejectionCallback = rejectionCallback;
|
|
38
|
+
this.lifecycle = 0;
|
|
39
|
+
if (totalNumCheckpoints < 1) {
|
|
40
|
+
throw new Error(`TopTreeProvingState requires at least one checkpoint; got ${totalNumCheckpoints}.`);
|
|
41
|
+
}
|
|
42
|
+
this.checkpointProofs = new UnbalancedTreeStore(totalNumCheckpoints);
|
|
43
|
+
}
|
|
44
|
+
// --- checkpoint root rollup ---
|
|
45
|
+
setCheckpointRootRollupProof(checkpointIndex, provingOutput) {
|
|
46
|
+
return this.checkpointProofs.setLeaf(checkpointIndex, {
|
|
47
|
+
provingOutput
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// --- checkpoint merge rollup ---
|
|
51
|
+
tryStartProvingCheckpointMerge(location) {
|
|
52
|
+
if (this.checkpointProofs.getNode(location)?.isProving) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
this.checkpointProofs.setNode(location, {
|
|
56
|
+
isProving: true
|
|
57
|
+
});
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
setCheckpointMergeRollupProof(location, provingOutput) {
|
|
61
|
+
this.checkpointProofs.setNode(location, {
|
|
62
|
+
provingOutput
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
isReadyForCheckpointMerge(location) {
|
|
66
|
+
return !!this.checkpointProofs.getSibling(location)?.provingOutput;
|
|
67
|
+
}
|
|
68
|
+
getParentLocation(location) {
|
|
69
|
+
return this.checkpointProofs.getParentLocation(location);
|
|
70
|
+
}
|
|
71
|
+
getCheckpointMergeRollupInputs(mergeLocation) {
|
|
72
|
+
const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map((c)=>c?.provingOutput);
|
|
73
|
+
if (!left || !right) {
|
|
74
|
+
throw new Error('At least one child is not ready for the checkpoint merge rollup.');
|
|
75
|
+
}
|
|
76
|
+
return new CheckpointMergeRollupPrivateInputs([
|
|
77
|
+
toProofData(left),
|
|
78
|
+
toProofData(right)
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
// --- padding (single-checkpoint case) ---
|
|
82
|
+
tryStartProvingPaddingCheckpoint() {
|
|
83
|
+
if (this.checkpointPaddingProof?.isProving) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
this.checkpointPaddingProof = {
|
|
87
|
+
isProving: true
|
|
88
|
+
};
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
setCheckpointPaddingProof(provingOutput) {
|
|
92
|
+
this.checkpointPaddingProof = {
|
|
93
|
+
provingOutput
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
getPaddingCheckpointInputs() {
|
|
97
|
+
return new CheckpointPaddingRollupPrivateInputs();
|
|
98
|
+
}
|
|
99
|
+
// --- root rollup ---
|
|
100
|
+
tryStartProvingRootRollup() {
|
|
101
|
+
if (this.rootRollupProof?.isProving) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
this.rootRollupProof = {
|
|
105
|
+
isProving: true
|
|
106
|
+
};
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
setRootRollupProof(provingOutput) {
|
|
110
|
+
this.rootRollupProof = {
|
|
111
|
+
provingOutput
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
isReadyForRootRollup() {
|
|
115
|
+
const childProofs = this.#getChildProofsForRoot();
|
|
116
|
+
return childProofs.every((p)=>!!p);
|
|
117
|
+
}
|
|
118
|
+
getRootRollupInputs() {
|
|
119
|
+
const [left, right] = this.#getChildProofsForRoot();
|
|
120
|
+
if (!left || !right) {
|
|
121
|
+
throw new Error('At least one child is not ready for the root rollup.');
|
|
122
|
+
}
|
|
123
|
+
return RootRollupPrivateInputs.from({
|
|
124
|
+
previousRollups: [
|
|
125
|
+
toProofData(left),
|
|
126
|
+
toProofData(right)
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
// --- blob accumulator finalisation ---
|
|
131
|
+
/**
|
|
132
|
+
* Sets the end-of-epoch blob accumulator, computed by the top-tree orchestrator
|
|
133
|
+
* from the surviving checkpoints' blob fields. Required before `finalizeBatchedBlob`.
|
|
134
|
+
*/ setEndBlobAccumulator(accumulator) {
|
|
135
|
+
this.endBlobAccumulator = accumulator;
|
|
136
|
+
}
|
|
137
|
+
async finalizeBatchedBlob() {
|
|
138
|
+
if (!this.endBlobAccumulator) {
|
|
139
|
+
throw new Error('End blob accumulator not set; call setEndBlobAccumulator before finalize.');
|
|
140
|
+
}
|
|
141
|
+
this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true);
|
|
142
|
+
}
|
|
143
|
+
getEpochProofResult() {
|
|
144
|
+
const provingOutput = this.rootRollupProof?.provingOutput;
|
|
145
|
+
if (!provingOutput || !this.finalBatchedBlob) {
|
|
146
|
+
throw new Error('Top-tree proof not ready; root rollup or batched blob missing.');
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
proof: provingOutput.proof.binaryProof,
|
|
150
|
+
publicInputs: provingOutput.inputs,
|
|
151
|
+
batchedBlobInputs: this.finalBatchedBlob
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// --- lifecycle ---
|
|
155
|
+
verifyState() {
|
|
156
|
+
return this.lifecycle === 0;
|
|
157
|
+
}
|
|
158
|
+
resolve() {
|
|
159
|
+
if (!this.verifyState()) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.lifecycle = 1;
|
|
163
|
+
this.completionCallback();
|
|
164
|
+
}
|
|
165
|
+
reject(reason) {
|
|
166
|
+
if (!this.verifyState()) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.lifecycle = 2;
|
|
170
|
+
this.rejectionCallback(reason);
|
|
171
|
+
}
|
|
172
|
+
cancel() {
|
|
173
|
+
this.reject('Top-tree proving cancelled');
|
|
174
|
+
}
|
|
175
|
+
#getChildProofsForRoot() {
|
|
176
|
+
const rootLocation = {
|
|
177
|
+
level: 0,
|
|
178
|
+
index: 0
|
|
179
|
+
};
|
|
180
|
+
return this.totalNumCheckpoints === 1 ? [
|
|
181
|
+
this.checkpointProofs.getNode(rootLocation)?.provingOutput,
|
|
182
|
+
this.checkpointPaddingProof?.provingOutput
|
|
183
|
+
] : this.checkpointProofs.getChildren(rootLocation).map((c)=>c?.provingOutput);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig } from '@aztec/bb-prover';
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import { type ActualProverConfig, type
|
|
5
|
+
import { type ActualProverConfig, type EpochProverManager, type ForkMerkleTreeOperations, type ProvingJobBroker, type ProvingJobConsumer, type ReadonlyWorldStateAccess, type ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
7
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
4
8
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
5
9
|
import type { ProverClientConfig } from '../config.js';
|
|
10
|
+
import { CheckpointSubTreeOrchestrator } from '../orchestrator/checkpoint-sub-tree-orchestrator.js';
|
|
11
|
+
import type { ChonkCache } from '../orchestrator/chonk-cache.js';
|
|
12
|
+
import { TopTreeOrchestrator } from '../orchestrator/top-tree-orchestrator.js';
|
|
13
|
+
/**
|
|
14
|
+
* The factory surface that `EpochProvingJob` (in `prover-node`) depends on. Implemented
|
|
15
|
+
* by `ProverClient`. Defined here rather than in stdlib because the return types
|
|
16
|
+
* (`CheckpointSubTreeOrchestrator`, `TopTreeOrchestrator`) are concrete classes from
|
|
17
|
+
* this package.
|
|
18
|
+
*
|
|
19
|
+
* A single `BrokerCircuitProverFacade` is owned by `ProverClient` and shared across
|
|
20
|
+
* every orchestrator (every sub-tree and every top-tree across every concurrent epoch
|
|
21
|
+
* job). The broker delivers each completed-job notification exactly once (drained on
|
|
22
|
+
* the first `getCompletedJobs` poll), so multiple facades polling the same broker
|
|
23
|
+
* race and lose notifications
|
|
24
|
+
*
|
|
25
|
+
* The facade's job map cleans up entries on resolve/reject, and the prover-node
|
|
26
|
+
* keeps `ProverClient` alive for its whole lifetime
|
|
27
|
+
*/
|
|
28
|
+
export interface EpochProverFactory {
|
|
29
|
+
getProverId(): EthAddress;
|
|
30
|
+
/**
|
|
31
|
+
* Constructs and starts a `CheckpointSubTreeOrchestrator` for a single checkpoint
|
|
32
|
+
* against the supplied shared `chonkCache`. The cache is owned by the prover-node
|
|
33
|
+
* and survives across epochs / sessions.
|
|
34
|
+
*/
|
|
35
|
+
createCheckpointSubTreeOrchestrator(chonkCache: ChonkCache, epochNumber: EpochNumber, checkpointConstants: CheckpointConstantData, l1ToL2Messages: Fr[], totalNumBlocks: number, headerOfLastBlockInPreviousCheckpoint: BlockHeader): Promise<CheckpointSubTreeOrchestrator>;
|
|
36
|
+
createTopTreeOrchestrator(): TopTreeOrchestrator;
|
|
37
|
+
}
|
|
6
38
|
/** Manages proving of epochs by orchestrating the proving of individual blocks relying on a pool of prover agents. */
|
|
7
|
-
export declare class ProverClient implements EpochProverManager {
|
|
39
|
+
export declare class ProverClient implements EpochProverManager, EpochProverFactory {
|
|
8
40
|
private config;
|
|
9
41
|
private worldState;
|
|
10
42
|
private orchestratorClient;
|
|
@@ -15,8 +47,33 @@ export declare class ProverClient implements EpochProverManager {
|
|
|
15
47
|
private log;
|
|
16
48
|
private running;
|
|
17
49
|
private agents;
|
|
50
|
+
/**
|
|
51
|
+
* The single broker facade shared by every orchestrator created from this client.
|
|
52
|
+
* Constructed lazily on `start()` and torn down on `stop()` — see the comment on
|
|
53
|
+
* `EpochProverFactory` for why a single shared facade is required.
|
|
54
|
+
*/
|
|
55
|
+
private facade;
|
|
56
|
+
/**
|
|
57
|
+
* Single deferred-proving-job queue shared across every orchestrator (sub-trees and
|
|
58
|
+
* top-trees, across every concurrent epoch session). Throttles the total rate of job
|
|
59
|
+
* submission to the broker once, rather than once per orchestrator. Started lazily
|
|
60
|
+
* alongside the facade and cancelled on `stop()`.
|
|
61
|
+
*/
|
|
62
|
+
private deferredJobQueue;
|
|
18
63
|
private constructor();
|
|
19
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Lazy-init the shared facade. The broker delivers each completed-job notification
|
|
66
|
+
* exactly once (drained on the first `getCompletedJobs` poll), so we cannot start
|
|
67
|
+
* a shared facade alongside the per-call facades that `createEpochProver` builds —
|
|
68
|
+
* they would race for notifications and one side would silently drop them. Starting
|
|
69
|
+
* the shared facade only on first use of one of the new factory methods keeps the
|
|
70
|
+
* legacy `createEpochProver` path race-free.
|
|
71
|
+
*/
|
|
72
|
+
private getFacade;
|
|
73
|
+
/** Lazy-init the shared deferred-job queue, started with the configured enqueue concurrency. */
|
|
74
|
+
private getDeferredJobQueue;
|
|
75
|
+
createCheckpointSubTreeOrchestrator(chonkCache: ChonkCache, epochNumber: EpochNumber, checkpointConstants: CheckpointConstantData, l1ToL2Messages: Fr[], totalNumBlocks: number, headerOfLastBlockInPreviousCheckpoint: BlockHeader): Promise<CheckpointSubTreeOrchestrator>;
|
|
76
|
+
createTopTreeOrchestrator(): TopTreeOrchestrator;
|
|
20
77
|
getProverId(): EthAddress;
|
|
21
78
|
updateProverConfig(config: Partial<ProverClientConfig>): Promise<void>;
|
|
22
79
|
/**
|
|
@@ -39,4 +96,4 @@ export declare class ProverClient implements EpochProverManager {
|
|
|
39
96
|
private stopAgents;
|
|
40
97
|
}
|
|
41
98
|
export declare function buildServerCircuitProver(config: Omit<ActualProverConfig, 'enqueueConcurrency'> & ACVMConfig & BBConfig, telemetry: TelemetryClient): Promise<ServerCircuitProver>;
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
99
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmVyLWNsaWVudC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Byb3Zlci1jbGllbnQvcHJvdmVyLWNsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxVQUFVLEVBQUUsS0FBSyxRQUFRLEVBQTJDLE1BQU0sa0JBQWtCLENBQUM7QUFDM0csT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFbkUsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFJaEUsT0FBTyxFQUNMLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssZ0JBQWdCLEVBQ3JCLEtBQUssa0JBQWtCLEVBRXZCLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssbUJBQW1CLEVBRXpCLE1BQU0saUNBQWlDLENBQUM7QUFDekMsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFB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UJBQW1CLElBQUksa0JBQWtCLENBTS9DO1lBRWEsb0JBQW9CO1lBcUJwQixVQUFVO0NBR3pCO0FBRUQsd0JBQWdCLHdCQUF3QixDQUN0QyxNQUFNLEVBQUUsSUFBSSxDQUFDLGtCQUFrQixFQUFFLG9CQUFvQixDQUFDLEdBQUcsVUFBVSxHQUFHLFFBQVEsRUFDOUUsU0FBUyxFQUFFLGVBQWUsR0FDekIsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBVzlCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prover-client.d.ts","sourceRoot":"","sources":["../../src/prover-client/prover-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAA2C,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"prover-client.d.ts","sourceRoot":"","sources":["../../src/prover-client/prover-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAA2C,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,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