@aztec/prover-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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.
Files changed (164) hide show
  1. package/dest/config.d.ts +2 -2
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +17 -3
  4. package/dest/light/index.d.ts +2 -0
  5. package/dest/light/index.d.ts.map +1 -0
  6. package/dest/light/index.js +1 -0
  7. package/dest/light/lightweight_checkpoint_builder.d.ts +38 -15
  8. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  9. package/dest/light/lightweight_checkpoint_builder.js +162 -36
  10. package/dest/mocks/fixtures.d.ts +1 -1
  11. package/dest/mocks/fixtures.d.ts.map +1 -1
  12. package/dest/mocks/fixtures.js +4 -3
  13. package/dest/mocks/test_context.d.ts +15 -13
  14. package/dest/mocks/test_context.d.ts.map +1 -1
  15. package/dest/mocks/test_context.js +50 -36
  16. package/dest/orchestrator/block-building-helpers.d.ts +6 -6
  17. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  18. package/dest/orchestrator/block-building-helpers.js +5 -5
  19. package/dest/orchestrator/block-proving-state.d.ts +5 -2
  20. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  21. package/dest/orchestrator/block-proving-state.js +8 -1
  22. package/dest/orchestrator/checkpoint-proving-state.d.ts +20 -23
  23. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  24. package/dest/orchestrator/checkpoint-proving-state.js +23 -87
  25. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +161 -0
  26. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
  27. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +1066 -0
  28. package/dest/orchestrator/chonk-cache.d.ts +39 -0
  29. package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
  30. package/dest/orchestrator/chonk-cache.js +80 -0
  31. package/dest/orchestrator/index.d.ts +4 -2
  32. package/dest/orchestrator/index.d.ts.map +1 -1
  33. package/dest/orchestrator/index.js +3 -1
  34. package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
  35. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  36. package/dest/orchestrator/orchestrator_metrics.js +2 -15
  37. package/dest/orchestrator/proving-scheduler.d.ts +81 -0
  38. package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
  39. package/dest/orchestrator/proving-scheduler.js +120 -0
  40. package/dest/orchestrator/top-tree-orchestrator.d.ts +88 -0
  41. package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
  42. package/dest/orchestrator/top-tree-orchestrator.js +232 -0
  43. package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
  44. package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
  45. package/dest/orchestrator/top-tree-proving-state.js +185 -0
  46. package/dest/orchestrator/tx-proving-state.d.ts +7 -6
  47. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  48. package/dest/orchestrator/tx-proving-state.js +8 -8
  49. package/dest/prover-client/factory.d.ts +3 -3
  50. package/dest/prover-client/factory.d.ts.map +1 -1
  51. package/dest/prover-client/prover-client.d.ts +65 -8
  52. package/dest/prover-client/prover-client.d.ts.map +1 -1
  53. package/dest/prover-client/prover-client.js +66 -14
  54. package/dest/proving_broker/broker_prover_facade.d.ts +8 -6
  55. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  56. package/dest/proving_broker/broker_prover_facade.js +18 -31
  57. package/dest/proving_broker/config.d.ts +13 -65
  58. package/dest/proving_broker/config.d.ts.map +1 -1
  59. package/dest/proving_broker/config.js +23 -6
  60. package/dest/proving_broker/fixtures.js +1 -1
  61. package/dest/proving_broker/index.d.ts +2 -1
  62. package/dest/proving_broker/index.d.ts.map +1 -1
  63. package/dest/proving_broker/index.js +1 -0
  64. package/dest/proving_broker/proof_store/factory.d.ts +2 -5
  65. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  66. package/dest/proving_broker/proof_store/factory.js +7 -30
  67. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
  68. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
  69. package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
  70. package/dest/proving_broker/proof_store/index.d.ts +2 -2
  71. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  72. package/dest/proving_broker/proof_store/index.js +1 -1
  73. package/dest/proving_broker/proving_agent.d.ts +5 -9
  74. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  75. package/dest/proving_broker/proving_agent.js +4 -19
  76. package/dest/proving_broker/proving_broker.d.ts +8 -5
  77. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  78. package/dest/proving_broker/proving_broker.js +72 -21
  79. package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
  80. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  81. package/dest/proving_broker/proving_broker_database/persisted.js +391 -3
  82. package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
  83. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  84. package/dest/proving_broker/proving_broker_instrumentation.js +22 -35
  85. package/dest/proving_broker/proving_job_controller.d.ts +4 -3
  86. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  87. package/dest/proving_broker/proving_job_controller.js +8 -6
  88. package/dest/proving_broker/rpc.d.ts +6 -2
  89. package/dest/proving_broker/rpc.d.ts.map +1 -1
  90. package/dest/proving_broker/rpc.js +87 -23
  91. package/dest/test/epoch_settlement.d.ts +36 -0
  92. package/dest/test/epoch_settlement.d.ts.map +1 -0
  93. package/dest/test/epoch_settlement.js +52 -0
  94. package/dest/test/index.d.ts +2 -0
  95. package/dest/test/index.d.ts.map +1 -0
  96. package/dest/test/index.js +1 -0
  97. package/dest/test/mock_proof_store.d.ts +3 -3
  98. package/dest/test/mock_proof_store.d.ts.map +1 -1
  99. package/dest/test/mock_prover.d.ts +5 -5
  100. package/dest/test/mock_prover.d.ts.map +1 -1
  101. package/dest/test/mock_prover.js +4 -4
  102. package/package.json +23 -22
  103. package/src/config.ts +19 -3
  104. package/src/light/index.ts +1 -0
  105. package/src/light/lightweight_checkpoint_builder.ts +229 -50
  106. package/src/mocks/fixtures.ts +4 -3
  107. package/src/mocks/test_context.ts +44 -48
  108. package/src/orchestrator/block-building-helpers.ts +5 -5
  109. package/src/orchestrator/block-proving-state.ts +10 -1
  110. package/src/orchestrator/checkpoint-proving-state.ts +22 -116
  111. package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +1044 -0
  112. package/src/orchestrator/chonk-cache.ts +99 -0
  113. package/src/orchestrator/index.ts +8 -1
  114. package/src/orchestrator/orchestrator_metrics.ts +2 -25
  115. package/src/orchestrator/proving-scheduler.ts +160 -0
  116. package/src/orchestrator/top-tree-orchestrator.ts +384 -0
  117. package/src/orchestrator/top-tree-proving-state.ts +219 -0
  118. package/src/orchestrator/tx-proving-state.ts +11 -15
  119. package/src/prover-client/factory.ts +6 -2
  120. package/src/prover-client/prover-client.ts +148 -29
  121. package/src/proving_broker/broker_prover_facade.ts +27 -37
  122. package/src/proving_broker/config.ts +26 -3
  123. package/src/proving_broker/fixtures.ts +1 -1
  124. package/src/proving_broker/index.ts +1 -0
  125. package/src/proving_broker/proof_store/factory.ts +10 -32
  126. package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
  127. package/src/proving_broker/proof_store/index.ts +1 -1
  128. package/src/proving_broker/proving_agent.ts +6 -19
  129. package/src/proving_broker/proving_broker.ts +68 -16
  130. package/src/proving_broker/proving_broker_database/persisted.ts +17 -3
  131. package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
  132. package/src/proving_broker/proving_job_controller.ts +11 -6
  133. package/src/proving_broker/rpc.ts +46 -20
  134. package/src/test/epoch_settlement.ts +82 -0
  135. package/src/test/index.ts +1 -0
  136. package/src/test/mock_prover.ts +3 -15
  137. package/dest/block-factory/index.d.ts +0 -2
  138. package/dest/block-factory/index.d.ts.map +0 -1
  139. package/dest/block-factory/index.js +0 -1
  140. package/dest/block-factory/light.d.ts +0 -38
  141. package/dest/block-factory/light.d.ts.map +0 -1
  142. package/dest/block-factory/light.js +0 -108
  143. package/dest/orchestrator/epoch-proving-state.d.ts +0 -74
  144. package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
  145. package/dest/orchestrator/epoch-proving-state.js +0 -233
  146. package/dest/orchestrator/orchestrator.d.ts +0 -113
  147. package/dest/orchestrator/orchestrator.d.ts.map +0 -1
  148. package/dest/orchestrator/orchestrator.js +0 -842
  149. package/dest/prover-client/server-epoch-prover.d.ts +0 -32
  150. package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
  151. package/dest/prover-client/server-epoch-prover.js +0 -40
  152. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
  153. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
  154. package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
  155. package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
  156. package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
  157. package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
  158. package/src/block-factory/index.ts +0 -1
  159. package/src/block-factory/light.ts +0 -137
  160. package/src/orchestrator/epoch-proving-state.ts +0 -330
  161. package/src/orchestrator/orchestrator.ts +0 -1265
  162. package/src/prover-client/server-epoch-prover.ts +0 -69
  163. package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
  164. package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
@@ -3,15 +3,15 @@ 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/fields';
6
+ import { Fr } from '@aztec/foundation/curves/bn254';
7
7
  import type { Logger } from '@aztec/foundation/log';
8
+ import { SerialQueue } from '@aztec/foundation/queue';
8
9
  import type { FieldsOf } from '@aztec/foundation/types';
9
10
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
10
11
  import { ProtocolContractsList } from '@aztec/protocol-contracts';
11
12
  import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
12
13
  import { PublicDataWrite } from '@aztec/stdlib/avm';
13
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
- import { EthAddress } from '@aztec/stdlib/block';
15
15
  import type { Checkpoint } from '@aztec/stdlib/checkpoint';
16
16
  import type { MerkleTreeWriteOperations, ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
17
17
  import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
@@ -24,6 +24,7 @@ import {
24
24
  StateReference,
25
25
  TreeSnapshots,
26
26
  } from '@aztec/stdlib/tx';
27
+ import type { GenesisData } from '@aztec/stdlib/world-state';
27
28
  import type { MerkleTreeAdminDatabase } from '@aztec/world-state';
28
29
  import { NativeWorldStateService } from '@aztec/world-state/native';
29
30
 
@@ -35,16 +36,27 @@ import {
35
36
  getTreeSnapshot,
36
37
  insertSideEffects,
37
38
  } from '../orchestrator/block-building-helpers.js';
38
- import type { BlockProvingState } from '../orchestrator/block-proving-state.js';
39
- import { ProvingOrchestrator } from '../orchestrator/index.js';
40
39
  import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
41
40
  import { TestBroker } from '../test/mock_prover.js';
42
41
  import { getEnvironmentConfig, getSimulator, makeCheckpointConstants, makeGlobals } from './fixtures.js';
43
42
 
43
+ /**
44
+ * Builds a started `SerialQueue` for use as an orchestrator's deferred-job queue in
45
+ * tests. Production wires a single shared queue via `ProverClient`; tests that construct
46
+ * orchestrators directly use one of these per orchestrator (or share one).
47
+ */
48
+ export function makeTestDeferredJobQueue(concurrency = 10): SerialQueue {
49
+ const queue = new SerialQueue();
50
+ queue.start(concurrency);
51
+ return queue;
52
+ }
53
+
44
54
  export class TestContext {
45
55
  private headers: Map<number, BlockHeader> = new Map();
46
56
  private checkpoints: Checkpoint[] = [];
57
+ private checkpointOutHashes: Fr[] = [];
47
58
  private nextCheckpointIndex = 0;
59
+ private nextCheckpointNumber = CheckpointNumber(1);
48
60
  private nextBlockNumber = 1;
49
61
  private epochNumber = 1;
50
62
  private feePayerBalance: Fr;
@@ -54,7 +66,6 @@ export class TestContext {
54
66
  public prover: ServerCircuitProver,
55
67
  public broker: TestBroker,
56
68
  public brokerProverFacade: BrokerCircuitProverFacade,
57
- public orchestrator: TestProvingOrchestrator,
58
69
  private feePayer: AztecAddress,
59
70
  initialFeePayerBalance: Fr,
60
71
  private directoriesToCleanup: string[],
@@ -63,10 +74,6 @@ export class TestContext {
63
74
  this.feePayerBalance = initialFeePayerBalance;
64
75
  }
65
76
 
66
- public get epochProver() {
67
- return this.orchestrator;
68
- }
69
-
70
77
  static async new(
71
78
  logger: Logger,
72
79
  {
@@ -79,17 +86,16 @@ export class TestContext {
79
86
  ) {
80
87
  const directoriesToCleanup: string[] = [];
81
88
 
82
- const feePayer = AztecAddress.fromNumber(42222);
89
+ const feePayer = AztecAddress.fromNumberUnsafe(42222);
83
90
  const initialFeePayerBalance = new Fr(10n ** 20n);
84
91
  const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer);
85
- const prefilledPublicData = [new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)];
92
+ const genesis: GenesisData = {
93
+ prefilledPublicData: [new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)],
94
+ genesisTimestamp: 0n,
95
+ };
86
96
 
87
97
  // Separated dbs for public processor and prover - see public_processor for context
88
- const ws = await NativeWorldStateService.tmp(
89
- /*rollupAddress=*/ undefined,
90
- /*cleanupTmpDir=*/ true,
91
- prefilledPublicData,
92
- );
98
+ const ws = await NativeWorldStateService.tmp(/*cleanupTmpDir=*/ true, genesis);
93
99
 
94
100
  let localProver: ServerCircuitProver;
95
101
  const config = await getEnvironmentConfig(logger);
@@ -102,8 +108,10 @@ export class TestContext {
102
108
  bbBinaryPath: config.expectedBBPath,
103
109
  bbWorkingDirectory: config.bbWorkingDirectory,
104
110
  bbSkipCleanup: config.bbSkipCleanup,
105
- numConcurrentIVCVerifiers: 2,
111
+ numConcurrentIVCVerifiers: 8,
106
112
  bbIVCConcurrency: 1,
113
+ bbChonkVerifyMaxBatch: 16,
114
+ bbChonkVerifyConcurrency: 6,
107
115
  };
108
116
  localProver = await createProver(bbConfig);
109
117
  }
@@ -114,22 +122,11 @@ export class TestContext {
114
122
 
115
123
  const broker = new TestBroker(proverCount, localProver);
116
124
  const facade = new BrokerCircuitProverFacade(broker);
117
- const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO);
118
125
 
119
126
  await broker.start();
120
127
  facade.start();
121
128
 
122
- return new this(
123
- ws,
124
- localProver,
125
- broker,
126
- facade,
127
- orchestrator,
128
- feePayer,
129
- initialFeePayerBalance,
130
- directoriesToCleanup,
131
- logger,
132
- );
129
+ return new this(ws, localProver, broker, facade, feePayer, initialFeePayerBalance, directoriesToCleanup, logger);
133
130
  }
134
131
 
135
132
  public getFork() {
@@ -139,6 +136,7 @@ export class TestContext {
139
136
  async cleanup() {
140
137
  await this.brokerProverFacade.stop();
141
138
  await this.broker.stop();
139
+ await this.worldState.close();
142
140
  for (const dir of this.directoriesToCleanup.filter(x => x !== '')) {
143
141
  try {
144
142
  await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
@@ -150,6 +148,7 @@ export class TestContext {
150
148
 
151
149
  public startNewEpoch() {
152
150
  this.checkpoints = [];
151
+ this.checkpointOutHashes = [];
153
152
  this.nextCheckpointIndex = 0;
154
153
  this.epochNumber++;
155
154
  }
@@ -187,7 +186,8 @@ export class TestContext {
187
186
  }
188
187
 
189
188
  const checkpointIndex = this.nextCheckpointIndex++;
190
- const checkpointNumber = CheckpointNumber(checkpointIndex + 1);
189
+ const checkpointNumber = this.nextCheckpointNumber;
190
+ this.nextCheckpointNumber++;
191
191
  const slotNumber = checkpointNumber * 15; // times an arbitrary number to make it different to the checkpoint number
192
192
 
193
193
  const constants = makeCheckpointConstants(slotNumber, constantOpts);
@@ -204,6 +204,8 @@ export class TestContext {
204
204
 
205
205
  const startBlockNumber = this.nextBlockNumber;
206
206
  const previousBlockHeader = this.getBlockHeader(BlockNumber(startBlockNumber - 1));
207
+ // All blocks in the same slot/checkpoint share the same timestamp.
208
+ const timestamp = BigInt(slotNumber * 26);
207
209
 
208
210
  // Build global variables.
209
211
  const blockGlobalVariables = times(numBlocks, i =>
@@ -211,6 +213,7 @@ export class TestContext {
211
213
  coinbase: constants.coinbase,
212
214
  feeRecipient: constants.feeRecipient,
213
215
  gasFees: constants.gasFees,
216
+ timestamp,
214
217
  }),
215
218
  );
216
219
  this.nextBlockNumber += numBlocks;
@@ -240,36 +243,42 @@ export class TestContext {
240
243
  });
241
244
 
242
245
  const cleanFork = await this.worldState.fork();
246
+ const previousCheckpointOutHashes = this.checkpointOutHashes;
243
247
  const builder = await LightweightCheckpointBuilder.startNewCheckpoint(
244
248
  checkpointNumber,
245
- constants,
249
+ { ...constants, timestamp },
246
250
  l1ToL2Messages,
251
+ previousCheckpointOutHashes,
247
252
  cleanFork,
248
253
  );
249
254
 
250
255
  // Add tx effects to db and build block headers.
251
256
  const blocks = [];
252
257
  for (let i = 0; i < numBlocks; i++) {
253
- const isFirstBlock = i === 0;
254
258
  const txs = blockTxs[i];
255
259
  const state = blockEndStates[i];
256
260
 
257
- const block = await builder.addBlock(blockGlobalVariables[i], state, txs);
261
+ const { block } = await builder.addBlock(blockGlobalVariables[i], txs, {
262
+ expectedEndState: state,
263
+ insertTxsEffects: true,
264
+ });
258
265
 
259
266
  const header = block.header;
260
267
  this.headers.set(block.number, header);
261
268
 
262
- const blockMsgs = isFirstBlock ? l1ToL2Messages : [];
263
- await this.worldState.handleL2BlockAndMessages(block, blockMsgs, isFirstBlock);
269
+ const blockMsgs = block.indexWithinCheckpoint === 0 ? l1ToL2Messages : [];
270
+ await this.worldState.handleL2BlockAndMessages(block, blockMsgs);
264
271
 
265
272
  blocks.push({ header, txs });
266
273
  }
267
274
 
268
275
  const checkpoint = await builder.completeCheckpoint();
269
276
  this.checkpoints.push(checkpoint);
277
+ this.checkpointOutHashes.push(checkpoint.getCheckpointOutHash());
270
278
 
271
279
  return {
272
280
  constants,
281
+ checkpoint,
273
282
  header: checkpoint.header,
274
283
  blocks,
275
284
  l1ToL2Messages,
@@ -337,16 +346,3 @@ export class TestContext {
337
346
  return endStateReference;
338
347
  }
339
348
  }
340
-
341
- class TestProvingOrchestrator extends ProvingOrchestrator {
342
- public isVerifyBuiltBlockAgainstSyncedStateEnabled = false;
343
-
344
- // Disable this check by default, since it requires seeding world state with the block being built
345
- // This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
346
- protected override verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState): Promise<void> {
347
- if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
348
- return super.verifyBuiltBlockAgainstSyncedState(provingState);
349
- }
350
- return Promise.resolve();
351
- }
352
- }
@@ -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/fields';
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(
@@ -253,8 +253,8 @@ export function getPublicChonkVerifierPrivateInputsFromTx(tx: Tx | ProcessedTx,
253
253
  // Build "hints" as the private inputs for the checkpoint root rollup circuit.
254
254
  // The `blobCommitments` will be accumulated and checked in the root rollup against the `finalBlobChallenges`.
255
255
  // The `blobsHash` will be validated on L1 against the submitted blob data.
256
- export const buildBlobHints = (blobFields: Fr[]) => {
257
- const blobs = getBlobsPerL1Block(blobFields);
256
+ export const buildBlobHints = async (blobFields: Fr[]) => {
257
+ const blobs = await getBlobsPerL1Block(blobFields);
258
258
  const blobCommitments = getBlobCommitmentsFromBlobs(blobs);
259
259
  const blobsHash = computeBlobsHashFromBlobs(blobs);
260
260
  return { blobCommitments, blobs, blobsHash };
@@ -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.endTimestamp,
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/fields';
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';
@@ -55,6 +55,7 @@ export class BlockProvingState {
55
55
  | ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
56
56
  | undefined;
57
57
  private builtBlockHeader: BlockHeader | undefined;
58
+ private builtArchive: AppendOnlyTreeSnapshot | undefined;
58
59
  private endState: StateReference | undefined;
59
60
  private endSpongeBlob: SpongeBlob | undefined;
60
61
  private txs: TxProvingState[] = [];
@@ -232,6 +233,14 @@ export class BlockProvingState {
232
233
  return this.builtBlockHeader;
233
234
  }
234
235
 
236
+ public setBuiltArchive(archive: AppendOnlyTreeSnapshot) {
237
+ this.builtArchive = archive;
238
+ }
239
+
240
+ public getBuiltArchive() {
241
+ return this.builtArchive;
242
+ }
243
+
235
244
  public getStartSpongeBlob() {
236
245
  return this.startSpongeBlob;
237
246
  }
@@ -1,53 +1,30 @@
1
- import {
2
- BatchedBlobAccumulator,
3
- type FinalBlobBatchingChallenges,
4
- SpongeBlob,
5
- encodeCheckpointBlobDataFromBlocks,
6
- } from '@aztec/blob-lib';
1
+ import { SpongeBlob } from '@aztec/blob-lib';
7
2
  import {
8
3
  type ARCHIVE_HEIGHT,
9
- BLOBS_PER_CHECKPOINT,
10
- FIELDS_PER_BLOB,
11
4
  type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
12
5
  type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
13
6
  NUM_MSGS_PER_BASE_PARITY,
14
7
  } from '@aztec/constants';
15
8
  import { BlockNumber } from '@aztec/foundation/branded-types';
16
9
  import { padArrayEnd } from '@aztec/foundation/collection';
17
- import { BLS12Point, Fr } from '@aztec/foundation/fields';
10
+ import { Fr } from '@aztec/foundation/curves/bn254';
18
11
  import type { Tuple } from '@aztec/foundation/serialize';
19
12
  import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
20
13
  import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
21
14
  import { ParityBasePrivateInputs } from '@aztec/stdlib/parity';
22
- import {
23
- BlockMergeRollupPrivateInputs,
24
- BlockRollupPublicInputs,
25
- CheckpointConstantData,
26
- CheckpointRollupPublicInputs,
27
- CheckpointRootRollupHints,
28
- CheckpointRootRollupPrivateInputs,
29
- CheckpointRootSingleBlockRollupPrivateInputs,
30
- } from '@aztec/stdlib/rollup';
31
- import type { CircuitName } from '@aztec/stdlib/stats';
15
+ import { BlockMergeRollupPrivateInputs, BlockRollupPublicInputs, CheckpointConstantData } from '@aztec/stdlib/rollup';
32
16
  import type { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
33
17
  import type { BlockHeader } from '@aztec/stdlib/tx';
34
18
  import type { UInt64 } from '@aztec/stdlib/types';
35
19
 
36
- import { accumulateBlobs, buildBlobHints, toProofData } from './block-building-helpers.js';
20
+ import { toProofData } from './block-building-helpers.js';
37
21
  import { BlockProvingState, type ProofState } from './block-proving-state.js';
38
- import type { EpochProvingState } from './epoch-proving-state.js';
39
22
 
40
23
  export class CheckpointProvingState {
41
24
  private blockProofs: UnbalancedTreeStore<
42
25
  ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
43
26
  >;
44
- private checkpointRootProof:
45
- | ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
46
- | undefined;
47
27
  private blocks: (BlockProvingState | undefined)[] = [];
48
- private startBlobAccumulator: BatchedBlobAccumulator | undefined;
49
- private endBlobAccumulator: BatchedBlobAccumulator | undefined;
50
- private blobFields: Fr[] | undefined;
51
28
  private error: string | undefined;
52
29
  public readonly firstBlockNumber: BlockNumber;
53
30
 
@@ -55,7 +32,6 @@ export class CheckpointProvingState {
55
32
  public readonly index: number,
56
33
  public readonly constants: CheckpointConstantData,
57
34
  public readonly totalNumBlocks: number,
58
- private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
59
35
  private readonly headerOfLastBlockInPreviousCheckpoint: BlockHeader,
60
36
  private readonly lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
61
37
  private readonly l1ToL2Messages: Fr[],
@@ -71,17 +47,16 @@ export class CheckpointProvingState {
71
47
  Fr,
72
48
  typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH
73
49
  >,
74
- public parentEpoch: EpochProvingState,
75
- private onBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
50
+ public readonly epochNumber: number,
51
+ /** Owner's liveness check. `verifyState()` returns false once this returns false. */
52
+ private readonly isAlive: () => boolean,
53
+ /** Owner's failure callback. Invoked from `reject` to surface the error upward. */
54
+ private readonly onReject: (reason: string) => void,
76
55
  ) {
77
56
  this.blockProofs = new UnbalancedTreeStore(totalNumBlocks);
78
57
  this.firstBlockNumber = BlockNumber(headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber + 1);
79
58
  }
80
59
 
81
- public get epochNumber(): number {
82
- return this.parentEpoch.epochNumber;
83
- }
84
-
85
60
  public startNewBlock(
86
61
  blockNumber: BlockNumber,
87
62
  timestamp: UInt64,
@@ -163,25 +138,6 @@ export class CheckpointProvingState {
163
138
  this.blockProofs.setNode(location, { provingOutput });
164
139
  }
165
140
 
166
- public tryStartProvingCheckpointRoot() {
167
- if (this.checkpointRootProof?.isProving) {
168
- return false;
169
- } else {
170
- this.checkpointRootProof = { isProving: true };
171
- return true;
172
- }
173
- }
174
-
175
- public setCheckpointRootRollupProof(
176
- provingOutput: PublicInputsAndRecursiveProof<
177
- CheckpointRollupPublicInputs,
178
- typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
179
- >,
180
- ): TreeNodeLocation {
181
- this.checkpointRootProof = { provingOutput };
182
- return this.parentEpoch.setCheckpointRootRollupProof(this.index, provingOutput);
183
- }
184
-
185
141
  public getBaseParityInputs(baseParityIndex: number) {
186
142
  const messages = padArrayEnd(
187
143
  this.l1ToL2Messages.slice(
@@ -191,25 +147,7 @@ export class CheckpointProvingState {
191
147
  Fr.ZERO,
192
148
  NUM_MSGS_PER_BASE_PARITY,
193
149
  );
194
- return new ParityBasePrivateInputs(messages, this.constants.vkTreeRoot);
195
- }
196
-
197
- public async accumulateBlobs(startBlobAccumulator: BatchedBlobAccumulator) {
198
- if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
199
- return;
200
- }
201
-
202
- this.blobFields = encodeCheckpointBlobDataFromBlocks(this.blocks.map(b => b!.getBlockBlobData()));
203
- this.endBlobAccumulator = await accumulateBlobs(this.blobFields!, startBlobAccumulator);
204
- this.startBlobAccumulator = startBlobAccumulator;
205
-
206
- this.onBlobAccumulatorSet(this);
207
-
208
- return this.endBlobAccumulator;
209
- }
210
-
211
- public getEndBlobAccumulator() {
212
- return this.endBlobAccumulator;
150
+ return new ParityBasePrivateInputs(messages, this.constants.vkTreeRoot, this.constants.proverId);
213
151
  }
214
152
 
215
153
  public getParentLocation(location: TreeNodeLocation) {
@@ -225,42 +163,6 @@ export class CheckpointProvingState {
225
163
  return new BlockMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
226
164
  }
227
165
 
228
- public getCheckpointRootRollupType(): CircuitName {
229
- return this.totalNumBlocks === 1 ? 'rollup-checkpoint-root-single-block' : 'rollup-checkpoint-root';
230
- }
231
-
232
- public getCheckpointRootRollupInputs() {
233
- const proofs = this.#getChildProofsForRoot();
234
- const nonEmptyProofs = proofs.filter(p => !!p);
235
- if (proofs.length !== nonEmptyProofs.length) {
236
- throw new Error('At least one child is not ready for the checkpoint root rollup.');
237
- }
238
- if (!this.startBlobAccumulator) {
239
- throw new Error('Start blob accumulator is not set.');
240
- }
241
-
242
- // `blobFields` must've been set if `startBlobAccumulator` is set (in `accumulateBlobs`).
243
- const blobFields = this.blobFields!;
244
-
245
- const { blobCommitments, blobsHash } = buildBlobHints(blobFields);
246
-
247
- const hints = CheckpointRootRollupHints.from({
248
- previousBlockHeader: this.headerOfLastBlockInPreviousCheckpoint,
249
- previousArchiveSiblingPath: this.lastArchiveSiblingPath,
250
- startBlobAccumulator: this.startBlobAccumulator.toBlobAccumulator(),
251
- finalBlobChallenges: this.finalBlobBatchingChallenges,
252
- blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT),
253
- blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO, BLOBS_PER_CHECKPOINT),
254
- blobsHash,
255
- });
256
-
257
- const [left, right] = nonEmptyProofs.map(p => toProofData(p));
258
-
259
- return !right
260
- ? new CheckpointRootSingleBlockRollupPrivateInputs(left, hints)
261
- : new CheckpointRootRollupPrivateInputs([left, right], hints);
262
- }
263
-
264
166
  public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
265
167
  const index = Number(blockNumber) - Number(this.firstBlockNumber);
266
168
  return this.blocks[index];
@@ -270,13 +172,8 @@ export class CheckpointProvingState {
270
172
  return !!this.blockProofs.getSibling(location)?.provingOutput;
271
173
  }
272
174
 
273
- public isReadyForCheckpointRoot() {
274
- const allChildProofsReady = this.#getChildProofsForRoot().every(p => !!p);
275
- return allChildProofsReady && !!this.startBlobAccumulator;
276
- }
277
-
278
175
  public verifyState() {
279
- return this.parentEpoch.verifyState();
176
+ return this.isAlive();
280
177
  }
281
178
 
282
179
  public getError() {
@@ -290,13 +187,22 @@ export class CheckpointProvingState {
290
187
 
291
188
  public reject(reason: string) {
292
189
  this.error = reason;
293
- this.parentEpoch.reject(reason);
190
+ this.onReject(reason);
294
191
  }
295
192
 
296
- #getChildProofsForRoot() {
193
+ /**
194
+ * Returns the block-level proof outputs that feed into the checkpoint root rollup.
195
+ * Used by `CheckpointSubTreeOrchestrator` to surface its sub-tree result.
196
+ */
197
+ public getSubTreeOutputProofs() {
297
198
  const rootLocation = { level: 0, index: 0 };
298
199
  return this.totalNumBlocks === 1
299
200
  ? [this.blockProofs.getNode(rootLocation)?.provingOutput] // If there's only 1 block, its proof will be stored at the root.
300
201
  : this.blockProofs.getChildren(rootLocation).map(c => c?.provingOutput);
301
202
  }
203
+
204
+ /** Sibling path of the archive tree captured before any block in this checkpoint landed. */
205
+ public getLastArchiveSiblingPath() {
206
+ return this.lastArchiveSiblingPath;
207
+ }
302
208
  }