@aztec/archiver 0.0.1-commit.96bb3f7 → 0.0.1-commit.96dac018d

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 (199) hide show
  1. package/README.md +156 -22
  2. package/dest/archiver.d.ts +139 -0
  3. package/dest/archiver.d.ts.map +1 -0
  4. package/dest/archiver.js +699 -0
  5. package/dest/{archiver/config.d.ts → config.d.ts} +9 -1
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/{archiver/config.js → config.js} +9 -0
  8. package/dest/errors.d.ts +41 -0
  9. package/dest/errors.d.ts.map +1 -0
  10. package/dest/{archiver/errors.js → errors.js} +8 -0
  11. package/dest/factory.d.ts +9 -7
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +91 -11
  14. package/dest/index.d.ts +11 -4
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +9 -3
  17. package/dest/interfaces.d.ts +9 -0
  18. package/dest/interfaces.d.ts.map +1 -0
  19. package/dest/interfaces.js +3 -0
  20. package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
  21. package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
  22. package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +35 -32
  23. package/dest/l1/calldata_retriever.d.ts +135 -0
  24. package/dest/l1/calldata_retriever.d.ts.map +1 -0
  25. package/dest/l1/calldata_retriever.js +402 -0
  26. package/dest/l1/data_retrieval.d.ts +85 -0
  27. package/dest/l1/data_retrieval.d.ts.map +1 -0
  28. package/dest/{archiver/l1 → l1}/data_retrieval.js +43 -66
  29. package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
  30. package/dest/l1/debug_tx.d.ts.map +1 -0
  31. package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +5 -5
  32. package/dest/l1/spire_proposer.d.ts.map +1 -0
  33. package/dest/{archiver/l1 → l1}/spire_proposer.js +9 -17
  34. package/dest/{archiver/l1 → l1}/trace_tx.d.ts +1 -1
  35. package/dest/l1/trace_tx.d.ts.map +1 -0
  36. package/dest/l1/types.d.ts +12 -0
  37. package/dest/l1/types.d.ts.map +1 -0
  38. package/dest/{archiver/l1 → l1}/validate_trace.d.ts +6 -3
  39. package/dest/l1/validate_trace.d.ts.map +1 -0
  40. package/dest/{archiver/l1 → l1}/validate_trace.js +13 -9
  41. package/dest/modules/data_source_base.d.ts +89 -0
  42. package/dest/modules/data_source_base.d.ts.map +1 -0
  43. package/dest/modules/data_source_base.js +216 -0
  44. package/dest/modules/data_store_updater.d.ts +80 -0
  45. package/dest/modules/data_store_updater.d.ts.map +1 -0
  46. package/dest/modules/data_store_updater.js +323 -0
  47. package/dest/modules/instrumentation.d.ts +50 -0
  48. package/dest/modules/instrumentation.d.ts.map +1 -0
  49. package/dest/{archiver → modules}/instrumentation.js +36 -12
  50. package/dest/modules/l1_synchronizer.d.ts +71 -0
  51. package/dest/modules/l1_synchronizer.d.ts.map +1 -0
  52. package/dest/modules/l1_synchronizer.js +1117 -0
  53. package/dest/{archiver → modules}/validation.d.ts +1 -1
  54. package/dest/modules/validation.d.ts.map +1 -0
  55. package/dest/{archiver → modules}/validation.js +6 -0
  56. package/dest/store/block_store.d.ts +196 -0
  57. package/dest/store/block_store.d.ts.map +1 -0
  58. package/dest/{archiver/kv_archiver_store → store}/block_store.js +207 -60
  59. package/dest/store/contract_class_store.d.ts +18 -0
  60. package/dest/store/contract_class_store.d.ts.map +1 -0
  61. package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +12 -8
  62. package/dest/store/contract_instance_store.d.ts +24 -0
  63. package/dest/store/contract_instance_store.d.ts.map +1 -0
  64. package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +1 -1
  65. package/dest/store/kv_archiver_store.d.ts +354 -0
  66. package/dest/store/kv_archiver_store.d.ts.map +1 -0
  67. package/dest/store/kv_archiver_store.js +464 -0
  68. package/dest/store/l2_tips_cache.d.ts +19 -0
  69. package/dest/store/l2_tips_cache.d.ts.map +1 -0
  70. package/dest/store/l2_tips_cache.js +89 -0
  71. package/dest/store/log_store.d.ts +54 -0
  72. package/dest/store/log_store.d.ts.map +1 -0
  73. package/dest/{archiver/kv_archiver_store → store}/log_store.js +146 -91
  74. package/dest/{archiver/kv_archiver_store → store}/message_store.d.ts +1 -1
  75. package/dest/store/message_store.d.ts.map +1 -0
  76. package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
  77. package/dest/structs/data_retrieval.d.ts.map +1 -0
  78. package/dest/structs/inbox_message.d.ts +15 -0
  79. package/dest/structs/inbox_message.d.ts.map +1 -0
  80. package/dest/{archiver/structs → structs}/published.d.ts +1 -1
  81. package/dest/structs/published.d.ts.map +1 -0
  82. package/dest/test/fake_l1_state.d.ts +195 -0
  83. package/dest/test/fake_l1_state.d.ts.map +1 -0
  84. package/dest/test/fake_l1_state.js +421 -0
  85. package/dest/test/index.d.ts +2 -1
  86. package/dest/test/index.d.ts.map +1 -1
  87. package/dest/test/index.js +4 -1
  88. package/dest/test/mock_archiver.d.ts +2 -2
  89. package/dest/test/mock_archiver.d.ts.map +1 -1
  90. package/dest/test/mock_archiver.js +3 -3
  91. package/dest/test/mock_l2_block_source.d.ts +35 -17
  92. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  93. package/dest/test/mock_l2_block_source.js +177 -74
  94. package/dest/test/mock_structs.d.ts +78 -3
  95. package/dest/test/mock_structs.d.ts.map +1 -1
  96. package/dest/test/mock_structs.js +140 -7
  97. package/dest/test/noop_l1_archiver.d.ts +23 -0
  98. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  99. package/dest/test/noop_l1_archiver.js +68 -0
  100. package/package.json +16 -17
  101. package/src/archiver.ts +443 -0
  102. package/src/{archiver/config.ts → config.ts} +11 -0
  103. package/src/{archiver/errors.ts → errors.ts} +12 -0
  104. package/src/factory.ts +139 -11
  105. package/src/index.ts +11 -3
  106. package/src/interfaces.ts +9 -0
  107. package/src/l1/README.md +55 -0
  108. package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +45 -33
  109. package/src/l1/calldata_retriever.ts +511 -0
  110. package/src/{archiver/l1 → l1}/data_retrieval.ts +61 -88
  111. package/src/{archiver/l1 → l1}/spire_proposer.ts +7 -15
  112. package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
  113. package/src/modules/data_source_base.ts +328 -0
  114. package/src/modules/data_store_updater.ts +448 -0
  115. package/src/{archiver → modules}/instrumentation.ts +46 -14
  116. package/src/modules/l1_synchronizer.ts +933 -0
  117. package/src/{archiver → modules}/validation.ts +5 -0
  118. package/src/{archiver/kv_archiver_store → store}/block_store.ts +258 -93
  119. package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +12 -8
  120. package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +1 -1
  121. package/src/{archiver/kv_archiver_store → store}/kv_archiver_store.ts +267 -38
  122. package/src/store/l2_tips_cache.ts +89 -0
  123. package/src/{archiver/kv_archiver_store → store}/log_store.ts +242 -121
  124. package/src/test/fake_l1_state.ts +657 -0
  125. package/src/test/index.ts +4 -0
  126. package/src/test/mock_archiver.ts +4 -3
  127. package/src/test/mock_l2_block_source.ts +218 -90
  128. package/src/test/mock_structs.ts +269 -8
  129. package/src/test/noop_l1_archiver.ts +109 -0
  130. package/dest/archiver/archiver.d.ts +0 -307
  131. package/dest/archiver/archiver.d.ts.map +0 -1
  132. package/dest/archiver/archiver.js +0 -2102
  133. package/dest/archiver/archiver_store.d.ts +0 -315
  134. package/dest/archiver/archiver_store.d.ts.map +0 -1
  135. package/dest/archiver/archiver_store.js +0 -4
  136. package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
  137. package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
  138. package/dest/archiver/archiver_store_test_suite.js +0 -2770
  139. package/dest/archiver/config.d.ts.map +0 -1
  140. package/dest/archiver/errors.d.ts +0 -36
  141. package/dest/archiver/errors.d.ts.map +0 -1
  142. package/dest/archiver/index.d.ts +0 -7
  143. package/dest/archiver/index.d.ts.map +0 -1
  144. package/dest/archiver/index.js +0 -4
  145. package/dest/archiver/instrumentation.d.ts +0 -37
  146. package/dest/archiver/instrumentation.d.ts.map +0 -1
  147. package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -164
  148. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
  149. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
  150. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
  151. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
  152. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
  153. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
  154. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
  155. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -316
  156. package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -45
  157. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
  158. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
  159. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
  160. package/dest/archiver/l1/calldata_retriever.d.ts +0 -112
  161. package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
  162. package/dest/archiver/l1/calldata_retriever.js +0 -471
  163. package/dest/archiver/l1/data_retrieval.d.ts +0 -90
  164. package/dest/archiver/l1/data_retrieval.d.ts.map +0 -1
  165. package/dest/archiver/l1/debug_tx.d.ts.map +0 -1
  166. package/dest/archiver/l1/spire_proposer.d.ts.map +0 -1
  167. package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
  168. package/dest/archiver/l1/types.d.ts +0 -12
  169. package/dest/archiver/l1/types.d.ts.map +0 -1
  170. package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
  171. package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
  172. package/dest/archiver/structs/inbox_message.d.ts +0 -15
  173. package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
  174. package/dest/archiver/structs/published.d.ts.map +0 -1
  175. package/dest/archiver/validation.d.ts.map +0 -1
  176. package/dest/rpc/index.d.ts +0 -9
  177. package/dest/rpc/index.d.ts.map +0 -1
  178. package/dest/rpc/index.js +0 -15
  179. package/src/archiver/archiver.ts +0 -2265
  180. package/src/archiver/archiver_store.ts +0 -380
  181. package/src/archiver/archiver_store_test_suite.ts +0 -2842
  182. package/src/archiver/index.ts +0 -6
  183. package/src/archiver/l1/README.md +0 -98
  184. package/src/archiver/l1/calldata_retriever.ts +0 -641
  185. package/src/rpc/index.ts +0 -16
  186. /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
  187. /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
  188. /package/dest/{archiver/l1 → l1}/types.js +0 -0
  189. /package/dest/{archiver/kv_archiver_store → store}/message_store.js +0 -0
  190. /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
  191. /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
  192. /package/dest/{archiver/structs → structs}/published.js +0 -0
  193. /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
  194. /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
  195. /package/src/{archiver/l1 → l1}/types.ts +0 -0
  196. /package/src/{archiver/kv_archiver_store → store}/message_store.ts +0 -0
  197. /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
  198. /package/src/{archiver/structs → structs}/inbox_message.ts +0 -0
  199. /package/src/{archiver/structs → structs}/published.ts +0 -0
@@ -6,33 +6,31 @@ import {
6
6
  decodeCheckpointBlobDataFromBlobs,
7
7
  encodeBlockBlobData,
8
8
  } from '@aztec/blob-lib';
9
- import type { EpochProofPublicInputArgs } from '@aztec/ethereum/contracts';
10
- import type { ViemClient, ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
9
+ import type {
10
+ CheckpointProposedLog,
11
+ EpochProofPublicInputArgs,
12
+ InboxContract,
13
+ MessageSentLog,
14
+ RollupContract,
15
+ } from '@aztec/ethereum/contracts';
16
+ import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
11
17
  import { asyncPool } from '@aztec/foundation/async-pool';
12
- import { CheckpointNumber } from '@aztec/foundation/branded-types';
13
- import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
18
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
14
19
  import { Fr } from '@aztec/foundation/curves/bn254';
15
20
  import { EthAddress } from '@aztec/foundation/eth-address';
16
21
  import { type Logger, createLogger } from '@aztec/foundation/log';
17
- import { type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
18
- import { Body, CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
22
+ import { RollupAbi } from '@aztec/l1-artifacts';
23
+ import { Body, CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
19
24
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
20
25
  import { Proof } from '@aztec/stdlib/proofs';
21
26
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
22
27
  import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
23
28
  import { BlockHeader, GlobalVariables, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
24
29
 
25
- import {
26
- type GetContractEventsReturnType,
27
- type GetContractReturnType,
28
- type Hex,
29
- decodeFunctionData,
30
- getAbiItem,
31
- hexToBytes,
32
- } from 'viem';
30
+ import { type Hex, decodeFunctionData, getAbiItem, hexToBytes } from 'viem';
33
31
 
34
32
  import { NoBlobBodiesFoundError } from '../errors.js';
35
- import type { ArchiverInstrumentation } from '../instrumentation.js';
33
+ import type { ArchiverInstrumentation } from '../modules/instrumentation.js';
36
34
  import type { DataRetrieval } from '../structs/data_retrieval.js';
37
35
  import type { InboxMessage } from '../structs/inbox_message.js';
38
36
  import { CalldataRetriever } from './calldata_retriever.js';
@@ -40,6 +38,7 @@ import { CalldataRetriever } from './calldata_retriever.js';
40
38
  export type RetrievedCheckpoint = {
41
39
  checkpointNumber: CheckpointNumber;
42
40
  archiveRoot: Fr;
41
+ feeAssetPriceModifier: bigint;
43
42
  header: CheckpointHeader;
44
43
  checkpointBlobData: CheckpointBlobData;
45
44
  l1: L1PublishedData;
@@ -51,6 +50,7 @@ export type RetrievedCheckpoint = {
51
50
  export async function retrievedToPublishedCheckpoint({
52
51
  checkpointNumber,
53
52
  archiveRoot,
53
+ feeAssetPriceModifier,
54
54
  header: checkpointHeader,
55
55
  checkpointBlobData,
56
56
  l1,
@@ -71,7 +71,7 @@ export async function retrievedToPublishedCheckpoint({
71
71
  const l1toL2MessageTreeRoot = blocksBlobData[0].l1ToL2MessageRoot!;
72
72
 
73
73
  const spongeBlob = SpongeBlob.init();
74
- const l2Blocks: L2BlockNew[] = [];
74
+ const l2Blocks: L2Block[] = [];
75
75
  for (let i = 0; i < blocksBlobData.length; i++) {
76
76
  const blockBlobData = blocksBlobData[i];
77
77
  const { blockEndMarker, blockEndStateField, lastArchiveRoot, noteHashRoot, nullifierRoot, publicDataRoot } =
@@ -102,7 +102,7 @@ export async function retrievedToPublishedCheckpoint({
102
102
  }),
103
103
  });
104
104
 
105
- const body = Body.fromTxBlobData(checkpointBlobData.blocks[0].txs);
105
+ const body = Body.fromTxBlobData(blockBlobData.txs);
106
106
 
107
107
  const blobFields = encodeBlockBlobData(blockBlobData);
108
108
  await spongeBlob.absorb(blobFields);
@@ -121,7 +121,7 @@ export async function retrievedToPublishedCheckpoint({
121
121
 
122
122
  const newArchive = new AppendOnlyTreeSnapshot(newArchiveRoots[i], l2BlockNumber + 1);
123
123
 
124
- l2Blocks.push(new L2BlockNew(newArchive, header, body, checkpointNumber, i));
124
+ l2Blocks.push(new L2Block(newArchive, header, body, checkpointNumber, IndexWithinCheckpoint(i)));
125
125
  }
126
126
 
127
127
  const lastBlock = l2Blocks.at(-1)!;
@@ -130,6 +130,7 @@ export async function retrievedToPublishedCheckpoint({
130
130
  header: checkpointHeader,
131
131
  blocks: l2Blocks,
132
132
  number: checkpointNumber,
133
+ feeAssetPriceModifier: feeAssetPriceModifier,
133
134
  });
134
135
 
135
136
  return PublishedCheckpoint.from({ checkpoint, l1, attestations });
@@ -137,7 +138,7 @@ export async function retrievedToPublishedCheckpoint({
137
138
 
138
139
  /**
139
140
  * Fetches new checkpoints.
140
- * @param rollup - The rollup contract instance.
141
+ * @param rollup - The rollup contract wrapper.
141
142
  * @param publicClient - The viem public client to use for transaction retrieval.
142
143
  * @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
143
144
  * @param blobClient - The blob client client for fetching blob data.
@@ -150,17 +151,12 @@ export async function retrievedToPublishedCheckpoint({
150
151
  * @returns An array of retrieved checkpoints.
151
152
  */
152
153
  export async function retrieveCheckpointsFromRollup(
153
- rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>,
154
+ rollup: RollupContract,
154
155
  publicClient: ViemPublicClient,
155
156
  debugClient: ViemPublicDebugClient,
156
157
  blobClient: BlobClientInterface,
157
158
  searchStartBlock: bigint,
158
159
  searchEndBlock: bigint,
159
- contractAddresses: {
160
- governanceProposerAddress: EthAddress;
161
- slashFactoryAddress?: EthAddress;
162
- slashingProposerAddress: EthAddress;
163
- },
164
160
  instrumentation: ArchiverInstrumentation,
165
161
  logger: Logger = createLogger('archiver'),
166
162
  isHistoricalSync: boolean = false,
@@ -173,15 +169,7 @@ export async function retrieveCheckpointsFromRollup(
173
169
  if (searchStartBlock > searchEndBlock) {
174
170
  break;
175
171
  }
176
- const checkpointProposedLogs = (
177
- await rollup.getEvents.CheckpointProposed(
178
- {},
179
- {
180
- fromBlock: searchStartBlock,
181
- toBlock: searchEndBlock,
182
- },
183
- )
184
- ).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);
172
+ const checkpointProposedLogs = await rollup.getCheckpointProposedEvents(searchStartBlock, searchEndBlock);
185
173
 
186
174
  if (checkpointProposedLogs.length === 0) {
187
175
  break;
@@ -189,19 +177,19 @@ export async function retrieveCheckpointsFromRollup(
189
177
 
190
178
  const lastLog = checkpointProposedLogs.at(-1)!;
191
179
  logger.debug(
192
- `Got ${checkpointProposedLogs.length} processed logs for checkpoints ${checkpointProposedLogs[0].args.checkpointNumber}-${lastLog.args.checkpointNumber} between L1 blocks ${searchStartBlock}-${searchEndBlock}`,
180
+ `Got ${checkpointProposedLogs.length} processed logs for checkpoints ${checkpointProposedLogs[0].args.checkpointNumber}-${lastLog.args.checkpointNumber} between L1 blocks ${searchStartBlock}-${searchEndBlock}`,
193
181
  );
194
182
 
195
183
  if (rollupConstants === undefined) {
196
184
  const [chainId, version, targetCommitteeSize] = await Promise.all([
197
185
  publicClient.getChainId(),
198
- rollup.read.getVersion(),
199
- rollup.read.getTargetCommitteeSize(),
186
+ rollup.getVersion(),
187
+ rollup.getTargetCommitteeSize(),
200
188
  ]);
201
189
  rollupConstants = {
202
190
  chainId: new Fr(chainId),
203
191
  version: new Fr(version),
204
- targetCommitteeSize: Number(targetCommitteeSize),
192
+ targetCommitteeSize,
205
193
  };
206
194
  }
207
195
 
@@ -212,13 +200,12 @@ export async function retrieveCheckpointsFromRollup(
212
200
  blobClient,
213
201
  checkpointProposedLogs,
214
202
  rollupConstants,
215
- contractAddresses,
216
203
  instrumentation,
217
204
  logger,
218
205
  isHistoricalSync,
219
206
  );
220
207
  retrievedCheckpoints.push(...newCheckpoints);
221
- searchStartBlock = lastLog.blockNumber! + 1n;
208
+ searchStartBlock = lastLog.l1BlockNumber + 1n;
222
209
  } while (searchStartBlock <= searchEndBlock);
223
210
 
224
211
  // The asyncPool from processCheckpointProposedLogs will not necessarily return the checkpoints in order, so we sort them before returning.
@@ -227,30 +214,24 @@ export async function retrieveCheckpointsFromRollup(
227
214
 
228
215
  /**
229
216
  * Processes newly received CheckpointProposed logs.
230
- * @param rollup - The rollup contract instance.
217
+ * @param rollup - The rollup contract wrapper.
231
218
  * @param publicClient - The viem public client to use for transaction retrieval.
232
219
  * @param debugClient - The viem debug client to use for trace/debug RPC methods (optional).
233
220
  * @param blobClient - The blob client client for fetching blob data.
234
221
  * @param logs - CheckpointProposed logs.
235
222
  * @param rollupConstants - The rollup constants (chainId, version, targetCommitteeSize).
236
- * @param contractAddresses - The contract addresses (governanceProposerAddress, slashFactoryAddress, slashingProposerAddress).
237
223
  * @param instrumentation - The archiver instrumentation instance.
238
224
  * @param logger - The logger instance.
239
225
  * @param isHistoricalSync - Whether this is a historical sync.
240
226
  * @returns An array of retrieved checkpoints.
241
227
  */
242
228
  async function processCheckpointProposedLogs(
243
- rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>,
229
+ rollup: RollupContract,
244
230
  publicClient: ViemPublicClient,
245
231
  debugClient: ViemPublicDebugClient,
246
232
  blobClient: BlobClientInterface,
247
- logs: GetContractEventsReturnType<typeof RollupAbi, 'CheckpointProposed'>,
233
+ logs: CheckpointProposedLog[],
248
234
  { chainId, version, targetCommitteeSize }: { chainId: Fr; version: Fr; targetCommitteeSize: number },
249
- contractAddresses: {
250
- governanceProposerAddress: EthAddress;
251
- slashFactoryAddress?: EthAddress;
252
- slashingProposerAddress: EthAddress;
253
- },
254
235
  instrumentation: ArchiverInstrumentation,
255
236
  logger: Logger,
256
237
  isHistoricalSync: boolean,
@@ -262,25 +243,24 @@ async function processCheckpointProposedLogs(
262
243
  targetCommitteeSize,
263
244
  instrumentation,
264
245
  logger,
265
- { ...contractAddresses, rollupAddress: EthAddress.fromString(rollup.address) },
246
+ EthAddress.fromString(rollup.address),
266
247
  );
267
248
 
268
249
  await asyncPool(10, logs, async log => {
269
- const checkpointNumber = CheckpointNumber.fromBigInt(log.args.checkpointNumber!);
270
- const archive = log.args.archive!;
271
- const archiveFromChain = await rollup.read.archiveAt([BigInt(checkpointNumber)]);
272
- const blobHashes = log.args.versionedBlobHashes!.map(blobHash => Buffer.from(blobHash.slice(2), 'hex'));
250
+ const checkpointNumber = log.args.checkpointNumber;
251
+ const archive = log.args.archive;
252
+ const archiveFromChain = await rollup.archiveAt(checkpointNumber);
253
+ const blobHashes = log.args.versionedBlobHashes;
273
254
 
274
255
  // The value from the event and contract will match only if the checkpoint is in the chain.
275
- if (archive === archiveFromChain) {
276
- // Build expected hashes object (fields may be undefined for backwards compatibility with older events)
256
+ if (archive.equals(archiveFromChain)) {
277
257
  const expectedHashes = {
278
- attestationsHash: log.args.attestationsHash,
279
- payloadDigest: log.args.payloadDigest,
258
+ attestationsHash: log.args.attestationsHash.toString() as Hex,
259
+ payloadDigest: log.args.payloadDigest.toString() as Hex,
280
260
  };
281
261
 
282
262
  const checkpoint = await calldataRetriever.getCheckpointFromRollupTx(
283
- log.transactionHash!,
263
+ log.l1TransactionHash,
284
264
  blobHashes,
285
265
  checkpointNumber,
286
266
  expectedHashes,
@@ -295,22 +275,22 @@ async function processCheckpointProposedLogs(
295
275
  );
296
276
 
297
277
  const l1 = new L1PublishedData(
298
- log.blockNumber,
299
- await getL1BlockTime(publicClient, log.blockNumber),
300
- log.blockHash,
278
+ log.l1BlockNumber,
279
+ await getL1BlockTime(publicClient, log.l1BlockNumber),
280
+ log.l1BlockHash.toString(),
301
281
  );
302
282
 
303
283
  retrievedCheckpoints.push({ ...checkpoint, checkpointBlobData, l1, chainId, version });
304
- logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.transactionHash}`, {
305
- l1BlockNumber: log.blockNumber,
284
+ logger.trace(`Retrieved checkpoint ${checkpointNumber} from L1 tx ${log.l1TransactionHash}`, {
285
+ l1BlockNumber: log.l1BlockNumber,
306
286
  checkpointNumber,
307
287
  archive: archive.toString(),
308
288
  attestations: checkpoint.attestations,
309
289
  });
310
290
  } else {
311
291
  logger.warn(`Ignoring checkpoint ${checkpointNumber} due to archive root mismatch`, {
312
- actual: archive,
313
- expected: archiveFromChain,
292
+ actual: archive.toString(),
293
+ expected: archiveFromChain.toString(),
314
294
  });
315
295
  }
316
296
  });
@@ -355,12 +335,12 @@ export async function getCheckpointBlobDataFromBlobs(
355
335
 
356
336
  /** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
357
337
  export async function retrieveL1ToL2Message(
358
- inbox: GetContractReturnType<typeof InboxAbi, ViemClient>,
338
+ inbox: InboxContract,
359
339
  leaf: Fr,
360
340
  fromBlock: bigint,
361
341
  toBlock: bigint,
362
342
  ): Promise<InboxMessage | undefined> {
363
- const logs = await inbox.getEvents.MessageSent({ hash: leaf.toString() }, { fromBlock, toBlock });
343
+ const logs = await inbox.getMessageSentEventByHash(leaf.toString(), fromBlock, toBlock);
364
344
 
365
345
  const messages = mapLogsInboxMessage(logs);
366
346
  return messages.length > 0 ? messages[0] : undefined;
@@ -368,47 +348,40 @@ export async function retrieveL1ToL2Message(
368
348
 
369
349
  /**
370
350
  * Fetch L1 to L2 messages.
371
- * @param publicClient - The viem public client to use for transaction retrieval.
372
- * @param inboxAddress - The address of the inbox contract to fetch messages from.
373
- * @param blockUntilSynced - If true, blocks until the archiver has fully synced.
351
+ * @param inbox - The inbox contract wrapper.
374
352
  * @param searchStartBlock - The block number to use for starting the search.
375
353
  * @param searchEndBlock - The highest block number that we should search up to.
376
354
  * @returns An array of InboxLeaf and next eth block to search from.
377
355
  */
378
356
  export async function retrieveL1ToL2Messages(
379
- inbox: GetContractReturnType<typeof InboxAbi, ViemClient>,
357
+ inbox: InboxContract,
380
358
  searchStartBlock: bigint,
381
359
  searchEndBlock: bigint,
382
360
  ): Promise<InboxMessage[]> {
383
361
  const retrievedL1ToL2Messages: InboxMessage[] = [];
384
362
  while (searchStartBlock <= searchEndBlock) {
385
- const messageSentLogs = (
386
- await inbox.getEvents.MessageSent({}, { fromBlock: searchStartBlock, toBlock: searchEndBlock })
387
- ).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);
363
+ const messageSentLogs = await inbox.getMessageSentEvents(searchStartBlock, searchEndBlock);
388
364
 
389
365
  if (messageSentLogs.length === 0) {
390
366
  break;
391
367
  }
392
368
 
393
369
  retrievedL1ToL2Messages.push(...mapLogsInboxMessage(messageSentLogs));
394
- searchStartBlock = messageSentLogs.at(-1)!.blockNumber + 1n;
370
+ searchStartBlock = messageSentLogs.at(-1)!.l1BlockNumber + 1n;
395
371
  }
396
372
 
397
373
  return retrievedL1ToL2Messages;
398
374
  }
399
375
 
400
- function mapLogsInboxMessage(logs: GetContractEventsReturnType<typeof InboxAbi, 'MessageSent'>): InboxMessage[] {
401
- return logs.map(log => {
402
- const { index, hash, checkpointNumber, rollingHash } = log.args;
403
- return {
404
- index: index!,
405
- leaf: Fr.fromHexString(hash!),
406
- l1BlockNumber: log.blockNumber,
407
- l1BlockHash: Buffer32.fromString(log.blockHash),
408
- checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber!),
409
- rollingHash: Buffer16.fromString(rollingHash!),
410
- };
411
- });
376
+ function mapLogsInboxMessage(logs: MessageSentLog[]): InboxMessage[] {
377
+ return logs.map(log => ({
378
+ index: log.args.index,
379
+ leaf: log.args.leaf,
380
+ l1BlockNumber: log.l1BlockNumber,
381
+ l1BlockHash: log.l1BlockHash,
382
+ checkpointNumber: log.args.checkpointNumber,
383
+ rollingHash: log.args.rollingHash,
384
+ }));
412
385
  }
413
386
 
414
387
  /** Retrieves L2ProofVerified events from the rollup contract. */
@@ -87,17 +87,17 @@ export async function verifyProxyImplementation(
87
87
  /**
88
88
  * Attempts to decode transaction as a Spire Proposer Multicall.
89
89
  * Spire Proposer is a proxy contract that wraps multiple calls.
90
- * Returns the target address and calldata of the wrapped call if validation succeeds and there is a single call.
90
+ * Returns all wrapped calls if validation succeeds (caller handles hash matching to find the propose call).
91
91
  * @param tx - The transaction to decode
92
92
  * @param publicClient - The viem public client for proxy verification
93
93
  * @param logger - Logger instance
94
- * @returns Object with 'to' and 'data' of the wrapped call, or undefined if validation fails
94
+ * @returns Array of wrapped calls with 'to' and 'data', or undefined if not a valid Spire Proposer tx
95
95
  */
96
- export async function getCallFromSpireProposer(
96
+ export async function getCallsFromSpireProposer(
97
97
  tx: Transaction,
98
98
  publicClient: { getStorageAt: (params: { address: Hex; slot: Hex }) => Promise<Hex | undefined> },
99
99
  logger: Logger,
100
- ): Promise<{ to: Hex; data: Hex } | undefined> {
100
+ ): Promise<{ to: Hex; data: Hex }[] | undefined> {
101
101
  const txHash = tx.hash;
102
102
 
103
103
  try {
@@ -141,17 +141,9 @@ export async function getCallFromSpireProposer(
141
141
 
142
142
  const [calls] = spireArgs;
143
143
 
144
- // Validate exactly ONE call (see ./README.md for rationale)
145
- if (calls.length !== 1) {
146
- logger.warn(`Spire Proposer multicall must contain exactly one call (got ${calls.length})`, { txHash });
147
- return undefined;
148
- }
149
-
150
- const call = calls[0];
151
-
152
- // Successfully extracted the single wrapped call
153
- logger.trace(`Decoded Spire Proposer with single call to ${call.target}`, { txHash });
154
- return { to: call.target, data: call.data };
144
+ // Return all wrapped calls (hash matching in the caller determines which is the propose call)
145
+ logger.trace(`Decoded Spire Proposer with ${calls.length} call(s)`, { txHash });
146
+ return calls.map(call => ({ to: call.target, data: call.data }));
155
147
  } catch (err) {
156
148
  // Any decoding error triggers fallback to trace
157
149
  logger.warn(`Failed to decode Spire Proposer: ${err}`, { txHash });
@@ -1,5 +1,5 @@
1
1
  import type { ViemPublicDebugClient } from '@aztec/ethereum/types';
2
- import { createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
3
 
4
4
  import type { Hex } from 'viem';
5
5
  import type { ZodSchema } from 'zod';
@@ -7,8 +7,6 @@ import type { ZodSchema } from 'zod';
7
7
  import { callTraceSchema } from './debug_tx.js';
8
8
  import { traceTransactionResponseSchema } from './trace_tx.js';
9
9
 
10
- const logger = createLogger('aztec:archiver:validate_trace');
11
-
12
10
  /**
13
11
  * Helper function to test a trace method with validation
14
12
  *
@@ -17,6 +15,7 @@ const logger = createLogger('aztec:archiver:validate_trace');
17
15
  * @param schema - Zod schema to validate the response
18
16
  * @param method - Name of the RPC method ('debug_traceTransaction' or 'trace_transaction')
19
17
  * @param blockType - Type of block being tested ('recent' or 'old')
18
+ * @param logger - Logger instance
20
19
  * @returns true if the method works and validation passes, false otherwise
21
20
  */
22
21
  async function testTraceMethod(
@@ -25,6 +24,7 @@ async function testTraceMethod(
25
24
  schema: ZodSchema,
26
25
  method: 'debug_traceTransaction' | 'trace_transaction',
27
26
  blockType: string,
27
+ logger: Logger,
28
28
  ): Promise<boolean> {
29
29
  try {
30
30
  // Make request with appropriate params based on method name
@@ -59,9 +59,14 @@ export interface TraceAvailability {
59
59
  * Validates the availability of debug/trace methods on the Ethereum client.
60
60
  *
61
61
  * @param client - The Viem public debug client
62
+ * @param bindings - Optional logger bindings for context
62
63
  * @returns Object indicating which trace methods are available for recent and old blocks
63
64
  */
64
- export async function validateTraceAvailability(client: ViemPublicDebugClient): Promise<TraceAvailability> {
65
+ export async function validateTraceAvailability(
66
+ client: ViemPublicDebugClient,
67
+ bindings?: LoggerBindings,
68
+ ): Promise<TraceAvailability> {
69
+ const logger = createLogger('archiver:validate_trace', bindings);
65
70
  const result: TraceAvailability = {
66
71
  debugTraceRecent: false,
67
72
  traceTransactionRecent: false,
@@ -95,6 +100,7 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
95
100
  callTraceSchema,
96
101
  'debug_traceTransaction',
97
102
  'recent',
103
+ logger,
98
104
  );
99
105
 
100
106
  // Test trace_transaction with recent block
@@ -104,6 +110,7 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
104
110
  traceTransactionResponseSchema,
105
111
  'trace_transaction',
106
112
  'recent',
113
+ logger,
107
114
  );
108
115
 
109
116
  // Get a block from 512 blocks ago
@@ -132,7 +139,14 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
132
139
  const oldTxHash = oldBlock.transactions[0] as Hex;
133
140
 
134
141
  // Test debug_traceTransaction with old block
135
- result.debugTraceOld = await testTraceMethod(client, oldTxHash, callTraceSchema, 'debug_traceTransaction', 'old');
142
+ result.debugTraceOld = await testTraceMethod(
143
+ client,
144
+ oldTxHash,
145
+ callTraceSchema,
146
+ 'debug_traceTransaction',
147
+ 'old',
148
+ logger,
149
+ );
136
150
 
137
151
  // Test trace_transaction with old block
138
152
  result.traceTransactionOld = await testTraceMethod(
@@ -141,6 +155,7 @@ export async function validateTraceAvailability(client: ViemPublicDebugClient):
141
155
  traceTransactionResponseSchema,
142
156
  'trace_transaction',
143
157
  'old',
158
+ logger,
144
159
  );
145
160
  } catch (error) {
146
161
  logger.warn(`Error validating debug_traceTransaction and trace_transaction availability: ${error}`);
@@ -159,15 +174,18 @@ function hasTxs(block: { transactions?: Hex[] }): boolean {
159
174
  *
160
175
  * @param client - The Viem public debug client
161
176
  * @param ethereumAllowNoDebugHosts - If false, throws an error when no trace methods are available
177
+ * @param bindings - Optional logger bindings for context
162
178
  * @throws Error if ethereumAllowNoDebugHosts is false and no trace methods are available
163
179
  */
164
180
  export async function validateAndLogTraceAvailability(
165
181
  client: ViemPublicDebugClient,
166
182
  ethereumAllowNoDebugHosts: boolean,
183
+ bindings?: LoggerBindings,
167
184
  ): Promise<void> {
185
+ const logger = createLogger('archiver:validate_trace', bindings);
168
186
  logger.debug('Validating trace/debug method availability...');
169
187
 
170
- const availability = await validateTraceAvailability(client);
188
+ const availability = await validateTraceAvailability(client, bindings);
171
189
 
172
190
  // Check if we have support for old blocks (either debug or trace)
173
191
  const hasOldBlockSupport = availability.debugTraceOld || availability.traceTransactionOld;