@aztec/prover-client 0.0.1-commit.9b94fc1 → 0.0.1-commit.c7c42ec

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 (82) hide show
  1. package/dest/block-factory/light.d.ts +2 -2
  2. package/dest/block-factory/light.d.ts.map +1 -1
  3. package/dest/block-factory/light.js +1 -1
  4. package/dest/config.d.ts +2 -2
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +1 -1
  7. package/dest/light/index.d.ts +2 -0
  8. package/dest/light/index.d.ts.map +1 -0
  9. package/dest/light/index.js +1 -0
  10. package/dest/light/lightweight_checkpoint_builder.d.ts +21 -13
  11. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  12. package/dest/light/lightweight_checkpoint_builder.js +55 -15
  13. package/dest/mocks/fixtures.js +4 -4
  14. package/dest/mocks/test_context.d.ts +2 -2
  15. package/dest/mocks/test_context.d.ts.map +1 -1
  16. package/dest/mocks/test_context.js +12 -9
  17. package/dest/orchestrator/block-building-helpers.d.ts +4 -4
  18. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  19. package/dest/orchestrator/block-building-helpers.js +3 -2
  20. package/dest/orchestrator/block-proving-state.d.ts +5 -4
  21. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  22. package/dest/orchestrator/block-proving-state.js +1 -1
  23. package/dest/orchestrator/checkpoint-proving-state.d.ts +6 -5
  24. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  25. package/dest/orchestrator/checkpoint-proving-state.js +6 -4
  26. package/dest/orchestrator/epoch-proving-state.d.ts +5 -5
  27. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  28. package/dest/orchestrator/epoch-proving-state.js +1 -1
  29. package/dest/orchestrator/orchestrator.d.ts +7 -7
  30. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  31. package/dest/orchestrator/orchestrator.js +8 -29
  32. package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
  33. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  34. package/dest/orchestrator/orchestrator_metrics.js +0 -9
  35. package/dest/orchestrator/tx-proving-state.d.ts +2 -2
  36. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  37. package/dest/orchestrator/tx-proving-state.js +3 -3
  38. package/dest/prover-client/factory.d.ts +3 -3
  39. package/dest/prover-client/factory.d.ts.map +1 -1
  40. package/dest/prover-client/prover-client.d.ts +3 -3
  41. package/dest/prover-client/prover-client.d.ts.map +1 -1
  42. package/dest/prover-client/server-epoch-prover.d.ts +5 -5
  43. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  44. package/dest/proving_broker/broker_prover_facade.d.ts +2 -2
  45. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  46. package/dest/proving_broker/broker_prover_facade.js +3 -10
  47. package/dest/proving_broker/config.d.ts +2 -2
  48. package/dest/proving_broker/config.d.ts.map +1 -1
  49. package/dest/proving_broker/config.js +1 -1
  50. package/dest/proving_broker/fixtures.js +1 -1
  51. package/dest/proving_broker/proving_broker.d.ts +1 -1
  52. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  53. package/dest/proving_broker/proving_broker.js +3 -0
  54. package/dest/proving_broker/proving_job_controller.d.ts +1 -1
  55. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  56. package/dest/proving_broker/proving_job_controller.js +2 -3
  57. package/dest/test/mock_prover.d.ts +2 -2
  58. package/dest/test/mock_prover.d.ts.map +1 -1
  59. package/dest/test/mock_prover.js +1 -1
  60. package/package.json +19 -17
  61. package/src/block-factory/light.ts +1 -1
  62. package/src/config.ts +1 -1
  63. package/src/light/index.ts +1 -0
  64. package/src/light/lightweight_checkpoint_builder.ts +79 -23
  65. package/src/mocks/fixtures.ts +4 -4
  66. package/src/mocks/test_context.ts +15 -10
  67. package/src/orchestrator/block-building-helpers.ts +3 -2
  68. package/src/orchestrator/block-proving-state.ts +3 -2
  69. package/src/orchestrator/checkpoint-proving-state.ts +9 -7
  70. package/src/orchestrator/epoch-proving-state.ts +8 -5
  71. package/src/orchestrator/orchestrator.ts +14 -38
  72. package/src/orchestrator/orchestrator_metrics.ts +1 -20
  73. package/src/orchestrator/tx-proving-state.ts +4 -5
  74. package/src/prover-client/factory.ts +6 -2
  75. package/src/prover-client/prover-client.ts +3 -2
  76. package/src/prover-client/server-epoch-prover.ts +4 -4
  77. package/src/proving_broker/broker_prover_facade.ts +2 -11
  78. package/src/proving_broker/config.ts +1 -1
  79. package/src/proving_broker/fixtures.ts +1 -1
  80. package/src/proving_broker/proving_broker.ts +3 -0
  81. package/src/proving_broker/proving_job_controller.ts +2 -3
  82. package/src/test/mock_prover.ts +1 -6
@@ -1,8 +1,9 @@
1
1
  import type { BBProverConfig } from '@aztec/bb-prover';
2
2
  import { TestCircuitProver } from '@aztec/bb-prover';
3
3
  import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
4
+ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
4
5
  import { padArrayEnd, times, timesAsync } from '@aztec/foundation/collection';
5
- import { Fr } from '@aztec/foundation/fields';
6
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
7
  import type { Logger } from '@aztec/foundation/log';
7
8
  import type { FieldsOf } from '@aztec/foundation/types';
8
9
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
@@ -186,7 +187,7 @@ export class TestContext {
186
187
  }
187
188
 
188
189
  const checkpointIndex = this.nextCheckpointIndex++;
189
- const checkpointNumber = checkpointIndex + 1;
190
+ const checkpointNumber = CheckpointNumber(checkpointIndex + 1);
190
191
  const slotNumber = checkpointNumber * 15; // times an arbitrary number to make it different to the checkpoint number
191
192
 
192
193
  const constants = makeCheckpointConstants(slotNumber, constantOpts);
@@ -202,7 +203,7 @@ export class TestContext {
202
203
  const newL1ToL2Snapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, fork);
203
204
 
204
205
  const startBlockNumber = this.nextBlockNumber;
205
- const previousBlockHeader = this.getBlockHeader(startBlockNumber - 1);
206
+ const previousBlockHeader = this.getBlockHeader(BlockNumber(startBlockNumber - 1));
206
207
 
207
208
  // Build global variables.
208
209
  const blockGlobalVariables = times(numBlocks, i =>
@@ -249,17 +250,19 @@ export class TestContext {
249
250
  // Add tx effects to db and build block headers.
250
251
  const blocks = [];
251
252
  for (let i = 0; i < numBlocks; i++) {
252
- const isFirstBlock = i === 0;
253
253
  const txs = blockTxs[i];
254
254
  const state = blockEndStates[i];
255
255
 
256
- const block = await builder.addBlock(blockGlobalVariables[i], state, txs);
256
+ const block = await builder.addBlock(blockGlobalVariables[i], txs, {
257
+ expectedEndState: state,
258
+ insertTxsEffects: true,
259
+ });
257
260
 
258
261
  const header = block.header;
259
262
  this.headers.set(block.number, header);
260
263
 
261
- const blockMsgs = isFirstBlock ? l1ToL2Messages : [];
262
- await this.worldState.handleL2BlockAndMessages(block, blockMsgs, isFirstBlock);
264
+ const blockMsgs = block.indexWithinCheckpoint === 0 ? l1ToL2Messages : [];
265
+ await this.worldState.handleL2BlockAndMessages(block, blockMsgs);
263
266
 
264
267
  blocks.push({ header, txs });
265
268
  }
@@ -296,11 +299,13 @@ export class TestContext {
296
299
  return tx;
297
300
  }
298
301
 
299
- private getBlockHeader(blockNumber: number): BlockHeader {
300
- if (blockNumber > 0 && blockNumber >= this.nextBlockNumber) {
302
+ private getBlockHeader(blockNumber: BlockNumber): BlockHeader {
303
+ if (Number(blockNumber) > 0 && Number(blockNumber) >= this.nextBlockNumber) {
301
304
  throw new Error(`Block header not built for block number ${blockNumber}.`);
302
305
  }
303
- return blockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.headers.get(blockNumber)!;
306
+ return Number(blockNumber) === 0
307
+ ? this.worldState.getCommitted().getInitialHeader()
308
+ : this.headers.get(Number(blockNumber))!;
304
309
  }
305
310
 
306
311
  private async updateTrees(txs: ProcessedTx[], fork: MerkleTreeWriteOperations) {
@@ -20,8 +20,9 @@ import {
20
20
  PUBLIC_DATA_TREE_HEIGHT,
21
21
  } from '@aztec/constants';
22
22
  import { makeTuple } from '@aztec/foundation/array';
23
+ import { BlockNumber } from '@aztec/foundation/branded-types';
23
24
  import { padArrayEnd } from '@aztec/foundation/collection';
24
- import { Fr } from '@aztec/foundation/fields';
25
+ import { Fr } from '@aztec/foundation/curves/bn254';
25
26
  import { type Bufferable, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize';
26
27
  import { MembershipWitness } from '@aztec/foundation/trees';
27
28
  import { getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
@@ -280,7 +281,7 @@ export const buildHeaderFromCircuitOutputs = runInSpan(
280
281
  const globalVariables = GlobalVariables.from({
281
282
  chainId: constants.chainId,
282
283
  version: constants.version,
283
- blockNumber: blockRootRollupOutput.previousArchive.nextAvailableLeafIndex,
284
+ blockNumber: BlockNumber(blockRootRollupOutput.previousArchive.nextAvailableLeafIndex),
284
285
  timestamp: blockRootRollupOutput.endTimestamp,
285
286
  slotNumber: constants.slotNumber,
286
287
  coinbase: constants.coinbase,
@@ -6,7 +6,8 @@ import {
6
6
  type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
7
7
  NUM_BASE_PARITY_PER_ROOT_PARITY,
8
8
  } from '@aztec/constants';
9
- import { Fr } from '@aztec/foundation/fields';
9
+ import { BlockNumber } from '@aztec/foundation/branded-types';
10
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
11
  import { type Tuple, assertLength } from '@aztec/foundation/serialize';
11
12
  import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
12
13
  import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
@@ -62,7 +63,7 @@ export class BlockProvingState {
62
63
 
63
64
  constructor(
64
65
  public readonly index: number,
65
- public readonly blockNumber: number,
66
+ public readonly blockNumber: BlockNumber,
66
67
  public readonly totalNumTxs: number,
67
68
  private readonly constants: CheckpointConstantData,
68
69
  private readonly timestamp: UInt64,
@@ -12,8 +12,10 @@ import {
12
12
  type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
13
13
  NUM_MSGS_PER_BASE_PARITY,
14
14
  } from '@aztec/constants';
15
+ import { BlockNumber } from '@aztec/foundation/branded-types';
15
16
  import { padArrayEnd } from '@aztec/foundation/collection';
16
- import { BLS12Point, Fr } from '@aztec/foundation/fields';
17
+ import { BLS12Point } from '@aztec/foundation/curves/bls12';
18
+ import { Fr } from '@aztec/foundation/curves/bn254';
17
19
  import type { Tuple } from '@aztec/foundation/serialize';
18
20
  import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
19
21
  import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
@@ -48,7 +50,7 @@ export class CheckpointProvingState {
48
50
  private endBlobAccumulator: BatchedBlobAccumulator | undefined;
49
51
  private blobFields: Fr[] | undefined;
50
52
  private error: string | undefined;
51
- public readonly firstBlockNumber: number;
53
+ public readonly firstBlockNumber: BlockNumber;
52
54
 
53
55
  constructor(
54
56
  public readonly index: number,
@@ -74,7 +76,7 @@ export class CheckpointProvingState {
74
76
  private onBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
75
77
  ) {
76
78
  this.blockProofs = new UnbalancedTreeStore(totalNumBlocks);
77
- this.firstBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber + 1;
79
+ this.firstBlockNumber = BlockNumber(headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber + 1);
78
80
  }
79
81
 
80
82
  public get epochNumber(): number {
@@ -82,13 +84,13 @@ export class CheckpointProvingState {
82
84
  }
83
85
 
84
86
  public startNewBlock(
85
- blockNumber: number,
87
+ blockNumber: BlockNumber,
86
88
  timestamp: UInt64,
87
89
  totalNumTxs: number,
88
90
  lastArchiveTreeSnapshot: AppendOnlyTreeSnapshot,
89
91
  lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
90
92
  ): BlockProvingState {
91
- const index = blockNumber - this.firstBlockNumber;
93
+ const index = Number(blockNumber) - Number(this.firstBlockNumber);
92
94
  if (index >= this.totalNumBlocks) {
93
95
  throw new Error(`Unable to start a new block at index ${index}. Expected at most ${this.totalNumBlocks} blocks.`);
94
96
  }
@@ -260,8 +262,8 @@ export class CheckpointProvingState {
260
262
  : new CheckpointRootRollupPrivateInputs([left, right], hints);
261
263
  }
262
264
 
263
- public getBlockProvingStateByBlockNumber(blockNumber: number) {
264
- const index = blockNumber - this.firstBlockNumber;
265
+ public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
266
+ const index = Number(blockNumber) - Number(this.firstBlockNumber);
265
267
  return this.blocks[index];
266
268
  }
267
269
 
@@ -5,8 +5,8 @@ import type {
5
5
  NESTED_RECURSIVE_PROOF_LENGTH,
6
6
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
7
7
  } from '@aztec/constants';
8
- import { EpochNumber } from '@aztec/foundation/branded-types';
9
- import type { Fr } from '@aztec/foundation/fields';
8
+ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
9
+ import type { Fr } from '@aztec/foundation/curves/bn254';
10
10
  import type { Tuple } from '@aztec/foundation/serialize';
11
11
  import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
12
12
  import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
@@ -126,13 +126,16 @@ export class EpochProvingState {
126
126
  return this.checkpoints[index];
127
127
  }
128
128
 
129
- public getCheckpointProvingStateByBlockNumber(blockNumber: number) {
129
+ public getCheckpointProvingStateByBlockNumber(blockNumber: BlockNumber) {
130
130
  return this.checkpoints.find(
131
- c => c && blockNumber >= c.firstBlockNumber && blockNumber < c.firstBlockNumber + c.totalNumBlocks,
131
+ c =>
132
+ c &&
133
+ Number(blockNumber) >= Number(c.firstBlockNumber) &&
134
+ Number(blockNumber) < Number(c.firstBlockNumber) + c.totalNumBlocks,
132
135
  );
133
136
  }
134
137
 
135
- public getBlockProvingStateByBlockNumber(blockNumber: number) {
138
+ public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
136
139
  return this.getCheckpointProvingStateByBlockNumber(blockNumber)?.getBlockProvingStateByBlockNumber(blockNumber);
137
140
  }
138
141
 
@@ -6,23 +6,23 @@ import {
6
6
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
7
7
  NUM_BASE_PARITY_PER_ROOT_PARITY,
8
8
  } from '@aztec/constants';
9
- import { EpochNumber } from '@aztec/foundation/branded-types';
9
+ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
10
10
  import { padArrayEnd } from '@aztec/foundation/collection';
11
+ import { Fr } from '@aztec/foundation/curves/bn254';
11
12
  import { AbortError } from '@aztec/foundation/error';
12
- import { Fr } from '@aztec/foundation/fields';
13
13
  import { createLogger } from '@aztec/foundation/log';
14
14
  import { promiseWithResolvers } from '@aztec/foundation/promise';
15
15
  import { assertLength } from '@aztec/foundation/serialize';
16
16
  import { pushTestData } from '@aztec/foundation/testing';
17
17
  import { elapsed } from '@aztec/foundation/timer';
18
18
  import type { TreeNodeLocation } from '@aztec/foundation/trees';
19
- import { readAvmMinimalPublicTxInputsFromFile } from '@aztec/simulator/public/fixtures';
20
19
  import { EthAddress } from '@aztec/stdlib/block';
21
20
  import type {
22
21
  EpochProver,
23
22
  ForkMerkleTreeOperations,
24
23
  MerkleTreeWriteOperations,
25
24
  PublicInputsAndRecursiveProof,
25
+ ReadonlyWorldStateAccess,
26
26
  ServerCircuitProver,
27
27
  } from '@aztec/stdlib/interfaces/server';
28
28
  import type { Proof } from '@aztec/stdlib/proofs';
@@ -93,10 +93,11 @@ export class ProvingOrchestrator implements EpochProver {
93
93
 
94
94
  private provingPromise: Promise<ProvingResult> | undefined = undefined;
95
95
  private metrics: ProvingOrchestratorMetrics;
96
- private dbs: Map<number, MerkleTreeWriteOperations> = new Map();
96
+ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
97
+ private dbs: Map<BlockNumber, MerkleTreeWriteOperations> = new Map();
97
98
 
98
99
  constructor(
99
- private dbProvider: ForkMerkleTreeOperations,
100
+ private dbProvider: ReadonlyWorldStateAccess & ForkMerkleTreeOperations,
100
101
  private prover: ServerCircuitProver,
101
102
  private readonly proverId: EthAddress,
102
103
  telemetryClient: TelemetryClient = getTelemetryClient(),
@@ -161,7 +162,7 @@ export class ProvingOrchestrator implements EpochProver {
161
162
  const lastBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber;
162
163
  const db = await this.dbProvider.fork(lastBlockNumber);
163
164
 
164
- const firstBlockNumber = lastBlockNumber + 1;
165
+ const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
165
166
  this.dbs.set(firstBlockNumber, db);
166
167
 
167
168
  // Get archive sibling path before any block in this checkpoint lands.
@@ -199,7 +200,7 @@ export class ProvingOrchestrator implements EpochProver {
199
200
  @trackSpan('ProvingOrchestrator.startNewBlock', blockNumber => ({
200
201
  [Attributes.BLOCK_NUMBER]: blockNumber,
201
202
  }))
202
- public async startNewBlock(blockNumber: number, timestamp: UInt64, totalNumTxs: number) {
203
+ public async startNewBlock(blockNumber: BlockNumber, timestamp: UInt64, totalNumTxs: number) {
203
204
  if (!this.provingState) {
204
205
  throw new Error('Empty epoch proving state. Call startNewEpoch before starting a block.');
205
206
  }
@@ -219,7 +220,7 @@ export class ProvingOrchestrator implements EpochProver {
219
220
  // Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
220
221
  if (!this.dbs.has(blockNumber)) {
221
222
  // Fork world state at the end of the immediately previous block
222
- const db = await this.dbProvider.fork(blockNumber - 1);
223
+ const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
223
224
  this.dbs.set(blockNumber, db);
224
225
  }
225
226
  const db = this.dbs.get(blockNumber)!;
@@ -278,7 +279,7 @@ export class ProvingOrchestrator implements EpochProver {
278
279
  return;
279
280
  }
280
281
 
281
- const blockNumber = txs[0].globalVariables.blockNumber;
282
+ const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
282
283
  const provingState = this.provingState.getBlockProvingStateByBlockNumber(blockNumber!);
283
284
  if (!provingState) {
284
285
  throw new Error(`Proving state for block ${blockNumber} not found. Call startNewBlock first.`);
@@ -309,7 +310,7 @@ export class ProvingOrchestrator implements EpochProver {
309
310
 
310
311
  validateTx(tx);
311
312
 
312
- logger.info(`Received transaction: ${tx.hash}`);
313
+ logger.debug(`Received transaction: ${tx.hash}`);
313
314
 
314
315
  const startSpongeBlob = spongeBlobState.clone();
315
316
  const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(
@@ -388,10 +389,10 @@ export class ProvingOrchestrator implements EpochProver {
388
389
  * Marks the block as completed.
389
390
  * Computes the block header and updates the archive tree.
390
391
  */
391
- @trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber: number) => ({
392
+ @trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber: BlockNumber) => ({
392
393
  [Attributes.BLOCK_NUMBER]: blockNumber,
393
394
  }))
394
- public async setBlockCompleted(blockNumber: number, expectedHeader?: BlockHeader): Promise<BlockHeader> {
395
+ public async setBlockCompleted(blockNumber: BlockNumber, expectedHeader?: BlockHeader): Promise<BlockHeader> {
395
396
  const provingState = this.provingState?.getBlockProvingStateByBlockNumber(blockNumber);
396
397
  if (!provingState) {
397
398
  throw new Error(`Block proving state for ${blockNumber} not found`);
@@ -1206,8 +1207,6 @@ export class ProvingOrchestrator implements EpochProver {
1206
1207
 
1207
1208
  const txProvingState = provingState.getTxProvingState(txIndex);
1208
1209
 
1209
- // This function tries to do AVM proving. If there is a failure, it fakes the proof unless AVM_PROVING_STRICT is defined.
1210
- // Nothing downstream depends on the AVM proof yet. So having this mode lets us incrementally build the AVM circuit.
1211
1210
  const doAvmProving = wrapCallbackInSpan(
1212
1211
  this.tracer,
1213
1212
  'ProvingOrchestrator.prover.getAvmProof',
@@ -1216,30 +1215,7 @@ export class ProvingOrchestrator implements EpochProver {
1216
1215
  },
1217
1216
  async (signal: AbortSignal) => {
1218
1217
  const inputs = txProvingState.getAvmInputs();
1219
- try {
1220
- // TODO(#14234)[Unconditional PIs validation]: Remove the whole try-catch logic and
1221
- // just keep the next line but removing the second argument (false).
1222
- return await this.prover.getAvmProof(inputs, false, signal, provingState.epochNumber);
1223
- } catch (err) {
1224
- if (process.env.AVM_PROVING_STRICT) {
1225
- logger.error(`Error thrown when proving AVM circuit with AVM_PROVING_STRICT on`, err);
1226
- throw err;
1227
- } else {
1228
- logger.warn(
1229
- `Error thrown when proving AVM circuit but AVM_PROVING_STRICT is off. Use snapshotted
1230
- AVM inputs and carrying on. ${inspect(err)}.`,
1231
- );
1232
-
1233
- try {
1234
- this.metrics.incAvmFallback();
1235
- const snapshotAvmPrivateInputs = readAvmMinimalPublicTxInputsFromFile();
1236
- return await this.prover.getAvmProof(snapshotAvmPrivateInputs, true, signal, provingState.epochNumber);
1237
- } catch (err) {
1238
- logger.error(`Error thrown when proving snapshotted AVM inputs.`, err);
1239
- throw err;
1240
- }
1241
- }
1242
- }
1218
+ return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
1243
1219
  },
1244
1220
  );
1245
1221
 
@@ -1,17 +1,9 @@
1
- import {
2
- type Histogram,
3
- Metrics,
4
- type TelemetryClient,
5
- type Tracer,
6
- type UpDownCounter,
7
- ValueType,
8
- } from '@aztec/telemetry-client';
1
+ import { type Histogram, Metrics, type TelemetryClient, type Tracer, ValueType } from '@aztec/telemetry-client';
9
2
 
10
3
  export class ProvingOrchestratorMetrics {
11
4
  public readonly tracer: Tracer;
12
5
 
13
6
  private baseRollupInputsDuration: Histogram;
14
- private avmFallbackCount: UpDownCounter;
15
7
 
16
8
  constructor(client: TelemetryClient, name = 'ProvingOrchestrator') {
17
9
  this.tracer = client.getTracer(name);
@@ -22,20 +14,9 @@ export class ProvingOrchestratorMetrics {
22
14
  description: 'Duration to build base rollup inputs',
23
15
  valueType: ValueType.INT,
24
16
  });
25
-
26
- this.avmFallbackCount = meter.createUpDownCounter(Metrics.PROVING_ORCHESTRATOR_AVM_FALLBACK_COUNT, {
27
- description: 'How many times the AVM fallback was used',
28
- valueType: ValueType.INT,
29
- });
30
-
31
- this.avmFallbackCount.add(0);
32
17
  }
33
18
 
34
19
  recordBaseRollupInputs(durationMs: number) {
35
20
  this.baseRollupInputsDuration.record(Math.ceil(durationMs));
36
21
  }
37
-
38
- incAvmFallback() {
39
- this.avmFallbackCount.add(1);
40
- }
41
22
  }
@@ -1,9 +1,9 @@
1
1
  import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/fields';
3
- import { getAvmVkData, getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
4
4
  import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
5
5
  import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
6
- import { ProofData } from '@aztec/stdlib/proofs';
6
+ import { ProofData, ProofDataForFixedVk } from '@aztec/stdlib/proofs';
7
7
  import {
8
8
  type BaseRollupHints,
9
9
  PrivateBaseRollupHints,
@@ -114,10 +114,9 @@ export class TxProvingState {
114
114
 
115
115
  const publicChonkVerifierProofData = toProofData(this.publicChonkVerifier);
116
116
 
117
- const avmProofData = new ProofData(
117
+ const avmProofData = new ProofDataForFixedVk(
118
118
  this.processedTx.avmProvingRequest.inputs.publicInputs,
119
119
  this.avm.proof,
120
- getAvmVkData(),
121
120
  );
122
121
 
123
122
  return new PublicTxBaseRollupPrivateInputs(publicChonkVerifierProofData, avmProofData, this.baseRollupHints);
@@ -1,4 +1,8 @@
1
- import type { ForkMerkleTreeOperations, ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
1
+ import type {
2
+ ForkMerkleTreeOperations,
3
+ ProvingJobBroker,
4
+ ReadonlyWorldStateAccess,
5
+ } from '@aztec/stdlib/interfaces/server';
2
6
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
3
7
 
4
8
  import type { ProverClientConfig } from '../config.js';
@@ -6,7 +10,7 @@ import { ProverClient } from './prover-client.js';
6
10
 
7
11
  export function createProverClient(
8
12
  config: ProverClientConfig,
9
- worldState: ForkMerkleTreeOperations,
13
+ worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
10
14
  broker: ProvingJobBroker,
11
15
  telemetry: TelemetryClient = getTelemetryClient(),
12
16
  ) {
@@ -11,6 +11,7 @@ import {
11
11
  type ProvingJobBroker,
12
12
  type ProvingJobConsumer,
13
13
  type ProvingJobProducer,
14
+ type ReadonlyWorldStateAccess,
14
15
  type ServerCircuitProver,
15
16
  tryStop,
16
17
  } from '@aztec/stdlib/interfaces/server';
@@ -33,7 +34,7 @@ export class ProverClient implements EpochProverManager {
33
34
 
34
35
  private constructor(
35
36
  private config: ProverClientConfig,
36
- private worldState: ForkMerkleTreeOperations,
37
+ private worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
37
38
  private orchestratorClient: ProvingJobProducer,
38
39
  private agentClient?: ProvingJobConsumer,
39
40
  private telemetry: TelemetryClient = getTelemetryClient(),
@@ -99,7 +100,7 @@ export class ProverClient implements EpochProverManager {
99
100
  */
100
101
  public static async new(
101
102
  config: ProverClientConfig,
102
- worldState: ForkMerkleTreeOperations,
103
+ worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
103
104
  broker: ProvingJobBroker,
104
105
  telemetry: TelemetryClient = getTelemetryClient(),
105
106
  ) {
@@ -1,6 +1,6 @@
1
1
  import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib/types';
2
- import { EpochNumber } from '@aztec/foundation/branded-types';
3
- import type { Fr } from '@aztec/foundation/fields';
2
+ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { EthAddress } from '@aztec/stdlib/block';
5
5
  import type { EpochProver } from '@aztec/stdlib/interfaces/server';
6
6
  import type { Proof } from '@aztec/stdlib/proofs';
@@ -44,7 +44,7 @@ export class ServerEpochProver implements EpochProver {
44
44
  startChonkVerifierCircuits(txs: Tx[]): Promise<void> {
45
45
  return this.orchestrator.startChonkVerifierCircuits(txs);
46
46
  }
47
- setBlockCompleted(blockNumber: number, expectedBlockHeader?: BlockHeader): Promise<BlockHeader> {
47
+ setBlockCompleted(blockNumber: BlockNumber, expectedBlockHeader?: BlockHeader): Promise<BlockHeader> {
48
48
  return this.orchestrator.setBlockCompleted(blockNumber, expectedBlockHeader);
49
49
  }
50
50
  finalizeEpoch(): Promise<{ publicInputs: RootRollupPublicInputs; proof: Proof; batchedBlobInputs: BatchedBlob }> {
@@ -60,7 +60,7 @@ export class ServerEpochProver implements EpochProver {
60
60
  await this.facade.stop();
61
61
  await this.orchestrator.stop();
62
62
  }
63
- startNewBlock(blockNumber: number, timestamp: UInt64, totalNumTxs: number): Promise<void> {
63
+ startNewBlock(blockNumber: BlockNumber, timestamp: UInt64, totalNumTxs: number): Promise<void> {
64
64
  return this.orchestrator.startNewBlock(blockNumber, timestamp, totalNumTxs);
65
65
  }
66
66
  addTxs(txs: ProcessedTx[]): Promise<void> {
@@ -5,8 +5,7 @@ import type {
5
5
  RECURSIVE_PROOF_LENGTH,
6
6
  } from '@aztec/constants';
7
7
  import { EpochNumber } from '@aztec/foundation/branded-types';
8
- import { sha256 } from '@aztec/foundation/crypto';
9
- import { Fr } from '@aztec/foundation/fields';
8
+ import { sha256 } from '@aztec/foundation/crypto/sha256';
10
9
  import { createLogger } from '@aztec/foundation/log';
11
10
  import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
12
11
  import { truncate } from '@aztec/foundation/string';
@@ -398,24 +397,16 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
398
397
 
399
398
  getAvmProof(
400
399
  inputs: AvmCircuitInputs,
401
- skipPublicInputsValidation?: boolean, // TODO(#14234)[Unconditional PIs validation]: remove this argument
402
400
  signal?: AbortSignal,
403
401
  epochNumber?: EpochNumber,
404
402
  ): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
405
- this.log.info(`getAvmProof() called with skipPublicInputsValidation: ${skipPublicInputsValidation}`);
406
-
407
403
  return this.enqueueJob(
408
404
  this.generateId(ProvingRequestType.PUBLIC_VM, inputs, epochNumber),
409
405
  ProvingRequestType.PUBLIC_VM,
410
406
  inputs,
411
407
  epochNumber,
412
408
  signal,
413
- ).then(result => {
414
- // TODO(#14234)[Unconditional PIs validation]: Remove ".then()".
415
- // Override the default value of skipPublicInputsValidation potentially set in BBNativeRollupProver.getAvmProof().
416
- result.proof.proof[0] = skipPublicInputsValidation ? new Fr(1) : new Fr(0);
417
- return result;
418
- });
409
+ );
419
410
  }
420
411
 
421
412
  getBaseParityProof(
@@ -1,4 +1,4 @@
1
- import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum';
1
+ import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
2
2
  import {
3
3
  type ConfigMappingsType,
4
4
  booleanConfigHelper,
@@ -1,5 +1,5 @@
1
1
  import { EpochNumber } from '@aztec/foundation/branded-types';
2
- import { randomBytes } from '@aztec/foundation/crypto';
2
+ import { randomBytes } from '@aztec/foundation/crypto/random';
3
3
  import { type ProofUri, type ProvingJobId, makeProvingJobId } from '@aztec/stdlib/interfaces/server';
4
4
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
5
5
 
@@ -302,6 +302,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
302
302
  this.resultsCache.delete(id);
303
303
  this.inProgress.delete(id);
304
304
  this.retries.delete(id);
305
+ this.enqueuedAt.delete(id);
305
306
  }
306
307
  }
307
308
 
@@ -354,6 +355,8 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
354
355
  const enqueuedAt = this.enqueuedAt.get(job.id);
355
356
  if (enqueuedAt) {
356
357
  this.instrumentation.recordJobWait(job.type, enqueuedAt);
358
+ // we can clear this flag now.
359
+ this.enqueuedAt.delete(job.id);
357
360
  }
358
361
 
359
362
  return { job, time };
@@ -1,5 +1,5 @@
1
1
  import { EpochNumber } from '@aztec/foundation/branded-types';
2
- import { randomBytes } from '@aztec/foundation/crypto';
2
+ import { randomBytes } from '@aztec/foundation/crypto/random';
3
3
  import { AbortError } from '@aztec/foundation/error';
4
4
  import { createLogger } from '@aztec/foundation/log';
5
5
  import type {
@@ -125,8 +125,7 @@ export class ProvingJobController {
125
125
  const signal = this.abortController.signal;
126
126
  switch (type) {
127
127
  case ProvingRequestType.PUBLIC_VM: {
128
- // TODO(#14234)[Unconditional PIs validation]: Remove argument "undefined".
129
- return await this.circuitProver.getAvmProof(inputs, undefined, signal, this.epochNumber);
128
+ return await this.circuitProver.getAvmProof(inputs, signal, this.epochNumber);
130
129
  }
131
130
 
132
131
  case ProvingRequestType.PUBLIC_CHONK_VERIFIER: {
@@ -105,12 +105,7 @@ export class TestBroker implements ProvingJobProducer {
105
105
  export class MockProver implements ServerCircuitProver {
106
106
  constructor() {}
107
107
 
108
- getAvmProof(
109
- _inputs: AvmCircuitInputs,
110
- _skipPublicInputsValidation?: boolean, // TODO(#14234)[Unconditional PIs validation]: Remove.
111
- _signal?: AbortSignal,
112
- _epochNumber?: number,
113
- ) {
108
+ getAvmProof(_inputs: AvmCircuitInputs, _signal?: AbortSignal, _epochNumber?: number) {
114
109
  return Promise.resolve(
115
110
  makeProofAndVerificationKey(
116
111
  makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),