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