@aztec/prover-client 0.71.0 → 0.73.0
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.js +3 -3
- package/dest/config.js +2 -2
- package/dest/mocks/test_context.d.ts +4 -3
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +11 -8
- package/dest/orchestrator/block-building-helpers.d.ts +3 -3
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +14 -13
- package/dest/orchestrator/block-proving-state.d.ts +14 -15
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +84 -64
- package/dest/orchestrator/epoch-proving-state.d.ts +7 -7
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +18 -36
- package/dest/orchestrator/orchestrator.d.ts +4 -3
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +77 -90
- package/dest/orchestrator/tx-proving-state.d.ts +2 -2
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +14 -14
- package/dest/prover-agent/rpc.d.ts +1 -1
- package/dest/prover-agent/rpc.d.ts.map +1 -1
- package/dest/prover-agent/rpc.js +6 -6
- package/dest/prover-client/server-epoch-prover.d.ts +2 -2
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +4 -4
- package/dest/proving_broker/broker_prover_facade.js +3 -3
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +3 -4
- package/dest/proving_broker/proving_broker_database/memory.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +3 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +12 -12
- package/dest/proving_broker/proving_broker_database.d.ts +1 -1
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/rpc.d.ts +3 -3
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +7 -7
- package/dest/test/mock_prover.d.ts +1 -1
- package/package.json +11 -11
- package/src/bin/get-proof-inputs.ts +2 -2
- package/src/config.ts +1 -1
- package/src/mocks/test_context.ts +14 -9
- package/src/orchestrator/block-building-helpers.ts +13 -14
- package/src/orchestrator/block-proving-state.ts +95 -69
- package/src/orchestrator/epoch-proving-state.ts +26 -52
- package/src/orchestrator/orchestrator.ts +101 -122
- package/src/orchestrator/tx-proving-state.ts +14 -14
- package/src/prover-agent/rpc.ts +5 -5
- package/src/prover-client/server-epoch-prover.ts +8 -4
- package/src/proving_broker/broker_prover_facade.ts +3 -3
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_broker.ts +2 -4
- package/src/proving_broker/proving_broker_database/memory.ts +2 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -15
- package/src/proving_broker/proving_broker_database.ts +1 -1
- package/src/proving_broker/rpc.ts +13 -6
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
12
12
|
MembershipWitness,
|
|
13
13
|
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
14
|
-
type NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
15
14
|
NUM_BASE_PARITY_PER_ROOT_PARITY,
|
|
16
15
|
type ParityPublicInputs,
|
|
17
16
|
type RECURSIVE_PROOF_LENGTH,
|
|
@@ -24,6 +23,7 @@ import { SpongeBlob } from '@aztec/circuits.js/blobs';
|
|
|
24
23
|
import {
|
|
25
24
|
type BaseOrMergeRollupPublicInputs,
|
|
26
25
|
type BlockRootOrBlockMergePublicInputs,
|
|
26
|
+
BlockRootRollupBlobData,
|
|
27
27
|
BlockRootRollupData,
|
|
28
28
|
BlockRootRollupInputs,
|
|
29
29
|
ConstantRollupData,
|
|
@@ -68,14 +68,12 @@ export class BlockProvingState {
|
|
|
68
68
|
constructor(
|
|
69
69
|
public readonly index: number,
|
|
70
70
|
public readonly globalVariables: GlobalVariables,
|
|
71
|
-
public readonly newL1ToL2Messages:
|
|
72
|
-
private readonly
|
|
73
|
-
private readonly
|
|
74
|
-
private readonly
|
|
75
|
-
private readonly
|
|
76
|
-
private readonly archiveTreeRootSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
71
|
+
public readonly newL1ToL2Messages: Fr[],
|
|
72
|
+
private readonly l1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
|
|
73
|
+
private readonly l1ToL2MessageTreeSnapshotAfterInsertion: AppendOnlyTreeSnapshot,
|
|
74
|
+
private readonly lastArchiveSnapshot: AppendOnlyTreeSnapshot,
|
|
75
|
+
private readonly newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
77
76
|
private readonly previousBlockHeader: BlockHeader,
|
|
78
|
-
private readonly previousBlockHash: Fr,
|
|
79
77
|
private readonly parentEpoch: EpochProvingState,
|
|
80
78
|
) {
|
|
81
79
|
this.baseParityProvingOutputs = Array.from({ length: NUM_BASE_PARITY_PER_ROOT_PARITY }).map(_ => undefined);
|
|
@@ -166,21 +164,18 @@ export class BlockProvingState {
|
|
|
166
164
|
return this.baseOrMergeProvingOutputs.getParentLocation(location);
|
|
167
165
|
}
|
|
168
166
|
|
|
169
|
-
public getMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
167
|
+
public async getMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
170
168
|
const [left, right] = this.baseOrMergeProvingOutputs.getChildren(mergeLocation);
|
|
171
169
|
if (!left || !right) {
|
|
172
170
|
throw new Error('At lease one child is not ready.');
|
|
173
171
|
}
|
|
174
172
|
|
|
175
|
-
return new MergeRollupInputs([this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)]);
|
|
173
|
+
return new MergeRollupInputs([await this.#getPreviousRollupData(left), await this.#getPreviousRollupData(right)]);
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
public getBlockRootRollupTypeAndInputs(proverId: Fr) {
|
|
179
|
-
if (this.
|
|
180
|
-
|
|
181
|
-
rollupType: 'empty-block-root-rollup' satisfies CircuitName,
|
|
182
|
-
inputs: this.#getEmptyBlockRootInputs(proverId),
|
|
183
|
-
};
|
|
176
|
+
public async getBlockRootRollupTypeAndInputs(proverId: Fr) {
|
|
177
|
+
if (!this.rootParityProvingOutput) {
|
|
178
|
+
throw new Error('Root parity is not ready.');
|
|
184
179
|
}
|
|
185
180
|
|
|
186
181
|
const proofs = this.#getChildProofsForBlockRoot();
|
|
@@ -189,49 +184,98 @@ export class BlockProvingState {
|
|
|
189
184
|
throw new Error('At lease one child is not ready for the block root.');
|
|
190
185
|
}
|
|
191
186
|
|
|
192
|
-
const
|
|
193
|
-
|
|
187
|
+
const data = await this.#getBlockRootRollupData(proverId);
|
|
188
|
+
|
|
189
|
+
if (this.totalNumTxs === 0) {
|
|
190
|
+
const constants = ConstantRollupData.from({
|
|
191
|
+
lastArchive: this.lastArchiveSnapshot,
|
|
192
|
+
globalVariables: this.globalVariables,
|
|
193
|
+
vkTreeRoot: await getVKTreeRoot(),
|
|
194
|
+
protocolContractTreeRoot,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
rollupType: 'empty-block-root-rollup' satisfies CircuitName,
|
|
199
|
+
inputs: EmptyBlockRootRollupInputs.from({
|
|
200
|
+
data,
|
|
201
|
+
constants,
|
|
202
|
+
isPadding: false,
|
|
203
|
+
}),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const previousRollupData = await Promise.all(nonEmptyProofs.map(p => this.#getPreviousRollupData(p!)));
|
|
208
|
+
const blobData = await this.#getBlockRootRollupBlobData();
|
|
194
209
|
|
|
195
210
|
if (previousRollupData.length === 1) {
|
|
196
211
|
return {
|
|
197
212
|
rollupType: 'single-tx-block-root-rollup' satisfies CircuitName,
|
|
198
|
-
inputs: new SingleTxBlockRootRollupInputs(previousRollupData as [PreviousRollupData], data),
|
|
213
|
+
inputs: new SingleTxBlockRootRollupInputs(previousRollupData as [PreviousRollupData], data, blobData),
|
|
199
214
|
};
|
|
200
215
|
} else {
|
|
201
216
|
return {
|
|
202
217
|
rollupType: 'block-root-rollup' satisfies CircuitName,
|
|
203
|
-
inputs: new BlockRootRollupInputs(
|
|
218
|
+
inputs: new BlockRootRollupInputs(
|
|
219
|
+
previousRollupData as [PreviousRollupData, PreviousRollupData],
|
|
220
|
+
data,
|
|
221
|
+
blobData,
|
|
222
|
+
),
|
|
204
223
|
};
|
|
205
224
|
}
|
|
206
225
|
}
|
|
207
226
|
|
|
208
|
-
public
|
|
227
|
+
public async getPaddingBlockRootInputs(proverId: Fr) {
|
|
228
|
+
if (!this.rootParityProvingOutput) {
|
|
229
|
+
throw new Error('Root parity is not ready.');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Use the new block header and archive of the current block as the previous header and archiver of the next padding block.
|
|
233
|
+
const newBlockHeader = await this.buildHeaderFromProvingOutputs();
|
|
234
|
+
const newArchive = this.blockRootProvingOutput!.inputs.newArchive;
|
|
235
|
+
|
|
236
|
+
const data = BlockRootRollupData.from({
|
|
237
|
+
l1ToL2Roots: await this.#getRootParityData(this.rootParityProvingOutput!),
|
|
238
|
+
l1ToL2MessageSubtreeSiblingPath: this.l1ToL2MessageSubtreeSiblingPath,
|
|
239
|
+
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
240
|
+
previousBlockHeader: newBlockHeader,
|
|
241
|
+
proverId,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const constants = ConstantRollupData.from({
|
|
245
|
+
lastArchive: newArchive,
|
|
246
|
+
globalVariables: this.globalVariables,
|
|
247
|
+
vkTreeRoot: await getVKTreeRoot(),
|
|
248
|
+
protocolContractTreeRoot,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
return EmptyBlockRootRollupInputs.from({
|
|
252
|
+
data,
|
|
253
|
+
constants,
|
|
254
|
+
isPadding: true,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public async getRootParityInputs() {
|
|
209
259
|
if (!this.baseParityProvingOutputs.every(p => !!p)) {
|
|
210
260
|
throw new Error('At lease one base parity is not ready.');
|
|
211
261
|
}
|
|
212
262
|
|
|
213
|
-
const children = this.baseParityProvingOutputs.map(p => this.#
|
|
263
|
+
const children = await Promise.all(this.baseParityProvingOutputs.map(p => this.#getRootParityData(p!)));
|
|
214
264
|
return new RootParityInputs(
|
|
215
265
|
children as Tuple<RootParityInput<typeof RECURSIVE_PROOF_LENGTH>, typeof NUM_BASE_PARITY_PER_ROOT_PARITY>,
|
|
216
266
|
);
|
|
217
267
|
}
|
|
218
268
|
|
|
219
|
-
public getL1ToL2Roots() {
|
|
220
|
-
if (!this.rootParityProvingOutput) {
|
|
221
|
-
throw new Error('Root parity is not ready.');
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return this.#getRootParityInputFromProvingOutput(this.rootParityProvingOutput);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
269
|
// Returns a specific transaction proving state
|
|
228
270
|
public getTxProvingState(txIndex: number) {
|
|
229
271
|
return this.txs[txIndex];
|
|
230
272
|
}
|
|
231
273
|
|
|
232
|
-
public buildHeaderFromProvingOutputs(logger?: Logger) {
|
|
274
|
+
public async buildHeaderFromProvingOutputs(logger?: Logger) {
|
|
233
275
|
const previousRollupData =
|
|
234
|
-
this.totalNumTxs === 0
|
|
276
|
+
this.totalNumTxs === 0
|
|
277
|
+
? []
|
|
278
|
+
: await Promise.all(this.#getChildProofsForBlockRoot().map(p => this.#getPreviousRollupData(p!)));
|
|
235
279
|
|
|
236
280
|
let endPartialState = this.previousBlockHeader.state.partial;
|
|
237
281
|
if (this.totalNumTxs !== 0) {
|
|
@@ -242,7 +286,7 @@ export class BlockProvingState {
|
|
|
242
286
|
}
|
|
243
287
|
endPartialState = lastRollup.inputs.end;
|
|
244
288
|
}
|
|
245
|
-
const endState = new StateReference(this.
|
|
289
|
+
const endState = new StateReference(this.l1ToL2MessageTreeSnapshotAfterInsertion, endPartialState);
|
|
246
290
|
|
|
247
291
|
return buildHeaderFromCircuitOutputs(
|
|
248
292
|
previousRollupData.map(d => d.baseOrMergeRollupPublicInputs),
|
|
@@ -268,6 +312,10 @@ export class BlockProvingState {
|
|
|
268
312
|
return this.baseParityProvingOutputs.every(p => !!p);
|
|
269
313
|
}
|
|
270
314
|
|
|
315
|
+
public isComplete() {
|
|
316
|
+
return !!this.blockRootProvingOutput;
|
|
317
|
+
}
|
|
318
|
+
|
|
271
319
|
// Returns whether the proving state is still valid
|
|
272
320
|
public verifyState() {
|
|
273
321
|
return this.parentEpoch.verifyState();
|
|
@@ -278,38 +326,20 @@ export class BlockProvingState {
|
|
|
278
326
|
this.parentEpoch.reject(reason);
|
|
279
327
|
}
|
|
280
328
|
|
|
281
|
-
#
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
protocolContractTreeRoot,
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
return EmptyBlockRootRollupInputs.from({
|
|
291
|
-
l1ToL2Roots,
|
|
292
|
-
newL1ToL2MessageTreeRootSiblingPath: this.messageTreeRootSiblingPath,
|
|
293
|
-
startL1ToL2MessageTreeSnapshot: this.messageTreeSnapshot,
|
|
294
|
-
newArchiveSiblingPath: this.archiveTreeRootSiblingPath,
|
|
295
|
-
previousBlockHash: this.previousBlockHash,
|
|
296
|
-
previousPartialState: this.previousBlockHeader.state.partial,
|
|
297
|
-
constants,
|
|
329
|
+
async #getBlockRootRollupData(proverId: Fr) {
|
|
330
|
+
return BlockRootRollupData.from({
|
|
331
|
+
l1ToL2Roots: await this.#getRootParityData(this.rootParityProvingOutput!),
|
|
332
|
+
l1ToL2MessageSubtreeSiblingPath: this.l1ToL2MessageSubtreeSiblingPath,
|
|
333
|
+
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
334
|
+
previousBlockHeader: this.previousBlockHeader,
|
|
298
335
|
proverId,
|
|
299
|
-
isPadding: false,
|
|
300
336
|
});
|
|
301
337
|
}
|
|
302
338
|
|
|
303
|
-
#
|
|
339
|
+
async #getBlockRootRollupBlobData() {
|
|
304
340
|
const txEffects = this.txs.map(txProvingState => txProvingState.processedTx.txEffect);
|
|
305
|
-
const { blobFields, blobCommitments, blobsHash } = buildBlobHints(txEffects);
|
|
306
|
-
return
|
|
307
|
-
l1ToL2Roots: this.getL1ToL2Roots(),
|
|
308
|
-
newL1ToL2MessageTreeRootSiblingPath: this.messageTreeRootSiblingPath,
|
|
309
|
-
startL1ToL2MessageTreeSnapshot: this.messageTreeSnapshot,
|
|
310
|
-
newArchiveSiblingPath: this.archiveTreeRootSiblingPath,
|
|
311
|
-
previousBlockHash: this.previousBlockHash,
|
|
312
|
-
proverId,
|
|
341
|
+
const { blobFields, blobCommitments, blobsHash } = await buildBlobHints(txEffects);
|
|
342
|
+
return BlockRootRollupBlobData.from({
|
|
313
343
|
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_BLOCK),
|
|
314
344
|
blobCommitments: padArrayEnd(blobCommitments, [Fr.ZERO, Fr.ZERO], BLOBS_PER_BLOCK),
|
|
315
345
|
blobsHash,
|
|
@@ -328,29 +358,25 @@ export class BlockProvingState {
|
|
|
328
358
|
: this.baseOrMergeProvingOutputs.getChildren(rootLocation);
|
|
329
359
|
}
|
|
330
360
|
|
|
331
|
-
#getPreviousRollupData({
|
|
361
|
+
async #getPreviousRollupData({
|
|
332
362
|
inputs,
|
|
333
363
|
proof,
|
|
334
364
|
verificationKey,
|
|
335
365
|
}: PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>) {
|
|
336
|
-
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
366
|
+
const leafIndex = await getVKIndex(verificationKey.keyAsFields);
|
|
337
367
|
return new PreviousRollupData(
|
|
338
368
|
inputs,
|
|
339
369
|
proof,
|
|
340
370
|
verificationKey.keyAsFields,
|
|
341
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
371
|
+
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), await getVKSiblingPath(leafIndex)),
|
|
342
372
|
);
|
|
343
373
|
}
|
|
344
374
|
|
|
345
|
-
#
|
|
346
|
-
inputs,
|
|
347
|
-
proof,
|
|
348
|
-
verificationKey,
|
|
349
|
-
}: PublicInputsAndRecursiveProof<ParityPublicInputs>) {
|
|
375
|
+
async #getRootParityData({ inputs, proof, verificationKey }: PublicInputsAndRecursiveProof<ParityPublicInputs>) {
|
|
350
376
|
return new RootParityInput(
|
|
351
377
|
proof,
|
|
352
378
|
verificationKey.keyAsFields,
|
|
353
|
-
getVKSiblingPath(getVKIndex(verificationKey)),
|
|
379
|
+
await getVKSiblingPath(await getVKIndex(verificationKey)),
|
|
354
380
|
inputs,
|
|
355
381
|
);
|
|
356
382
|
}
|
|
@@ -4,33 +4,27 @@ import {
|
|
|
4
4
|
type PublicInputsAndRecursiveProof,
|
|
5
5
|
} from '@aztec/circuit-types';
|
|
6
6
|
import {
|
|
7
|
-
ARCHIVE_HEIGHT,
|
|
8
|
-
AppendOnlyTreeSnapshot,
|
|
7
|
+
type ARCHIVE_HEIGHT,
|
|
8
|
+
type AppendOnlyTreeSnapshot,
|
|
9
9
|
type BlockHeader,
|
|
10
|
-
Fr,
|
|
10
|
+
type Fr,
|
|
11
11
|
type GlobalVariables,
|
|
12
|
-
L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
12
|
+
type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
13
13
|
MembershipWitness,
|
|
14
14
|
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
15
|
-
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
16
15
|
type TUBE_PROOF_LENGTH,
|
|
17
16
|
VK_TREE_HEIGHT,
|
|
18
17
|
} from '@aztec/circuits.js';
|
|
19
18
|
import {
|
|
20
19
|
BlockMergeRollupInputs,
|
|
21
20
|
type BlockRootOrBlockMergePublicInputs,
|
|
22
|
-
ConstantRollupData,
|
|
23
|
-
EmptyBlockRootRollupInputs,
|
|
24
21
|
PreviousRollupBlockData,
|
|
25
22
|
RootRollupInputs,
|
|
26
23
|
type RootRollupPublicInputs,
|
|
27
24
|
} from '@aztec/circuits.js/rollup';
|
|
28
|
-
import { makeTuple } from '@aztec/foundation/array';
|
|
29
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
30
25
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
31
26
|
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
32
|
-
import { getVKIndex, getVKSiblingPath
|
|
33
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
27
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vks';
|
|
34
28
|
|
|
35
29
|
import { BlockProvingState } from './block-proving-state.js';
|
|
36
30
|
|
|
@@ -81,26 +75,22 @@ export class EpochProvingState {
|
|
|
81
75
|
public startNewBlock(
|
|
82
76
|
globalVariables: GlobalVariables,
|
|
83
77
|
l1ToL2Messages: Fr[],
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
archiveTreeRootSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
78
|
+
l1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
|
|
79
|
+
l1ToL2MessageTreeSnapshotAfterInsertion: AppendOnlyTreeSnapshot,
|
|
80
|
+
lastArchiveSnapshot: AppendOnlyTreeSnapshot,
|
|
81
|
+
newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
89
82
|
previousBlockHeader: BlockHeader,
|
|
90
|
-
previousBlockHash: Fr,
|
|
91
83
|
): BlockProvingState {
|
|
92
84
|
const index = globalVariables.blockNumber.toNumber() - this.firstBlockNumber;
|
|
93
85
|
const block = new BlockProvingState(
|
|
94
86
|
index,
|
|
95
87
|
globalVariables,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
archiveTreeRootSiblingPath,
|
|
88
|
+
l1ToL2Messages,
|
|
89
|
+
l1ToL2MessageSubtreeSiblingPath,
|
|
90
|
+
l1ToL2MessageTreeSnapshotAfterInsertion,
|
|
91
|
+
lastArchiveSnapshot,
|
|
92
|
+
newArchiveSiblingPath,
|
|
102
93
|
previousBlockHeader,
|
|
103
|
-
previousBlockHash,
|
|
104
94
|
this,
|
|
105
95
|
);
|
|
106
96
|
this.blocks[index] = block;
|
|
@@ -160,52 +150,36 @@ export class EpochProvingState {
|
|
|
160
150
|
return this.blockRootOrMergeProvingOutputs.getParentLocation(location);
|
|
161
151
|
}
|
|
162
152
|
|
|
163
|
-
public getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
153
|
+
public async getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
164
154
|
const [left, right] = this.blockRootOrMergeProvingOutputs.getChildren(mergeLocation);
|
|
165
155
|
if (!left || !right) {
|
|
166
156
|
throw new Error('At lease one child is not ready.');
|
|
167
157
|
}
|
|
168
158
|
|
|
169
|
-
return new BlockMergeRollupInputs([
|
|
159
|
+
return new BlockMergeRollupInputs([
|
|
160
|
+
await this.#getPreviousRollupData(left),
|
|
161
|
+
await this.#getPreviousRollupData(right),
|
|
162
|
+
]);
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
public getRootRollupInputs(proverId: Fr) {
|
|
165
|
+
public async getRootRollupInputs(proverId: Fr) {
|
|
173
166
|
const [left, right] = this.#getChildProofsForRoot();
|
|
174
167
|
if (!left || !right) {
|
|
175
168
|
throw new Error('At lease one child is not ready.');
|
|
176
169
|
}
|
|
177
170
|
|
|
178
171
|
return RootRollupInputs.from({
|
|
179
|
-
previousRollupData: [this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)],
|
|
172
|
+
previousRollupData: [await this.#getPreviousRollupData(left), await this.#getPreviousRollupData(right)],
|
|
180
173
|
proverId,
|
|
181
174
|
});
|
|
182
175
|
}
|
|
183
176
|
|
|
184
177
|
public getPaddingBlockRootInputs(proverId: Fr) {
|
|
185
|
-
|
|
186
|
-
const l1ToL2Roots = this.blocks[0]?.getL1ToL2Roots();
|
|
187
|
-
if (!block || !l1ToL2Roots) {
|
|
178
|
+
if (!this.blocks[0]?.isComplete()) {
|
|
188
179
|
throw new Error('Epoch needs one completed block in order to be padded.');
|
|
189
180
|
}
|
|
190
181
|
|
|
191
|
-
|
|
192
|
-
lastArchive: block.archive,
|
|
193
|
-
globalVariables: block.header.globalVariables,
|
|
194
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
195
|
-
protocolContractTreeRoot,
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
return EmptyBlockRootRollupInputs.from({
|
|
199
|
-
l1ToL2Roots,
|
|
200
|
-
newL1ToL2MessageTreeRootSiblingPath: makeTuple(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, Fr.zero),
|
|
201
|
-
startL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot.zero(),
|
|
202
|
-
newArchiveSiblingPath: makeTuple(ARCHIVE_HEIGHT, Fr.zero),
|
|
203
|
-
previousBlockHash: block.header.hash(),
|
|
204
|
-
previousPartialState: block.header.state.partial,
|
|
205
|
-
constants,
|
|
206
|
-
proverId,
|
|
207
|
-
isPadding: true,
|
|
208
|
-
});
|
|
182
|
+
return this.blocks[0].getPaddingBlockRootInputs(proverId);
|
|
209
183
|
}
|
|
210
184
|
|
|
211
185
|
// Returns a specific transaction proving state
|
|
@@ -267,7 +241,7 @@ export class EpochProvingState {
|
|
|
267
241
|
: this.blockRootOrMergeProvingOutputs.getChildren(rootLocation);
|
|
268
242
|
}
|
|
269
243
|
|
|
270
|
-
#getPreviousRollupData({
|
|
244
|
+
async #getPreviousRollupData({
|
|
271
245
|
inputs,
|
|
272
246
|
proof,
|
|
273
247
|
verificationKey,
|
|
@@ -275,12 +249,12 @@ export class EpochProvingState {
|
|
|
275
249
|
BlockRootOrBlockMergePublicInputs,
|
|
276
250
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
277
251
|
>) {
|
|
278
|
-
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
252
|
+
const leafIndex = await getVKIndex(verificationKey.keyAsFields);
|
|
279
253
|
return new PreviousRollupBlockData(
|
|
280
254
|
inputs,
|
|
281
255
|
proof,
|
|
282
256
|
verificationKey.keyAsFields,
|
|
283
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
257
|
+
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), await getVKSiblingPath(leafIndex)),
|
|
284
258
|
);
|
|
285
259
|
}
|
|
286
260
|
}
|