@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
@@ -1,6 +0,0 @@
1
- export * from './archiver.js';
2
- export * from './config.js';
3
- export { type L1PublishedData } from './structs/published.js';
4
- export type { ArchiverDataStore } from './archiver_store.js';
5
- export { KVArchiverDataStore, ARCHIVER_DB_VERSION } from './kv_archiver_store/kv_archiver_store.js';
6
- export { ContractInstanceStore } from './kv_archiver_store/contract_instance_store.js';
@@ -1,98 +0,0 @@
1
- # Archiver L1 Data Retrieval
2
-
3
- Modules and classes to handle data retrieval from L1 for the archiver.
4
-
5
- ## Calldata Retriever
6
-
7
- The sequencer publisher bundles multiple operations into a single multicall3 transaction for gas
8
- efficiency. A typical transaction includes:
9
-
10
- 1. Attestation invalidations (if needed): `invalidateBadAttestation`, `invalidateInsufficientAttestations`
11
- 2. Block proposal: `propose` (exactly one per transaction to the rollup contract)
12
- 3. Governance and slashing (if needed): votes, payload creation/execution
13
-
14
- The archiver needs to extract the `propose` calldata from these bundled transactions to reconstruct
15
- L2 blocks. This class needs to handle scenarios where the transaction was submitted via multicall3,
16
- as well as alternative ways for submitting the `propose` call that other clients might use.
17
-
18
- ### Multicall3 Validation and Decoding
19
-
20
- First attempt to decode the transaction as a multicall3 `aggregate3` call with validation:
21
-
22
- - Check if transaction is to multicall3 address (`0xcA11bde05977b3631167028862bE2a173976CA11`)
23
- - Decode as `aggregate3(Call3[] calldata calls)`
24
- - Allow calls to known addresses and methods (rollup, governance, slashing contracts, etc.)
25
- - Find the single `propose` call to the rollup contract
26
- - Verify exactly one `propose` call exists
27
- - Extract and return the propose calldata
28
-
29
- This step handles the common case efficiently without requiring expensive trace or debug RPC calls.
30
- Any validation failure triggers fallback to the next step.
31
-
32
- ### Direct Propose Call
33
-
34
- Second attempt to decode the transaction as a direct `propose` call to the rollup contract:
35
-
36
- - Check if transaction is to the rollup address
37
- - Decode as `propose` function call
38
- - Verify the function is indeed `propose`
39
- - Return the transaction input as the propose calldata
40
-
41
- This handles scenarios where clients submit transactions directly to the rollup contract without
42
- using multicall3 for bundling. Any validation failure triggers fallback to the next step.
43
-
44
- ### Spire Proposer Call
45
-
46
- Given existing attempts to route the call via the Spire proposer, we also check if the tx is `to` the
47
- proposer known address, and if so, we try decoding it as either a multicall3 or a direct call to the
48
- rollup contract.
49
-
50
- Similar as with the multicall3 check, we check that there are no other calls in the Spire proposer, so
51
- we are absolutely sure that the only call is the successful one to the rollup. Any extraneous call would
52
- imply an unexpected path to calling `propose` in the rollup contract, and since we cannot verify if the
53
- calldata arguments we extracted are the correct ones (see the section below), we cannot know for sure which
54
- one is the call that succeeded, so we don't know which calldata to process.
55
-
56
- Furthermore, since the Spire proposer is upgradeable, we check if the implementation has not changed in
57
- order to decode. As usual, any validation failure triggers fallback to the next step.
58
-
59
- ### Verifying Multicall3 Arguments
60
-
61
- **This is NOT implemented for simplicity's sake**
62
-
63
- If the checks above don't hold, such as when there are multiple calls to `propose`, then we cannot
64
- reliably extract the `propose` calldata from the multicall3 arguments alone. We can try a best-effort
65
- where we try all `propose` calls we see and validate them against on-chain data. Note that we can use these
66
- same strategies if we were to obtain the calldata from another source.
67
-
68
- #### TempBlockLog Verification
69
-
70
- Read the stored `TempBlockLog` for the L2 block number from L1 and verify it matches our decoded header hash,
71
- since the `TempBlockLog` stores the hash of the proposed block header, the payload commitment, and the attestations.
72
-
73
- However, `TempBlockLog` is only stored temporarily and deleted after proven, so this method only works for recent
74
- blocks, not for historical data syncing.
75
-
76
- #### Archive Verification
77
-
78
- Verify that the archive root in the decoded propose is correct with regard to the block header. This requires
79
- hashing the block header we have retrieved, inserting it into the archive tree, and checking the resulting root
80
- against the one we got from L1.
81
-
82
- However, this requires that the archive keeps a reference to world-state, which is not the case in the current
83
- system.
84
-
85
- #### Emit Commitments in Rollup Contract
86
-
87
- Modify rollup contract to emit commitments to the block header in the `L2BlockProposed` event, allowing us to easily
88
- verify the calldata we obtained vs the emitted event.
89
-
90
- However, modifying the rollup contract is out of scope for this change. But we can implement this approach in `v2`.
91
-
92
- ### Debug and Trace Transaction Fallback
93
-
94
- Last, we use L1 node's trace/debug RPC methods to definitively identify the one successful `propose` call within the tx.
95
- We can then extract the exact calldata that hit the `propose` function in the rollup contract.
96
-
97
- This approach requires access to a debug-enabled L1 node, which may be more resource-intensive, so we only
98
- use it as a fallback when the first step fails, which should be rare in practice.