@aztec/prover-client 0.0.1-commit.c31f2472 → 0.0.1-commit.c52d6e7

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 (133) hide show
  1. package/dest/config.d.ts +1 -1
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +16 -2
  4. package/dest/light/lightweight_checkpoint_builder.d.ts +12 -5
  5. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  6. package/dest/light/lightweight_checkpoint_builder.js +59 -23
  7. package/dest/mocks/fixtures.d.ts +1 -1
  8. package/dest/mocks/fixtures.d.ts.map +1 -1
  9. package/dest/mocks/fixtures.js +3 -3
  10. package/dest/mocks/test_context.d.ts +11 -11
  11. package/dest/mocks/test_context.d.ts.map +1 -1
  12. package/dest/mocks/test_context.js +31 -30
  13. package/dest/orchestrator/block-building-helpers.d.ts +4 -4
  14. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  15. package/dest/orchestrator/block-building-helpers.js +4 -4
  16. package/dest/orchestrator/block-proving-state.d.ts +4 -1
  17. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  18. package/dest/orchestrator/block-proving-state.js +7 -0
  19. package/dest/orchestrator/checkpoint-proving-state.d.ts +20 -36
  20. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  21. package/dest/orchestrator/checkpoint-proving-state.js +22 -120
  22. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +161 -0
  23. package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
  24. package/dest/orchestrator/{orchestrator.js → checkpoint-sub-tree-orchestrator.js} +285 -462
  25. package/dest/orchestrator/chonk-cache.d.ts +39 -0
  26. package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
  27. package/dest/orchestrator/chonk-cache.js +80 -0
  28. package/dest/orchestrator/index.d.ts +4 -2
  29. package/dest/orchestrator/index.d.ts.map +1 -1
  30. package/dest/orchestrator/index.js +3 -1
  31. package/dest/orchestrator/proving-scheduler.d.ts +81 -0
  32. package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
  33. package/dest/orchestrator/proving-scheduler.js +120 -0
  34. package/dest/orchestrator/top-tree-orchestrator.d.ts +88 -0
  35. package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
  36. package/dest/orchestrator/top-tree-orchestrator.js +232 -0
  37. package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
  38. package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
  39. package/dest/orchestrator/top-tree-proving-state.js +185 -0
  40. package/dest/orchestrator/tx-proving-state.d.ts +3 -3
  41. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  42. package/dest/prover-client/prover-client.d.ts +64 -7
  43. package/dest/prover-client/prover-client.d.ts.map +1 -1
  44. package/dest/prover-client/prover-client.js +62 -13
  45. package/dest/proving_broker/broker_prover_facade.d.ts +3 -3
  46. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  47. package/dest/proving_broker/broker_prover_facade.js +26 -20
  48. package/dest/proving_broker/config.d.ts +11 -67
  49. package/dest/proving_broker/config.d.ts.map +1 -1
  50. package/dest/proving_broker/config.js +16 -5
  51. package/dest/proving_broker/index.d.ts +2 -1
  52. package/dest/proving_broker/index.d.ts.map +1 -1
  53. package/dest/proving_broker/index.js +1 -0
  54. package/dest/proving_broker/proof_store/factory.d.ts +2 -5
  55. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  56. package/dest/proving_broker/proof_store/factory.js +7 -30
  57. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
  58. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
  59. package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
  60. package/dest/proving_broker/proof_store/index.d.ts +2 -2
  61. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  62. package/dest/proving_broker/proof_store/index.js +1 -1
  63. package/dest/proving_broker/proving_broker.d.ts +9 -5
  64. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  65. package/dest/proving_broker/proving_broker.js +245 -70
  66. package/dest/proving_broker/proving_broker_database/memory.d.ts +5 -2
  67. package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
  68. package/dest/proving_broker/proving_broker_database/memory.js +14 -1
  69. package/dest/proving_broker/proving_broker_database/persisted.d.ts +15 -2
  70. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  71. package/dest/proving_broker/proving_broker_database/persisted.js +57 -6
  72. package/dest/proving_broker/proving_broker_database.d.ts +27 -1
  73. package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
  74. package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
  75. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  76. package/dest/proving_broker/proving_broker_instrumentation.js +7 -0
  77. package/dest/proving_broker/rpc.d.ts +18 -5
  78. package/dest/proving_broker/rpc.d.ts.map +1 -1
  79. package/dest/proving_broker/rpc.js +98 -23
  80. package/dest/test/epoch_settlement.d.ts +36 -0
  81. package/dest/test/epoch_settlement.d.ts.map +1 -0
  82. package/dest/test/epoch_settlement.js +52 -0
  83. package/dest/test/index.d.ts +2 -0
  84. package/dest/test/index.d.ts.map +1 -0
  85. package/dest/test/index.js +1 -0
  86. package/dest/test/mock_prover.d.ts +4 -4
  87. package/dest/test/mock_prover.js +2 -2
  88. package/package.json +20 -20
  89. package/src/config.ts +18 -2
  90. package/src/light/lightweight_checkpoint_builder.ts +63 -25
  91. package/src/mocks/fixtures.ts +2 -4
  92. package/src/mocks/test_context.ts +27 -43
  93. package/src/orchestrator/block-building-helpers.ts +4 -4
  94. package/src/orchestrator/block-proving-state.ts +9 -0
  95. package/src/orchestrator/checkpoint-proving-state.ts +21 -162
  96. package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +1044 -0
  97. package/src/orchestrator/chonk-cache.ts +99 -0
  98. package/src/orchestrator/index.ts +8 -1
  99. package/src/orchestrator/proving-scheduler.ts +160 -0
  100. package/src/orchestrator/top-tree-orchestrator.ts +384 -0
  101. package/src/orchestrator/top-tree-proving-state.ts +219 -0
  102. package/src/orchestrator/tx-proving-state.ts +3 -3
  103. package/src/prover-client/prover-client.ts +134 -25
  104. package/src/proving_broker/broker_prover_facade.ts +29 -23
  105. package/src/proving_broker/config.ts +16 -2
  106. package/src/proving_broker/index.ts +1 -0
  107. package/src/proving_broker/proof_store/factory.ts +10 -32
  108. package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
  109. package/src/proving_broker/proof_store/index.ts +1 -1
  110. package/src/proving_broker/proving_broker.ts +237 -72
  111. package/src/proving_broker/proving_broker_database/memory.ts +16 -2
  112. package/src/proving_broker/proving_broker_database/persisted.ts +71 -8
  113. package/src/proving_broker/proving_broker_database.ts +30 -0
  114. package/src/proving_broker/proving_broker_instrumentation.ts +9 -0
  115. package/src/proving_broker/rpc.ts +62 -20
  116. package/src/test/epoch_settlement.ts +82 -0
  117. package/src/test/index.ts +1 -0
  118. package/src/test/mock_prover.ts +2 -2
  119. package/dest/orchestrator/epoch-proving-state.d.ts +0 -75
  120. package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
  121. package/dest/orchestrator/epoch-proving-state.js +0 -267
  122. package/dest/orchestrator/orchestrator.d.ts +0 -128
  123. package/dest/orchestrator/orchestrator.d.ts.map +0 -1
  124. package/dest/prover-client/server-epoch-prover.d.ts +0 -32
  125. package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
  126. package/dest/prover-client/server-epoch-prover.js +0 -40
  127. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
  128. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
  129. package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
  130. package/src/orchestrator/epoch-proving-state.ts +0 -378
  131. package/src/orchestrator/orchestrator.ts +0 -1281
  132. package/src/prover-client/server-epoch-prover.ts +0 -69
  133. package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/prover-client",
3
- "version": "0.0.1-commit.c31f2472",
3
+ "version": "0.0.1-commit.c52d6e7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -9,7 +9,8 @@
9
9
  "./orchestrator": "./dest/orchestrator/index.js",
10
10
  "./helpers": "./dest/orchestrator/block-building-helpers.js",
11
11
  "./light": "./dest/light/index.js",
12
- "./config": "./dest/config.js"
12
+ "./config": "./dest/config.js",
13
+ "./test": "./dest/test/index.js"
13
14
  },
14
15
  "typedocOptions": {
15
16
  "entryPoints": [
@@ -27,8 +28,8 @@
27
28
  "build:dev": "../scripts/tsc.sh --watch",
28
29
  "clean": "rm -rf ./dest .tsbuildinfo",
29
30
  "bb": "node --no-warnings ./dest/bb/index.js",
30
- "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=3500000 --forceExit",
31
- "test:debug": "LOG_LEVEL=debug NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit --testNamePattern prover/bb_prover/parity"
31
+ "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=3500000",
32
+ "test:debug": "LOG_LEVEL=\"debug; info: json-rpc, simulator\" NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --testNamePattern prover/bb_prover/parity"
32
33
  },
33
34
  "jest": {
34
35
  "moduleNameMapper": {
@@ -68,29 +69,28 @@
68
69
  ]
69
70
  },
70
71
  "dependencies": {
71
- "@aztec/bb-prover": "0.0.1-commit.c31f2472",
72
- "@aztec/blob-lib": "0.0.1-commit.c31f2472",
73
- "@aztec/constants": "0.0.1-commit.c31f2472",
74
- "@aztec/ethereum": "0.0.1-commit.c31f2472",
75
- "@aztec/foundation": "0.0.1-commit.c31f2472",
76
- "@aztec/kv-store": "0.0.1-commit.c31f2472",
77
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.c31f2472",
78
- "@aztec/noir-types": "0.0.1-commit.c31f2472",
79
- "@aztec/protocol-contracts": "0.0.1-commit.c31f2472",
80
- "@aztec/simulator": "0.0.1-commit.c31f2472",
81
- "@aztec/stdlib": "0.0.1-commit.c31f2472",
82
- "@aztec/telemetry-client": "0.0.1-commit.c31f2472",
83
- "@aztec/world-state": "0.0.1-commit.c31f2472",
84
- "@google-cloud/storage": "^7.15.0",
72
+ "@aztec/bb-prover": "0.0.1-commit.c52d6e7",
73
+ "@aztec/blob-lib": "0.0.1-commit.c52d6e7",
74
+ "@aztec/constants": "0.0.1-commit.c52d6e7",
75
+ "@aztec/ethereum": "0.0.1-commit.c52d6e7",
76
+ "@aztec/foundation": "0.0.1-commit.c52d6e7",
77
+ "@aztec/kv-store": "0.0.1-commit.c52d6e7",
78
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.c52d6e7",
79
+ "@aztec/noir-types": "6.0.0-nightly.20260807",
80
+ "@aztec/protocol-contracts": "0.0.1-commit.c52d6e7",
81
+ "@aztec/simulator": "0.0.1-commit.c52d6e7",
82
+ "@aztec/stdlib": "0.0.1-commit.c52d6e7",
83
+ "@aztec/telemetry-client": "0.0.1-commit.c52d6e7",
84
+ "@aztec/world-state": "0.0.1-commit.c52d6e7",
85
85
  "@iarna/toml": "^2.2.5",
86
86
  "commander": "^12.1.0",
87
87
  "lodash.chunk": "^4.2.0",
88
88
  "source-map-support": "^0.5.21",
89
89
  "tslib": "^2.4.0",
90
- "zod": "^3.23.8"
90
+ "zod": "^4"
91
91
  },
92
92
  "devDependencies": {
93
- "@aztec/noir-contracts.js": "0.0.1-commit.c31f2472",
93
+ "@aztec/noir-contracts.js": "0.0.1-commit.c52d6e7",
94
94
  "@jest/globals": "^30.0.0",
95
95
  "@types/jest": "^30.0.0",
96
96
  "@types/node": "^22.15.17",
package/src/config.ts CHANGED
@@ -44,14 +44,30 @@ export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
44
44
  },
45
45
  numConcurrentIVCVerifiers: {
46
46
  env: 'BB_NUM_IVC_VERIFIERS',
47
- description: 'Max number of chonk verifiers to run concurrently',
47
+ description: 'Max concurrent verifications for the RPC verifier (QueuedIVCVerifier).',
48
48
  ...numberConfigHelper(8),
49
49
  },
50
50
  bbIVCConcurrency: {
51
51
  env: 'BB_IVC_CONCURRENCY',
52
- description: 'Number of threads to use for IVC verification',
52
+ description: 'Thread count for the RPC IVC verifier.',
53
53
  ...numberConfigHelper(1),
54
54
  },
55
+ bbChonkVerifyMaxBatch: {
56
+ env: 'BB_CHONK_VERIFY_MAX_BATCH',
57
+ description:
58
+ 'Upper bound on proofs per batch for the peer chonk batch verifier. Proofs are verified immediately as they arrive; this only caps how many can accumulate while a batch is already being processed.',
59
+ ...numberConfigHelper(16),
60
+ },
61
+ bbChonkVerifyConcurrency: {
62
+ env: 'BB_CHONK_VERIFY_BATCH_CONCURRENCY',
63
+ description: 'Thread count for the peer batch verifier parallel reduce. 0 = auto.',
64
+ ...numberConfigHelper(6),
65
+ },
66
+ bbDebugOutputDir: {
67
+ env: 'BB_DEBUG_OUTPUT_DIR',
68
+ description:
69
+ 'When set, bb.js operations write input/output files and log equivalent CLI commands to this directory',
70
+ },
55
71
  };
56
72
 
57
73
  export const proverClientConfigMappings: ConfigMappingsType<ProverClientUserConfig> = {
@@ -1,14 +1,14 @@
1
1
  import { SpongeBlob, computeBlobsHashFromBlobs, encodeCheckpointEndMarker, getBlobsPerL1Block } from '@aztec/blob-lib';
2
- import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
3
2
  import { type CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
4
- import { padArrayEnd } from '@aztec/foundation/collection';
5
3
  import { Fr } from '@aztec/foundation/curves/bn254';
6
4
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
5
+ import { elapsed } from '@aztec/foundation/timer';
7
6
  import { L2Block } from '@aztec/stdlib/block';
8
7
  import { Checkpoint } from '@aztec/stdlib/checkpoint';
9
8
  import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
10
9
  import {
11
10
  accumulateCheckpointOutHashes,
11
+ appendL1ToL2MessagesToTree,
12
12
  computeCheckpointOutHash,
13
13
  computeInHashFromL1ToL2Messages,
14
14
  } from '@aztec/stdlib/messaging';
@@ -44,6 +44,7 @@ export class LightweightCheckpointBuilder {
44
44
  constructor(
45
45
  public readonly checkpointNumber: CheckpointNumber,
46
46
  public readonly constants: CheckpointGlobalVariables,
47
+ public feeAssetPriceModifier: bigint,
47
48
  public readonly l1ToL2Messages: Fr[],
48
49
  private readonly previousCheckpointOutHashes: Fr[],
49
50
  public readonly db: MerkleTreeWriteOperations,
@@ -54,7 +55,7 @@ export class LightweightCheckpointBuilder {
54
55
  instanceId: `checkpoint-${checkpointNumber}`,
55
56
  });
56
57
  this.spongeBlob = SpongeBlob.init();
57
- this.logger.debug('Starting new checkpoint', { constants, l1ToL2Messages });
58
+ this.logger.debug('Starting new checkpoint', { constants, l1ToL2Messages, feeAssetPriceModifier });
58
59
  }
59
60
 
60
61
  static async startNewCheckpoint(
@@ -64,16 +65,15 @@ export class LightweightCheckpointBuilder {
64
65
  previousCheckpointOutHashes: Fr[],
65
66
  db: MerkleTreeWriteOperations,
66
67
  bindings?: LoggerBindings,
68
+ feeAssetPriceModifier: bigint = 0n,
67
69
  ): Promise<LightweightCheckpointBuilder> {
68
70
  // Insert l1-to-l2 messages into the tree.
69
- await db.appendLeaves(
70
- MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
71
- padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
72
- );
71
+ await appendL1ToL2MessagesToTree(db, l1ToL2Messages);
73
72
 
74
73
  return new LightweightCheckpointBuilder(
75
74
  checkpointNumber,
76
75
  constants,
76
+ feeAssetPriceModifier,
77
77
  l1ToL2Messages,
78
78
  previousCheckpointOutHashes,
79
79
  db,
@@ -90,6 +90,7 @@ export class LightweightCheckpointBuilder {
90
90
  static async resumeCheckpoint(
91
91
  checkpointNumber: CheckpointNumber,
92
92
  constants: CheckpointGlobalVariables,
93
+ feeAssetPriceModifier: bigint,
93
94
  l1ToL2Messages: Fr[],
94
95
  previousCheckpointOutHashes: Fr[],
95
96
  db: MerkleTreeWriteOperations,
@@ -99,6 +100,7 @@ export class LightweightCheckpointBuilder {
99
100
  const builder = new LightweightCheckpointBuilder(
100
101
  checkpointNumber,
101
102
  constants,
103
+ feeAssetPriceModifier,
102
104
  l1ToL2Messages,
103
105
  previousCheckpointOutHashes,
104
106
  db,
@@ -111,6 +113,10 @@ export class LightweightCheckpointBuilder {
111
113
  blockNumbers: existingBlocks.map(b => b.header.getBlockNumber()),
112
114
  });
113
115
 
116
+ if (existingBlocks.length === 0) {
117
+ throw new Error(`Cannot resume checkpoint ${checkpointNumber} with no existing blocks`);
118
+ }
119
+
114
120
  // Validate block order and consistency
115
121
  for (let i = 1; i < existingBlocks.length; i++) {
116
122
  const prev = existingBlocks[i - 1];
@@ -143,6 +149,15 @@ export class LightweightCheckpointBuilder {
143
149
  return builder;
144
150
  }
145
151
 
152
+ /** Returns how many blocks have been added to this checkpoint so far */
153
+ public getBlockCount() {
154
+ return this.blocks.length;
155
+ }
156
+
157
+ public getBlocks() {
158
+ return this.blocks;
159
+ }
160
+
146
161
  /**
147
162
  * Adds a new block to the checkpoint. The tx effects must have already been inserted into the db if
148
163
  * this is called after tx processing, if that's not the case, then set `insertTxsEffects` to true.
@@ -151,7 +166,8 @@ export class LightweightCheckpointBuilder {
151
166
  globalVariables: GlobalVariables,
152
167
  txs: ProcessedTx[],
153
168
  opts: { insertTxsEffects?: boolean; expectedEndState?: StateReference } = {},
154
- ): Promise<L2Block> {
169
+ ): Promise<{ block: L2Block; timings: Record<string, number> }> {
170
+ const timings: Record<string, number> = {};
155
171
  const isFirstBlock = this.blocks.length === 0;
156
172
 
157
173
  // Empty blocks are only allowed as the first block in a checkpoint
@@ -160,7 +176,9 @@ export class LightweightCheckpointBuilder {
160
176
  }
161
177
 
162
178
  if (isFirstBlock) {
163
- this.lastArchives.push(await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
179
+ const [msGetInitialArchive, initialArchive] = await elapsed(() => getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
180
+ this.lastArchives.push(initialArchive);
181
+ timings.getInitialArchive = msGetInitialArchive;
164
182
  }
165
183
 
166
184
  const lastArchive = this.lastArchives.at(-1)!;
@@ -170,12 +188,17 @@ export class LightweightCheckpointBuilder {
170
188
  `Inserting side effects for ${txs.length} txs for block ${globalVariables.blockNumber} into db`,
171
189
  { txs: txs.map(tx => tx.hash.toString()) },
172
190
  );
191
+ let msInsertSideEffects = 0;
173
192
  for (const tx of txs) {
174
- await insertSideEffects(tx, this.db);
193
+ const [ms] = await elapsed(() => insertSideEffects(tx, this.db));
194
+ msInsertSideEffects += ms;
175
195
  }
196
+ timings.insertSideEffects = msInsertSideEffects;
176
197
  }
177
198
 
178
- const endState = await this.db.getStateReference();
199
+ const [msGetEndState, endState] = await elapsed(() => this.db.getStateReference());
200
+ timings.getEndState = msGetEndState;
201
+
179
202
  if (opts.expectedEndState && !endState.equals(opts.expectedEndState)) {
180
203
  this.logger.error('End state after processing txs does not match expected end state', {
181
204
  globalVariables: globalVariables.toInspect(),
@@ -185,26 +208,31 @@ export class LightweightCheckpointBuilder {
185
208
  throw new Error(`End state does not match expected end state when building block ${globalVariables.blockNumber}`);
186
209
  }
187
210
 
188
- const { header, body, blockBlobFields } = await buildHeaderAndBodyFromTxs(
189
- txs,
190
- lastArchive,
191
- endState,
192
- globalVariables,
193
- this.spongeBlob,
194
- isFirstBlock,
211
+ const [msBuildHeaderAndBody, { header, body, blockBlobFields }] = await elapsed(() =>
212
+ buildHeaderAndBodyFromTxs(txs, lastArchive, endState, globalVariables, this.spongeBlob, isFirstBlock),
195
213
  );
214
+ timings.buildHeaderAndBody = msBuildHeaderAndBody;
196
215
 
197
216
  header.state.validate();
198
217
 
199
218
  await this.db.updateArchive(header);
200
- const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
219
+ const [msUpdateArchive, newArchive] = await elapsed(() => getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db));
220
+ timings.updateArchive = msUpdateArchive;
201
221
  this.lastArchives.push(newArchive);
202
222
 
223
+ const expectedNextLeafIndex = Number(globalVariables.blockNumber) + 1;
224
+ if (newArchive.nextAvailableLeafIndex !== expectedNextLeafIndex) {
225
+ throw new Error(
226
+ `Archive tree next leaf index mismatch after building block ${globalVariables.blockNumber} (expected ${expectedNextLeafIndex} but got ${newArchive.nextAvailableLeafIndex})`,
227
+ );
228
+ }
229
+
203
230
  const indexWithinCheckpoint = IndexWithinCheckpoint(this.blocks.length);
204
231
  const block = new L2Block(newArchive, header, body, this.checkpointNumber, indexWithinCheckpoint);
205
232
  this.blocks.push(block);
206
233
 
207
- await this.spongeBlob.absorb(blockBlobFields);
234
+ const [msSpongeAbsorb] = await elapsed(() => this.spongeBlob.absorb(blockBlobFields));
235
+ timings.spongeAbsorb = msSpongeAbsorb;
208
236
  this.blobFields.push(...blockBlobFields);
209
237
 
210
238
  this.logger.debug(`Built block ${header.getBlockNumber()}`, {
@@ -215,7 +243,7 @@ export class LightweightCheckpointBuilder {
215
243
  txs: block.body.txEffects.map(tx => tx.txHash.toString()),
216
244
  });
217
245
 
218
- return block;
246
+ return { block, timings };
219
247
  }
220
248
 
221
249
  async completeCheckpoint(): Promise<Checkpoint> {
@@ -232,7 +260,7 @@ export class LightweightCheckpointBuilder {
232
260
 
233
261
  const newArchive = this.lastArchives[this.lastArchives.length - 1];
234
262
 
235
- const blobs = getBlobsPerL1Block(this.blobFields);
263
+ const blobs = await getBlobsPerL1Block(this.blobFields);
236
264
  const blobsHash = computeBlobsHashFromBlobs(blobs);
237
265
 
238
266
  const inHash = computeInHashFromL1ToL2Messages(this.l1ToL2Messages);
@@ -243,11 +271,11 @@ export class LightweightCheckpointBuilder {
243
271
  );
244
272
  const epochOutHash = accumulateCheckpointOutHashes([...this.previousCheckpointOutHashes, checkpointOutHash]);
245
273
 
246
- // TODO(palla/mbps): Should we source this from the constants instead?
247
- // timestamp of a checkpoint is the timestamp of the last block in the checkpoint.
274
+ // All blocks in the checkpoint have the same timestamp
248
275
  const timestamp = blocks[blocks.length - 1].timestamp;
249
276
 
250
277
  const totalManaUsed = blocks.reduce((acc, block) => acc.add(block.header.totalManaUsed), Fr.ZERO);
278
+ const accumulatedFees = blocks.reduce((acc, block) => acc.add(block.header.totalFees), Fr.ZERO);
251
279
 
252
280
  const header = CheckpointHeader.from({
253
281
  lastArchiveRoot: this.lastArchives[0].root,
@@ -261,15 +289,25 @@ export class LightweightCheckpointBuilder {
261
289
  feeRecipient,
262
290
  gasFees,
263
291
  totalManaUsed,
292
+ accumulatedFees,
293
+ });
294
+
295
+ this.logger.debug(`Completed checkpoint ${this.checkpointNumber}`, {
296
+ checkpointNumber: this.checkpointNumber,
297
+ headerHash: header.hash().toString(),
298
+ checkpointOutHash: checkpointOutHash.toString(),
299
+ numPreviousCheckpointOutHashes: this.previousCheckpointOutHashes.length,
300
+ ...header.toInspect(),
264
301
  });
265
302
 
266
- return new Checkpoint(newArchive, header, blocks, this.checkpointNumber);
303
+ return new Checkpoint(newArchive, header, blocks, this.checkpointNumber, this.feeAssetPriceModifier);
267
304
  }
268
305
 
269
306
  clone() {
270
307
  const clone = new LightweightCheckpointBuilder(
271
308
  this.checkpointNumber,
272
309
  this.constants,
310
+ this.feeAssetPriceModifier,
273
311
  [...this.l1ToL2Messages],
274
312
  [...this.previousCheckpointOutHashes],
275
313
  this.db,
@@ -17,12 +17,10 @@ import { promises as fs } from 'fs';
17
17
  import path from 'path';
18
18
 
19
19
  const {
20
- BB_RELEASE_DIR = 'cpp/build/bin',
21
20
  TEMP_DIR = '/tmp',
22
21
  BB_BINARY_PATH = '',
23
22
  BB_WORKING_DIRECTORY = '',
24
23
  BB_SKIP_CLEANUP = '',
25
- NOIR_RELEASE_DIR = 'noir-repo/target/release',
26
24
  ACVM_BINARY_PATH = '',
27
25
  ACVM_WORKING_DIRECTORY = '',
28
26
  } = process.env;
@@ -32,7 +30,7 @@ export const getEnvironmentConfig = async (logger: Logger) => {
32
30
  try {
33
31
  const expectedBBPath = BB_BINARY_PATH
34
32
  ? BB_BINARY_PATH
35
- : `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/', BB_RELEASE_DIR)}/bb-avm`;
33
+ : `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../labs-aztec-toolchain/bin')}/bb-avm`;
36
34
  await fs.access(expectedBBPath, fs.constants.R_OK);
37
35
  const tempWorkingDirectory = `${TEMP_DIR}/${randomBytes(4).toString('hex')}`;
38
36
  const bbWorkingDirectory = BB_WORKING_DIRECTORY ? BB_WORKING_DIRECTORY : `${tempWorkingDirectory}/bb`;
@@ -41,7 +39,7 @@ export const getEnvironmentConfig = async (logger: Logger) => {
41
39
 
42
40
  const expectedAcvmPath = ACVM_BINARY_PATH
43
41
  ? ACVM_BINARY_PATH
44
- : `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../noir/', NOIR_RELEASE_DIR)}/acvm`;
42
+ : `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../labs-aztec-toolchain/bin')}/acvm`;
45
43
  await fs.access(expectedAcvmPath, fs.constants.R_OK);
46
44
  const acvmWorkingDirectory = ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : `${tempWorkingDirectory}/acvm`;
47
45
  await fs.mkdir(acvmWorkingDirectory, { recursive: true });
@@ -5,13 +5,13 @@ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
5
5
  import { padArrayEnd, times, timesAsync } from '@aztec/foundation/collection';
6
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,12 +36,21 @@ 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[] = [];
@@ -56,7 +66,6 @@ export class TestContext {
56
66
  public prover: ServerCircuitProver,
57
67
  public broker: TestBroker,
58
68
  public brokerProverFacade: BrokerCircuitProverFacade,
59
- public orchestrator: TestProvingOrchestrator,
60
69
  private feePayer: AztecAddress,
61
70
  initialFeePayerBalance: Fr,
62
71
  private directoriesToCleanup: string[],
@@ -65,10 +74,6 @@ export class TestContext {
65
74
  this.feePayerBalance = initialFeePayerBalance;
66
75
  }
67
76
 
68
- public get epochProver() {
69
- return this.orchestrator;
70
- }
71
-
72
77
  static async new(
73
78
  logger: Logger,
74
79
  {
@@ -81,17 +86,16 @@ export class TestContext {
81
86
  ) {
82
87
  const directoriesToCleanup: string[] = [];
83
88
 
84
- const feePayer = AztecAddress.fromNumber(42222);
89
+ const feePayer = AztecAddress.fromNumberUnsafe(42222);
85
90
  const initialFeePayerBalance = new Fr(10n ** 20n);
86
91
  const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer);
87
- const prefilledPublicData = [new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)];
92
+ const genesis: GenesisData = {
93
+ prefilledPublicData: [new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)],
94
+ genesisTimestamp: 0n,
95
+ };
88
96
 
89
97
  // Separated dbs for public processor and prover - see public_processor for context
90
- const ws = await NativeWorldStateService.tmp(
91
- /*rollupAddress=*/ undefined,
92
- /*cleanupTmpDir=*/ true,
93
- prefilledPublicData,
94
- );
98
+ const ws = await NativeWorldStateService.tmp(/*cleanupTmpDir=*/ true, genesis);
95
99
 
96
100
  let localProver: ServerCircuitProver;
97
101
  const config = await getEnvironmentConfig(logger);
@@ -104,8 +108,10 @@ export class TestContext {
104
108
  bbBinaryPath: config.expectedBBPath,
105
109
  bbWorkingDirectory: config.bbWorkingDirectory,
106
110
  bbSkipCleanup: config.bbSkipCleanup,
107
- numConcurrentIVCVerifiers: 2,
111
+ numConcurrentIVCVerifiers: 8,
108
112
  bbIVCConcurrency: 1,
113
+ bbChonkVerifyMaxBatch: 16,
114
+ bbChonkVerifyConcurrency: 6,
109
115
  };
110
116
  localProver = await createProver(bbConfig);
111
117
  }
@@ -116,22 +122,11 @@ export class TestContext {
116
122
 
117
123
  const broker = new TestBroker(proverCount, localProver);
118
124
  const facade = new BrokerCircuitProverFacade(broker);
119
- const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO);
120
125
 
121
126
  await broker.start();
122
127
  facade.start();
123
128
 
124
- return new this(
125
- ws,
126
- localProver,
127
- broker,
128
- facade,
129
- orchestrator,
130
- feePayer,
131
- initialFeePayerBalance,
132
- directoriesToCleanup,
133
- logger,
134
- );
129
+ return new this(ws, localProver, broker, facade, feePayer, initialFeePayerBalance, directoriesToCleanup, logger);
135
130
  }
136
131
 
137
132
  public getFork() {
@@ -141,6 +136,7 @@ export class TestContext {
141
136
  async cleanup() {
142
137
  await this.brokerProverFacade.stop();
143
138
  await this.broker.stop();
139
+ await this.worldState.close();
144
140
  for (const dir of this.directoriesToCleanup.filter(x => x !== '')) {
145
141
  try {
146
142
  await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
@@ -250,7 +246,7 @@ export class TestContext {
250
246
  const previousCheckpointOutHashes = this.checkpointOutHashes;
251
247
  const builder = await LightweightCheckpointBuilder.startNewCheckpoint(
252
248
  checkpointNumber,
253
- constants,
249
+ { ...constants, timestamp },
254
250
  l1ToL2Messages,
255
251
  previousCheckpointOutHashes,
256
252
  cleanFork,
@@ -262,7 +258,7 @@ export class TestContext {
262
258
  const txs = blockTxs[i];
263
259
  const state = blockEndStates[i];
264
260
 
265
- const block = await builder.addBlock(blockGlobalVariables[i], txs, {
261
+ const { block } = await builder.addBlock(blockGlobalVariables[i], txs, {
266
262
  expectedEndState: state,
267
263
  insertTxsEffects: true,
268
264
  });
@@ -282,6 +278,7 @@ export class TestContext {
282
278
 
283
279
  return {
284
280
  constants,
281
+ checkpoint,
285
282
  header: checkpoint.header,
286
283
  blocks,
287
284
  l1ToL2Messages,
@@ -349,16 +346,3 @@ export class TestContext {
349
346
  return endStateReference;
350
347
  }
351
348
  }
352
-
353
- class TestProvingOrchestrator extends ProvingOrchestrator {
354
- public isVerifyBuiltBlockAgainstSyncedStateEnabled = false;
355
-
356
- // Disable this check by default, since it requires seeding world state with the block being built
357
- // This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
358
- protected override verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState): Promise<void> {
359
- if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
360
- return super.verifyBuiltBlockAgainstSyncedState(provingState);
361
- }
362
- return Promise.resolve();
363
- }
364
- }
@@ -97,9 +97,9 @@ export const insertSideEffectsAndBuildBaseRollupHints = runInSpan(
97
97
 
98
98
  const { nullifierInsertionResult, publicDataInsertionResult } = await insertSideEffects(tx, db);
99
99
 
100
- const blockHash = (await tx.data.constants.anchorBlockHeader.hash()).toField();
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 };
@@ -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
  }