@aztec-labs/archiver 6.0.0-nightly.20260829

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 (174) hide show
  1. package/README.md +178 -0
  2. package/dest/archiver.d.ts +194 -0
  3. package/dest/archiver.d.ts.map +1 -0
  4. package/dest/archiver.js +948 -0
  5. package/dest/config.d.ts +34 -0
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/config.js +100 -0
  8. package/dest/errors.d.ts +97 -0
  9. package/dest/errors.d.ts.map +1 -0
  10. package/dest/errors.js +141 -0
  11. package/dest/factory.d.ts +32 -0
  12. package/dest/factory.d.ts.map +1 -0
  13. package/dest/factory.js +183 -0
  14. package/dest/index.d.ts +20 -0
  15. package/dest/index.d.ts.map +1 -0
  16. package/dest/index.js +18 -0
  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/l1/bin/retrieve-calldata.d.ts +3 -0
  21. package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
  22. package/dest/l1/bin/retrieve-calldata.js +152 -0
  23. package/dest/l1/calldata_retriever.d.ts +143 -0
  24. package/dest/l1/calldata_retriever.d.ts.map +1 -0
  25. package/dest/l1/calldata_retriever.js +413 -0
  26. package/dest/l1/data_retrieval.d.ts +102 -0
  27. package/dest/l1/data_retrieval.d.ts.map +1 -0
  28. package/dest/l1/data_retrieval.js +308 -0
  29. package/dest/l1/debug_tx.d.ts +19 -0
  30. package/dest/l1/debug_tx.d.ts.map +1 -0
  31. package/dest/l1/debug_tx.js +73 -0
  32. package/dest/l1/spire_proposer.d.ts +70 -0
  33. package/dest/l1/spire_proposer.d.ts.map +1 -0
  34. package/dest/l1/spire_proposer.js +149 -0
  35. package/dest/l1/trace_tx.d.ts +43 -0
  36. package/dest/l1/trace_tx.d.ts.map +1 -0
  37. package/dest/l1/trace_tx.js +91 -0
  38. package/dest/l1/types.d.ts +12 -0
  39. package/dest/l1/types.d.ts.map +1 -0
  40. package/dest/l1/types.js +3 -0
  41. package/dest/l1/validate_historical_logs.d.ts +23 -0
  42. package/dest/l1/validate_historical_logs.d.ts.map +1 -0
  43. package/dest/l1/validate_historical_logs.js +108 -0
  44. package/dest/l1/validate_trace.d.ts +32 -0
  45. package/dest/l1/validate_trace.d.ts.map +1 -0
  46. package/dest/l1/validate_trace.js +154 -0
  47. package/dest/modules/contract_data_source_adapter.d.ts +25 -0
  48. package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
  49. package/dest/modules/contract_data_source_adapter.js +32 -0
  50. package/dest/modules/data_source_base.d.ts +116 -0
  51. package/dest/modules/data_source_base.d.ts.map +1 -0
  52. package/dest/modules/data_source_base.js +334 -0
  53. package/dest/modules/data_store_updater.d.ts +105 -0
  54. package/dest/modules/data_store_updater.d.ts.map +1 -0
  55. package/dest/modules/data_store_updater.js +392 -0
  56. package/dest/modules/instrumentation.d.ts +63 -0
  57. package/dest/modules/instrumentation.d.ts.map +1 -0
  58. package/dest/modules/instrumentation.js +166 -0
  59. package/dest/modules/l1_synchronizer.d.ts +77 -0
  60. package/dest/modules/l1_synchronizer.d.ts.map +1 -0
  61. package/dest/modules/l1_synchronizer.js +1369 -0
  62. package/dest/modules/outbox_trees_resolver.d.ts +64 -0
  63. package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
  64. package/dest/modules/outbox_trees_resolver.js +184 -0
  65. package/dest/modules/validation.d.ts +40 -0
  66. package/dest/modules/validation.d.ts.map +1 -0
  67. package/dest/modules/validation.js +122 -0
  68. package/dest/store/block_store.d.ts +304 -0
  69. package/dest/store/block_store.d.ts.map +1 -0
  70. package/dest/store/block_store.js +1252 -0
  71. package/dest/store/contract_class_store.d.ts +31 -0
  72. package/dest/store/contract_class_store.d.ts.map +1 -0
  73. package/dest/store/contract_class_store.js +98 -0
  74. package/dest/store/contract_instance_store.d.ts +51 -0
  75. package/dest/store/contract_instance_store.d.ts.map +1 -0
  76. package/dest/store/contract_instance_store.js +129 -0
  77. package/dest/store/data_stores.d.ts +68 -0
  78. package/dest/store/data_stores.d.ts.map +1 -0
  79. package/dest/store/data_stores.js +54 -0
  80. package/dest/store/function_names_cache.d.ts +17 -0
  81. package/dest/store/function_names_cache.d.ts.map +1 -0
  82. package/dest/store/function_names_cache.js +30 -0
  83. package/dest/store/l2_tips_cache.d.ts +25 -0
  84. package/dest/store/l2_tips_cache.d.ts.map +1 -0
  85. package/dest/store/l2_tips_cache.js +26 -0
  86. package/dest/store/log_store.d.ts +59 -0
  87. package/dest/store/log_store.d.ts.map +1 -0
  88. package/dest/store/log_store.js +310 -0
  89. package/dest/store/log_store_codec.d.ts +78 -0
  90. package/dest/store/log_store_codec.d.ts.map +1 -0
  91. package/dest/store/log_store_codec.js +110 -0
  92. package/dest/store/message_store.d.ts +111 -0
  93. package/dest/store/message_store.d.ts.map +1 -0
  94. package/dest/store/message_store.js +522 -0
  95. package/dest/structs/data_retrieval.d.ts +27 -0
  96. package/dest/structs/data_retrieval.d.ts.map +1 -0
  97. package/dest/structs/data_retrieval.js +5 -0
  98. package/dest/structs/inbox_message.d.ts +17 -0
  99. package/dest/structs/inbox_message.d.ts.map +1 -0
  100. package/dest/structs/inbox_message.js +33 -0
  101. package/dest/structs/published.d.ts +2 -0
  102. package/dest/structs/published.d.ts.map +1 -0
  103. package/dest/structs/published.js +1 -0
  104. package/dest/test/fake_l1_state.d.ts +220 -0
  105. package/dest/test/fake_l1_state.d.ts.map +1 -0
  106. package/dest/test/fake_l1_state.js +565 -0
  107. package/dest/test/index.d.ts +5 -0
  108. package/dest/test/index.d.ts.map +1 -0
  109. package/dest/test/index.js +6 -0
  110. package/dest/test/mock_archiver.d.ts +35 -0
  111. package/dest/test/mock_archiver.d.ts.map +1 -0
  112. package/dest/test/mock_archiver.js +93 -0
  113. package/dest/test/mock_l1_to_l2_message_source.d.ts +24 -0
  114. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -0
  115. package/dest/test/mock_l1_to_l2_message_source.js +79 -0
  116. package/dest/test/mock_l2_block_source.d.ts +139 -0
  117. package/dest/test/mock_l2_block_source.d.ts.map +1 -0
  118. package/dest/test/mock_l2_block_source.js +489 -0
  119. package/dest/test/mock_structs.d.ts +92 -0
  120. package/dest/test/mock_structs.d.ts.map +1 -0
  121. package/dest/test/mock_structs.js +188 -0
  122. package/dest/test/noop_l1_archiver.d.ts +34 -0
  123. package/dest/test/noop_l1_archiver.d.ts.map +1 -0
  124. package/dest/test/noop_l1_archiver.js +88 -0
  125. package/package.json +108 -0
  126. package/src/archiver.ts +785 -0
  127. package/src/config.ts +133 -0
  128. package/src/errors.ts +211 -0
  129. package/src/factory.ts +262 -0
  130. package/src/index.ts +29 -0
  131. package/src/interfaces.ts +9 -0
  132. package/src/l1/README.md +55 -0
  133. package/src/l1/bin/retrieve-calldata.ts +194 -0
  134. package/src/l1/calldata_retriever.ts +529 -0
  135. package/src/l1/data_retrieval.ts +498 -0
  136. package/src/l1/debug_tx.ts +98 -0
  137. package/src/l1/spire_proposer.ts +151 -0
  138. package/src/l1/trace_tx.ts +127 -0
  139. package/src/l1/types.ts +12 -0
  140. package/src/l1/validate_historical_logs.ts +140 -0
  141. package/src/l1/validate_trace.ts +228 -0
  142. package/src/modules/contract_data_source_adapter.ts +46 -0
  143. package/src/modules/data_source_base.ts +482 -0
  144. package/src/modules/data_store_updater.ts +520 -0
  145. package/src/modules/instrumentation.ts +217 -0
  146. package/src/modules/l1_synchronizer.ts +1296 -0
  147. package/src/modules/outbox_trees_resolver.ts +220 -0
  148. package/src/modules/validation.ts +186 -0
  149. package/src/store/block_store.ts +1604 -0
  150. package/src/store/contract_class_store.ts +126 -0
  151. package/src/store/contract_instance_store.ts +178 -0
  152. package/src/store/data_stores.ts +103 -0
  153. package/src/store/function_names_cache.ts +37 -0
  154. package/src/store/l2_tips_cache.ts +35 -0
  155. package/src/store/log_store.ts +380 -0
  156. package/src/store/log_store_codec.ts +143 -0
  157. package/src/store/message_store.ts +621 -0
  158. package/src/structs/data_retrieval.ts +27 -0
  159. package/src/structs/inbox_message.ts +48 -0
  160. package/src/structs/published.ts +1 -0
  161. package/src/test/fake_l1_state.ts +807 -0
  162. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  163. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  164. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  165. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  166. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  167. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  168. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  169. package/src/test/index.ts +7 -0
  170. package/src/test/mock_archiver.ts +122 -0
  171. package/src/test/mock_l1_to_l2_message_source.ts +81 -0
  172. package/src/test/mock_l2_block_source.ts +620 -0
  173. package/src/test/mock_structs.ts +317 -0
  174. package/src/test/noop_l1_archiver.ts +157 -0
@@ -0,0 +1,807 @@
1
+ import { RollupAbi } from '@aztec/l1-artifacts';
2
+
3
+ import type { BlobClientInterface } from '@aztec-labs/blob-client/client';
4
+ import { type Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec-labs/blob-lib';
5
+ import type {
6
+ CheckpointProposedLog,
7
+ InboxContract,
8
+ MessageSentLog,
9
+ RollupContract,
10
+ } from '@aztec-labs/ethereum/contracts';
11
+ import { MULTI_CALL_3_ADDRESS } from '@aztec-labs/ethereum/contracts';
12
+ import type { ViemPublicClient } from '@aztec-labs/ethereum/types';
13
+ import { type BlockNumber, CheckpointNumber, SlotNumber } from '@aztec-labs/foundation/branded-types';
14
+ import { Buffer32 } from '@aztec-labs/foundation/buffer';
15
+ import { Secp256k1Signer } from '@aztec-labs/foundation/crypto/secp256k1-signer';
16
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
17
+ import { EthAddress } from '@aztec-labs/foundation/eth-address';
18
+ import { createLogger } from '@aztec-labs/foundation/log';
19
+ import { CommitteeAttestation, CommitteeAttestationsAndSigners, L2Block } from '@aztec-labs/stdlib/block';
20
+ import { Checkpoint } from '@aztec-labs/stdlib/checkpoint';
21
+ import { getSlotAtTimestamp } from '@aztec-labs/stdlib/epoch-helpers';
22
+ import { updateInboxRollingHash } from '@aztec-labs/stdlib/messaging';
23
+ import { ConsensusPayload, getHashedSignaturePayloadTypedData } from '@aztec-labs/stdlib/p2p';
24
+ import { mockCheckpointAndMessages } from '@aztec-labs/stdlib/testing';
25
+ import { AppendOnlyTreeSnapshot } from '@aztec-labs/stdlib/trees';
26
+ import { type MockProxy, mock } from 'jest-mock-extended';
27
+ import {
28
+ type AbiParameter,
29
+ type FormattedBlock,
30
+ type Transaction,
31
+ encodeAbiParameters,
32
+ encodeFunctionData,
33
+ keccak256,
34
+ multicall3Abi,
35
+ toHex,
36
+ } from 'viem';
37
+
38
+ /** Configuration for the fake L1 state. */
39
+ export type FakeL1StateConfig = {
40
+ /** Genesis archive root. */
41
+ genesisArchiveRoot: Fr;
42
+ /** L1 start block number. */
43
+ l1StartBlock: bigint;
44
+ /** L1 genesis time in seconds. */
45
+ l1GenesisTime: bigint;
46
+ /** Ethereum slot duration in seconds. */
47
+ ethereumSlotDuration: number;
48
+ /** Rollup address for mock contracts. */
49
+ rollupAddress: EthAddress;
50
+ /** Inbox address for mock contracts. */
51
+ inboxAddress: EthAddress;
52
+ /** Aztec slot duration in seconds */
53
+ slotDuration: number;
54
+ };
55
+
56
+ /** Options for adding a checkpoint. */
57
+ type AddCheckpointOptions = {
58
+ /** L1 block number where checkpoint was proposed. */
59
+ l1BlockNumber: bigint;
60
+ /** Number of L2 blocks in the checkpoint. Default: 1 */
61
+ numBlocks?: number;
62
+ /** Or the actual blocks for the checkpoint */
63
+ blocks?: L2Block[];
64
+ /** Number of transactions per block. Default: 4 */
65
+ txsPerBlock?: number;
66
+ /** Max number of effects per tx (for generating large blobs). Default: undefined */
67
+ maxEffects?: number;
68
+ /** Signers for attestations. Default: none */
69
+ signers?: Secp256k1Signer[];
70
+ /** Override slot number. */
71
+ slotNumber?: SlotNumber;
72
+ /** Override previous archive. */
73
+ previousArchive?: AppendOnlyTreeSnapshot;
74
+ /** Timestamp for the checkpoint. */
75
+ timestamp?: bigint;
76
+ /** Number of L1-to-L2 messages. Default: 3 */
77
+ numL1ToL2Messages?: number;
78
+ /** L1 block number where messages were sent. Default: l1BlockNumber - 3 */
79
+ messagesL1BlockNumber?: bigint;
80
+ };
81
+
82
+ /** Result from adding a checkpoint. */
83
+ type AddCheckpointResult = {
84
+ /** The checkpoint that was created. */
85
+ checkpoint: Checkpoint;
86
+ /** The L1-to-L2 messages for this checkpoint. */
87
+ messages: Fr[];
88
+ };
89
+
90
+ /** Data stored for a checkpoint. */
91
+ type CheckpointData = {
92
+ checkpointNumber: CheckpointNumber;
93
+ checkpoint: Checkpoint;
94
+ l1BlockNumber: bigint;
95
+ tx: Transaction;
96
+ blobHashes: `0x${string}`[];
97
+ blobs: Blob[];
98
+ signers: Secp256k1Signer[];
99
+ /** Hash of the packed attestations, matching what the L1 event emits. */
100
+ attestationsHash: Buffer32;
101
+ /** Payload digest, matching what the L1 event emits. */
102
+ payloadDigest: Buffer32;
103
+ /** If true, archiveAt will ignore it */
104
+ pruned?: boolean;
105
+ };
106
+
107
+ /** Data stored for a message. */
108
+ type MessageData = {
109
+ l1BlockNumber: bigint;
110
+ index: bigint;
111
+ leaf: Fr;
112
+ inboxRollingHash: Fr;
113
+ bucketSeq: bigint;
114
+ };
115
+
116
+ // Mirror of the on-chain per-bucket message cap: further messages in the same L1 block spill into the next bucket.
117
+ const MAX_MSGS_PER_BUCKET = 256;
118
+
119
+ /**
120
+ * Stateful fake for L1 data used by the archiver.
121
+ *
122
+ * This class simulates the L1 blockchain state that the archiver reads from:
123
+ * - RollupContract: status(), archiveAt(), getVersion(), getTargetCommitteeSize(), CheckpointProposed events
124
+ * - InboxContract: getState(), MessageSent events
125
+ * - PublicClient: getBlockNumber(), getBlock(), getTransaction()
126
+ * - BlobClient: getBlobSidecar()
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const fake = new FakeL1State(config);
131
+ *
132
+ * // Add checkpoint (creates messages automatically)
133
+ * const { checkpoint, messages } = await fake.addCheckpoint(CheckpointNumber(1), { l1BlockNumber: 101n });
134
+ * fake.setL1BlockNumber(105n);
135
+ *
136
+ * // Status auto-updated
137
+ * expect(fake.getRollupStatus().pendingCheckpointNumber).toEqual(CheckpointNumber(1));
138
+ * ```
139
+ */
140
+ export class FakeL1State {
141
+ private readonly log = createLogger('archiver:test:fake-l1');
142
+ private l1BlockNumber: bigint;
143
+ private checkpoints: CheckpointData[] = [];
144
+ private messages: MessageData[] = [];
145
+ // Consensus rolling-hash and bucket-ring state, mirroring the on-chain Inbox.
146
+ private messagesConsensusRollingHash: Fr = Fr.ZERO;
147
+ private currentBucketSeq: bigint = 0n;
148
+ private currentBucketTimestamp: bigint = 0n;
149
+ private currentBucketMsgCount: number = 0;
150
+ private lastArchive: AppendOnlyTreeSnapshot;
151
+ private provenCheckpointNumber: CheckpointNumber = CheckpointNumber(0);
152
+ private targetCommitteeSize: number = 0;
153
+ private version: bigint = 1n;
154
+ private canPruneResult: boolean = false;
155
+
156
+ // Computed from checkpoints based on L1 block visibility
157
+ private pendingCheckpointNumber: CheckpointNumber = CheckpointNumber(0);
158
+
159
+ // The L1 block number reported as "finalized" (defaults to the start block).
160
+ // `undefined` simulates the startup window on a fresh devnet where
161
+ // `getBlock({ blockTag: 'finalized' })` fails with "finalized block not found".
162
+ private finalizedL1BlockNumber: bigint | undefined;
163
+
164
+ constructor(private readonly config: FakeL1StateConfig) {
165
+ this.l1BlockNumber = config.l1StartBlock;
166
+ this.finalizedL1BlockNumber = config.l1StartBlock;
167
+ this.lastArchive = new AppendOnlyTreeSnapshot(config.genesisArchiveRoot, 1);
168
+ }
169
+
170
+ /**
171
+ * Adds messages for a checkpoint. Returns the message leaves.
172
+ * Auto-updates rolling hash.
173
+ *
174
+ * Note: For most use cases, use `addCheckpoint` which creates both checkpoint and messages.
175
+ * Use this method only when you need to add messages without creating a checkpoint (e.g., for reorg tests).
176
+ */
177
+ addMessages(_checkpointNumber: CheckpointNumber, l1BlockNumber: bigint, messageLeaves: Fr[]): void {
178
+ const timestamp = this.getTimestampAtL1Block(l1BlockNumber);
179
+ messageLeaves.forEach(leaf => {
180
+ // Compact global insertion index: the position in the Inbox's insertion order.
181
+ const index = BigInt(this.messages.length);
182
+ const { bucketSeq, inboxRollingHash } = this.absorbIntoBucket(leaf, timestamp);
183
+
184
+ this.messages.push({
185
+ l1BlockNumber,
186
+ index,
187
+ leaf,
188
+ inboxRollingHash,
189
+ bucketSeq,
190
+ });
191
+ });
192
+ }
193
+
194
+ /** Mirrors the on-chain `_absorbIntoBucket`: opens a new bucket on a strictly larger timestamp or a full bucket. */
195
+ private absorbIntoBucket(leaf: Fr, timestamp: bigint): { bucketSeq: bigint; inboxRollingHash: Fr } {
196
+ if (
197
+ this.currentBucketSeq === 0n ||
198
+ this.currentBucketTimestamp < timestamp ||
199
+ this.currentBucketMsgCount === MAX_MSGS_PER_BUCKET
200
+ ) {
201
+ this.currentBucketSeq += 1n;
202
+ this.currentBucketTimestamp = timestamp;
203
+ this.currentBucketMsgCount = 0;
204
+ }
205
+ this.messagesConsensusRollingHash = updateInboxRollingHash(this.messagesConsensusRollingHash, leaf);
206
+ this.currentBucketMsgCount += 1;
207
+ return { bucketSeq: this.currentBucketSeq, inboxRollingHash: this.messagesConsensusRollingHash };
208
+ }
209
+
210
+ /** Rebuilds all per-message derived state (rolling hashes and bucket assignments) after the message set changes. */
211
+ private recomputeDerivedMessageState(): void {
212
+ this.messagesConsensusRollingHash = Fr.ZERO;
213
+ this.currentBucketSeq = 0n;
214
+ this.currentBucketTimestamp = 0n;
215
+ this.currentBucketMsgCount = 0;
216
+ this.messages.forEach((msg, i) => {
217
+ const { bucketSeq, inboxRollingHash } = this.absorbIntoBucket(
218
+ msg.leaf,
219
+ this.getTimestampAtL1Block(msg.l1BlockNumber),
220
+ );
221
+ msg.index = BigInt(i);
222
+ msg.inboxRollingHash = inboxRollingHash;
223
+ msg.bucketSeq = bucketSeq;
224
+ });
225
+ }
226
+
227
+ /**
228
+ * Creates blocks for a checkpoint without adding them to L1 state.
229
+ * Useful for creating blocks to pass to addBlock() for testing provisional block handling.
230
+ * Returns the blocks directly.
231
+ */
232
+ public async makeBlocks(checkpointNumber: CheckpointNumber, options: Partial<AddCheckpointOptions>) {
233
+ return (await this.makeCheckpointAndMessages(checkpointNumber, options)).checkpoint.blocks;
234
+ }
235
+
236
+ /**
237
+ * Creates and adds a checkpoint with its L1-to-L2 messages.
238
+ * Returns both the checkpoint and the message leaves.
239
+ * Auto-chains from lastArchive, auto-updates pending status if L1 block >= checkpoint's L1 block.
240
+ */
241
+ public async addCheckpoint(
242
+ checkpointNumber: CheckpointNumber,
243
+ options: AddCheckpointOptions,
244
+ ): Promise<AddCheckpointResult> {
245
+ this.log.warn(`Adding checkpoint ${checkpointNumber}`);
246
+
247
+ const { l1BlockNumber, signers = [], messagesL1BlockNumber = l1BlockNumber - 3n } = options;
248
+
249
+ // Create the checkpoint using the stdlib helper
250
+ const { checkpoint, messages, lastArchive } = await this.makeCheckpointAndMessages(checkpointNumber, {
251
+ ...options,
252
+ numL1ToL2Messages: options.numL1ToL2Messages ?? 3,
253
+ });
254
+
255
+ // Store the messages internally so they match the checkpoint's inHash
256
+ this.addMessages(checkpointNumber, messagesL1BlockNumber, messages);
257
+
258
+ // Create the transaction, blobs, and event hashes
259
+ const { tx, attestationsHash, payloadDigest } = await this.makeRollupTx(checkpoint, signers);
260
+ const blobHashes = await this.makeVersionedBlobHashes(checkpoint);
261
+ const blobs = await this.makeBlobsFromCheckpoint(checkpoint);
262
+
263
+ // Store the checkpoint data
264
+ this.checkpoints.push({
265
+ checkpointNumber,
266
+ checkpoint,
267
+ l1BlockNumber,
268
+ tx,
269
+ blobHashes,
270
+ blobs,
271
+ signers,
272
+ attestationsHash,
273
+ payloadDigest,
274
+ });
275
+
276
+ // Update last archive for auto-chaining
277
+ this.lastArchive = lastArchive ?? checkpoint.blocks.at(-1)!.archive;
278
+
279
+ // Auto-update pending checkpoint number
280
+ this.updatePendingCheckpointNumber();
281
+
282
+ return { checkpoint, messages };
283
+ }
284
+
285
+ /** Creates a checkpoint and messages without adding them to L1 state. */
286
+ private makeCheckpointAndMessages(checkpointNumber: CheckpointNumber, options: Partial<AddCheckpointOptions>) {
287
+ const {
288
+ numBlocks = 1,
289
+ txsPerBlock = 4,
290
+ maxEffects,
291
+ slotNumber,
292
+ previousArchive = this.lastArchive,
293
+ timestamp,
294
+ l1BlockNumber,
295
+ numL1ToL2Messages = 0,
296
+ blocks,
297
+ } = options;
298
+
299
+ return mockCheckpointAndMessages(checkpointNumber, {
300
+ startBlockNumber: this.getNextBlockNumber(checkpointNumber),
301
+ numBlocks,
302
+ blocks,
303
+ numTxsPerBlock: txsPerBlock,
304
+ numL1ToL2Messages,
305
+ previousArchive,
306
+ slotNumber: slotNumber ?? (l1BlockNumber !== undefined ? this.getL2SlotAtL1Block(l1BlockNumber) : undefined),
307
+ timestamp: timestamp ?? (l1BlockNumber !== undefined ? this.getTimestampAtL1Block(l1BlockNumber) : undefined),
308
+ ...(maxEffects !== undefined ? { maxEffects } : {}),
309
+ });
310
+ }
311
+
312
+ /** Returns the L2 slot at the given L1 block (assuming all L1 blocks are mined) */
313
+ public getL2SlotAtL1Block(l1BlockNumber: bigint): SlotNumber {
314
+ const timestamp = this.getTimestampAtL1Block(l1BlockNumber);
315
+ return getSlotAtTimestamp(timestamp, this.config);
316
+ }
317
+
318
+ /** Returns the timestamp at the given L1 block (assuming all L1 blocks are mined) */
319
+ public getTimestampAtL1Block(l1BlockNumber: bigint): bigint {
320
+ const { l1GenesisTime, l1StartBlock, ethereumSlotDuration } = this.config;
321
+ return l1GenesisTime + (l1BlockNumber - l1StartBlock) * BigInt(ethereumSlotDuration);
322
+ }
323
+
324
+ /**
325
+ * Sets the current L1 block number.
326
+ * Auto-updates pending checkpoint number based on visible checkpoints.
327
+ */
328
+ setL1BlockNumber(blockNumber: bigint): void {
329
+ this.l1BlockNumber = blockNumber;
330
+ this.updatePendingCheckpointNumber();
331
+ }
332
+
333
+ /**
334
+ * Sets the L1 block number that will be reported as "finalized". Pass `undefined` to
335
+ * simulate a chain that does not yet have a finalized block (devnet startup).
336
+ */
337
+ setFinalizedL1BlockNumber(blockNumber: bigint | undefined): void {
338
+ this.finalizedL1BlockNumber = blockNumber;
339
+ }
340
+
341
+ /** Marks a checkpoint as proven. Updates provenCheckpointNumber. */
342
+ markCheckpointAsProven(checkpointNumber: CheckpointNumber): void {
343
+ this.provenCheckpointNumber = checkpointNumber;
344
+ }
345
+
346
+ /**
347
+ * Simulates what `rollup.getProvenCheckpointNumber({ blockNumber: atL1Block })` would return.
348
+ */
349
+ getProvenCheckpointNumberAtL1Block(atL1Block: bigint): CheckpointNumber {
350
+ if (this.provenCheckpointNumber === 0) {
351
+ return CheckpointNumber(0);
352
+ }
353
+ const checkpoint = this.checkpoints.find(cp => cp.checkpointNumber === this.provenCheckpointNumber);
354
+ if (checkpoint && checkpoint.l1BlockNumber <= atL1Block) {
355
+ return this.provenCheckpointNumber;
356
+ }
357
+ return CheckpointNumber(0);
358
+ }
359
+
360
+ /** Sets the target committee size for attestation validation. */
361
+ setTargetCommitteeSize(size: number): void {
362
+ this.targetCommitteeSize = size;
363
+ }
364
+
365
+ /** Sets whether the rollup contract would allow pruning at the next block. */
366
+ setCanPrune(value: boolean): void {
367
+ this.canPruneResult = value;
368
+ }
369
+
370
+ /**
371
+ * Removes all entries for a checkpoint number (simulates L1 reorg or prune).
372
+ * Note: Does NOT remove messages for this checkpoint (use numL1ToL2Messages: 0 when re-adding).
373
+ * Auto-updates pending status.
374
+ */
375
+ removeCheckpoint(checkpointNumber: CheckpointNumber): void {
376
+ this.checkpoints = this.checkpoints.filter(cpData => cpData.checkpointNumber !== checkpointNumber);
377
+ this.updatePendingCheckpointNumber();
378
+ }
379
+
380
+ /**
381
+ * Moves a checkpoint to a different L1 block number (simulates L1 reorg that
382
+ * re-includes the same checkpoint transaction in a different block).
383
+ * The checkpoint content stays the same — only the L1 metadata changes.
384
+ * Auto-updates pending status.
385
+ */
386
+ moveCheckpointToL1Block(checkpointNumber: CheckpointNumber, newL1BlockNumber: bigint): void {
387
+ for (const cpData of this.checkpoints) {
388
+ if (cpData.checkpointNumber === checkpointNumber) {
389
+ cpData.l1BlockNumber = newL1BlockNumber;
390
+ }
391
+ }
392
+ this.updatePendingCheckpointNumber();
393
+ }
394
+
395
+ /**
396
+ * Removes messages after a given total index (simulates L1 reorg).
397
+ * Auto-updates rolling hash.
398
+ */
399
+ removeMessagesAfter(totalIndex: number): void {
400
+ this.messages = this.messages.slice(0, totalIndex);
401
+ this.recomputeDerivedMessageState();
402
+ }
403
+
404
+ /**
405
+ * Simulates a pruned checkpoint by marking all entries with this number as pruned.
406
+ * The event will still be returned, but archiveAt() will return the previous checkpoint's archive
407
+ * (or genesis if no previous checkpoint), causing a mismatch that the archiver will detect.
408
+ */
409
+ markCheckpointAsPruned(checkpointNumber: CheckpointNumber): void {
410
+ for (const cpData of this.checkpoints) {
411
+ if (cpData.checkpointNumber === checkpointNumber) {
412
+ cpData.pruned = true;
413
+ }
414
+ }
415
+ this.updatePendingCheckpointNumber();
416
+ }
417
+
418
+ /**
419
+ * Moves messages at a given L1 block to a new L1 block.
420
+ * Useful for simulating partial message visibility (messages at higher L1 blocks won't be fetched).
421
+ */
422
+ moveMessagesToL1Block(fromL1Block: bigint, toL1Block: bigint): void {
423
+ this.messages.forEach(msg => {
424
+ if (msg.l1BlockNumber === fromL1Block) {
425
+ msg.l1BlockNumber = toL1Block;
426
+ }
427
+ });
428
+ }
429
+
430
+ /**
431
+ * Moves a specific message (by index in the messages array) to a new L1 block.
432
+ */
433
+ moveMessageAtIndexToL1Block(index: number, toL1Block: bigint): void {
434
+ if (this.messages[index]) {
435
+ this.messages[index].l1BlockNumber = toL1Block;
436
+ }
437
+ }
438
+
439
+ /** Gets current rollup status. */
440
+ getRollupStatus(): {
441
+ provenCheckpointNumber: CheckpointNumber;
442
+ pendingCheckpointNumber: CheckpointNumber;
443
+ provenArchive: Fr;
444
+ pendingArchive: Fr;
445
+ } {
446
+ return {
447
+ provenCheckpointNumber: this.provenCheckpointNumber,
448
+ pendingCheckpointNumber: this.pendingCheckpointNumber,
449
+ provenArchive: this.getArchiveAt(this.provenCheckpointNumber),
450
+ pendingArchive: this.getArchiveAt(this.pendingCheckpointNumber),
451
+ };
452
+ }
453
+
454
+ /** Gets the last archive (for manual chaining if needed). */
455
+ getLastArchive(): AppendOnlyTreeSnapshot {
456
+ return this.lastArchive;
457
+ }
458
+
459
+ /** Gets the latest checkpoint entry by number (returns the last added one). */
460
+ getCheckpoint(checkpointNumber: CheckpointNumber): Checkpoint | undefined {
461
+ return this.checkpoints.findLast(cpData => cpData.checkpointNumber === checkpointNumber)?.checkpoint;
462
+ }
463
+
464
+ /** Gets the blobs for a checkpoint. */
465
+ getCheckpointBlobs(checkpointNumber: CheckpointNumber): Blob[] {
466
+ return this.checkpoints.findLast(cpData => cpData.checkpointNumber === checkpointNumber)?.blobs ?? [];
467
+ }
468
+
469
+ /** Creates mock RollupContract that reads from this fake state. */
470
+ createMockRollupContract(_publicClient: MockProxy<ViemPublicClient>): MockProxy<RollupContract> {
471
+ const mockRollup = mock<RollupContract>();
472
+
473
+ mockRollup.getVersion.mockImplementation(() => Promise.resolve(this.version));
474
+ mockRollup.getTargetCommitteeSize.mockImplementation(() => Promise.resolve(this.targetCommitteeSize));
475
+ mockRollup.archiveAt.mockImplementation((cpNum: CheckpointNumber) => Promise.resolve(this.getArchiveAt(cpNum)));
476
+ mockRollup.status.mockImplementation((localCheckpointNum: CheckpointNumber) => {
477
+ const status = this.getRollupStatus();
478
+ return Promise.resolve({
479
+ provenCheckpointNumber: status.provenCheckpointNumber,
480
+ provenArchive: status.provenArchive,
481
+ pendingCheckpointNumber: status.pendingCheckpointNumber,
482
+ pendingArchive: status.pendingArchive,
483
+ archiveOfMyCheckpoint: this.getArchiveAt(localCheckpointNum),
484
+ });
485
+ });
486
+
487
+ mockRollup.getProvenCheckpointNumber.mockImplementation((options?: { blockNumber?: bigint }) => {
488
+ const atBlock = options?.blockNumber ?? this.l1BlockNumber;
489
+ return Promise.resolve(this.getProvenCheckpointNumberAtL1Block(atBlock));
490
+ });
491
+
492
+ mockRollup.canPruneAtTime.mockImplementation(() => Promise.resolve(this.canPruneResult));
493
+
494
+ // Mock the wrapper method for fetching checkpoint events
495
+ mockRollup.getCheckpointProposedEvents.mockImplementation((fromBlock: bigint, toBlock: bigint) =>
496
+ Promise.resolve(this.getCheckpointProposedLogs(fromBlock, toBlock)),
497
+ );
498
+
499
+ Object.defineProperty(mockRollup, 'address', { get: () => this.config.rollupAddress.toString() });
500
+
501
+ return mockRollup;
502
+ }
503
+
504
+ /** Creates mock InboxContract that reads from this fake state. */
505
+ createMockInboxContract(_publicClient: MockProxy<ViemPublicClient>): MockProxy<InboxContract> {
506
+ const mockInbox = mock<InboxContract>();
507
+
508
+ // Mirror the on-chain Inbox live state: its consensus rolling hash and cumulative total are the chain
509
+ // position the archiver's message sync compares against, read atomically.
510
+ mockInbox.getState.mockImplementation((opts: { blockTag?: string; blockNumber?: bigint } = {}) => {
511
+ const blockNumber = opts.blockNumber ?? this.l1BlockNumber;
512
+ const visibleMessages = this.messages.filter(m => m.l1BlockNumber <= blockNumber);
513
+ const last = visibleMessages.at(-1);
514
+ return Promise.resolve({
515
+ rollingHash: last?.inboxRollingHash ?? Fr.ZERO,
516
+ totalMessagesInserted: BigInt(visibleMessages.length),
517
+ currentBucketSeq: last?.bucketSeq ?? 0n,
518
+ });
519
+ });
520
+
521
+ // Mock the wrapper methods for fetching message events
522
+ mockInbox.getMessageSentEvents.mockImplementation((fromBlock: bigint, toBlock: bigint) =>
523
+ Promise.resolve(this.getMessageSentLogs(fromBlock, toBlock)),
524
+ );
525
+
526
+ mockInbox.getMessageSentEventByHash.mockImplementation((msgHash: string, aroundL1BlockNumber: bigint) =>
527
+ Promise.resolve(this.getMessageSentLogByHash(msgHash, aroundL1BlockNumber) as MessageSentLog),
528
+ );
529
+
530
+ return mockInbox;
531
+ }
532
+
533
+ /** Creates mock PublicClient that reads from this fake state. */
534
+ createMockPublicClient(): MockProxy<ViemPublicClient> {
535
+ const publicClient = mock<ViemPublicClient>();
536
+
537
+ publicClient.getChainId.mockResolvedValue(1);
538
+ // Several consumers (CalldataRetriever, ArchiverL1Synchronizer) derive the EIP-712 signing
539
+ // context from `publicClient.chain.id`. Pin it so it matches `getSignatureContext()` below.
540
+ (publicClient as unknown as { chain: { id: number } }).chain = { id: 1 };
541
+ publicClient.getBlockNumber.mockImplementation(() => Promise.resolve(this.l1BlockNumber));
542
+
543
+ publicClient.getBlock.mockImplementation((async (args: { blockNumber?: bigint; blockTag?: string } = {}) => {
544
+ let blockNum: bigint;
545
+ if (args.blockTag === 'finalized') {
546
+ if (this.finalizedL1BlockNumber === undefined) {
547
+ throw Object.assign(new Error('finalized block not found'), {
548
+ details: 'finalized block not found',
549
+ });
550
+ }
551
+ blockNum = this.finalizedL1BlockNumber;
552
+ } else {
553
+ blockNum = args.blockNumber ?? (await publicClient.getBlockNumber());
554
+ }
555
+ return {
556
+ number: blockNum,
557
+ timestamp: BigInt(blockNum) * BigInt(this.config.ethereumSlotDuration) + this.config.l1GenesisTime,
558
+ hash: Buffer32.fromBigInt(blockNum).toString(),
559
+ } as FormattedBlock;
560
+ }) as any);
561
+
562
+ // Use the same pattern as existing test for getTransaction
563
+ publicClient.getTransaction.mockImplementation((args: { hash?: `0x${string}` }) =>
564
+ Promise.resolve(
565
+ args.hash ? (this.checkpoints.find(cpData => cpData.tx.hash === args.hash)?.tx as any) : undefined,
566
+ ),
567
+ );
568
+
569
+ return publicClient;
570
+ }
571
+
572
+ /** Creates mock BlobClient that reads from this fake state. */
573
+ createMockBlobClient(): MockProxy<BlobClientInterface> {
574
+ const blobClient = mock<BlobClientInterface>();
575
+
576
+ // The blockId is the L1 block hash, which we derive from the L1 block number
577
+ blobClient.getBlobSidecar.mockImplementation((blockId: `0x${string}`) =>
578
+ Promise.resolve(
579
+ this.checkpoints.find(cpData => Buffer32.fromBigInt(cpData.l1BlockNumber).toString() === blockId)?.blobs ?? [],
580
+ ),
581
+ );
582
+
583
+ blobClient.testSources.mockResolvedValue(undefined);
584
+
585
+ return blobClient;
586
+ }
587
+
588
+ private updatePendingCheckpointNumber(): void {
589
+ this.pendingCheckpointNumber = this.checkpoints
590
+ .filter(cpData => cpData.l1BlockNumber <= this.l1BlockNumber && !cpData.pruned)
591
+ .reduce((max, cpData) => (cpData.checkpointNumber > max ? cpData.checkpointNumber : max), CheckpointNumber(0));
592
+ }
593
+
594
+ private getArchiveAt(checkpointNumber: CheckpointNumber): Fr {
595
+ if (checkpointNumber === 0) {
596
+ return this.config.genesisArchiveRoot;
597
+ }
598
+ // Find the latest non-pruned entry for this checkpoint number
599
+ const entries = this.checkpoints.filter(cpData => cpData.checkpointNumber === checkpointNumber);
600
+ const latestEntry = entries.at(-1);
601
+
602
+ if (!latestEntry || latestEntry.pruned) {
603
+ // For pruned or missing checkpoints, return the previous non-pruned checkpoint's archive
604
+ return this.getArchiveAt(CheckpointNumber(checkpointNumber - 1));
605
+ }
606
+ return latestEntry.checkpoint.archive.root;
607
+ }
608
+
609
+ private getNextBlockNumber(checkpointNumber: CheckpointNumber): BlockNumber {
610
+ const lastBlockNumber = this.checkpoints
611
+ .filter(cpData => cpData.checkpointNumber < checkpointNumber)
612
+ .flatMap(cpData => cpData.checkpoint.blocks.map(b => b.number))
613
+ .reduce((max, num) => Math.max(max, num), 0);
614
+ return (lastBlockNumber + 1) as BlockNumber;
615
+ }
616
+
617
+ private getCheckpointProposedLogs(fromBlock: bigint, toBlock: bigint): CheckpointProposedLog[] {
618
+ return this.checkpoints
619
+ .filter(cpData => cpData.l1BlockNumber >= fromBlock && cpData.l1BlockNumber <= toBlock)
620
+ .map(cpData => ({
621
+ l1BlockNumber: cpData.l1BlockNumber,
622
+ l1BlockHash: Buffer32.fromBigInt(cpData.l1BlockNumber),
623
+ l1TransactionHash: cpData.tx.hash as `0x${string}`,
624
+ args: {
625
+ checkpointNumber: cpData.checkpointNumber,
626
+ archive: cpData.checkpoint.archive.root,
627
+ versionedBlobHashes: cpData.blobHashes.map(h => Buffer.from(h.slice(2), 'hex')),
628
+ attestationsHash: cpData.attestationsHash,
629
+ payloadDigest: cpData.payloadDigest,
630
+ },
631
+ }));
632
+ }
633
+
634
+ private getMessageSentLogs(fromBlock?: bigint, toBlock?: bigint, hashFilter?: string): MessageSentLog[] {
635
+ return this.messages
636
+ .filter(
637
+ msg =>
638
+ (!hashFilter || msg.leaf.toString() === hashFilter) &&
639
+ (!fromBlock || msg.l1BlockNumber >= fromBlock) &&
640
+ (!toBlock || msg.l1BlockNumber <= toBlock),
641
+ )
642
+ .map(msg => ({
643
+ l1BlockNumber: msg.l1BlockNumber,
644
+ l1BlockHash: Buffer32.fromBigInt(msg.l1BlockNumber),
645
+ l1TransactionHash: `0x${msg.l1BlockNumber.toString(16)}` as `0x${string}`,
646
+ l1BlockTimestamp: this.getTimestampAtL1Block(msg.l1BlockNumber),
647
+ args: {
648
+ index: msg.index,
649
+ leaf: msg.leaf,
650
+ inboxRollingHash: msg.inboxRollingHash,
651
+ bucketSeq: msg.bucketSeq,
652
+ message: this.makeFakeMessageSentMessage(msg.index),
653
+ },
654
+ }));
655
+ }
656
+
657
+ private getMessageSentLogByHash(msgHash: string, aroundL1BlockNumber: bigint): MessageSentLog | undefined {
658
+ const msg = this.messages.find(
659
+ msg =>
660
+ msg.leaf.toString() === msgHash &&
661
+ msg.l1BlockNumber >= aroundL1BlockNumber - 5n &&
662
+ msg.l1BlockNumber <= aroundL1BlockNumber + 5n,
663
+ );
664
+ if (!msg) {
665
+ return undefined;
666
+ }
667
+ return {
668
+ l1BlockNumber: msg.l1BlockNumber,
669
+ l1BlockHash: Buffer32.fromBigInt(msg.l1BlockNumber),
670
+ l1TransactionHash: `0x${msg.l1BlockNumber.toString(16)}` as `0x${string}`,
671
+ l1BlockTimestamp: this.getTimestampAtL1Block(msg.l1BlockNumber),
672
+ args: {
673
+ index: msg.index,
674
+ leaf: msg.leaf,
675
+ inboxRollingHash: msg.inboxRollingHash,
676
+ bucketSeq: msg.bucketSeq,
677
+ message: this.makeFakeMessageSentMessage(msg.index),
678
+ },
679
+ };
680
+ }
681
+
682
+ // The fake tracks only leaves, so the emitted message carries placeholder fields; nothing in the archiver
683
+ // consumes them (it stores leaf and consensus metadata only).
684
+ private makeFakeMessageSentMessage(index: bigint) {
685
+ return {
686
+ sender: { actor: `0x${'0'.repeat(40)}` as `0x${string}`, chainId: 1n },
687
+ recipient: { actor: Fr.ZERO, version: 1n },
688
+ content: Fr.ZERO,
689
+ secretHash: Fr.ZERO,
690
+ index,
691
+ };
692
+ }
693
+
694
+ private async makeRollupTx(
695
+ checkpoint: Checkpoint,
696
+ signers: Secp256k1Signer[],
697
+ ): Promise<{ tx: Transaction; attestationsHash: Buffer32; payloadDigest: Buffer32 }> {
698
+ const signatureContext = this.getSignatureContext();
699
+ const consensusPayload = ConsensusPayload.fromCheckpoint(checkpoint, signatureContext);
700
+ const attestationDigest = getHashedSignaturePayloadTypedData(consensusPayload);
701
+ const attestations = signers
702
+ .map(signer => CommitteeAttestation.fromSignature(signer.sign(attestationDigest)))
703
+ .map(committeeAttestation => committeeAttestation.toViem());
704
+
705
+ const header = checkpoint.header.toViem();
706
+ const blobInput = getPrefixedEthBlobCommitments(await getBlobsPerL1Block(checkpoint.toBlobFields()));
707
+ const archive = toHex(checkpoint.archive.root.toBuffer());
708
+ const attestationsAndSigners = new CommitteeAttestationsAndSigners(
709
+ attestations.map(attestation => CommitteeAttestation.fromViem(attestation)),
710
+ signatureContext,
711
+ );
712
+
713
+ // Fall back to a random signer when no attesters are provided, so tests that
714
+ // don't care about the proposer identity (e.g. sync tests) still produce a
715
+ // valid-looking signature for the attestationsAndSigners struct.
716
+ const proposerSigner = signers[0] ?? Secp256k1Signer.random();
717
+ const attestationsAndSignersSignature = proposerSigner.sign(
718
+ getHashedSignaturePayloadTypedData(attestationsAndSigners),
719
+ );
720
+
721
+ const verbatimAttestations = attestationsAndSigners.getPackedAttestations();
722
+
723
+ const rollupInput = encodeFunctionData({
724
+ abi: RollupAbi,
725
+ functionName: 'propose',
726
+ args: [
727
+ {
728
+ header,
729
+ archive,
730
+ oracleInput: { feeAssetPriceModifier: 0n },
731
+ bucketHint: 0n,
732
+ },
733
+ verbatimAttestations,
734
+ attestationsAndSigners.getSigners().map(signer => signer.toString()),
735
+ attestationsAndSignersSignature.toViemSignature(),
736
+ blobInput,
737
+ ],
738
+ });
739
+
740
+ const multiCallInput = encodeFunctionData({
741
+ abi: multicall3Abi,
742
+ functionName: 'aggregate3',
743
+ args: [
744
+ [
745
+ {
746
+ target: this.config.rollupAddress.toString(),
747
+ callData: rollupInput,
748
+ allowFailure: false,
749
+ },
750
+ ],
751
+ ],
752
+ });
753
+
754
+ // Compute attestationsHash (same logic as CalldataRetriever)
755
+ const attestationsHash = Buffer32.fromString(
756
+ keccak256(encodeAbiParameters([this.getCommitteeAttestationsStructDef()], [verbatimAttestations])),
757
+ );
758
+
759
+ // Compute payloadDigest (same logic as CalldataRetriever)
760
+ const payloadDigest = getHashedSignaturePayloadTypedData(consensusPayload);
761
+
762
+ const tx = {
763
+ input: multiCallInput,
764
+ hash: archive,
765
+ blockHash: archive,
766
+ to: MULTI_CALL_3_ADDRESS as `0x${string}`,
767
+ } as Transaction<bigint, number>;
768
+
769
+ return { tx, attestationsHash, payloadDigest };
770
+ }
771
+
772
+ private getSignatureContext() {
773
+ return {
774
+ chainId: 1,
775
+ rollupAddress: this.config.rollupAddress,
776
+ };
777
+ }
778
+
779
+ /** Extracts the CommitteeAttestations struct definition from RollupAbi for hash computation. */
780
+ private getCommitteeAttestationsStructDef(): AbiParameter {
781
+ const proposeFunction = RollupAbi.find(item => item.type === 'function' && item.name === 'propose') as
782
+ | { type: 'function'; name: string; inputs: readonly AbiParameter[] }
783
+ | undefined;
784
+
785
+ if (!proposeFunction) {
786
+ throw new Error('propose function not found in RollupAbi');
787
+ }
788
+
789
+ const attestationsParam = proposeFunction.inputs.find(param => param.name === '_attestations');
790
+ if (!attestationsParam) {
791
+ throw new Error('_attestations parameter not found in propose function');
792
+ }
793
+
794
+ const tupleParam = attestationsParam as unknown as { type: 'tuple'; components?: readonly AbiParameter[] };
795
+ return { type: 'tuple', components: tupleParam.components || [] } as AbiParameter;
796
+ }
797
+
798
+ private async makeVersionedBlobHashes(checkpoint: Checkpoint): Promise<`0x${string}`[]> {
799
+ return (await getBlobsPerL1Block(checkpoint.toBlobFields())).map(
800
+ b => `0x${b.getEthVersionedBlobHash().toString('hex')}` as `0x${string}`,
801
+ );
802
+ }
803
+
804
+ private async makeBlobsFromCheckpoint(checkpoint: Checkpoint): Promise<Blob[]> {
805
+ return await getBlobsPerL1Block(checkpoint.toBlobFields());
806
+ }
807
+ }