@aztec/prover-client 0.0.0-test.1 → 0.0.1-fake-c83136db25
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/block-factory/index.d.ts +2 -0
- package/dest/block-factory/index.d.ts.map +1 -0
- package/dest/block-factory/light.d.ts +38 -0
- package/dest/block-factory/light.d.ts.map +1 -0
- package/dest/block-factory/light.js +94 -0
- package/dest/config.d.ts +6 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/mocks/fixtures.d.ts +7 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +32 -4
- package/dest/mocks/test_context.d.ts +43 -15
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +110 -48
- package/dest/orchestrator/block-building-helpers.d.ts +37 -28
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +156 -150
- package/dest/orchestrator/block-proving-state.d.ts +62 -46
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +223 -179
- package/dest/orchestrator/checkpoint-proving-state.d.ts +63 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +211 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +37 -24
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +143 -73
- package/dest/orchestrator/orchestrator.d.ts +34 -31
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +392 -234
- package/dest/orchestrator/orchestrator_metrics.d.ts +2 -0
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +9 -0
- package/dest/orchestrator/tx-proving-state.d.ts +12 -10
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +30 -38
- package/dest/prover-client/prover-client.d.ts +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +5 -4
- package/dest/prover-client/server-epoch-prover.d.ts +13 -10
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +22 -15
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +64 -39
- package/dest/proving_broker/config.d.ts +9 -4
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +15 -4
- package/dest/proving_broker/factory.d.ts +1 -1
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -1
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proof_store/factory.js +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +1 -0
- package/dest/proving_broker/proof_store/index.d.ts +1 -0
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -0
- package/dest/proving_broker/proving_agent.d.ts +3 -3
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +83 -47
- package/dest/proving_broker/proving_broker.d.ts +11 -2
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +34 -22
- package/dest/proving_broker/proving_broker_database/memory.js +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +9 -8
- package/dest/proving_broker/proving_job_controller.d.ts +7 -8
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +89 -61
- package/dest/proving_broker/rpc.d.ts +3 -5
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +1 -4
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -16
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +29 -29
- package/src/block-factory/index.ts +1 -0
- package/src/block-factory/light.ts +140 -0
- package/src/config.ts +24 -8
- package/src/mocks/fixtures.ts +43 -15
- package/src/mocks/test_context.ts +201 -75
- package/src/orchestrator/block-building-helpers.ts +247 -243
- package/src/orchestrator/block-proving-state.ts +247 -231
- package/src/orchestrator/checkpoint-proving-state.ts +299 -0
- package/src/orchestrator/epoch-proving-state.ts +187 -111
- package/src/orchestrator/orchestrator.ts +590 -289
- package/src/orchestrator/orchestrator_metrics.ts +20 -1
- package/src/orchestrator/tx-proving-state.ts +60 -61
- package/src/prover-client/prover-client.ts +16 -14
- package/src/prover-client/server-epoch-prover.ts +40 -21
- package/src/proving_broker/broker_prover_facade.ts +200 -113
- package/src/proving_broker/config.ts +17 -6
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proof_store/factory.ts +1 -1
- package/src/proving_broker/proof_store/gcs_proof_store.ts +5 -1
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +89 -47
- package/src/proving_broker/proving_broker.ts +51 -32
- package/src/proving_broker/proving_broker_database/memory.ts +1 -1
- package/src/proving_broker/proving_broker_database/persisted.ts +9 -8
- package/src/proving_broker/proving_job_controller.ts +92 -81
- package/src/proving_broker/rpc.ts +1 -6
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +164 -60
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- package/src/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- /package/dest/{block_builder → block-factory}/index.js +0 -0
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { BatchedBlob, BatchedBlobAccumulator, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import type {
|
|
3
|
+
ARCHIVE_HEIGHT,
|
|
4
|
+
L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
5
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
6
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
7
7
|
} from '@aztec/constants';
|
|
8
8
|
import type { Fr } from '@aztec/foundation/fields';
|
|
9
9
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
10
|
+
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
11
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
13
12
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
14
13
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
CheckpointConstantData,
|
|
15
|
+
CheckpointMergeRollupPrivateInputs,
|
|
16
|
+
CheckpointPaddingRollupPrivateInputs,
|
|
17
|
+
CheckpointRollupPublicInputs,
|
|
18
|
+
PublicChonkVerifierPublicInputs,
|
|
19
|
+
RootRollupPrivateInputs,
|
|
19
20
|
type RootRollupPublicInputs,
|
|
20
21
|
} from '@aztec/stdlib/rollup';
|
|
21
22
|
import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
22
|
-
import type { BlockHeader
|
|
23
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
23
24
|
|
|
24
|
-
import {
|
|
25
|
+
import { toProofData } from './block-building-helpers.js';
|
|
26
|
+
import type { ProofState } from './block-proving-state.js';
|
|
27
|
+
import { CheckpointProvingState } from './checkpoint-proving-state.js';
|
|
25
28
|
|
|
26
29
|
export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
|
|
27
30
|
|
|
@@ -41,58 +44,97 @@ export type ProvingResult = { status: 'success' } | { status: 'failure'; reason:
|
|
|
41
44
|
* Captures resolve and reject callbacks to provide a promise base interface to the consumer of our proving.
|
|
42
45
|
*/
|
|
43
46
|
export class EpochProvingState {
|
|
44
|
-
private
|
|
45
|
-
|
|
47
|
+
private checkpointProofs: UnbalancedTreeStore<
|
|
48
|
+
ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
46
49
|
>;
|
|
47
|
-
private
|
|
48
|
-
|
|
|
50
|
+
private checkpointPaddingProof:
|
|
51
|
+
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
49
52
|
| undefined;
|
|
50
|
-
private
|
|
53
|
+
private rootRollupProof: ProofState<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
|
|
54
|
+
private checkpoints: (CheckpointProvingState | undefined)[] = [];
|
|
55
|
+
private startBlobAccumulator: BatchedBlobAccumulator;
|
|
56
|
+
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
57
|
+
private finalBatchedBlob: BatchedBlob | undefined;
|
|
51
58
|
private provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
|
|
52
59
|
|
|
53
|
-
// Map from tx hash to
|
|
54
|
-
public readonly
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
// Map from tx hash to chonk verifier proof promise. Used when kickstarting chonk verifier proofs before tx processing.
|
|
61
|
+
public readonly cachedChonkVerifierProofs = new Map<
|
|
62
|
+
string,
|
|
63
|
+
Promise<
|
|
64
|
+
PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
65
|
+
>
|
|
66
|
+
>();
|
|
57
67
|
|
|
58
68
|
constructor(
|
|
59
69
|
public readonly epochNumber: number,
|
|
60
|
-
public readonly
|
|
61
|
-
|
|
70
|
+
public readonly totalNumCheckpoints: number,
|
|
71
|
+
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
72
|
+
private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
|
|
62
73
|
private completionCallback: (result: ProvingResult) => void,
|
|
63
74
|
private rejectionCallback: (reason: string) => void,
|
|
64
75
|
) {
|
|
65
|
-
this.
|
|
76
|
+
this.checkpointProofs = new UnbalancedTreeStore(totalNumCheckpoints);
|
|
77
|
+
this.startBlobAccumulator = BatchedBlobAccumulator.newWithChallenges(finalBlobBatchingChallenges);
|
|
66
78
|
}
|
|
67
79
|
|
|
68
80
|
// Adds a block to the proving state, returns its index
|
|
69
81
|
// Will update the proving life cycle if this is the last block
|
|
70
|
-
public
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
lastArchiveSnapshot: AppendOnlyTreeSnapshot,
|
|
76
|
-
newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
82
|
+
public startNewCheckpoint(
|
|
83
|
+
checkpointIndex: number,
|
|
84
|
+
constants: CheckpointConstantData,
|
|
85
|
+
totalNumBlocks: number,
|
|
86
|
+
totalNumBlobFields: number,
|
|
77
87
|
previousBlockHeader: BlockHeader,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
89
|
+
l1ToL2Messages: Fr[],
|
|
90
|
+
lastL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
91
|
+
lastL1ToL2MessageSubtreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH>,
|
|
92
|
+
newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
93
|
+
newL1ToL2MessageSubtreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH>,
|
|
94
|
+
): CheckpointProvingState {
|
|
95
|
+
if (checkpointIndex >= this.totalNumCheckpoints) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Unable to start a new checkpoint at index ${checkpointIndex}. Expected at most ${this.totalNumCheckpoints} checkpoints.`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const checkpoint = new CheckpointProvingState(
|
|
102
|
+
checkpointIndex,
|
|
103
|
+
constants,
|
|
104
|
+
totalNumBlocks,
|
|
105
|
+
totalNumBlobFields,
|
|
106
|
+
this.finalBlobBatchingChallenges,
|
|
88
107
|
previousBlockHeader,
|
|
108
|
+
lastArchiveSiblingPath,
|
|
109
|
+
l1ToL2Messages,
|
|
110
|
+
lastL1ToL2MessageTreeSnapshot,
|
|
111
|
+
lastL1ToL2MessageSubtreeRootSiblingPath,
|
|
112
|
+
newL1ToL2MessageTreeSnapshot,
|
|
113
|
+
newL1ToL2MessageSubtreeRootSiblingPath,
|
|
89
114
|
this,
|
|
115
|
+
this.onCheckpointBlobAccumulatorSet,
|
|
90
116
|
);
|
|
91
|
-
this.
|
|
92
|
-
|
|
117
|
+
this.checkpoints[checkpointIndex] = checkpoint;
|
|
118
|
+
|
|
119
|
+
if (this.checkpoints.filter(c => !!c).length === this.totalNumCheckpoints) {
|
|
93
120
|
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL;
|
|
94
121
|
}
|
|
95
|
-
|
|
122
|
+
|
|
123
|
+
return checkpoint;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public getCheckpointProvingState(index: number) {
|
|
127
|
+
return this.checkpoints[index];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public getCheckpointProvingStateByBlockNumber(blockNumber: number) {
|
|
131
|
+
return this.checkpoints.find(
|
|
132
|
+
c => c && blockNumber >= c.firstBlockNumber && blockNumber < c.firstBlockNumber + c.totalNumBlocks,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public getBlockProvingStateByBlockNumber(blockNumber: number) {
|
|
137
|
+
return this.getCheckpointProvingStateByBlockNumber(blockNumber)?.getBlockProvingStateByBlockNumber(blockNumber);
|
|
96
138
|
}
|
|
97
139
|
|
|
98
140
|
// Returns true if this proving state is still valid, false otherwise
|
|
@@ -103,95 +145,146 @@ export class EpochProvingState {
|
|
|
103
145
|
);
|
|
104
146
|
}
|
|
105
147
|
|
|
106
|
-
// Returns true if we are still able to accept
|
|
107
|
-
public
|
|
108
|
-
return this.
|
|
148
|
+
// Returns true if we are still able to accept checkpoints, false otherwise.
|
|
149
|
+
public isAcceptingCheckpoints() {
|
|
150
|
+
return this.checkpoints.filter(c => !!c).length < this.totalNumCheckpoints;
|
|
109
151
|
}
|
|
110
152
|
|
|
111
|
-
public
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
153
|
+
public setCheckpointRootRollupProof(
|
|
154
|
+
checkpointIndex: number,
|
|
155
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
156
|
+
CheckpointRollupPublicInputs,
|
|
115
157
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
116
158
|
>,
|
|
117
159
|
): TreeNodeLocation {
|
|
118
|
-
return this.
|
|
160
|
+
return this.checkpointProofs.setLeaf(checkpointIndex, { provingOutput });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public tryStartProvingCheckpointMerge(location: TreeNodeLocation) {
|
|
164
|
+
if (this.checkpointProofs.getNode(location)?.isProving) {
|
|
165
|
+
return false;
|
|
166
|
+
} else {
|
|
167
|
+
this.checkpointProofs.setNode(location, { isProving: true });
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
119
170
|
}
|
|
120
171
|
|
|
121
|
-
public
|
|
172
|
+
public setCheckpointMergeRollupProof(
|
|
122
173
|
location: TreeNodeLocation,
|
|
123
|
-
|
|
124
|
-
|
|
174
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
175
|
+
CheckpointRollupPublicInputs,
|
|
125
176
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
126
177
|
>,
|
|
127
178
|
) {
|
|
128
|
-
this.
|
|
179
|
+
this.checkpointProofs.setNode(location, { provingOutput });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public tryStartProvingRootRollup() {
|
|
183
|
+
if (this.rootRollupProof?.isProving) {
|
|
184
|
+
return false;
|
|
185
|
+
} else {
|
|
186
|
+
this.rootRollupProof = { isProving: true };
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
129
189
|
}
|
|
130
190
|
|
|
131
|
-
public setRootRollupProof(
|
|
132
|
-
this.
|
|
191
|
+
public setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
|
|
192
|
+
this.rootRollupProof = { provingOutput };
|
|
133
193
|
}
|
|
134
194
|
|
|
135
|
-
public
|
|
136
|
-
|
|
137
|
-
|
|
195
|
+
public tryStartProvingPaddingCheckpoint() {
|
|
196
|
+
if (this.checkpointPaddingProof?.isProving) {
|
|
197
|
+
return false;
|
|
198
|
+
} else {
|
|
199
|
+
this.checkpointPaddingProof = { isProving: true };
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public setCheckpointPaddingProof(
|
|
205
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
206
|
+
CheckpointRollupPublicInputs,
|
|
138
207
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
139
208
|
>,
|
|
140
209
|
) {
|
|
141
|
-
this.
|
|
210
|
+
this.checkpointPaddingProof = { provingOutput };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public async setBlobAccumulators() {
|
|
214
|
+
let previousAccumulator = this.startBlobAccumulator;
|
|
215
|
+
// Accumulate blobs as far as we can for this epoch.
|
|
216
|
+
for (let i = 0; i < this.totalNumCheckpoints; i++) {
|
|
217
|
+
const checkpoint = this.checkpoints[i];
|
|
218
|
+
if (!checkpoint) {
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const endAccumulator =
|
|
223
|
+
checkpoint.getEndBlobAccumulator() || (await checkpoint.accumulateBlobs(previousAccumulator));
|
|
224
|
+
if (!endAccumulator) {
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
previousAccumulator = endAccumulator;
|
|
229
|
+
|
|
230
|
+
// If this is the last checkpoint, set the end blob accumulator.
|
|
231
|
+
if (i === this.totalNumCheckpoints - 1) {
|
|
232
|
+
this.endBlobAccumulator = endAccumulator;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public async finalizeBatchedBlob() {
|
|
238
|
+
if (!this.endBlobAccumulator) {
|
|
239
|
+
throw new Error('End blob accumulator not ready.');
|
|
240
|
+
}
|
|
241
|
+
this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true /* verifyProof */);
|
|
142
242
|
}
|
|
143
243
|
|
|
144
244
|
public getParentLocation(location: TreeNodeLocation) {
|
|
145
|
-
return this.
|
|
245
|
+
return this.checkpointProofs.getParentLocation(location);
|
|
146
246
|
}
|
|
147
247
|
|
|
148
|
-
public
|
|
149
|
-
const [left, right] = this.
|
|
248
|
+
public getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
249
|
+
const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
150
250
|
if (!left || !right) {
|
|
151
|
-
throw new Error('At
|
|
251
|
+
throw new Error('At least one child is not ready for the checkpoint merge rollup.');
|
|
152
252
|
}
|
|
153
253
|
|
|
154
|
-
return new
|
|
254
|
+
return new CheckpointMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
155
255
|
}
|
|
156
256
|
|
|
157
|
-
public getRootRollupInputs(
|
|
257
|
+
public getRootRollupInputs() {
|
|
158
258
|
const [left, right] = this.#getChildProofsForRoot();
|
|
159
259
|
if (!left || !right) {
|
|
160
|
-
throw new Error('At
|
|
260
|
+
throw new Error('At least one child is not ready for the root rollup.');
|
|
161
261
|
}
|
|
162
262
|
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
proverId,
|
|
263
|
+
return RootRollupPrivateInputs.from({
|
|
264
|
+
previousRollups: [toProofData(left), toProofData(right)],
|
|
166
265
|
});
|
|
167
266
|
}
|
|
168
267
|
|
|
169
|
-
public
|
|
170
|
-
|
|
171
|
-
throw new Error('Epoch needs one completed block in order to be padded.');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return this.blocks[0].getPaddingBlockRootInputs(proverId);
|
|
268
|
+
public getPaddingCheckpointInputs() {
|
|
269
|
+
return new CheckpointPaddingRollupPrivateInputs();
|
|
175
270
|
}
|
|
176
271
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return this.blocks.find(block => block?.blockNumber === blockNumber);
|
|
180
|
-
}
|
|
272
|
+
public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs; batchedBlobInputs: BatchedBlob } {
|
|
273
|
+
const provingOutput = this.rootRollupProof?.provingOutput;
|
|
181
274
|
|
|
182
|
-
|
|
183
|
-
if (!this.rootRollupProvingOutput) {
|
|
275
|
+
if (!provingOutput || !this.finalBatchedBlob) {
|
|
184
276
|
throw new Error('Unable to get epoch proof result. Root rollup is not ready.');
|
|
185
277
|
}
|
|
186
278
|
|
|
187
279
|
return {
|
|
188
|
-
proof:
|
|
189
|
-
publicInputs:
|
|
280
|
+
proof: provingOutput.proof.binaryProof,
|
|
281
|
+
publicInputs: provingOutput.inputs,
|
|
282
|
+
batchedBlobInputs: this.finalBatchedBlob,
|
|
190
283
|
};
|
|
191
284
|
}
|
|
192
285
|
|
|
193
|
-
public
|
|
194
|
-
return this.
|
|
286
|
+
public isReadyForCheckpointMerge(location: TreeNodeLocation) {
|
|
287
|
+
return !!this.checkpointProofs.getSibling(location)?.provingOutput;
|
|
195
288
|
}
|
|
196
289
|
|
|
197
290
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
@@ -228,25 +321,8 @@ export class EpochProvingState {
|
|
|
228
321
|
#getChildProofsForRoot() {
|
|
229
322
|
const rootLocation = { level: 0, index: 0 };
|
|
230
323
|
// If there's only 1 block, its block root proof will be stored at the root.
|
|
231
|
-
return this.
|
|
232
|
-
? [this.
|
|
233
|
-
: this.
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
#getPreviousRollupData({
|
|
237
|
-
inputs,
|
|
238
|
-
proof,
|
|
239
|
-
verificationKey,
|
|
240
|
-
}: PublicInputsAndRecursiveProof<
|
|
241
|
-
BlockRootOrBlockMergePublicInputs,
|
|
242
|
-
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
243
|
-
>) {
|
|
244
|
-
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
245
|
-
return new PreviousRollupBlockData(
|
|
246
|
-
inputs,
|
|
247
|
-
proof,
|
|
248
|
-
verificationKey.keyAsFields,
|
|
249
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
250
|
-
);
|
|
324
|
+
return this.totalNumCheckpoints === 1
|
|
325
|
+
? [this.checkpointProofs.getNode(rootLocation)?.provingOutput, this.checkpointPaddingProof?.provingOutput]
|
|
326
|
+
: this.checkpointProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
251
327
|
}
|
|
252
328
|
}
|