@aztec/archiver 0.0.1-commit.3f296a7d2 → 0.0.1-commit.3f5453c7b

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 (71) hide show
  1. package/README.md +12 -6
  2. package/dest/archiver.d.ts +6 -4
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +11 -4
  5. package/dest/errors.d.ts +14 -2
  6. package/dest/errors.d.ts.map +1 -1
  7. package/dest/errors.js +18 -2
  8. package/dest/l1/calldata_retriever.d.ts +1 -1
  9. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  10. package/dest/l1/calldata_retriever.js +2 -1
  11. package/dest/l1/data_retrieval.d.ts +3 -3
  12. package/dest/l1/data_retrieval.d.ts.map +1 -1
  13. package/dest/l1/data_retrieval.js +14 -15
  14. package/dest/modules/data_source_base.d.ts +4 -2
  15. package/dest/modules/data_source_base.d.ts.map +1 -1
  16. package/dest/modules/data_source_base.js +6 -0
  17. package/dest/modules/data_store_updater.d.ts +3 -2
  18. package/dest/modules/data_store_updater.d.ts.map +1 -1
  19. package/dest/modules/data_store_updater.js +9 -0
  20. package/dest/modules/instrumentation.d.ts +4 -2
  21. package/dest/modules/instrumentation.d.ts.map +1 -1
  22. package/dest/modules/instrumentation.js +17 -6
  23. package/dest/modules/l1_synchronizer.d.ts +3 -2
  24. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  25. package/dest/modules/l1_synchronizer.js +131 -124
  26. package/dest/modules/validation.d.ts +1 -1
  27. package/dest/modules/validation.d.ts.map +1 -1
  28. package/dest/modules/validation.js +2 -2
  29. package/dest/store/block_store.d.ts +39 -4
  30. package/dest/store/block_store.d.ts.map +1 -1
  31. package/dest/store/block_store.js +230 -61
  32. package/dest/store/kv_archiver_store.d.ts +21 -8
  33. package/dest/store/kv_archiver_store.d.ts.map +1 -1
  34. package/dest/store/kv_archiver_store.js +25 -8
  35. package/dest/store/l2_tips_cache.d.ts +2 -1
  36. package/dest/store/l2_tips_cache.d.ts.map +1 -1
  37. package/dest/store/l2_tips_cache.js +25 -5
  38. package/dest/store/message_store.d.ts +3 -3
  39. package/dest/store/message_store.d.ts.map +1 -1
  40. package/dest/store/message_store.js +9 -10
  41. package/dest/test/fake_l1_state.d.ts +9 -1
  42. package/dest/test/fake_l1_state.d.ts.map +1 -1
  43. package/dest/test/fake_l1_state.js +41 -6
  44. package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
  45. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  46. package/dest/test/mock_l1_to_l2_message_source.js +2 -1
  47. package/dest/test/mock_l2_block_source.d.ts +7 -2
  48. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  49. package/dest/test/mock_l2_block_source.js +28 -3
  50. package/dest/test/noop_l1_archiver.d.ts +1 -1
  51. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  52. package/dest/test/noop_l1_archiver.js +0 -1
  53. package/package.json +13 -13
  54. package/src/archiver.ts +19 -9
  55. package/src/errors.ts +30 -2
  56. package/src/l1/calldata_retriever.ts +2 -1
  57. package/src/l1/data_retrieval.ts +8 -12
  58. package/src/modules/data_source_base.ts +15 -1
  59. package/src/modules/data_store_updater.ts +14 -1
  60. package/src/modules/instrumentation.ts +19 -7
  61. package/src/modules/l1_synchronizer.ts +145 -151
  62. package/src/modules/validation.ts +2 -2
  63. package/src/store/block_store.ts +300 -73
  64. package/src/store/kv_archiver_store.ts +43 -12
  65. package/src/store/l2_tips_cache.ts +50 -11
  66. package/src/store/message_store.ts +10 -12
  67. package/src/structs/inbox_message.ts +1 -1
  68. package/src/test/fake_l1_state.ts +56 -7
  69. package/src/test/mock_l1_to_l2_message_source.ts +1 -0
  70. package/src/test/mock_l2_block_source.ts +37 -2
  71. package/src/test/noop_l1_archiver.ts +0 -1
@@ -19,6 +19,7 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
19
19
  provenBlockNumber = 0;
20
20
  finalizedBlockNumber = 0;
21
21
  checkpointedBlockNumber = 0;
22
+ proposedCheckpointBlockNumber = 0;
22
23
  log = createLogger('archiver:mock_l2_block_source');
23
24
  /** Creates blocks grouped into single-block checkpoints. */ async createBlocks(numBlocks) {
24
25
  await this.createCheckpoints(numBlocks, 1);
@@ -56,6 +57,7 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
56
57
  });
57
58
  // Keep tip numbers consistent with remaining blocks.
58
59
  this.checkpointedBlockNumber = Math.min(this.checkpointedBlockNumber, maxBlockNum);
60
+ this.proposedCheckpointBlockNumber = Math.min(this.proposedCheckpointBlockNumber, maxBlockNum);
59
61
  this.provenBlockNumber = Math.min(this.provenBlockNumber, maxBlockNum);
60
62
  this.finalizedBlockNumber = Math.min(this.finalizedBlockNumber, maxBlockNum);
61
63
  this.log.verbose(`Removed ${numBlocks} blocks from the mock L2 block source`);
@@ -69,9 +71,16 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
69
71
  }
70
72
  this.finalizedBlockNumber = finalizedBlockNumber;
71
73
  }
74
+ setProposedCheckpointBlockNumber(blockNumber) {
75
+ this.proposedCheckpointBlockNumber = blockNumber;
76
+ }
72
77
  setCheckpointedBlockNumber(checkpointedBlockNumber) {
73
78
  const prevCheckpointed = this.checkpointedBlockNumber;
74
79
  this.checkpointedBlockNumber = checkpointedBlockNumber;
80
+ // Proposed checkpoint is always at least as advanced as checkpointed
81
+ if (this.proposedCheckpointBlockNumber < checkpointedBlockNumber) {
82
+ this.proposedCheckpointBlockNumber = checkpointedBlockNumber;
83
+ }
75
84
  // Auto-create single-block checkpoints for newly checkpointed blocks that don't have one yet.
76
85
  // This handles blocks added via addProposedBlocks that are now being marked as checkpointed.
77
86
  const newCheckpoints = [];
@@ -124,6 +133,9 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
124
133
  getFinalizedL2BlockNumber() {
125
134
  return Promise.resolve(BlockNumber(this.finalizedBlockNumber));
126
135
  }
136
+ getProposedCheckpointL2BlockNumber() {
137
+ return Promise.resolve(BlockNumber(this.proposedCheckpointBlockNumber));
138
+ }
127
139
  getCheckpointedBlock(number) {
128
140
  if (number > this.checkpointedBlockNumber) {
129
141
  return Promise.resolve(undefined);
@@ -315,16 +327,18 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
315
327
  return undefined;
316
328
  }
317
329
  async getL2Tips() {
318
- const [latest, proven, finalized, checkpointed] = [
330
+ const [latest, proven, finalized, checkpointed, proposedCheckpoint] = [
319
331
  await this.getBlockNumber(),
320
332
  await this.getProvenBlockNumber(),
321
333
  this.finalizedBlockNumber,
322
- this.checkpointedBlockNumber
334
+ this.checkpointedBlockNumber,
335
+ await this.getProposedCheckpointL2BlockNumber()
323
336
  ];
324
337
  const latestBlock = this.l2Blocks[latest - 1];
325
338
  const provenBlock = this.l2Blocks[proven - 1];
326
339
  const finalizedBlock = this.l2Blocks[finalized - 1];
327
340
  const checkpointedBlock = this.l2Blocks[checkpointed - 1];
341
+ const proposedCheckpointBlock = this.l2Blocks[proposedCheckpoint - 1];
328
342
  const latestBlockId = {
329
343
  number: BlockNumber(latest),
330
344
  hash: (await latestBlock?.hash())?.toString()
@@ -341,6 +355,10 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
341
355
  number: BlockNumber(checkpointed),
342
356
  hash: (await checkpointedBlock?.hash())?.toString()
343
357
  };
358
+ const proposedCheckpointBlockId = {
359
+ number: BlockNumber(proposedCheckpoint),
360
+ hash: (await proposedCheckpointBlock?.hash())?.toString()
361
+ };
344
362
  const makeTipId = (blockId)=>({
345
363
  block: blockId,
346
364
  checkpoint: {
@@ -352,7 +370,8 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
352
370
  proposed: latestBlockId,
353
371
  checkpointed: makeTipId(checkpointedBlockId),
354
372
  proven: makeTipId(provenBlockId),
355
- finalized: makeTipId(finalizedBlockId)
373
+ finalized: makeTipId(finalizedBlockId),
374
+ proposedCheckpoint: makeTipId(proposedCheckpointBlockId)
356
375
  };
357
376
  }
358
377
  getSyncedL2EpochNumber() {
@@ -418,6 +437,12 @@ import { TxExecutionResult, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
418
437
  valid: true
419
438
  });
420
439
  }
440
+ getProposedCheckpoint() {
441
+ return Promise.resolve(undefined);
442
+ }
443
+ getProposedCheckpointOnly() {
444
+ return Promise.resolve(undefined);
445
+ }
421
446
  /** Returns checkpoints whose slot falls within the given epoch. */ getCheckpointsInEpoch(epochNumber) {
422
447
  const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
423
448
  const [start, end] = getSlotRangeForEpoch(epochNumber, {
@@ -23,4 +23,4 @@ export declare class NoopL1Archiver extends Archiver {
23
23
  export declare function createNoopL1Archiver(dataStore: KVArchiverDataStore, l1Constants: L1RollupConstants & {
24
24
  genesisArchiveRoot: Fr;
25
25
  }, telemetry?: TelemetryClient): Promise<NoopL1Archiver>;
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9vcF9sMV9hcmNoaXZlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3Qvbm9vcF9sMV9hcmNoaXZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFN0QsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBSXBELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDckUsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFtQyxNQUFNLHlCQUF5QixDQUFDO0FBS2hHLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQ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","sourceRoot":"","sources":["../../src/test/noop_l1_archiver.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAmC,MAAM,yBAAyB,CAAC;AAKhG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAyBzE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,YACE,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,iBAAiB,GAAG;QAAE,kBAAkB,EAAE,EAAE,CAAA;KAAE,EAC3D,eAAe,EAAE,uBAAuB,EAuCzC;IAED,mDAAmD;IACnC,KAAK,CAAC,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhE;IAED,6EAA6E;IAC7D,qBAAqB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEvE;CACF;AAED,mEAAmE;AACnE,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,iBAAiB,GAAG;IAAE,kBAAkB,EAAE,EAAE,CAAA;CAAE,EAC3D,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,cAAc,CAAC,CAGzB"}
1
+ {"version":3,"file":"noop_l1_archiver.d.ts","sourceRoot":"","sources":["../../src/test/noop_l1_archiver.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAmC,MAAM,yBAAyB,CAAC;AAKhG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAyBzE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,YACE,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,iBAAiB,GAAG;QAAE,kBAAkB,EAAE,EAAE,CAAA;KAAE,EAC3D,eAAe,EAAE,uBAAuB,EAsCzC;IAED,mDAAmD;IACnC,KAAK,CAAC,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhE;IAED,6EAA6E;IAC7D,qBAAqB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEvE;CACF;AAED,mEAAmE;AACnE,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,iBAAiB,GAAG;IAAE,kBAAkB,EAAE,EAAE,CAAA;CAAE,EAC3D,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,cAAc,CAAC,CAGzB"}
@@ -44,7 +44,6 @@ import { ArchiverInstrumentation } from '../modules/instrumentation.js';
44
44
  super(publicClient, debugClient, rollup, {
45
45
  registryAddress: EthAddress.ZERO,
46
46
  governanceProposerAddress: EthAddress.ZERO,
47
- slashFactoryAddress: EthAddress.ZERO,
48
47
  slashingProposerAddress: EthAddress.ZERO
49
48
  }, dataStore, {
50
49
  pollingIntervalMs: 1000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/archiver",
3
- "version": "0.0.1-commit.3f296a7d2",
3
+ "version": "0.0.1-commit.3f5453c7b",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -65,18 +65,18 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@aztec/blob-client": "0.0.1-commit.3f296a7d2",
69
- "@aztec/blob-lib": "0.0.1-commit.3f296a7d2",
70
- "@aztec/constants": "0.0.1-commit.3f296a7d2",
71
- "@aztec/epoch-cache": "0.0.1-commit.3f296a7d2",
72
- "@aztec/ethereum": "0.0.1-commit.3f296a7d2",
73
- "@aztec/foundation": "0.0.1-commit.3f296a7d2",
74
- "@aztec/kv-store": "0.0.1-commit.3f296a7d2",
75
- "@aztec/l1-artifacts": "0.0.1-commit.3f296a7d2",
76
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.3f296a7d2",
77
- "@aztec/protocol-contracts": "0.0.1-commit.3f296a7d2",
78
- "@aztec/stdlib": "0.0.1-commit.3f296a7d2",
79
- "@aztec/telemetry-client": "0.0.1-commit.3f296a7d2",
68
+ "@aztec/blob-client": "0.0.1-commit.3f5453c7b",
69
+ "@aztec/blob-lib": "0.0.1-commit.3f5453c7b",
70
+ "@aztec/constants": "0.0.1-commit.3f5453c7b",
71
+ "@aztec/epoch-cache": "0.0.1-commit.3f5453c7b",
72
+ "@aztec/ethereum": "0.0.1-commit.3f5453c7b",
73
+ "@aztec/foundation": "0.0.1-commit.3f5453c7b",
74
+ "@aztec/kv-store": "0.0.1-commit.3f5453c7b",
75
+ "@aztec/l1-artifacts": "0.0.1-commit.3f5453c7b",
76
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.3f5453c7b",
77
+ "@aztec/protocol-contracts": "0.0.1-commit.3f5453c7b",
78
+ "@aztec/stdlib": "0.0.1-commit.3f5453c7b",
79
+ "@aztec/telemetry-client": "0.0.1-commit.3f5453c7b",
80
80
  "lodash.groupby": "^4.6.0",
81
81
  "lodash.omit": "^4.5.0",
82
82
  "tslib": "^2.5.0",
package/src/archiver.ts CHANGED
@@ -11,7 +11,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
11
11
  import { type Logger, createLogger } from '@aztec/foundation/log';
12
12
  import { type PromiseWithResolvers, promiseWithResolvers } from '@aztec/foundation/promise';
13
13
  import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
14
- import { DateProvider } from '@aztec/foundation/timer';
14
+ import { DateProvider, elapsed } from '@aztec/foundation/timer';
15
15
  import {
16
16
  type ArchiverEmitter,
17
17
  L2Block,
@@ -19,7 +19,7 @@ import {
19
19
  type L2Tips,
20
20
  type ValidateCheckpointResult,
21
21
  } from '@aztec/stdlib/block';
22
- import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
22
+ import { type ProposedCheckpointInput, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
23
23
  import {
24
24
  type L1RollupConstants,
25
25
  getEpochAtSlot,
@@ -85,13 +85,15 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
85
85
 
86
86
  public readonly tracer: Tracer;
87
87
 
88
+ private readonly instrumentation: ArchiverInstrumentation;
89
+
88
90
  /**
89
91
  * Creates a new instance of the Archiver.
90
92
  * @param publicClient - A client for interacting with the Ethereum node.
91
93
  * @param debugClient - A client for interacting with the Ethereum node for debug/trace methods.
92
94
  * @param rollup - Rollup contract instance.
93
95
  * @param inbox - Inbox contract instance.
94
- * @param l1Addresses - L1 contract addresses (registry, governance proposer, slash factory, slashing proposer).
96
+ * @param l1Addresses - L1 contract addresses (registry, governance proposer, slashing proposer).
95
97
  * @param dataStore - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
96
98
  * @param config - Archiver configuration options.
97
99
  * @param blobClient - Client for retrieving blob data.
@@ -104,10 +106,9 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
104
106
  private readonly publicClient: ViemPublicClient,
105
107
  private readonly debugClient: ViemPublicDebugClient,
106
108
  private readonly rollup: RollupContract,
107
- private readonly l1Addresses: Pick<
108
- L1ContractAddresses,
109
- 'registryAddress' | 'governanceProposerAddress' | 'slashFactoryAddress'
110
- > & { slashingProposerAddress: EthAddress },
109
+ private readonly l1Addresses: Pick<L1ContractAddresses, 'registryAddress' | 'governanceProposerAddress'> & {
110
+ slashingProposerAddress: EthAddress;
111
+ },
111
112
  readonly dataStore: KVArchiverDataStore,
112
113
  private config: {
113
114
  pollingIntervalMs: number;
@@ -130,6 +131,7 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
130
131
  super(dataStore, l1Constants);
131
132
 
132
133
  this.tracer = instrumentation.tracer;
134
+ this.instrumentation = instrumentation;
133
135
  this.initialSyncPromise = promiseWithResolvers();
134
136
  this.synchronizer = synchronizer;
135
137
  this.events = events;
@@ -209,6 +211,10 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
209
211
  });
210
212
  }
211
213
 
214
+ public async setProposedCheckpoint(pending: ProposedCheckpointInput): Promise<void> {
215
+ await this.updater.setProposedCheckpoint(pending);
216
+ }
217
+
212
218
  /**
213
219
  * Processes all queued blocks, adding them to the store.
214
220
  * Called at the beginning of each sync iteration.
@@ -241,7 +247,8 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
241
247
  }
242
248
 
243
249
  try {
244
- await this.updater.addProposedBlock(block);
250
+ const [durationMs] = await elapsed(() => this.updater.addProposedBlock(block));
251
+ this.instrumentation.processNewProposedBlock(durationMs, block);
245
252
  this.log.debug(`Added block ${block.number} to store`);
246
253
  resolve();
247
254
  } catch (err: any) {
@@ -486,7 +493,10 @@ export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Tra
486
493
  await this.store.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
487
494
  this.log.info(`Setting L1 syncpoints to ${targetL1BlockNumber}`);
488
495
  await this.store.setCheckpointSynchedL1BlockNumber(targetL1BlockNumber);
489
- await this.store.setMessageSynchedL1Block({ l1BlockNumber: targetL1BlockNumber, l1BlockHash: targetL1BlockHash });
496
+ await this.store.setMessageSyncState(
497
+ { l1BlockNumber: targetL1BlockNumber, l1BlockHash: targetL1BlockHash },
498
+ undefined,
499
+ );
490
500
  if (targetL2BlockNumber < currentProvenBlock) {
491
501
  this.log.info(`Rolling back proven L2 checkpoint to ${targetCheckpointNumber}`);
492
502
  await this.updater.setProvenCheckpointNumber(targetCheckpointNumber);
package/src/errors.ts CHANGED
@@ -26,9 +26,13 @@ export class InitialCheckpointNumberNotSequentialError extends Error {
26
26
  }
27
27
 
28
28
  export class CheckpointNumberNotSequentialError extends Error {
29
- constructor(newCheckpointNumber: number, previous: number | undefined) {
29
+ constructor(
30
+ newCheckpointNumber: number,
31
+ previous: number | undefined,
32
+ source: 'confirmed' | 'proposed' = 'confirmed',
33
+ ) {
30
34
  super(
31
- `Cannot insert new checkpoint ${newCheckpointNumber} given previous checkpoint number in batch is ${previous ?? 'undefined'}`,
35
+ `Cannot insert new checkpoint ${newCheckpointNumber} given previous ${source} checkpoint number is ${previous ?? 'undefined'}`,
32
36
  );
33
37
  }
34
38
  }
@@ -104,6 +108,30 @@ export class L1ToL2MessagesNotReadyError extends Error {
104
108
  }
105
109
  }
106
110
 
111
+ /** Thrown when a proposed checkpoint number is stale (already processed). */
112
+ export class ProposedCheckpointStaleError extends Error {
113
+ constructor(
114
+ public readonly proposedCheckpointNumber: number,
115
+ public readonly currentProposedNumber: number,
116
+ ) {
117
+ super(`Stale proposed checkpoint ${proposedCheckpointNumber}: current proposed is ${currentProposedNumber}`);
118
+ this.name = 'ProposedCheckpointStaleError';
119
+ }
120
+ }
121
+
122
+ /** Thrown when a proposed checkpoint number is not the expected confirmed + 1. */
123
+ export class ProposedCheckpointNotSequentialError extends Error {
124
+ constructor(
125
+ public readonly proposedCheckpointNumber: number,
126
+ public readonly confirmedCheckpointNumber: number,
127
+ ) {
128
+ super(
129
+ `Proposed checkpoint ${proposedCheckpointNumber} is not sequential: expected ${confirmedCheckpointNumber + 1} (confirmed + 1)`,
130
+ );
131
+ this.name = 'ProposedCheckpointNotSequentialError';
132
+ }
133
+ }
134
+
107
135
  /** Thrown when a proposed block conflicts with an already checkpointed block (different content). */
108
136
  export class CannotOverwriteCheckpointedBlockError extends Error {
109
137
  constructor(
@@ -1,6 +1,7 @@
1
1
  import { MULTI_CALL_3_ADDRESS, type ViemCommitteeAttestations, type ViemHeader } from '@aztec/ethereum/contracts';
2
2
  import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
3
3
  import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
+ import { LruSet } from '@aztec/foundation/collection';
4
5
  import { Fr } from '@aztec/foundation/curves/bn254';
5
6
  import { EthAddress } from '@aztec/foundation/eth-address';
6
7
  import type { Logger } from '@aztec/foundation/log';
@@ -44,7 +45,7 @@ type CheckpointData = {
44
45
  */
45
46
  export class CalldataRetriever {
46
47
  /** Tx hashes we've already logged for trace+debug failure (log once per tx per process). */
47
- private static readonly traceFailureWarnedTxHashes = new Set<string>();
48
+ private static readonly traceFailureWarnedTxHashes = new LruSet<string>(1000);
48
49
 
49
50
  /** Clears the trace-failure warned set. For testing only. */
50
51
  static resetTraceFailureWarnedForTesting(): void {
@@ -144,7 +144,7 @@ export async function retrievedToPublishedCheckpoint({
144
144
  * @param blobClient - The blob client client for fetching blob data.
145
145
  * @param searchStartBlock - The block number to use for starting the search.
146
146
  * @param searchEndBlock - The highest block number that we should search up to.
147
- * @param contractAddresses - The contract addresses (governanceProposerAddress, slashFactoryAddress, slashingProposerAddress).
147
+ * @param contractAddresses - The contract addresses (governanceProposerAddress, slashingProposerAddress).
148
148
  * @param instrumentation - The archiver instrumentation instance.
149
149
  * @param logger - The logger instance.
150
150
  * @param isHistoricalSync - Whether this is a historical sync.
@@ -344,14 +344,10 @@ export async function getCheckpointBlobDataFromBlobs(
344
344
  /** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
345
345
  export async function retrieveL1ToL2Message(
346
346
  inbox: InboxContract,
347
- leaf: Fr,
348
- fromBlock: bigint,
349
- toBlock: bigint,
347
+ message: InboxMessage,
350
348
  ): Promise<InboxMessage | undefined> {
351
- const logs = await inbox.getMessageSentEventByHash(leaf.toString(), fromBlock, toBlock);
352
-
353
- const messages = mapLogsInboxMessage(logs);
354
- return messages.length > 0 ? messages[0] : undefined;
349
+ const log = await inbox.getMessageSentEventByHash(message.leaf.toString(), message.l1BlockHash.toString());
350
+ return log && mapLogInboxMessage(log);
355
351
  }
356
352
 
357
353
  /**
@@ -374,22 +370,22 @@ export async function retrieveL1ToL2Messages(
374
370
  break;
375
371
  }
376
372
 
377
- retrievedL1ToL2Messages.push(...mapLogsInboxMessage(messageSentLogs));
373
+ retrievedL1ToL2Messages.push(...messageSentLogs.map(mapLogInboxMessage));
378
374
  searchStartBlock = messageSentLogs.at(-1)!.l1BlockNumber + 1n;
379
375
  }
380
376
 
381
377
  return retrievedL1ToL2Messages;
382
378
  }
383
379
 
384
- function mapLogsInboxMessage(logs: MessageSentLog[]): InboxMessage[] {
385
- return logs.map(log => ({
380
+ function mapLogInboxMessage(log: MessageSentLog): InboxMessage {
381
+ return {
386
382
  index: log.args.index,
387
383
  leaf: log.args.leaf,
388
384
  l1BlockNumber: log.l1BlockNumber,
389
385
  l1BlockHash: log.l1BlockHash,
390
386
  checkpointNumber: log.args.checkpointNumber,
391
387
  rollingHash: log.args.rollingHash,
392
- }));
388
+ };
393
389
  }
394
390
 
395
391
  /** Retrieves L2ProofVerified events from the rollup contract. */
@@ -6,7 +6,13 @@ import { isDefined } from '@aztec/foundation/types';
6
6
  import type { FunctionSelector } from '@aztec/stdlib/abi';
7
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
8
8
  import { type BlockData, type BlockHash, CheckpointedL2Block, L2Block, type L2Tips } from '@aztec/stdlib/block';
9
- import { Checkpoint, type CheckpointData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
+ import {
10
+ Checkpoint,
11
+ type CheckpointData,
12
+ type CommonCheckpointData,
13
+ type ProposedCheckpointData,
14
+ PublishedCheckpoint,
15
+ } from '@aztec/stdlib/checkpoint';
10
16
  import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
11
17
  import { type L1RollupConstants, getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
12
18
  import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
@@ -157,6 +163,14 @@ export abstract class ArchiverDataSourceBase
157
163
  return this.store.getSettledTxReceipt(txHash, this.l1Constants);
158
164
  }
159
165
 
166
+ public getProposedCheckpoint(): Promise<CommonCheckpointData | undefined> {
167
+ return this.store.getProposedCheckpoint();
168
+ }
169
+
170
+ public getProposedCheckpointOnly(): Promise<ProposedCheckpointData | undefined> {
171
+ return this.store.getProposedCheckpointOnly();
172
+ }
173
+
160
174
  public isPendingChainInvalid(): Promise<boolean> {
161
175
  return this.getPendingChainValidationStatus().then(status => !status.valid);
162
176
  }
@@ -7,7 +7,7 @@ import {
7
7
  ContractInstanceUpdatedEvent,
8
8
  } from '@aztec/protocol-contracts/instance-registry';
9
9
  import type { L2Block, ValidateCheckpointResult } from '@aztec/stdlib/block';
10
- import { type PublishedCheckpoint, validateCheckpoint } from '@aztec/stdlib/checkpoint';
10
+ import { type ProposedCheckpointInput, type PublishedCheckpoint, validateCheckpoint } from '@aztec/stdlib/checkpoint';
11
11
  import {
12
12
  type ContractClassPublicWithCommitment,
13
13
  computeContractAddressFromInstance,
@@ -118,6 +118,15 @@ export class ArchiverDataStoreUpdater {
118
118
  return result;
119
119
  }
120
120
 
121
+ public async setProposedCheckpoint(proposedCheckpoint: ProposedCheckpointInput) {
122
+ const result = await this.store.transactionAsync(async () => {
123
+ await this.store.setProposedCheckpoint(proposedCheckpoint);
124
+ await this.l2TipsCache?.refresh();
125
+ });
126
+
127
+ return result;
128
+ }
129
+
121
130
  /**
122
131
  * Checks for local proposed blocks that do not match the ones to be checkpointed and prunes them.
123
132
  * This method handles multiple checkpoints but returns after pruning the first conflict found.
@@ -211,6 +220,10 @@ export class ArchiverDataStoreUpdater {
211
220
  }
212
221
 
213
222
  const result = await this.removeBlocksAfter(blockNumber);
223
+
224
+ // Clear the proposed checkpoint if it exists, since its blocks have been pruned
225
+ await this.store.deleteProposedCheckpoint();
226
+
214
227
  await this.l2TipsCache?.refresh();
215
228
  return result;
216
229
  });
@@ -32,6 +32,7 @@ export class ArchiverInstrumentation {
32
32
  private pruneCount: UpDownCounter;
33
33
 
34
34
  private syncDurationPerBlock: Histogram;
35
+ private syncDurationPerCheckpoint: Histogram;
35
36
  private syncBlockCount: UpDownCounter;
36
37
  private manaPerBlock: Histogram;
37
38
  private txsPerBlock: Histogram;
@@ -68,6 +69,8 @@ export class ArchiverInstrumentation {
68
69
 
69
70
  this.syncDurationPerBlock = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_BLOCK);
70
71
 
72
+ this.syncDurationPerCheckpoint = meter.createHistogram(Metrics.ARCHIVER_SYNC_PER_CHECKPOINT);
73
+
71
74
  this.syncBlockCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_SYNC_BLOCK_COUNT);
72
75
 
73
76
  this.manaPerBlock = meter.createHistogram(Metrics.ARCHIVER_MANA_PER_BLOCK);
@@ -113,17 +116,26 @@ export class ArchiverInstrumentation {
113
116
  return this.telemetry.isEnabled();
114
117
  }
115
118
 
116
- public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
119
+ public processNewProposedBlock(syncTimePerBlock: number, block: L2Block) {
120
+ const attrs = { [Attributes.STATUS]: 'proposed' };
121
+ this.blockHeight.record(block.number, attrs);
117
122
  this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
123
+
124
+ // Per block metrics
125
+ this.txCount.add(block.body.txEffects.length);
126
+ this.txsPerBlock.record(block.body.txEffects.length);
127
+ this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
128
+ }
129
+
130
+ public processNewCheckpointedBlocks(syncTimePerCheckpoint: number, blocks: L2Block[]) {
131
+ if (blocks.length === 0) {
132
+ return;
133
+ }
134
+
135
+ this.syncDurationPerCheckpoint.record(Math.ceil(syncTimePerCheckpoint));
118
136
  this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
119
137
  this.checkpointHeight.record(Math.max(...blocks.map(b => b.checkpointNumber)));
120
138
  this.syncBlockCount.add(blocks.length);
121
-
122
- for (const block of blocks) {
123
- this.txCount.add(block.body.txEffects.length);
124
- this.txsPerBlock.record(block.body.txEffects.length);
125
- this.manaPerBlock.record(block.header.totalManaUsed.toNumber() / 1e6);
126
- }
127
139
  }
128
140
 
129
141
  public processNewMessages(count: number, syncPerMessageMs: number) {