@aztec/prover-client 0.0.1-commit.d3ec352c → 0.0.1-commit.e3c1de76
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 +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -1
- package/dest/light/index.d.ts +2 -0
- package/dest/light/index.d.ts.map +1 -0
- package/dest/light/index.js +1 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts +33 -15
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +116 -23
- package/dest/mocks/fixtures.d.ts +1 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +4 -3
- package/dest/mocks/test_context.d.ts +5 -3
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +21 -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 +3 -3
- package/dest/orchestrator/block-proving-state.d.ts +2 -2
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +1 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +16 -3
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +36 -2
- package/dest/orchestrator/epoch-proving-state.d.ts +5 -4
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +35 -1
- package/dest/orchestrator/orchestrator.d.ts +20 -5
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +535 -134
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -15
- package/dest/orchestrator/tx-proving-state.d.ts +6 -5
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +8 -8
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/prover-client.d.ts +3 -3
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +7 -4
- 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/proving_broker/broker_prover_facade.d.ts +7 -5
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +6 -13
- package/dest/proving_broker/config.d.ts +6 -2
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +8 -2
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proving_agent.d.ts +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- package/dest/proving_broker/proving_broker.d.ts +1 -1
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +4 -10
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +389 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +15 -35
- package/dest/proving_broker/proving_job_controller.d.ts +4 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +8 -6
- package/dest/test/mock_proof_store.d.ts +3 -3
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +2 -2
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +4 -4
- package/package.json +18 -17
- package/src/config.ts +1 -1
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +177 -31
- package/src/mocks/fixtures.ts +4 -3
- package/src/mocks/test_context.ts +18 -6
- package/src/orchestrator/block-building-helpers.ts +3 -3
- package/src/orchestrator/block-proving-state.ts +1 -1
- package/src/orchestrator/checkpoint-proving-state.ts +49 -2
- package/src/orchestrator/epoch-proving-state.ts +56 -8
- package/src/orchestrator/orchestrator.ts +130 -114
- package/src/orchestrator/orchestrator_metrics.ts +2 -25
- package/src/orchestrator/tx-proving-state.ts +10 -14
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +25 -15
- package/src/prover-client/server-epoch-prover.ts +1 -1
- package/src/proving_broker/broker_prover_facade.ts +10 -17
- package/src/proving_broker/config.ts +10 -1
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +4 -8
- package/src/proving_broker/proving_broker_database/persisted.ts +15 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +14 -35
- package/src/proving_broker/proving_job_controller.ts +11 -6
- package/src/test/mock_prover.ts +2 -14
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -108
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -137
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
package/src/mocks/fixtures.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import type { Logger } from '@aztec/foundation/log';
|
|
6
6
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
7
7
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
@@ -75,7 +75,8 @@ export async function getSimulator(
|
|
|
75
75
|
logger?.info(
|
|
76
76
|
`Using native ACVM at ${config.acvmBinaryPath} and working directory ${config.acvmWorkingDirectory}`,
|
|
77
77
|
);
|
|
78
|
-
|
|
78
|
+
const acvmLogger = logger?.createChild('acvm-native');
|
|
79
|
+
return new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, acvmLogger);
|
|
79
80
|
} catch {
|
|
80
81
|
logger?.warn(`Failed to access ACVM at ${config.acvmBinaryPath}, falling back to WASM`);
|
|
81
82
|
}
|
|
@@ -3,7 +3,7 @@ import { TestCircuitProver } from '@aztec/bb-prover';
|
|
|
3
3
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
4
4
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
5
5
|
import { padArrayEnd, times, timesAsync } from '@aztec/foundation/collection';
|
|
6
|
-
import { Fr } from '@aztec/foundation/
|
|
6
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
7
|
import type { Logger } from '@aztec/foundation/log';
|
|
8
8
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
9
9
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
@@ -44,7 +44,9 @@ import { getEnvironmentConfig, getSimulator, makeCheckpointConstants, makeGlobal
|
|
|
44
44
|
export class TestContext {
|
|
45
45
|
private headers: Map<number, BlockHeader> = new Map();
|
|
46
46
|
private checkpoints: Checkpoint[] = [];
|
|
47
|
+
private checkpointOutHashes: Fr[] = [];
|
|
47
48
|
private nextCheckpointIndex = 0;
|
|
49
|
+
private nextCheckpointNumber = CheckpointNumber(1);
|
|
48
50
|
private nextBlockNumber = 1;
|
|
49
51
|
private epochNumber = 1;
|
|
50
52
|
private feePayerBalance: Fr;
|
|
@@ -150,6 +152,7 @@ export class TestContext {
|
|
|
150
152
|
|
|
151
153
|
public startNewEpoch() {
|
|
152
154
|
this.checkpoints = [];
|
|
155
|
+
this.checkpointOutHashes = [];
|
|
153
156
|
this.nextCheckpointIndex = 0;
|
|
154
157
|
this.epochNumber++;
|
|
155
158
|
}
|
|
@@ -187,7 +190,8 @@ export class TestContext {
|
|
|
187
190
|
}
|
|
188
191
|
|
|
189
192
|
const checkpointIndex = this.nextCheckpointIndex++;
|
|
190
|
-
const checkpointNumber =
|
|
193
|
+
const checkpointNumber = this.nextCheckpointNumber;
|
|
194
|
+
this.nextCheckpointNumber++;
|
|
191
195
|
const slotNumber = checkpointNumber * 15; // times an arbitrary number to make it different to the checkpoint number
|
|
192
196
|
|
|
193
197
|
const constants = makeCheckpointConstants(slotNumber, constantOpts);
|
|
@@ -204,6 +208,8 @@ export class TestContext {
|
|
|
204
208
|
|
|
205
209
|
const startBlockNumber = this.nextBlockNumber;
|
|
206
210
|
const previousBlockHeader = this.getBlockHeader(BlockNumber(startBlockNumber - 1));
|
|
211
|
+
// All blocks in the same slot/checkpoint share the same timestamp.
|
|
212
|
+
const timestamp = BigInt(slotNumber * 26);
|
|
207
213
|
|
|
208
214
|
// Build global variables.
|
|
209
215
|
const blockGlobalVariables = times(numBlocks, i =>
|
|
@@ -211,6 +217,7 @@ export class TestContext {
|
|
|
211
217
|
coinbase: constants.coinbase,
|
|
212
218
|
feeRecipient: constants.feeRecipient,
|
|
213
219
|
gasFees: constants.gasFees,
|
|
220
|
+
timestamp,
|
|
214
221
|
}),
|
|
215
222
|
);
|
|
216
223
|
this.nextBlockNumber += numBlocks;
|
|
@@ -240,33 +247,38 @@ export class TestContext {
|
|
|
240
247
|
});
|
|
241
248
|
|
|
242
249
|
const cleanFork = await this.worldState.fork();
|
|
250
|
+
const previousCheckpointOutHashes = this.checkpointOutHashes;
|
|
243
251
|
const builder = await LightweightCheckpointBuilder.startNewCheckpoint(
|
|
244
252
|
checkpointNumber,
|
|
245
253
|
constants,
|
|
246
254
|
l1ToL2Messages,
|
|
255
|
+
previousCheckpointOutHashes,
|
|
247
256
|
cleanFork,
|
|
248
257
|
);
|
|
249
258
|
|
|
250
259
|
// Add tx effects to db and build block headers.
|
|
251
260
|
const blocks = [];
|
|
252
261
|
for (let i = 0; i < numBlocks; i++) {
|
|
253
|
-
const isFirstBlock = i === 0;
|
|
254
262
|
const txs = blockTxs[i];
|
|
255
263
|
const state = blockEndStates[i];
|
|
256
264
|
|
|
257
|
-
const block = await builder.addBlock(blockGlobalVariables[i],
|
|
265
|
+
const block = await builder.addBlock(blockGlobalVariables[i], txs, {
|
|
266
|
+
expectedEndState: state,
|
|
267
|
+
insertTxsEffects: true,
|
|
268
|
+
});
|
|
258
269
|
|
|
259
270
|
const header = block.header;
|
|
260
271
|
this.headers.set(block.number, header);
|
|
261
272
|
|
|
262
|
-
const blockMsgs =
|
|
263
|
-
await this.worldState.handleL2BlockAndMessages(block, blockMsgs
|
|
273
|
+
const blockMsgs = block.indexWithinCheckpoint === 0 ? l1ToL2Messages : [];
|
|
274
|
+
await this.worldState.handleL2BlockAndMessages(block, blockMsgs);
|
|
264
275
|
|
|
265
276
|
blocks.push({ header, txs });
|
|
266
277
|
}
|
|
267
278
|
|
|
268
279
|
const checkpoint = await builder.completeCheckpoint();
|
|
269
280
|
this.checkpoints.push(checkpoint);
|
|
281
|
+
this.checkpointOutHashes.push(checkpoint.getCheckpointOutHash());
|
|
270
282
|
|
|
271
283
|
return {
|
|
272
284
|
constants,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
import { makeTuple } from '@aztec/foundation/array';
|
|
23
23
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
24
24
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
25
|
-
import { Fr } from '@aztec/foundation/
|
|
25
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
26
26
|
import { type Bufferable, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize';
|
|
27
27
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
28
28
|
import { getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
@@ -99,7 +99,7 @@ export const insertSideEffectsAndBuildBaseRollupHints = runInSpan(
|
|
|
99
99
|
|
|
100
100
|
const blockHash = await tx.data.constants.anchorBlockHeader.hash();
|
|
101
101
|
const anchorBlockArchiveSiblingPath = (
|
|
102
|
-
await getMembershipWitnessFor(blockHash, MerkleTreeId.ARCHIVE, ARCHIVE_HEIGHT, db)
|
|
102
|
+
await getMembershipWitnessFor(blockHash.toFr(), MerkleTreeId.ARCHIVE, ARCHIVE_HEIGHT, db)
|
|
103
103
|
).siblingPath;
|
|
104
104
|
|
|
105
105
|
const contractClassLogsFields = makeTuple(
|
|
@@ -282,7 +282,7 @@ export const buildHeaderFromCircuitOutputs = runInSpan(
|
|
|
282
282
|
chainId: constants.chainId,
|
|
283
283
|
version: constants.version,
|
|
284
284
|
blockNumber: BlockNumber(blockRootRollupOutput.previousArchive.nextAvailableLeafIndex),
|
|
285
|
-
timestamp: blockRootRollupOutput.
|
|
285
|
+
timestamp: blockRootRollupOutput.timestamp,
|
|
286
286
|
slotNumber: constants.slotNumber,
|
|
287
287
|
coinbase: constants.coinbase,
|
|
288
288
|
feeRecipient: constants.feeRecipient,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
NUM_BASE_PARITY_PER_ROOT_PARITY,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
9
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
12
12
|
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
13
13
|
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
@@ -11,13 +11,16 @@ import {
|
|
|
11
11
|
type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
12
12
|
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
13
13
|
NUM_MSGS_PER_BASE_PARITY,
|
|
14
|
+
OUT_HASH_TREE_HEIGHT,
|
|
14
15
|
} from '@aztec/constants';
|
|
15
16
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
16
17
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
17
|
-
import { BLS12Point
|
|
18
|
+
import { BLS12Point } from '@aztec/foundation/curves/bls12';
|
|
19
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
18
20
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
19
21
|
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
20
22
|
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
23
|
+
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
21
24
|
import { ParityBasePrivateInputs } from '@aztec/stdlib/parity';
|
|
22
25
|
import {
|
|
23
26
|
BlockMergeRollupPrivateInputs,
|
|
@@ -37,6 +40,11 @@ import { accumulateBlobs, buildBlobHints, toProofData } from './block-building-h
|
|
|
37
40
|
import { BlockProvingState, type ProofState } from './block-proving-state.js';
|
|
38
41
|
import type { EpochProvingState } from './epoch-proving-state.js';
|
|
39
42
|
|
|
43
|
+
type OutHashHint = {
|
|
44
|
+
treeSnapshot: AppendOnlyTreeSnapshot;
|
|
45
|
+
siblingPath: Tuple<Fr, typeof OUT_HASH_TREE_HEIGHT>;
|
|
46
|
+
};
|
|
47
|
+
|
|
40
48
|
export class CheckpointProvingState {
|
|
41
49
|
private blockProofs: UnbalancedTreeStore<
|
|
42
50
|
ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
@@ -45,6 +53,11 @@ export class CheckpointProvingState {
|
|
|
45
53
|
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
46
54
|
| undefined;
|
|
47
55
|
private blocks: (BlockProvingState | undefined)[] = [];
|
|
56
|
+
private previousOutHashHint: OutHashHint | undefined;
|
|
57
|
+
private outHash: Fr | undefined;
|
|
58
|
+
// The snapshot and sibling path after the checkpoint's out hash is inserted.
|
|
59
|
+
// Stored here to be retrieved for the next checkpoint when it's added.
|
|
60
|
+
private newOutHashHint: OutHashHint | undefined;
|
|
48
61
|
private startBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
49
62
|
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
50
63
|
private blobFields: Fr[] | undefined;
|
|
@@ -194,6 +207,35 @@ export class CheckpointProvingState {
|
|
|
194
207
|
return new ParityBasePrivateInputs(messages, this.constants.vkTreeRoot);
|
|
195
208
|
}
|
|
196
209
|
|
|
210
|
+
public setOutHashHint(hint: OutHashHint) {
|
|
211
|
+
this.previousOutHashHint = hint;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public getOutHashHint() {
|
|
215
|
+
return this.previousOutHashHint;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public accumulateBlockOutHashes() {
|
|
219
|
+
if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (!this.outHash) {
|
|
224
|
+
const messagesPerBlock = this.blocks.map(b => b!.getTxEffects().map(tx => tx.l2ToL1Msgs));
|
|
225
|
+
this.outHash = computeCheckpointOutHash(messagesPerBlock);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return this.outHash;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public setOutHashHintForNextCheckpoint(hint: OutHashHint) {
|
|
232
|
+
this.newOutHashHint = hint;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
public getOutHashHintForNextCheckpoint() {
|
|
236
|
+
return this.newOutHashHint;
|
|
237
|
+
}
|
|
238
|
+
|
|
197
239
|
public async accumulateBlobs(startBlobAccumulator: BatchedBlobAccumulator) {
|
|
198
240
|
if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
|
|
199
241
|
return;
|
|
@@ -235,6 +277,9 @@ export class CheckpointProvingState {
|
|
|
235
277
|
if (proofs.length !== nonEmptyProofs.length) {
|
|
236
278
|
throw new Error('At least one child is not ready for the checkpoint root rollup.');
|
|
237
279
|
}
|
|
280
|
+
if (!this.previousOutHashHint) {
|
|
281
|
+
throw new Error('Out hash hint is not set.');
|
|
282
|
+
}
|
|
238
283
|
if (!this.startBlobAccumulator) {
|
|
239
284
|
throw new Error('Start blob accumulator is not set.');
|
|
240
285
|
}
|
|
@@ -247,6 +292,8 @@ export class CheckpointProvingState {
|
|
|
247
292
|
const hints = CheckpointRootRollupHints.from({
|
|
248
293
|
previousBlockHeader: this.headerOfLastBlockInPreviousCheckpoint,
|
|
249
294
|
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
295
|
+
previousOutHash: this.previousOutHashHint.treeSnapshot,
|
|
296
|
+
newOutHashSiblingPath: this.previousOutHashHint.siblingPath,
|
|
250
297
|
startBlobAccumulator: this.startBlobAccumulator.toBlobAccumulator(),
|
|
251
298
|
finalBlobChallenges: this.finalBlobBatchingChallenges,
|
|
252
299
|
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT),
|
|
@@ -272,7 +319,7 @@ export class CheckpointProvingState {
|
|
|
272
319
|
|
|
273
320
|
public isReadyForCheckpointRoot() {
|
|
274
321
|
const allChildProofsReady = this.#getChildProofsForRoot().every(p => !!p);
|
|
275
|
-
return allChildProofsReady && !!this.startBlobAccumulator;
|
|
322
|
+
return allChildProofsReady && !!this.previousOutHashHint && !!this.startBlobAccumulator;
|
|
276
323
|
}
|
|
277
324
|
|
|
278
325
|
public verifyState() {
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { BatchedBlob, BatchedBlobAccumulator, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
-
import
|
|
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,
|
|
2
|
+
import {
|
|
3
|
+
type ARCHIVE_HEIGHT,
|
|
4
|
+
type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
5
|
+
type NESTED_RECURSIVE_PROOF_LENGTH,
|
|
6
|
+
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
7
|
+
OUT_HASH_TREE_HEIGHT,
|
|
7
8
|
} from '@aztec/constants';
|
|
8
9
|
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
9
|
-
import
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
11
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
11
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
MerkleTreeCalculator,
|
|
14
|
+
type TreeNodeLocation,
|
|
15
|
+
UnbalancedTreeStore,
|
|
16
|
+
shaMerkleHash,
|
|
17
|
+
} from '@aztec/foundation/trees';
|
|
12
18
|
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
13
19
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
14
20
|
import {
|
|
@@ -20,7 +26,7 @@ import {
|
|
|
20
26
|
RootRollupPrivateInputs,
|
|
21
27
|
type RootRollupPublicInputs,
|
|
22
28
|
} from '@aztec/stdlib/rollup';
|
|
23
|
-
import
|
|
29
|
+
import { AppendOnlyTreeSnapshot, type MerkleTreeId } from '@aztec/stdlib/trees';
|
|
24
30
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
25
31
|
|
|
26
32
|
import { toProofData } from './block-building-helpers.js';
|
|
@@ -212,6 +218,48 @@ export class EpochProvingState {
|
|
|
212
218
|
this.checkpointPaddingProof = { provingOutput };
|
|
213
219
|
}
|
|
214
220
|
|
|
221
|
+
public async accumulateCheckpointOutHashes() {
|
|
222
|
+
const treeCalculator = await MerkleTreeCalculator.create(OUT_HASH_TREE_HEIGHT, undefined, (left, right) =>
|
|
223
|
+
Promise.resolve(shaMerkleHash(left, right)),
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const computeOutHashHint = async (leaves: Fr[]) => {
|
|
227
|
+
const tree = await treeCalculator.computeTree(leaves.map(l => l.toBuffer()));
|
|
228
|
+
const nextAvailableLeafIndex = leaves.length;
|
|
229
|
+
return {
|
|
230
|
+
treeSnapshot: new AppendOnlyTreeSnapshot(Fr.fromBuffer(tree.root), nextAvailableLeafIndex),
|
|
231
|
+
siblingPath: tree.getSiblingPath(nextAvailableLeafIndex).map(Fr.fromBuffer) as Tuple<
|
|
232
|
+
Fr,
|
|
233
|
+
typeof OUT_HASH_TREE_HEIGHT
|
|
234
|
+
>,
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
let hint = this.checkpoints[0]?.getOutHashHint();
|
|
239
|
+
const outHashes = [];
|
|
240
|
+
for (let i = 0; i < this.totalNumCheckpoints; i++) {
|
|
241
|
+
const checkpoint = this.checkpoints[i];
|
|
242
|
+
if (!checkpoint) {
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// If hints are not set yet, it must be the first checkpoint. Compute the hints with an empty tree.
|
|
247
|
+
hint ??= await computeOutHashHint([]);
|
|
248
|
+
checkpoint.setOutHashHint(hint);
|
|
249
|
+
|
|
250
|
+
// Get the out hash for this checkpoint.
|
|
251
|
+
const outHash = checkpoint.accumulateBlockOutHashes();
|
|
252
|
+
if (!outHash) {
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
outHashes.push(outHash);
|
|
256
|
+
|
|
257
|
+
// Get or create hints for the next checkpoint.
|
|
258
|
+
hint = checkpoint.getOutHashHintForNextCheckpoint() ?? (await computeOutHashHint(outHashes));
|
|
259
|
+
checkpoint.setOutHashHintForNextCheckpoint(hint);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
215
263
|
public async setBlobAccumulators() {
|
|
216
264
|
let previousAccumulator = this.startBlobAccumulator;
|
|
217
265
|
// Accumulate blobs as far as we can for this epoch.
|