@aztec/prover-node 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891

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 (56) 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 +4 -3
  4. package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
  5. package/dest/actions/rerun-epoch-proving-job.js +2 -2
  6. package/dest/actions/upload-epoch-proof-failure.d.ts +2 -2
  7. package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -1
  8. package/dest/bin/run-failed-epoch.d.ts +1 -1
  9. package/dest/bin/run-failed-epoch.js +5 -2
  10. package/dest/config.d.ts +8 -10
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +19 -21
  13. package/dest/factory.d.ts +20 -16
  14. package/dest/factory.d.ts.map +1 -1
  15. package/dest/factory.js +28 -62
  16. package/dest/index.d.ts +2 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -0
  19. package/dest/job/epoch-proving-job-data.d.ts +8 -6
  20. package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
  21. package/dest/job/epoch-proving-job-data.js +25 -18
  22. package/dest/job/epoch-proving-job.d.ts +7 -13
  23. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  24. package/dest/job/epoch-proving-job.js +513 -105
  25. package/dest/metrics.d.ts +14 -3
  26. package/dest/metrics.d.ts.map +1 -1
  27. package/dest/metrics.js +55 -98
  28. package/dest/monitors/epoch-monitor.d.ts +3 -2
  29. package/dest/monitors/epoch-monitor.d.ts.map +1 -1
  30. package/dest/monitors/epoch-monitor.js +8 -18
  31. package/dest/monitors/index.d.ts +1 -1
  32. package/dest/prover-node-publisher.d.ts +14 -11
  33. package/dest/prover-node-publisher.d.ts.map +1 -1
  34. package/dest/prover-node-publisher.js +49 -42
  35. package/dest/prover-node.d.ts +27 -16
  36. package/dest/prover-node.d.ts.map +1 -1
  37. package/dest/prover-node.js +445 -59
  38. package/dest/prover-publisher-factory.d.ts +9 -5
  39. package/dest/prover-publisher-factory.d.ts.map +1 -1
  40. package/dest/prover-publisher-factory.js +4 -2
  41. package/dest/test/index.d.ts +1 -1
  42. package/dest/test/index.d.ts.map +1 -1
  43. package/package.json +27 -25
  44. package/src/actions/rerun-epoch-proving-job.ts +5 -3
  45. package/src/actions/upload-epoch-proof-failure.ts +1 -1
  46. package/src/bin/run-failed-epoch.ts +5 -2
  47. package/src/config.ts +27 -33
  48. package/src/factory.ts +64 -102
  49. package/src/index.ts +1 -0
  50. package/src/job/epoch-proving-job-data.ts +31 -25
  51. package/src/job/epoch-proving-job.ts +155 -110
  52. package/src/metrics.ts +65 -82
  53. package/src/monitors/epoch-monitor.ts +8 -15
  54. package/src/prover-node-publisher.ts +71 -58
  55. package/src/prover-node.ts +65 -53
  56. package/src/prover-publisher-factory.ts +16 -8
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';
@@ -13,7 +13,7 @@ import {
13
13
  type TelemetryClient,
14
14
  type Tracer,
15
15
  type UpDownCounter,
16
- ValueType,
16
+ createUpDownCounterWithDefault,
17
17
  } from '@aztec/telemetry-client';
18
18
 
19
19
  import { formatEther, formatUnits } from 'viem';
@@ -21,40 +21,69 @@ 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
 
28
+ private blobProcessingDuration: Gauge;
29
+ private chonkVerifierDuration: Gauge;
30
+ private blockProcessingDuration: Histogram;
31
+ private checkpointProcessingDuration: Histogram;
32
+ private allCheckpointsProcessingDuration: Gauge;
33
+
27
34
  constructor(
28
35
  private meter: Meter,
29
36
  public readonly tracer: Tracer,
30
37
  private logger = createLogger('prover-node:publisher:metrics'),
31
38
  ) {
32
- this.proverEpochExecutionDuration = this.meter.createHistogram(Metrics.PROVER_NODE_EXECUTION_DURATION, {
33
- description: 'Duration of execution of an epoch by the prover',
34
- unit: 'ms',
35
- valueType: ValueType.INT,
36
- });
37
- this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION, {
38
- description: 'Duration of proving job',
39
- unit: 's',
40
- valueType: ValueType.DOUBLE,
41
- });
42
- this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS, {
43
- description: 'Number of blocks in a proven epoch',
44
- valueType: ValueType.INT,
45
- });
46
- this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS, {
47
- description: 'Number of transactions in a proven epoch',
48
- valueType: ValueType.INT,
49
- });
39
+ this.proverEpochExecutionDuration = this.meter.createHistogram(Metrics.PROVER_NODE_EXECUTION_DURATION);
40
+ this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION);
41
+ this.provingJobCheckpoints = this.meter.createGauge(Metrics.PROVER_NODE_JOB_CHECKPOINTS);
42
+ this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS);
43
+ this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS);
44
+
45
+ this.blobProcessingDuration = this.meter.createGauge(Metrics.PROVER_NODE_BLOB_PROCESSING_LAST_DURATION);
46
+ this.chonkVerifierDuration = this.meter.createGauge(Metrics.PROVER_NODE_CHONK_VERIFIER_LAST_DURATION);
47
+ this.blockProcessingDuration = this.meter.createHistogram(Metrics.PROVER_NODE_BLOCK_PROCESSING_DURATION);
48
+ this.checkpointProcessingDuration = this.meter.createHistogram(Metrics.PROVER_NODE_CHECKPOINT_PROCESSING_DURATION);
49
+ this.allCheckpointsProcessingDuration = this.meter.createGauge(
50
+ Metrics.PROVER_NODE_ALL_CHECKPOINTS_PROCESSING_LAST_DURATION,
51
+ );
50
52
  }
51
53
 
52
- public recordProvingJob(executionTimeMs: number, totalTimeMs: number, numBlocks: number, numTxs: number) {
54
+ public recordProvingJob(
55
+ executionTimeMs: number,
56
+ totalTimeMs: number,
57
+ numCheckpoints: number,
58
+ numBlocks: number,
59
+ numTxs: number,
60
+ ) {
53
61
  this.proverEpochExecutionDuration.record(Math.ceil(executionTimeMs));
54
62
  this.provingJobDuration.record(totalTimeMs / 1000);
63
+ this.provingJobCheckpoints.record(Math.floor(numCheckpoints));
55
64
  this.provingJobBlocks.record(Math.floor(numBlocks));
56
65
  this.provingJobTransactions.record(Math.floor(numTxs));
57
66
  }
67
+
68
+ public recordBlobProcessing(durationMs: number) {
69
+ this.blobProcessingDuration.record(Math.ceil(durationMs));
70
+ }
71
+
72
+ public recordChonkVerifier(durationMs: number) {
73
+ this.chonkVerifierDuration.record(Math.ceil(durationMs));
74
+ }
75
+
76
+ public recordBlockProcessing(durationMs: number) {
77
+ this.blockProcessingDuration.record(Math.ceil(durationMs));
78
+ }
79
+
80
+ public recordCheckpointProcessing(durationMs: number) {
81
+ this.checkpointProcessingDuration.record(Math.ceil(durationMs));
82
+ }
83
+
84
+ public recordAllCheckpointsProcessing(durationMs: number) {
85
+ this.allCheckpointsProcessingDuration.record(Math.ceil(durationMs));
86
+ }
58
87
  }
59
88
 
60
89
  export class ProverNodeRewardsMetrics {
@@ -69,15 +98,9 @@ export class ProverNodeRewardsMetrics {
69
98
  private rollup: RollupContract,
70
99
  private logger = createLogger('prover-node:publisher:metrics'),
71
100
  ) {
72
- this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH, {
73
- valueType: ValueType.DOUBLE,
74
- description: 'The rewards earned',
75
- });
101
+ this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH);
76
102
 
77
- this.accumulatedRewards = this.meter.createUpDownCounter(Metrics.PROVER_NODE_REWARDS_TOTAL, {
78
- valueType: ValueType.DOUBLE,
79
- description: 'The rewards earned (total)',
80
- });
103
+ this.accumulatedRewards = createUpDownCounterWithDefault(this.meter, Metrics.PROVER_NODE_REWARDS_TOTAL);
81
104
  }
82
105
 
83
106
  public async start() {
@@ -97,7 +120,7 @@ export class ProverNodeRewardsMetrics {
97
120
  // look at the prev epoch so that we get an accurate value, after proof submission window has closed
98
121
  // For example, if proof submission window is 1 epoch, and we are in epoch 2, we should be looking at epoch 0.
99
122
  // 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;
123
+ const closedEpoch = BigInt(epoch) - BigInt(this.proofSubmissionEpochs) - 1n;
101
124
  const rewards = await this.rollup.getSpecificProverRewardsForEpoch(closedEpoch, this.coinbase);
102
125
 
103
126
  const fmt = parseFloat(formatUnits(rewards, 18));
@@ -138,68 +161,28 @@ export class ProverNodePublisherMetrics {
138
161
  ) {
139
162
  this.meter = client.getMeter(name);
140
163
 
141
- this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE, {
142
- description: 'The gas price used for transactions',
143
- unit: 'gwei',
144
- valueType: ValueType.DOUBLE,
145
- });
164
+ this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
146
165
 
147
- this.txCount = this.meter.createUpDownCounter(Metrics.L1_PUBLISHER_TX_COUNT, {
148
- description: 'The number of transactions processed',
166
+ this.txCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_PUBLISHER_TX_COUNT, {
167
+ [Attributes.L1_TX_TYPE]: ['submitProof'],
168
+ [Attributes.OK]: [true, false],
149
169
  });
150
170
 
151
- this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION, {
152
- description: 'The duration of transaction processing',
153
- unit: 'ms',
154
- valueType: ValueType.INT,
155
- });
171
+ this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
156
172
 
157
- this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS, {
158
- description: 'The gas consumed by transactions',
159
- unit: 'gas',
160
- valueType: ValueType.INT,
161
- });
173
+ this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
162
174
 
163
- this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE, {
164
- description: 'The size of the calldata in transactions',
165
- unit: 'By',
166
- valueType: ValueType.INT,
167
- });
175
+ this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
168
176
 
169
- this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS, {
170
- description: 'The gas consumed by the calldata in transactions',
171
- unit: 'gas',
172
- valueType: ValueType.INT,
173
- });
177
+ this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
174
178
 
175
- this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED, {
176
- description: 'The amount of blob gas used in transactions',
177
- unit: 'gas',
178
- valueType: ValueType.INT,
179
- });
179
+ this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
180
180
 
181
- this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST, {
182
- description: 'The gas cost of blobs in transactions',
183
- unit: 'gwei',
184
- valueType: ValueType.INT,
185
- });
181
+ this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
186
182
 
187
- this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
188
- description: 'How much L1 tx costs',
189
- unit: 'gwei',
190
- valueType: ValueType.DOUBLE,
191
- advice: {
192
- explicitBucketBoundaries: [
193
- 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
194
- ],
195
- },
196
- });
183
+ this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
197
184
 
198
- this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
199
- unit: 'eth',
200
- description: 'The balance of the sender address',
201
- valueType: ValueType.DOUBLE,
202
- });
185
+ this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
203
186
  }
204
187
 
205
188
  recordFailedTx() {
@@ -1,18 +1,13 @@
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';
4
5
  import type { L2BlockSource } from '@aztec/stdlib/block';
5
6
  import { type L1RollupConstants, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
6
- import {
7
- type TelemetryClient,
8
- type Traceable,
9
- type Tracer,
10
- getTelemetryClient,
11
- trackSpan,
12
- } from '@aztec/telemetry-client';
7
+ import { type TelemetryClient, type Traceable, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
13
8
 
14
9
  export interface EpochMonitorHandler {
15
- handleEpochReadyToProve(epochNumber: bigint): Promise<boolean>;
10
+ handleEpochReadyToProve(epochNumber: EpochNumber): Promise<boolean>;
16
11
  }
17
12
 
18
13
  /**
@@ -32,7 +27,7 @@ export class EpochMonitor implements Traceable {
32
27
  public readonly tracer: Tracer;
33
28
 
34
29
  private handler: EpochMonitorHandler | undefined;
35
- private latestEpochNumber: bigint | undefined;
30
+ private latestEpochNumber: EpochNumber | undefined;
36
31
 
37
32
  constructor(
38
33
  private readonly l2BlockSource: L2BlockSource,
@@ -72,12 +67,10 @@ export class EpochMonitor implements Traceable {
72
67
  this.log.info('Stopped EpochMonitor');
73
68
  }
74
69
 
75
- @trackSpan('EpochMonitor.work')
76
70
  public async work() {
77
71
  const { epochToProve, blockNumber, slotNumber } = await this.getEpochNumberToProve();
78
- this.log.debug(`Epoch to prove: ${epochToProve}`, { blockNumber, slotNumber });
79
72
  if (epochToProve === undefined) {
80
- this.log.trace(`Next block to prove ${blockNumber} not yet mined`, { blockNumber });
73
+ this.log.trace(`Next block to prove ${blockNumber} not yet mined`, { epochToProve, blockNumber, slotNumber });
81
74
  return;
82
75
  }
83
76
  if (this.latestEpochNumber !== undefined && epochToProve <= this.latestEpochNumber) {
@@ -92,11 +85,11 @@ export class EpochMonitor implements Traceable {
92
85
  }
93
86
 
94
87
  if (this.options.provingDelayMs) {
95
- this.log.debug(`Waiting ${this.options.provingDelayMs}ms before proving epoch ${epochToProve}`);
88
+ this.log.warn(`Waiting ${this.options.provingDelayMs}ms before proving epoch ${epochToProve}`);
96
89
  await sleep(this.options.provingDelayMs);
97
90
  }
98
91
 
99
- this.log.debug(`Epoch ${epochToProve} is ready to be proven`);
92
+ this.log.verbose(`Epoch ${epochToProve} is ready to be proven`);
100
93
  if (await this.handler?.handleEpochReadyToProve(epochToProve)) {
101
94
  this.latestEpochNumber = epochToProve;
102
95
  }
@@ -104,7 +97,7 @@ export class EpochMonitor implements Traceable {
104
97
 
105
98
  private async getEpochNumberToProve() {
106
99
  const lastBlockProven = await this.l2BlockSource.getProvenBlockNumber();
107
- const firstBlockToProve = lastBlockProven + 1;
100
+ const firstBlockToProve = BlockNumber(lastBlockProven + 1);
108
101
  const firstBlockHeaderToProve = await this.l2BlockSource.getBlockHeader(firstBlockToProve);
109
102
  if (!firstBlockHeaderToProve) {
110
103
  return { epochToProve: undefined, blockNumber: firstBlockToProve };
@@ -1,11 +1,13 @@
1
- import type { BatchedBlob } from '@aztec/blob-lib';
2
- import { AZTEC_MAX_EPOCH_DURATION } from '@aztec/constants';
3
- import type { L1TxUtils, RollupContract, ViemCommitteeAttestation } from '@aztec/ethereum';
1
+ import { BatchedBlob, getEthBlobEvaluationInputs } from '@aztec/blob-lib';
2
+ import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
3
+ import type { RollupContract, ViemCommitteeAttestation } from '@aztec/ethereum/contracts';
4
+ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
4
5
  import { makeTuple } from '@aztec/foundation/array';
6
+ import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
5
7
  import { areArraysEqual } from '@aztec/foundation/collection';
8
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
9
  import { EthAddress } from '@aztec/foundation/eth-address';
7
- import { Fr } from '@aztec/foundation/fields';
8
- import { createLogger } from '@aztec/foundation/log';
10
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
9
11
  import type { Tuple } from '@aztec/foundation/serialize';
10
12
  import { Timer } from '@aztec/foundation/timer';
11
13
  import { RollupAbi } from '@aztec/l1-artifacts';
@@ -29,7 +31,7 @@ export type L1SubmitEpochProofArgs = {
29
31
  endTimestamp: Fr;
30
32
  outHash: Fr;
31
33
  proverId: Fr;
32
- fees: Tuple<FeeRecipient, typeof AZTEC_MAX_EPOCH_DURATION>;
34
+ fees: Tuple<FeeRecipient, typeof MAX_CHECKPOINTS_PER_EPOCH>;
33
35
  proof: Proof;
34
36
  };
35
37
 
@@ -37,7 +39,7 @@ export class ProverNodePublisher {
37
39
  private interrupted = false;
38
40
  private metrics: ProverNodePublisherMetrics;
39
41
 
40
- protected log = createLogger('prover-node:l1-tx-publisher');
42
+ protected log: Logger;
41
43
 
42
44
  protected rollupContract: RollupContract;
43
45
 
@@ -50,10 +52,12 @@ export class ProverNodePublisher {
50
52
  l1TxUtils: L1TxUtils;
51
53
  telemetry?: TelemetryClient;
52
54
  },
55
+ bindings?: LoggerBindings,
53
56
  ) {
54
57
  const telemetry = deps.telemetry ?? getTelemetryClient();
55
58
 
56
59
  this.metrics = new ProverNodePublisherMetrics(telemetry, 'ProverNode');
60
+ this.log = createLogger('prover-node:l1-tx-publisher', bindings);
57
61
 
58
62
  this.rollupContract = deps.rollupContract;
59
63
  this.l1TxUtils = deps.l1TxUtils;
@@ -85,16 +89,16 @@ export class ProverNodePublisher {
85
89
  }
86
90
 
87
91
  public async submitEpochProof(args: {
88
- epochNumber: number;
89
- fromBlock: number;
90
- toBlock: number;
92
+ epochNumber: EpochNumber;
93
+ fromCheckpoint: CheckpointNumber;
94
+ toCheckpoint: CheckpointNumber;
91
95
  publicInputs: RootRollupPublicInputs;
92
96
  proof: Proof;
93
97
  batchedBlobInputs: BatchedBlob;
94
98
  attestations: ViemCommitteeAttestation[];
95
99
  }): Promise<boolean> {
96
- const { epochNumber, fromBlock, toBlock } = args;
97
- const ctx = { epochNumber, fromBlock, toBlock };
100
+ const { epochNumber, fromCheckpoint, toCheckpoint } = args;
101
+ const ctx = { epochNumber, fromCheckpoint, toCheckpoint };
98
102
 
99
103
  if (!this.interrupted) {
100
104
  const timer = new Timer();
@@ -103,6 +107,7 @@ export class ProverNodePublisher {
103
107
 
104
108
  const txReceipt = await this.sendSubmitEpochProofTx(args);
105
109
  if (!txReceipt) {
110
+ this.log.error(`Failed to mine submitEpochProof tx`, undefined, ctx);
106
111
  return false;
107
112
  }
108
113
 
@@ -135,47 +140,51 @@ export class ProverNodePublisher {
135
140
  }
136
141
 
137
142
  this.metrics.recordFailedTx();
138
- this.log.error(`Rollup.submitEpochProof tx status failed ${txReceipt.transactionHash}`, undefined, ctx);
143
+ this.log.error(`Rollup submitEpochProof tx reverted ${txReceipt.transactionHash}`, undefined, ctx);
139
144
  }
140
145
 
141
- this.log.verbose('L2 block data syncing interrupted', ctx);
146
+ this.log.verbose('Checkpoint data syncing interrupted', ctx);
142
147
  return false;
143
148
  }
144
149
 
145
150
  private async validateEpochProofSubmission(args: {
146
- fromBlock: number;
147
- toBlock: number;
151
+ fromCheckpoint: CheckpointNumber;
152
+ toCheckpoint: CheckpointNumber;
148
153
  publicInputs: RootRollupPublicInputs;
149
154
  proof: Proof;
150
155
  batchedBlobInputs: BatchedBlob;
151
156
  attestations: ViemCommitteeAttestation[];
152
157
  }) {
153
- const { fromBlock, toBlock, publicInputs, batchedBlobInputs } = args;
158
+ const { fromCheckpoint, toCheckpoint, publicInputs, batchedBlobInputs } = args;
154
159
 
155
- // Check that the block numbers match the expected epoch to be proven
156
- const { pendingBlockNumber: pending, provenBlockNumber: proven } = await this.rollupContract.getTips();
157
- // Don't publish if proven is beyond our toBlock, pointless to do so
158
- if (proven > BigInt(toBlock)) {
159
- throw new Error(`Cannot submit epoch proof for ${fromBlock}-${toBlock} as proven block is ${proven}`);
160
+ // Check that the checkpoint numbers match the expected epoch to be proven
161
+ const { pending, proven } = await this.rollupContract.getTips();
162
+ // Don't publish if proven is beyond our toCheckpoint, pointless to do so
163
+ if (proven > toCheckpoint) {
164
+ throw new Error(
165
+ `Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as proven checkpoint is ${proven}`,
166
+ );
160
167
  }
161
- // toBlock can't be greater than pending
162
- if (toBlock > pending) {
163
- throw new Error(`Cannot submit epoch proof for ${fromBlock}-${toBlock} as pending block is ${pending}`);
168
+ // toCheckpoint can't be greater than pending
169
+ if (toCheckpoint > pending) {
170
+ throw new Error(
171
+ `Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as pending checkpoint is ${pending}`,
172
+ );
164
173
  }
165
174
 
166
- // Check the archive for the immediate block before the epoch
167
- const blockLog = await this.rollupContract.getBlock(BigInt(fromBlock - 1));
168
- if (publicInputs.previousArchiveRoot.toString() !== blockLog.archive) {
175
+ // Check the archive for the immediate checkpoint before the epoch
176
+ const checkpointLog = await this.rollupContract.getCheckpoint(CheckpointNumber(fromCheckpoint - 1));
177
+ if (!publicInputs.previousArchiveRoot.equals(checkpointLog.archive)) {
169
178
  throw new Error(
170
- `Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${blockLog.archive}`,
179
+ `Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${checkpointLog.archive.toString()}`,
171
180
  );
172
181
  }
173
182
 
174
- // Check the archive for the last block in the epoch
175
- const endBlockLog = await this.rollupContract.getBlock(BigInt(toBlock));
176
- if (publicInputs.endArchiveRoot.toString() !== endBlockLog.archive) {
183
+ // Check the archive for the last checkpoint in the epoch
184
+ const endCheckpointLog = await this.rollupContract.getCheckpoint(toCheckpoint);
185
+ if (!publicInputs.endArchiveRoot.equals(endCheckpointLog.archive)) {
177
186
  throw new Error(
178
- `End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${endBlockLog.archive}`,
187
+ `End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${endCheckpointLog.archive.toString()}`,
179
188
  );
180
189
  }
181
190
 
@@ -193,7 +202,7 @@ export class ProverNodePublisher {
193
202
  );
194
203
  const argsPublicInputs = [...publicInputs.toFields()];
195
204
 
196
- if (!areArraysEqual(rollupPublicInputs.map(Fr.fromHexString), argsPublicInputs, (a, b) => a.equals(b))) {
205
+ if (!areArraysEqual(rollupPublicInputs, argsPublicInputs, (a, b) => a.equals(b))) {
197
206
  const fmt = (inputs: Fr[] | readonly string[]) => inputs.map(x => x.toString()).join(', ');
198
207
  throw new Error(
199
208
  `Root rollup public inputs mismatch:\nRollup: ${fmt(rollupPublicInputs)}\nComputed:${fmt(argsPublicInputs)}`,
@@ -202,8 +211,8 @@ export class ProverNodePublisher {
202
211
  }
203
212
 
204
213
  private async sendSubmitEpochProofTx(args: {
205
- fromBlock: number;
206
- toBlock: number;
214
+ fromCheckpoint: CheckpointNumber;
215
+ toCheckpoint: CheckpointNumber;
207
216
  publicInputs: RootRollupPublicInputs;
208
217
  proof: Proof;
209
218
  batchedBlobInputs: BatchedBlob;
@@ -213,8 +222,8 @@ export class ProverNodePublisher {
213
222
 
214
223
  this.log.info(`Submitting epoch proof to L1 rollup contract`, {
215
224
  proofSize: args.proof.withoutPublicInputs().length,
216
- fromBlock: args.fromBlock,
217
- toBlock: args.toBlock,
225
+ fromCheckpoint: args.fromCheckpoint,
226
+ toCheckpoint: args.toCheckpoint,
218
227
  });
219
228
  const data = encodeFunctionData({
220
229
  abi: RollupAbi,
@@ -223,53 +232,57 @@ export class ProverNodePublisher {
223
232
  });
224
233
  try {
225
234
  const { receipt } = await this.l1TxUtils.sendAndMonitorTransaction({ to: this.rollupContract.address, data });
235
+ if (receipt.status !== 'success') {
236
+ const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
237
+ data,
238
+ {
239
+ args: [...txArgs],
240
+ functionName: 'submitEpochRootProof',
241
+ abi: RollupAbi,
242
+ address: this.rollupContract.address,
243
+ },
244
+ /*blobInputs*/ undefined,
245
+ /*stateOverride*/ [],
246
+ );
247
+ this.log.error(`Rollup submit epoch proof tx reverted with ${errorMsg ?? 'unknown error'}`);
248
+ return undefined;
249
+ }
226
250
  return receipt;
227
251
  } catch (err) {
228
252
  this.log.error(`Rollup submit epoch proof failed`, err);
229
- const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
230
- data,
231
- {
232
- args: [...txArgs],
233
- functionName: 'submitEpochRootProof',
234
- abi: RollupAbi,
235
- address: this.rollupContract.address,
236
- },
237
- /*blobInputs*/ undefined,
238
- /*stateOverride*/ [],
239
- );
240
- this.log.error(`Rollup submit epoch proof tx reverted. ${errorMsg}`);
241
253
  return undefined;
242
254
  }
243
255
  }
244
256
 
245
257
  private getEpochProofPublicInputsArgs(args: {
246
- fromBlock: number;
247
- toBlock: number;
258
+ fromCheckpoint: CheckpointNumber;
259
+ toCheckpoint: CheckpointNumber;
248
260
  publicInputs: RootRollupPublicInputs;
249
261
  batchedBlobInputs: BatchedBlob;
250
262
  attestations: ViemCommitteeAttestation[];
251
263
  }) {
252
264
  // Returns arguments for EpochProofLib.sol -> getEpochProofPublicInputs()
253
265
  return [
254
- BigInt(args.fromBlock) /*_start*/,
255
- BigInt(args.toBlock) /*_end*/,
266
+ BigInt(args.fromCheckpoint) /*_start*/,
267
+ BigInt(args.toCheckpoint) /*_end*/,
256
268
  {
257
269
  previousArchive: args.publicInputs.previousArchiveRoot.toString(),
258
270
  endArchive: args.publicInputs.endArchiveRoot.toString(),
271
+ outHash: args.publicInputs.outHash.toString(),
259
272
  proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString(),
260
273
  } /*_args*/,
261
- makeTuple(AZTEC_MAX_EPOCH_DURATION * 2, i =>
274
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH * 2, i =>
262
275
  i % 2 === 0
263
276
  ? args.publicInputs.fees[i / 2].recipient.toField().toString()
264
277
  : args.publicInputs.fees[(i - 1) / 2].value.toString(),
265
278
  ) /*_fees*/,
266
- args.batchedBlobInputs.getEthBlobEvaluationInputs() /*_blobPublicInputs*/,
279
+ getEthBlobEvaluationInputs(args.batchedBlobInputs) /*_blobPublicInputs*/,
267
280
  ] as const;
268
281
  }
269
282
 
270
283
  private getSubmitEpochProofArgs(args: {
271
- fromBlock: number;
272
- toBlock: number;
284
+ fromCheckpoint: CheckpointNumber;
285
+ toCheckpoint: CheckpointNumber;
273
286
  publicInputs: RootRollupPublicInputs;
274
287
  proof: Proof;
275
288
  batchedBlobInputs: BatchedBlob;