@aztec/archiver 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +27 -6
  2. package/dest/archiver/archiver.d.ts +127 -84
  3. package/dest/archiver/archiver.d.ts.map +1 -1
  4. package/dest/archiver/archiver.js +1150 -382
  5. package/dest/archiver/archiver_store.d.ts +122 -45
  6. package/dest/archiver/archiver_store.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
  8. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  9. package/dest/archiver/archiver_store_test_suite.js +2013 -343
  10. package/dest/archiver/config.d.ts +7 -20
  11. package/dest/archiver/config.d.ts.map +1 -1
  12. package/dest/archiver/config.js +21 -5
  13. package/dest/archiver/errors.d.ts +25 -1
  14. package/dest/archiver/errors.d.ts.map +1 -1
  15. package/dest/archiver/errors.js +37 -0
  16. package/dest/archiver/index.d.ts +2 -2
  17. package/dest/archiver/index.d.ts.map +1 -1
  18. package/dest/archiver/instrumentation.d.ts +5 -3
  19. package/dest/archiver/instrumentation.d.ts.map +1 -1
  20. package/dest/archiver/instrumentation.js +14 -0
  21. package/dest/archiver/kv_archiver_store/block_store.d.ts +83 -15
  22. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  23. package/dest/archiver/kv_archiver_store/block_store.js +396 -73
  24. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -2
  25. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  26. package/dest/archiver/kv_archiver_store/contract_class_store.js +1 -1
  27. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +2 -2
  28. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  29. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +51 -55
  30. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  31. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +82 -46
  32. package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
  33. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  34. package/dest/archiver/kv_archiver_store/log_store.js +149 -84
  35. package/dest/archiver/kv_archiver_store/message_store.d.ts +6 -5
  36. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  37. package/dest/archiver/kv_archiver_store/message_store.js +15 -14
  38. package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
  39. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
  40. package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
  41. package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
  42. package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
  43. package/dest/archiver/l1/calldata_retriever.js +471 -0
  44. package/dest/archiver/l1/data_retrieval.d.ts +90 -0
  45. package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
  46. package/dest/archiver/l1/data_retrieval.js +331 -0
  47. package/dest/archiver/l1/debug_tx.d.ts +19 -0
  48. package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
  49. package/dest/archiver/l1/debug_tx.js +73 -0
  50. package/dest/archiver/l1/spire_proposer.d.ts +70 -0
  51. package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
  52. package/dest/archiver/l1/spire_proposer.js +157 -0
  53. package/dest/archiver/l1/trace_tx.d.ts +97 -0
  54. package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
  55. package/dest/archiver/l1/trace_tx.js +91 -0
  56. package/dest/archiver/l1/types.d.ts +12 -0
  57. package/dest/archiver/l1/types.d.ts.map +1 -0
  58. package/dest/archiver/l1/types.js +3 -0
  59. package/dest/archiver/l1/validate_trace.d.ts +29 -0
  60. package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
  61. package/dest/archiver/l1/validate_trace.js +150 -0
  62. package/dest/archiver/structs/data_retrieval.d.ts +1 -1
  63. package/dest/archiver/structs/inbox_message.d.ts +4 -4
  64. package/dest/archiver/structs/inbox_message.d.ts.map +1 -1
  65. package/dest/archiver/structs/inbox_message.js +6 -5
  66. package/dest/archiver/structs/published.d.ts +2 -2
  67. package/dest/archiver/structs/published.d.ts.map +1 -1
  68. package/dest/archiver/validation.d.ts +10 -4
  69. package/dest/archiver/validation.d.ts.map +1 -1
  70. package/dest/archiver/validation.js +66 -44
  71. package/dest/factory.d.ts +4 -6
  72. package/dest/factory.d.ts.map +1 -1
  73. package/dest/factory.js +5 -4
  74. package/dest/index.d.ts +2 -2
  75. package/dest/index.d.ts.map +1 -1
  76. package/dest/index.js +1 -1
  77. package/dest/rpc/index.d.ts +2 -2
  78. package/dest/test/index.d.ts +1 -1
  79. package/dest/test/mock_archiver.d.ts +16 -8
  80. package/dest/test/mock_archiver.d.ts.map +1 -1
  81. package/dest/test/mock_archiver.js +19 -14
  82. package/dest/test/mock_l1_to_l2_message_source.d.ts +7 -6
  83. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  84. package/dest/test/mock_l1_to_l2_message_source.js +10 -9
  85. package/dest/test/mock_l2_block_source.d.ts +31 -20
  86. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  87. package/dest/test/mock_l2_block_source.js +85 -18
  88. package/dest/test/mock_structs.d.ts +3 -2
  89. package/dest/test/mock_structs.d.ts.map +1 -1
  90. package/dest/test/mock_structs.js +9 -8
  91. package/package.json +18 -17
  92. package/src/archiver/archiver.ts +990 -481
  93. package/src/archiver/archiver_store.ts +141 -44
  94. package/src/archiver/archiver_store_test_suite.ts +2114 -331
  95. package/src/archiver/config.ts +30 -35
  96. package/src/archiver/errors.ts +64 -0
  97. package/src/archiver/index.ts +1 -1
  98. package/src/archiver/instrumentation.ts +19 -2
  99. package/src/archiver/kv_archiver_store/block_store.ts +541 -83
  100. package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -1
  101. package/src/archiver/kv_archiver_store/contract_instance_store.ts +1 -1
  102. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +107 -67
  103. package/src/archiver/kv_archiver_store/log_store.ts +209 -99
  104. package/src/archiver/kv_archiver_store/message_store.ts +21 -18
  105. package/src/archiver/l1/README.md +98 -0
  106. package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
  107. package/src/archiver/l1/calldata_retriever.ts +641 -0
  108. package/src/archiver/l1/data_retrieval.ts +512 -0
  109. package/src/archiver/l1/debug_tx.ts +99 -0
  110. package/src/archiver/l1/spire_proposer.ts +160 -0
  111. package/src/archiver/l1/trace_tx.ts +128 -0
  112. package/src/archiver/l1/types.ts +13 -0
  113. package/src/archiver/l1/validate_trace.ts +211 -0
  114. package/src/archiver/structs/inbox_message.ts +8 -8
  115. package/src/archiver/structs/published.ts +1 -1
  116. package/src/archiver/validation.ts +86 -32
  117. package/src/factory.ts +6 -7
  118. package/src/index.ts +1 -1
  119. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  120. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  121. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  122. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  123. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  124. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  125. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  126. package/src/test/mock_archiver.ts +22 -16
  127. package/src/test/mock_l1_to_l2_message_source.ts +10 -9
  128. package/src/test/mock_l2_block_source.ts +114 -27
  129. package/src/test/mock_structs.ts +10 -9
  130. package/dest/archiver/data_retrieval.d.ts +0 -78
  131. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  132. package/dest/archiver/data_retrieval.js +0 -354
  133. package/src/archiver/data_retrieval.ts +0 -535
@@ -1,50 +1,31 @@
1
- import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
1
+ import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
2
+ import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
3
+ import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
4
+ import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
2
5
  import {
3
- type L1ContractAddresses,
4
- type L1ContractsConfig,
5
- type L1ReaderConfig,
6
- l1ContractAddressesMapping,
7
- l1ContractsConfigMappings,
8
- l1ReaderConfigMappings,
9
- } from '@aztec/ethereum';
10
- import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
6
+ type ConfigMappingsType,
7
+ booleanConfigHelper,
8
+ getConfigFromMappings,
9
+ numberConfigHelper,
10
+ } from '@aztec/foundation/config';
11
11
  import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
12
+ import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
12
13
 
13
14
  /**
15
+ * The archiver configuration.
14
16
  * There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
15
17
  * This is the interval between successive calls to eth_blockNumber via viem.
16
18
  * Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
17
19
  * As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
18
20
  */
19
-
20
- /**
21
- * The archiver configuration.
22
- */
23
- export type ArchiverConfig = {
24
- /** The polling interval in ms for retrieving new L2 blocks and encrypted logs. */
25
- archiverPollingIntervalMS?: number;
26
-
27
- /** The number of L2 blocks the archiver will attempt to download at a time. */
28
- archiverBatchSize?: number;
29
-
30
- /** The polling interval viem uses in ms */
31
- viemPollingIntervalMS?: number;
32
-
33
- /** The deployed L1 contract addresses */
34
- l1Contracts: L1ContractAddresses;
35
-
36
- /** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
37
- maxLogs?: number;
38
-
39
- /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
40
- archiverStoreMapSizeKb?: number;
41
- } & L1ReaderConfig &
21
+ export type ArchiverConfig = ArchiverSpecificConfig &
22
+ L1ReaderConfig &
42
23
  L1ContractsConfig &
43
- BlobSinkConfig &
24
+ BlobClientConfig &
44
25
  ChainConfig;
45
26
 
46
27
  export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
47
- ...blobSinkConfigMapping,
28
+ ...blobClientConfigMapping,
48
29
  archiverPollingIntervalMS: {
49
30
  env: 'ARCHIVER_POLLING_INTERVAL_MS',
50
31
  description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
@@ -63,7 +44,21 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
63
44
  archiverStoreMapSizeKb: {
64
45
  env: 'ARCHIVER_STORE_MAP_SIZE_KB',
65
46
  parseEnv: (val: string | undefined) => (val ? +val : undefined),
66
- description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB.',
47
+ description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.',
48
+ },
49
+ skipValidateBlockAttestations: {
50
+ description: 'Whether to skip validating block attestations (use only for testing).',
51
+ ...booleanConfigHelper(false),
52
+ },
53
+ maxAllowedEthClientDriftSeconds: {
54
+ env: 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS',
55
+ description: 'Maximum allowed drift in seconds between the Ethereum client and current time.',
56
+ ...numberConfigHelper(300),
57
+ },
58
+ ethereumAllowNoDebugHosts: {
59
+ env: 'ETHEREUM_ALLOW_NO_DEBUG_HOSTS',
60
+ description: 'Whether to allow starting the archiver without debug/trace method support on Ethereum hosts',
61
+ ...booleanConfigHelper(true),
67
62
  },
68
63
  ...chainConfigMappings,
69
64
  ...l1ReaderConfigMappings,
@@ -1,3 +1,5 @@
1
+ import type { Fr } from '@aztec/foundation/schemas';
2
+
1
3
  export class NoBlobBodiesFoundError extends Error {
2
4
  constructor(l2BlockNum: number) {
3
5
  super(`No blob bodies found for block ${l2BlockNum}`);
@@ -24,3 +26,65 @@ export class BlockNumberNotSequentialError extends Error {
24
26
  );
25
27
  }
26
28
  }
29
+
30
+ export class InitialCheckpointNumberNotSequentialError extends Error {
31
+ constructor(
32
+ public readonly newCheckpointNumber: number,
33
+ public readonly previousCheckpointNumber: number | undefined,
34
+ ) {
35
+ super(
36
+ `Cannot insert new checkpoint ${newCheckpointNumber} given previous checkpoint number in store is ${
37
+ previousCheckpointNumber ?? 'undefined'
38
+ }`,
39
+ );
40
+ }
41
+ }
42
+
43
+ export class CheckpointNumberNotSequentialError extends Error {
44
+ constructor(newCheckpointNumber: number, previous: number | undefined) {
45
+ super(
46
+ `Cannot insert new checkpoint ${newCheckpointNumber} given previous checkpoint number in batch is ${previous ?? 'undefined'}`,
47
+ );
48
+ }
49
+ }
50
+
51
+ export class CheckpointNumberNotConsistentError extends Error {
52
+ constructor(newCheckpointNumber: number, previous: number | undefined) {
53
+ super(
54
+ `Cannot insert block for new checkpoint ${newCheckpointNumber} given previous block was checkpoint ${previous ?? 'undefined'}`,
55
+ );
56
+ }
57
+ }
58
+
59
+ export class BlockIndexNotSequentialError extends Error {
60
+ constructor(newBlockIndex: number, previousBlockIndex: number | undefined) {
61
+ super(
62
+ `Cannot insert new block at checkpoint index ${newBlockIndex} given previous block index is ${previousBlockIndex ?? 'undefined'}`,
63
+ );
64
+ }
65
+ }
66
+
67
+ export class BlockArchiveNotConsistentError extends Error {
68
+ constructor(
69
+ newBlockNumber: number,
70
+ previousBlockNumber: number | undefined,
71
+ newBlockArchive: Fr,
72
+ previousBlockArchive: Fr,
73
+ ) {
74
+ super(
75
+ `Cannot insert new block number ${newBlockNumber} with archive ${newBlockArchive.toString()} previous block number is ${previousBlockNumber ?? 'undefined'}, previous archive is ${previousBlockArchive?.toString() ?? 'undefined'}`,
76
+ );
77
+ }
78
+ }
79
+
80
+ export class CheckpointNotFoundError extends Error {
81
+ constructor(checkpointNumber: number) {
82
+ super(`Failed to find expected checkpoint number ${checkpointNumber}`);
83
+ }
84
+ }
85
+
86
+ export class BlockNotFoundError extends Error {
87
+ constructor(blockNumber: number) {
88
+ super(`Failed to find expected block number ${blockNumber}`);
89
+ }
90
+ }
@@ -1,6 +1,6 @@
1
1
  export * from './archiver.js';
2
2
  export * from './config.js';
3
- export { type PublishedL2Block, type L1PublishedData } from './structs/published.js';
3
+ export { type L1PublishedData } from './structs/published.js';
4
4
  export type { ArchiverDataStore } from './archiver_store.js';
5
5
  export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './kv_archiver_store/kv_archiver_store.js';
6
6
  export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
- import type { L2Block } from '@aztec/stdlib/block';
2
+ import type { L2BlockNew } from '@aztec/stdlib/block';
3
3
  import {
4
4
  Attributes,
5
5
  type Gauge,
@@ -34,6 +34,8 @@ export class ArchiverInstrumentation {
34
34
  private syncDurationPerMessage: Histogram;
35
35
  private syncMessageCount: UpDownCounter;
36
36
 
37
+ private blockProposalTxTargetCount: UpDownCounter;
38
+
37
39
  private log = createLogger('archiver:instrumentation');
38
40
 
39
41
  private constructor(
@@ -114,6 +116,11 @@ export class ArchiverInstrumentation {
114
116
  valueType: ValueType.INT,
115
117
  });
116
118
 
119
+ this.blockProposalTxTargetCount = meter.createUpDownCounter(Metrics.ARCHIVER_BLOCK_PROPOSAL_TX_TARGET_COUNT, {
120
+ description: 'Number of block proposals by tx target',
121
+ valueType: ValueType.INT,
122
+ });
123
+
117
124
  this.dbMetrics = new LmdbMetrics(
118
125
  meter,
119
126
  {
@@ -139,7 +146,7 @@ export class ArchiverInstrumentation {
139
146
  return this.telemetry.isEnabled();
140
147
  }
141
148
 
142
- public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
149
+ public processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]) {
143
150
  this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
144
151
  this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
145
152
  this.syncBlockCount.add(blocks.length);
@@ -152,6 +159,9 @@ export class ArchiverInstrumentation {
152
159
  }
153
160
 
154
161
  public processNewMessages(count: number, syncPerMessageMs: number) {
162
+ if (count === 0) {
163
+ return;
164
+ }
155
165
  this.syncMessageCount.add(count);
156
166
  this.syncDurationPerMessage.record(Math.ceil(syncPerMessageMs));
157
167
  }
@@ -181,4 +191,11 @@ export class ArchiverInstrumentation {
181
191
  public updateL1BlockHeight(blockNumber: bigint) {
182
192
  this.l1BlockHeight.record(Number(blockNumber));
183
193
  }
194
+
195
+ public recordBlockProposalTxTarget(target: string, usedTrace: boolean) {
196
+ this.blockProposalTxTargetCount.add(1, {
197
+ [Attributes.L1_BLOCK_PROPOSAL_TX_TARGET]: target.toLowerCase(),
198
+ [Attributes.L1_BLOCK_PROPOSAL_USED_TRACE]: usedTrace,
199
+ });
200
+ }
184
201
  }