@aztec/prover-node 3.0.0-devnet.2 → 3.0.0-devnet.20251212

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 (46) hide show
  1. package/dest/actions/download-epoch-proving-job.d.ts +4 -4
  2. package/dest/actions/index.d.ts +1 -1
  3. package/dest/actions/rerun-epoch-proving-job.d.ts +2 -2
  4. package/dest/actions/upload-epoch-proof-failure.d.ts +1 -1
  5. package/dest/bin/run-failed-epoch.d.ts +1 -1
  6. package/dest/config.d.ts +2 -2
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +1 -1
  9. package/dest/factory.d.ts +2 -2
  10. package/dest/factory.d.ts.map +1 -1
  11. package/dest/factory.js +5 -3
  12. package/dest/index.d.ts +1 -1
  13. package/dest/job/epoch-proving-job-data.d.ts +8 -6
  14. package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
  15. package/dest/job/epoch-proving-job-data.js +25 -18
  16. package/dest/job/epoch-proving-job.d.ts +5 -12
  17. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  18. package/dest/job/epoch-proving-job.js +94 -84
  19. package/dest/metrics.d.ts +4 -3
  20. package/dest/metrics.d.ts.map +1 -1
  21. package/dest/metrics.js +8 -2
  22. package/dest/monitors/epoch-monitor.d.ts +3 -2
  23. package/dest/monitors/epoch-monitor.d.ts.map +1 -1
  24. package/dest/monitors/epoch-monitor.js +2 -1
  25. package/dest/monitors/index.d.ts +1 -1
  26. package/dest/prover-node-publisher.d.ts +9 -7
  27. package/dest/prover-node-publisher.d.ts.map +1 -1
  28. package/dest/prover-node-publisher.js +43 -37
  29. package/dest/prover-node.d.ts +8 -7
  30. package/dest/prover-node.d.ts.map +1 -1
  31. package/dest/prover-node.js +34 -31
  32. package/dest/prover-publisher-factory.d.ts +4 -2
  33. package/dest/prover-publisher-factory.d.ts.map +1 -1
  34. package/dest/test/index.d.ts +1 -1
  35. package/dest/test/index.d.ts.map +1 -1
  36. package/package.json +26 -25
  37. package/src/bin/run-failed-epoch.ts +1 -1
  38. package/src/config.ts +1 -1
  39. package/src/factory.ts +8 -2
  40. package/src/job/epoch-proving-job-data.ts +31 -25
  41. package/src/job/epoch-proving-job.ts +107 -100
  42. package/src/metrics.ts +15 -3
  43. package/src/monitors/epoch-monitor.ts +4 -3
  44. package/src/prover-node-publisher.ts +62 -52
  45. package/src/prover-node.ts +46 -42
  46. package/src/prover-publisher-factory.ts +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/prover-node",
3
- "version": "3.0.0-devnet.2",
3
+ "version": "3.0.0-devnet.20251212",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -11,8 +11,8 @@
11
11
  "../package.common.json"
12
12
  ],
13
13
  "scripts": {
14
- "build": "yarn clean && tsc -b",
15
- "build:dev": "tsc -b --watch",
14
+ "build": "yarn clean && ../scripts/tsc.sh",
15
+ "build:dev": "../scripts/tsc.sh --watch",
16
16
  "clean": "rm -rf ./dest .tsbuildinfo",
17
17
  "bb": "node --no-warnings ./dest/bb/index.js",
18
18
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
@@ -56,36 +56,37 @@
56
56
  ]
57
57
  },
58
58
  "dependencies": {
59
- "@aztec/archiver": "3.0.0-devnet.2",
60
- "@aztec/bb-prover": "3.0.0-devnet.2",
61
- "@aztec/blob-lib": "3.0.0-devnet.2",
62
- "@aztec/blob-sink": "3.0.0-devnet.2",
63
- "@aztec/constants": "3.0.0-devnet.2",
64
- "@aztec/epoch-cache": "3.0.0-devnet.2",
65
- "@aztec/ethereum": "3.0.0-devnet.2",
66
- "@aztec/foundation": "3.0.0-devnet.2",
67
- "@aztec/kv-store": "3.0.0-devnet.2",
68
- "@aztec/l1-artifacts": "3.0.0-devnet.2",
69
- "@aztec/node-keystore": "3.0.0-devnet.2",
70
- "@aztec/node-lib": "3.0.0-devnet.2",
71
- "@aztec/noir-protocol-circuits-types": "3.0.0-devnet.2",
72
- "@aztec/p2p": "3.0.0-devnet.2",
73
- "@aztec/protocol-contracts": "3.0.0-devnet.2",
74
- "@aztec/prover-client": "3.0.0-devnet.2",
75
- "@aztec/sequencer-client": "3.0.0-devnet.2",
76
- "@aztec/simulator": "3.0.0-devnet.2",
77
- "@aztec/stdlib": "3.0.0-devnet.2",
78
- "@aztec/telemetry-client": "3.0.0-devnet.2",
79
- "@aztec/world-state": "3.0.0-devnet.2",
59
+ "@aztec/archiver": "3.0.0-devnet.20251212",
60
+ "@aztec/bb-prover": "3.0.0-devnet.20251212",
61
+ "@aztec/blob-lib": "3.0.0-devnet.20251212",
62
+ "@aztec/blob-sink": "3.0.0-devnet.20251212",
63
+ "@aztec/constants": "3.0.0-devnet.20251212",
64
+ "@aztec/epoch-cache": "3.0.0-devnet.20251212",
65
+ "@aztec/ethereum": "3.0.0-devnet.20251212",
66
+ "@aztec/foundation": "3.0.0-devnet.20251212",
67
+ "@aztec/kv-store": "3.0.0-devnet.20251212",
68
+ "@aztec/l1-artifacts": "3.0.0-devnet.20251212",
69
+ "@aztec/node-keystore": "3.0.0-devnet.20251212",
70
+ "@aztec/node-lib": "3.0.0-devnet.20251212",
71
+ "@aztec/noir-protocol-circuits-types": "3.0.0-devnet.20251212",
72
+ "@aztec/p2p": "3.0.0-devnet.20251212",
73
+ "@aztec/protocol-contracts": "3.0.0-devnet.20251212",
74
+ "@aztec/prover-client": "3.0.0-devnet.20251212",
75
+ "@aztec/sequencer-client": "3.0.0-devnet.20251212",
76
+ "@aztec/simulator": "3.0.0-devnet.20251212",
77
+ "@aztec/stdlib": "3.0.0-devnet.20251212",
78
+ "@aztec/telemetry-client": "3.0.0-devnet.20251212",
79
+ "@aztec/world-state": "3.0.0-devnet.20251212",
80
80
  "source-map-support": "^0.5.21",
81
81
  "tslib": "^2.4.0",
82
- "viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
82
+ "viem": "npm:@aztec/viem@2.38.2"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@jest/globals": "^30.0.0",
86
86
  "@types/jest": "^30.0.0",
87
87
  "@types/node": "^22.15.17",
88
88
  "@types/source-map-support": "^0.5.10",
89
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
89
90
  "jest": "^30.0.0",
90
91
  "jest-mock-extended": "^4.0.0",
91
92
  "ts-node": "^10.9.1",
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import type { L1ContractAddresses } from '@aztec/ethereum';
2
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
5
5
  import { createLogger } from '@aztec/foundation/log';
package/src/config.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
2
2
  import type { ACVMConfig, BBConfig } from '@aztec/bb-prover/config';
3
- import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum';
3
+ import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum/config';
4
4
  import {
5
5
  type ConfigMappingsType,
6
6
  booleanConfigHelper,
package/src/factory.ts CHANGED
@@ -2,7 +2,10 @@ import { type Archiver, createArchiver } from '@aztec/archiver';
2
2
  import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
3
3
  import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
4
4
  import { EpochCache } from '@aztec/epoch-cache';
5
- import { L1TxUtils, PublisherManager, RollupContract, createEthereumChain } from '@aztec/ethereum';
5
+ import { createEthereumChain } from '@aztec/ethereum/chain';
6
+ import { RollupContract } from '@aztec/ethereum/contracts';
7
+ import { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
8
+ import { PublisherManager } from '@aztec/ethereum/publisher-manager';
6
9
  import { pick } from '@aztec/foundation/collection';
7
10
  import { type Logger, createLogger } from '@aztec/foundation/log';
8
11
  import { DateProvider } from '@aztec/foundation/timer';
@@ -148,7 +151,9 @@ export async function createProverNode(
148
151
 
149
152
  const proofVerifier = new QueuedIVCVerifier(
150
153
  config,
151
- config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(),
154
+ config.realProofs || config.debugForceTxProofVerification
155
+ ? await BBCircuitVerifier.new(config)
156
+ : new TestCircuitVerifier(config.proverTestVerificationDelayMs),
152
157
  );
153
158
 
154
159
  const p2pClient = await createP2PClient(
@@ -181,6 +186,7 @@ export async function createProverNode(
181
186
  'txGatheringIntervalMs',
182
187
  'txGatheringTimeoutMs',
183
188
  'proverNodeFailedEpochStore',
189
+ 'proverNodeDisableProofPublish',
184
190
  'dataDirectory',
185
191
  'l1ChainId',
186
192
  'rollupVersion',
@@ -1,49 +1,55 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
- import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
4
+ import { CommitteeAttestation } from '@aztec/stdlib/block';
5
+ import { Checkpoint } from '@aztec/stdlib/checkpoint';
4
6
  import { BlockHeader, Tx } from '@aztec/stdlib/tx';
5
7
 
6
8
  /** All data from an epoch used in proving. */
7
9
  export type EpochProvingJobData = {
8
- epochNumber: bigint;
9
- blocks: L2Block[];
10
+ epochNumber: EpochNumber;
11
+ checkpoints: Checkpoint[];
10
12
  txs: Map<string, Tx>;
11
- l1ToL2Messages: Record<number, Fr[]>;
13
+ l1ToL2Messages: Record<CheckpointNumber, Fr[]>;
12
14
  previousBlockHeader: BlockHeader;
13
15
  attestations: CommitteeAttestation[];
14
16
  };
15
17
 
16
18
  export function validateEpochProvingJobData(data: EpochProvingJobData) {
17
- if (data.blocks.length > 0 && data.previousBlockHeader.getBlockNumber() + 1 !== data.blocks[0].number) {
19
+ if (data.checkpoints.length === 0) {
20
+ throw new Error('No checkpoints to prove');
21
+ }
22
+
23
+ const firstBlockNumber = data.checkpoints[0].blocks[0].number;
24
+ const previousBlockNumber = data.previousBlockHeader.getBlockNumber();
25
+ if (previousBlockNumber + 1 !== firstBlockNumber) {
18
26
  throw new Error(
19
- `Initial block number ${
20
- data.blocks[0].number
21
- } does not match previous block header ${data.previousBlockHeader.getBlockNumber()}`,
27
+ `Initial block number ${firstBlockNumber} does not match previous block header ${previousBlockNumber}`,
22
28
  );
23
29
  }
24
30
 
25
- for (const blockNumber of data.blocks.map(block => block.number)) {
26
- if (!(blockNumber in data.l1ToL2Messages)) {
27
- throw new Error(`Missing L1 to L2 messages for block number ${blockNumber}`);
31
+ for (const checkpoint of data.checkpoints) {
32
+ if (!(checkpoint.number in data.l1ToL2Messages)) {
33
+ throw new Error(`Missing L1 to L2 messages for checkpoint number ${checkpoint.number}`);
28
34
  }
29
35
  }
30
36
  }
31
37
 
32
38
  export function serializeEpochProvingJobData(data: EpochProvingJobData): Buffer {
33
- const blocks = data.blocks.map(block => block.toBuffer());
39
+ const checkpoints = data.checkpoints.map(checkpoint => checkpoint.toBuffer());
34
40
  const txs = Array.from(data.txs.values()).map(tx => tx.toBuffer());
35
- const l1ToL2Messages = Object.entries(data.l1ToL2Messages).map(([blockNumber, messages]) => [
36
- Number(blockNumber),
41
+ const l1ToL2Messages = Object.entries(data.l1ToL2Messages).map(([checkpointNumber, messages]) => [
42
+ Number(checkpointNumber),
37
43
  messages.length,
38
44
  ...messages,
39
45
  ]);
40
46
  const attestations = data.attestations.map(attestation => attestation.toBuffer());
41
47
 
42
48
  return serializeToBuffer(
43
- Number(data.epochNumber),
49
+ data.epochNumber,
44
50
  data.previousBlockHeader,
45
- blocks.length,
46
- ...blocks,
51
+ checkpoints.length,
52
+ ...checkpoints,
47
53
  txs.length,
48
54
  ...txs,
49
55
  l1ToL2Messages.length,
@@ -55,22 +61,22 @@ export function serializeEpochProvingJobData(data: EpochProvingJobData): Buffer
55
61
 
56
62
  export function deserializeEpochProvingJobData(buf: Buffer): EpochProvingJobData {
57
63
  const reader = BufferReader.asReader(buf);
58
- const epochNumber = BigInt(reader.readNumber());
64
+ const epochNumber = EpochNumber(reader.readNumber());
59
65
  const previousBlockHeader = reader.readObject(BlockHeader);
60
- const blocks = reader.readVector(L2Block);
66
+ const checkpoints = reader.readVector(Checkpoint);
61
67
  const txArray = reader.readVector(Tx);
62
68
 
63
- const l1ToL2MessageBlockCount = reader.readNumber();
69
+ const l1ToL2MessageCheckpointCount = reader.readNumber();
64
70
  const l1ToL2Messages: Record<number, Fr[]> = {};
65
- for (let i = 0; i < l1ToL2MessageBlockCount; i++) {
66
- const blockNumber = reader.readNumber();
71
+ for (let i = 0; i < l1ToL2MessageCheckpointCount; i++) {
72
+ const checkpointNumber = CheckpointNumber(reader.readNumber());
67
73
  const messages = reader.readVector(Fr);
68
- l1ToL2Messages[blockNumber] = messages;
74
+ l1ToL2Messages[checkpointNumber] = messages;
69
75
  }
70
76
 
71
77
  const attestations = reader.readVector(CommitteeAttestation);
72
78
 
73
79
  const txs = new Map<string, Tx>(txArray.map(tx => [tx.getTxHash().toString(), tx]));
74
80
 
75
- return { epochNumber, previousBlockHeader, blocks, txs, l1ToL2Messages, attestations };
81
+ return { epochNumber, previousBlockHeader, checkpoints, txs, l1ToL2Messages, attestations };
76
82
  }
@@ -1,7 +1,8 @@
1
1
  import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
2
  import { asyncPool } from '@aztec/foundation/async-pool';
3
+ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
3
4
  import { padArrayEnd } from '@aztec/foundation/collection';
4
- import { Fr } from '@aztec/foundation/fields';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
6
  import { createLogger } from '@aztec/foundation/log';
6
7
  import { RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
7
8
  import { Timer } from '@aztec/foundation/timer';
@@ -9,7 +10,9 @@ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
9
10
  import { protocolContractsHash } from '@aztec/protocol-contracts';
10
11
  import { buildFinalBlobChallenges } from '@aztec/prover-client/helpers';
11
12
  import type { PublicProcessor, PublicProcessorFactory } from '@aztec/simulator/server';
12
- import type { L2Block, L2BlockSource } from '@aztec/stdlib/block';
13
+ import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
14
+ import type { L2BlockNew, L2BlockSource } from '@aztec/stdlib/block';
15
+ import type { Checkpoint } from '@aztec/stdlib/checkpoint';
13
16
  import {
14
17
  type EpochProver,
15
18
  type EpochProvingJobState,
@@ -73,7 +76,7 @@ export class EpochProvingJob implements Traceable {
73
76
  return this.state;
74
77
  }
75
78
 
76
- public getEpochNumber(): bigint {
79
+ public getEpochNumber(): EpochNumber {
77
80
  return this.data.epochNumber;
78
81
  }
79
82
 
@@ -89,8 +92,8 @@ export class EpochProvingJob implements Traceable {
89
92
  return this.data.epochNumber;
90
93
  }
91
94
 
92
- private get blocks() {
93
- return this.data.blocks;
95
+ private get checkpoints() {
96
+ return this.data.checkpoints;
94
97
  }
95
98
 
96
99
  private get txs() {
@@ -105,7 +108,7 @@ export class EpochProvingJob implements Traceable {
105
108
  * Proves the given epoch and submits the proof to L1.
106
109
  */
107
110
  @trackSpan('EpochProvingJob.run', function () {
108
- return { [Attributes.EPOCH_NUMBER]: Number(this.data.epochNumber) };
111
+ return { [Attributes.EPOCH_NUMBER]: this.data.epochNumber };
109
112
  })
110
113
  public async run() {
111
114
  this.scheduleDeadlineStop();
@@ -114,14 +117,22 @@ export class EpochProvingJob implements Traceable {
114
117
  }
115
118
 
116
119
  const attestations = this.attestations.map(attestation => attestation.toViem());
117
- const epochNumber = Number(this.epochNumber);
118
- const epochSizeBlocks = this.blocks.length;
119
- const epochSizeTxs = this.blocks.reduce((total, current) => total + current.body.txEffects.length, 0);
120
- const [fromBlock, toBlock] = [this.blocks[0].number, this.blocks.at(-1)!.number];
121
- this.log.info(`Starting epoch ${epochNumber} proving job with blocks ${fromBlock} to ${toBlock}`, {
120
+ const epochNumber = this.epochNumber;
121
+ const epochSizeCheckpoints = this.checkpoints.length;
122
+ const epochSizeBlocks = this.checkpoints.reduce((accum, checkpoint) => accum + checkpoint.blocks.length, 0);
123
+ const epochSizeTxs = this.checkpoints.reduce(
124
+ (accum, checkpoint) =>
125
+ accum + checkpoint.blocks.reduce((accumC, block) => accumC + block.body.txEffects.length, 0),
126
+ 0,
127
+ );
128
+ const fromCheckpoint = this.checkpoints[0].number;
129
+ const toCheckpoint = this.checkpoints.at(-1)!.number;
130
+ const fromBlock = this.checkpoints[0].blocks[0].number;
131
+ const toBlock = this.checkpoints.at(-1)!.blocks.at(-1)!.number;
132
+ this.log.info(`Starting epoch ${epochNumber} proving job with checkpoints ${fromCheckpoint} to ${toCheckpoint}`, {
122
133
  fromBlock,
123
134
  toBlock,
124
- epochSizeBlocks,
135
+ epochSizeTxs,
125
136
  epochNumber,
126
137
  uuid: this.uuid,
127
138
  });
@@ -132,83 +143,93 @@ export class EpochProvingJob implements Traceable {
132
143
  this.runPromise = promise;
133
144
 
134
145
  try {
135
- const blobFieldsPerCheckpoint = this.blocks.map(block => block.getCheckpointBlobFields());
146
+ const blobFieldsPerCheckpoint = this.checkpoints.map(checkpoint => checkpoint.toBlobFields());
136
147
  const finalBlobBatchingChallenges = await buildFinalBlobChallenges(blobFieldsPerCheckpoint);
137
148
 
138
- // TODO(#17027): Enable multiple blocks per checkpoint.
139
- // Total number of checkpoints equals number of blocks because we currently build a checkpoint with only one block.
140
- const totalNumCheckpoints = epochSizeBlocks;
149
+ this.prover.startNewEpoch(epochNumber, epochSizeCheckpoints, finalBlobBatchingChallenges);
150
+ await this.prover.startChonkVerifierCircuits(Array.from(this.txs.values()));
141
151
 
142
- this.prover.startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges);
143
- await this.prover.startTubeCircuits(Array.from(this.txs.values()));
152
+ // Everything in the epoch should have the same chainId and version.
153
+ const { chainId, version } = this.checkpoints[0].blocks[0].header.globalVariables;
144
154
 
145
- await asyncPool(this.config.parallelBlockLimit ?? 32, this.blocks, async block => {
146
- this.checkState();
155
+ const previousBlockHeaders = this.gatherPreviousBlockHeaders();
147
156
 
148
- const globalVariables = block.header.globalVariables;
149
- const txs = this.getTxs(block);
150
- const l1ToL2Messages = this.getL1ToL2Messages(block);
151
- const previousHeader = this.getBlockHeader(block.number - 1)!;
152
-
153
- this.log.verbose(`Starting processing block ${block.number}`, {
154
- number: block.number,
155
- blockHash: (await block.hash()).toString(),
156
- lastArchive: block.header.lastArchive.root,
157
- noteHashTreeRoot: block.header.state.partial.noteHashTree.root,
158
- nullifierTreeRoot: block.header.state.partial.nullifierTree.root,
159
- publicDataTreeRoot: block.header.state.partial.publicDataTree.root,
160
- previousHeader: previousHeader.hash(),
161
- uuid: this.uuid,
162
- ...globalVariables,
163
- });
157
+ await asyncPool(this.config.parallelBlockLimit ?? 32, this.checkpoints, async checkpoint => {
158
+ this.checkState();
164
159
 
160
+ const checkpointIndex = checkpoint.number - fromCheckpoint;
165
161
  const checkpointConstants = CheckpointConstantData.from({
166
- chainId: globalVariables.chainId,
167
- version: globalVariables.version,
162
+ chainId,
163
+ version,
168
164
  vkTreeRoot: getVKTreeRoot(),
169
165
  protocolContractsHash: protocolContractsHash,
170
166
  proverId: this.prover.getProverId().toField(),
171
- slotNumber: globalVariables.slotNumber,
172
- coinbase: globalVariables.coinbase,
173
- feeRecipient: globalVariables.feeRecipient,
174
- gasFees: globalVariables.gasFees,
167
+ slotNumber: checkpoint.header.slotNumber,
168
+ coinbase: checkpoint.header.coinbase,
169
+ feeRecipient: checkpoint.header.feeRecipient,
170
+ gasFees: checkpoint.header.gasFees,
171
+ });
172
+ const previousHeader = previousBlockHeaders[checkpointIndex];
173
+ const l1ToL2Messages = this.getL1ToL2Messages(checkpoint);
174
+
175
+ this.log.verbose(`Starting processing checkpoint ${checkpoint.number}`, {
176
+ number: checkpoint.number,
177
+ checkpointHash: checkpoint.hash().toString(),
178
+ lastArchive: checkpoint.header.lastArchiveRoot,
179
+ previousHeader: previousHeader.hash(),
180
+ uuid: this.uuid,
175
181
  });
176
182
 
177
- // TODO(#17027): Enable multiple blocks per checkpoint.
178
- // Each checkpoint has only one block.
179
- const totalNumBlocks = 1;
180
- const checkpointIndex = block.number - fromBlock;
181
183
  await this.prover.startNewCheckpoint(
182
184
  checkpointIndex,
183
185
  checkpointConstants,
184
186
  l1ToL2Messages,
185
- totalNumBlocks,
186
- blobFieldsPerCheckpoint[checkpointIndex].length,
187
+ checkpoint.blocks.length,
187
188
  previousHeader,
188
189
  );
189
190
 
190
- // Start block proving
191
- await this.prover.startNewBlock(block.number, globalVariables.timestamp, txs.length);
191
+ for (const block of checkpoint.blocks) {
192
+ const globalVariables = block.header.globalVariables;
193
+ const txs = this.getTxs(block);
194
+
195
+ this.log.verbose(`Starting processing block ${block.number}`, {
196
+ number: block.number,
197
+ blockHash: (await block.hash()).toString(),
198
+ lastArchive: block.header.lastArchive.root,
199
+ noteHashTreeRoot: block.header.state.partial.noteHashTree.root,
200
+ nullifierTreeRoot: block.header.state.partial.nullifierTree.root,
201
+ publicDataTreeRoot: block.header.state.partial.publicDataTree.root,
202
+ ...globalVariables,
203
+ numTxs: txs.length,
204
+ });
192
205
 
193
- // Process public fns
194
- const db = await this.createFork(block.number - 1, l1ToL2Messages);
195
- const publicProcessor = this.publicProcessorFactory.create(db, globalVariables, {
196
- skipFeeEnforcement: true,
197
- clientInitiatedSimulation: false,
198
- proverId: this.prover.getProverId().toField(),
199
- });
200
- const processed = await this.processTxs(publicProcessor, txs);
201
- await this.prover.addTxs(processed);
202
- await db.close();
203
- this.log.verbose(`Processed all ${txs.length} txs for block ${block.number}`, {
204
- blockNumber: block.number,
205
- blockHash: (await block.hash()).toString(),
206
- uuid: this.uuid,
207
- });
206
+ // Start block proving
207
+ await this.prover.startNewBlock(block.number, globalVariables.timestamp, txs.length);
208
+
209
+ // Process public fns
210
+ const db = await this.createFork(BlockNumber(block.number - 1), l1ToL2Messages);
211
+ const config = PublicSimulatorConfig.from({
212
+ proverId: this.prover.getProverId().toField(),
213
+ skipFeeEnforcement: false,
214
+ collectDebugLogs: false,
215
+ collectHints: true,
216
+ collectPublicInputs: true,
217
+ collectStatistics: false,
218
+ });
219
+ const publicProcessor = this.publicProcessorFactory.create(db, globalVariables, config);
220
+ const processed = await this.processTxs(publicProcessor, txs);
221
+ await this.prover.addTxs(processed);
222
+ await db.close();
223
+ this.log.verbose(`Processed all ${txs.length} txs for block ${block.number}`, {
224
+ blockNumber: block.number,
225
+ blockHash: (await block.hash()).toString(),
226
+ uuid: this.uuid,
227
+ });
208
228
 
209
- // Mark block as completed to pad it
210
- const expectedBlockHeader = block.getBlockHeader();
211
- await this.prover.setBlockCompleted(block.number, expectedBlockHeader);
229
+ // Mark block as completed to pad it
230
+ const expectedBlockHeader = block.header;
231
+ await this.prover.setBlockCompleted(block.number, expectedBlockHeader);
232
+ }
212
233
  });
213
234
 
214
235
  const executionTime = timer.ms();
@@ -221,16 +242,16 @@ export class EpochProvingJob implements Traceable {
221
242
 
222
243
  if (this.config.skipSubmitProof) {
223
244
  this.log.info(
224
- `Proof publishing is disabled. Dropping valid proof for epoch ${epochNumber} (blocks ${fromBlock} to ${toBlock})`,
245
+ `Proof publishing is disabled. Dropping valid proof for epoch ${epochNumber} (checkpoints ${fromCheckpoint} to ${toCheckpoint})`,
225
246
  );
226
247
  this.state = 'completed';
227
- this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeBlocks, epochSizeTxs);
248
+ this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeCheckpoints, epochSizeBlocks, epochSizeTxs);
228
249
  return;
229
250
  }
230
251
 
231
252
  const success = await this.publisher.submitEpochProof({
232
- fromBlock,
233
- toBlock,
253
+ fromCheckpoint,
254
+ toCheckpoint,
234
255
  epochNumber,
235
256
  publicInputs,
236
257
  proof,
@@ -241,12 +262,12 @@ export class EpochProvingJob implements Traceable {
241
262
  throw new Error('Failed to submit epoch proof to L1');
242
263
  }
243
264
 
244
- this.log.info(`Submitted proof for epoch ${epochNumber} (blocks ${fromBlock} to ${toBlock})`, {
265
+ this.log.info(`Submitted proof for epoch ${epochNumber} (checkpoints ${fromCheckpoint} to ${toCheckpoint})`, {
245
266
  epochNumber,
246
267
  uuid: this.uuid,
247
268
  });
248
269
  this.state = 'completed';
249
- this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeBlocks, epochSizeTxs);
270
+ this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeCheckpoints, epochSizeBlocks, epochSizeTxs);
250
271
  } catch (err: any) {
251
272
  if (err && err.name === 'HaltExecutionError') {
252
273
  this.log.warn(`Halted execution of epoch ${epochNumber} prover job`, {
@@ -272,7 +293,7 @@ export class EpochProvingJob implements Traceable {
272
293
  * Create a new db fork for tx processing, inserting all L1 to L2.
273
294
  * REFACTOR: The prover already spawns a db fork of its own for each block, so we may be able to do away with just one fork.
274
295
  */
275
- private async createFork(blockNumber: number, l1ToL2Messages: Fr[]) {
296
+ private async createFork(blockNumber: BlockNumber, l1ToL2Messages: Fr[]) {
276
297
  const db = await this.dbProvider.fork(blockNumber);
277
298
  const l1ToL2MessagesPadded = padArrayEnd<Fr, number>(
278
299
  l1ToL2Messages,
@@ -282,7 +303,7 @@ export class EpochProvingJob implements Traceable {
282
303
  );
283
304
  this.log.verbose(`Creating fork at ${blockNumber} with ${l1ToL2Messages.length} L1 to L2 messages`, {
284
305
  blockNumber,
285
- l1ToL2Messages: l1ToL2MessagesPadded.map(m => m.toString()),
306
+ l1ToL2Messages: l1ToL2Messages.map(m => m.toString()),
286
307
  });
287
308
  await db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
288
309
  return db;
@@ -343,11 +364,9 @@ export class EpochProvingJob implements Traceable {
343
364
  async () => {
344
365
  const blocks = await l2BlockSource.getBlockHeadersForEpoch(this.epochNumber);
345
366
  const blockHashes = await Promise.all(blocks.map(block => block.hash()));
346
- const thisBlockHashes = await Promise.all(this.blocks.map(block => block.hash()));
347
- if (
348
- blocks.length !== this.blocks.length ||
349
- !blockHashes.every((block, i) => block.equals(thisBlockHashes[i]))
350
- ) {
367
+ const thisBlocks = this.checkpoints.flatMap(checkpoint => checkpoint.blocks);
368
+ const thisBlockHashes = await Promise.all(thisBlocks.map(block => block.hash()));
369
+ if (blocks.length !== thisBlocks.length || !blockHashes.every((block, i) => block.equals(thisBlockHashes[i]))) {
351
370
  this.log.warn('Epoch blocks changed underfoot', {
352
371
  uuid: this.uuid,
353
372
  epochNumber: this.epochNumber,
@@ -363,30 +382,18 @@ export class EpochProvingJob implements Traceable {
363
382
  this.log.verbose(`Scheduled epoch check for epoch ${this.epochNumber} every ${intervalMs}ms`);
364
383
  }
365
384
 
366
- /* Returns the header for the given block number based on the epoch proving job data. */
367
- private getBlockHeader(blockNumber: number) {
368
- const block = this.blocks.find(b => b.number === blockNumber);
369
- if (block) {
370
- return block.getBlockHeader();
371
- }
372
-
373
- if (blockNumber === Number(this.data.previousBlockHeader.getBlockNumber())) {
374
- return this.data.previousBlockHeader;
375
- }
376
-
377
- throw new Error(
378
- `Block header not found for block number ${blockNumber} (got ${this.blocks
379
- .map(b => b.number)
380
- .join(', ')} and previous header ${this.data.previousBlockHeader.getBlockNumber()})`,
381
- );
385
+ /* Returns the last block header in the previous checkpoint for all checkpoints in the epoch */
386
+ private gatherPreviousBlockHeaders() {
387
+ const lastBlocks = this.checkpoints.map(checkpoint => checkpoint.blocks.at(-1)!);
388
+ return [this.data.previousBlockHeader, ...lastBlocks.map(block => block.header).slice(0, -1)];
382
389
  }
383
390
 
384
- private getTxs(block: L2Block): Tx[] {
391
+ private getTxs(block: L2BlockNew): Tx[] {
385
392
  return block.body.txEffects.map(txEffect => this.txs.get(txEffect.txHash.toString())!);
386
393
  }
387
394
 
388
- private getL1ToL2Messages(block: L2Block) {
389
- return this.data.l1ToL2Messages[block.number];
395
+ private getL1ToL2Messages(checkpoint: Checkpoint) {
396
+ return this.data.l1ToL2Messages[checkpoint.number];
390
397
  }
391
398
 
392
399
  private async processTxs(publicProcessor: PublicProcessor, txs: Tx[]): Promise<ProcessedTx[]> {
package/src/metrics.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RollupContract } from '@aztec/ethereum';
1
+ import type { RollupContract } from '@aztec/ethereum/contracts';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import type { L1PublishProofStats, L1PublishStats } from '@aztec/stdlib/stats';
@@ -21,6 +21,7 @@ import { formatEther, formatUnits } from 'viem';
21
21
  export class ProverNodeJobMetrics {
22
22
  proverEpochExecutionDuration: Histogram;
23
23
  provingJobDuration: Histogram;
24
+ provingJobCheckpoints: Gauge;
24
25
  provingJobBlocks: Gauge;
25
26
  provingJobTransactions: Gauge;
26
27
 
@@ -39,6 +40,10 @@ export class ProverNodeJobMetrics {
39
40
  unit: 's',
40
41
  valueType: ValueType.DOUBLE,
41
42
  });
43
+ this.provingJobCheckpoints = this.meter.createGauge(Metrics.PROVER_NODE_JOB_CHECKPOINTS, {
44
+ description: 'Number of checkpoints in a proven epoch',
45
+ valueType: ValueType.INT,
46
+ });
42
47
  this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS, {
43
48
  description: 'Number of blocks in a proven epoch',
44
49
  valueType: ValueType.INT,
@@ -49,9 +54,16 @@ export class ProverNodeJobMetrics {
49
54
  });
50
55
  }
51
56
 
52
- public recordProvingJob(executionTimeMs: number, totalTimeMs: number, numBlocks: number, numTxs: number) {
57
+ public recordProvingJob(
58
+ executionTimeMs: number,
59
+ totalTimeMs: number,
60
+ numCheckpoints: number,
61
+ numBlocks: number,
62
+ numTxs: number,
63
+ ) {
53
64
  this.proverEpochExecutionDuration.record(Math.ceil(executionTimeMs));
54
65
  this.provingJobDuration.record(totalTimeMs / 1000);
66
+ this.provingJobCheckpoints.record(Math.floor(numCheckpoints));
55
67
  this.provingJobBlocks.record(Math.floor(numBlocks));
56
68
  this.provingJobTransactions.record(Math.floor(numTxs));
57
69
  }
@@ -97,7 +109,7 @@ export class ProverNodeRewardsMetrics {
97
109
  // look at the prev epoch so that we get an accurate value, after proof submission window has closed
98
110
  // For example, if proof submission window is 1 epoch, and we are in epoch 2, we should be looking at epoch 0.
99
111
  // Similarly, if the proof submission window is 0, and we are in epoch 1, we should be looking at epoch 0.
100
- const closedEpoch = epoch - BigInt(this.proofSubmissionEpochs) - 1n;
112
+ const closedEpoch = BigInt(epoch) - BigInt(this.proofSubmissionEpochs) - 1n;
101
113
  const rewards = await this.rollup.getSpecificProverRewardsForEpoch(closedEpoch, this.coinbase);
102
114
 
103
115
  const fmt = parseFloat(formatUnits(rewards, 18));
@@ -1,3 +1,4 @@
1
+ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
1
2
  import { createLogger } from '@aztec/foundation/log';
2
3
  import { RunningPromise } from '@aztec/foundation/running-promise';
3
4
  import { sleep } from '@aztec/foundation/sleep';
@@ -12,7 +13,7 @@ import {
12
13
  } from '@aztec/telemetry-client';
13
14
 
14
15
  export interface EpochMonitorHandler {
15
- handleEpochReadyToProve(epochNumber: bigint): Promise<boolean>;
16
+ handleEpochReadyToProve(epochNumber: EpochNumber): Promise<boolean>;
16
17
  }
17
18
 
18
19
  /**
@@ -32,7 +33,7 @@ export class EpochMonitor implements Traceable {
32
33
  public readonly tracer: Tracer;
33
34
 
34
35
  private handler: EpochMonitorHandler | undefined;
35
- private latestEpochNumber: bigint | undefined;
36
+ private latestEpochNumber: EpochNumber | undefined;
36
37
 
37
38
  constructor(
38
39
  private readonly l2BlockSource: L2BlockSource,
@@ -104,7 +105,7 @@ export class EpochMonitor implements Traceable {
104
105
 
105
106
  private async getEpochNumberToProve() {
106
107
  const lastBlockProven = await this.l2BlockSource.getProvenBlockNumber();
107
- const firstBlockToProve = lastBlockProven + 1;
108
+ const firstBlockToProve = BlockNumber(lastBlockProven + 1);
108
109
  const firstBlockHeaderToProve = await this.l2BlockSource.getBlockHeader(firstBlockToProve);
109
110
  if (!firstBlockHeaderToProve) {
110
111
  return { epochToProve: undefined, blockNumber: firstBlockToProve };