@aztec/stdlib 0.0.1-commit.ff7989d6c → 0.0.1-commit.fff30aa

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 (372) hide show
  1. package/dest/abi/abi.d.ts +57 -85
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +55 -6
  4. package/dest/abi/buffer.d.ts +14 -4
  5. package/dest/abi/buffer.d.ts.map +1 -1
  6. package/dest/abi/buffer.js +25 -4
  7. package/dest/abi/decoder.d.ts +6 -45
  8. package/dest/abi/decoder.d.ts.map +1 -1
  9. package/dest/abi/decoder.js +17 -70
  10. package/dest/abi/encoder.d.ts +1 -1
  11. package/dest/abi/encoder.d.ts.map +1 -1
  12. package/dest/abi/encoder.js +37 -6
  13. package/dest/abi/event_metadata_definition.d.ts +3 -1
  14. package/dest/abi/event_metadata_definition.d.ts.map +1 -1
  15. package/dest/abi/event_metadata_definition.js +1 -1
  16. package/dest/abi/function_selector.js +1 -1
  17. package/dest/abi/function_signature_decoder.d.ts +43 -0
  18. package/dest/abi/function_signature_decoder.d.ts.map +1 -0
  19. package/dest/abi/function_signature_decoder.js +66 -0
  20. package/dest/abi/index.d.ts +2 -1
  21. package/dest/abi/index.d.ts.map +1 -1
  22. package/dest/abi/index.js +1 -0
  23. package/dest/abi/selector.d.ts +2 -2
  24. package/dest/abi/selector.d.ts.map +1 -1
  25. package/dest/abi/selector.js +1 -1
  26. package/dest/abi/utils.d.ts +14 -1
  27. package/dest/abi/utils.d.ts.map +1 -1
  28. package/dest/abi/utils.js +15 -0
  29. package/dest/avm/avm.d.ts +300 -300
  30. package/dest/avm/avm_accumulated_data.js +2 -2
  31. package/dest/avm/avm_circuit_public_inputs.js +2 -2
  32. package/dest/avm/avm_proving_request.d.ts +166 -166
  33. package/dest/avm/revert_code.d.ts +9 -4
  34. package/dest/avm/revert_code.d.ts.map +1 -1
  35. package/dest/avm/revert_code.js +16 -21
  36. package/dest/block/l2_block.d.ts +9 -1
  37. package/dest/block/l2_block.d.ts.map +1 -1
  38. package/dest/block/l2_block.js +12 -2
  39. package/dest/block/l2_block_source.d.ts +16 -8
  40. package/dest/block/l2_block_source.d.ts.map +1 -1
  41. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  42. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  43. package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
  44. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  45. package/dest/block/l2_block_stream/l2_block_stream.js +10 -0
  46. package/dest/checkpoint/checkpoint.d.ts +2 -1
  47. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  48. package/dest/checkpoint/checkpoint.js +9 -4
  49. package/dest/checkpoint/index.d.ts +2 -1
  50. package/dest/checkpoint/index.d.ts.map +1 -1
  51. package/dest/checkpoint/index.js +1 -0
  52. package/dest/checkpoint/validate.d.ts +36 -0
  53. package/dest/checkpoint/validate.d.ts.map +1 -0
  54. package/dest/checkpoint/validate.js +120 -0
  55. package/dest/config/sequencer-config.d.ts +2 -2
  56. package/dest/config/sequencer-config.d.ts.map +1 -1
  57. package/dest/config/sequencer-config.js +5 -0
  58. package/dest/epoch-helpers/index.d.ts +9 -1
  59. package/dest/epoch-helpers/index.d.ts.map +1 -1
  60. package/dest/epoch-helpers/index.js +13 -2
  61. package/dest/gas/gas_fees.d.ts +1 -1
  62. package/dest/gas/gas_fees.d.ts.map +1 -1
  63. package/dest/gas/gas_fees.js +4 -1
  64. package/dest/gas/gas_settings.d.ts +40 -3
  65. package/dest/gas/gas_settings.d.ts.map +1 -1
  66. package/dest/gas/gas_settings.js +50 -6
  67. package/dest/hash/hash.d.ts +19 -1
  68. package/dest/hash/hash.d.ts.map +1 -1
  69. package/dest/hash/hash.js +29 -0
  70. package/dest/interfaces/allowed_element.d.ts +26 -20
  71. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  72. package/dest/interfaces/allowed_element.js +8 -8
  73. package/dest/interfaces/archiver.d.ts +1 -1
  74. package/dest/interfaces/archiver.d.ts.map +1 -1
  75. package/dest/interfaces/archiver.js +3 -2
  76. package/dest/interfaces/aztec-node-admin.d.ts +64 -27
  77. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  78. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  79. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  80. package/dest/interfaces/aztec-node-debug.js +18 -0
  81. package/dest/interfaces/aztec-node.d.ts +12 -6
  82. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  83. package/dest/interfaces/aztec-node.js +5 -2
  84. package/dest/interfaces/block-builder.d.ts +38 -11
  85. package/dest/interfaces/block-builder.d.ts.map +1 -1
  86. package/dest/interfaces/block-builder.js +13 -6
  87. package/dest/interfaces/client.d.ts +2 -1
  88. package/dest/interfaces/client.d.ts.map +1 -1
  89. package/dest/interfaces/client.js +1 -0
  90. package/dest/interfaces/configs.d.ts +62 -32
  91. package/dest/interfaces/configs.d.ts.map +1 -1
  92. package/dest/interfaces/configs.js +6 -2
  93. package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
  94. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  95. package/dest/interfaces/p2p.d.ts +3 -8
  96. package/dest/interfaces/p2p.d.ts.map +1 -1
  97. package/dest/interfaces/prover-client.d.ts +6 -1
  98. package/dest/interfaces/prover-client.d.ts.map +1 -1
  99. package/dest/interfaces/prover-client.js +7 -1
  100. package/dest/interfaces/validator.d.ts +68 -26
  101. package/dest/interfaces/validator.d.ts.map +1 -1
  102. package/dest/interfaces/validator.js +7 -3
  103. package/dest/interfaces/world_state.d.ts +5 -4
  104. package/dest/interfaces/world_state.d.ts.map +1 -1
  105. package/dest/kernel/claimed_length_array.js +1 -1
  106. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +3 -3
  107. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  108. package/dest/kernel/hints/build_note_hash_read_request_hints.js +13 -10
  109. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
  110. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  111. package/dest/kernel/hints/build_nullifier_read_request_hints.js +13 -10
  112. package/dest/kernel/hints/build_transient_data_hints.d.ts +5 -2
  113. package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
  114. package/dest/kernel/hints/build_transient_data_hints.js +9 -3
  115. package/dest/kernel/hints/private_kernel_reset_hints.d.ts +1 -1
  116. package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
  117. package/dest/kernel/padded_side_effects.js +1 -1
  118. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
  119. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
  120. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
  121. package/dest/kernel/private_to_avm_accumulated_data.js +2 -2
  122. package/dest/kernel/private_to_public_accumulated_data.js +2 -2
  123. package/dest/kernel/private_to_rollup_accumulated_data.js +1 -1
  124. package/dest/logs/debug_log_store.d.ts +30 -0
  125. package/dest/logs/debug_log_store.d.ts.map +1 -0
  126. package/dest/logs/debug_log_store.js +30 -0
  127. package/dest/logs/extended_directional_app_tagging_secret.d.ts +47 -0
  128. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -0
  129. package/dest/logs/{directional_app_tagging_secret.js → extended_directional_app_tagging_secret.js} +35 -20
  130. package/dest/logs/index.d.ts +4 -2
  131. package/dest/logs/index.d.ts.map +1 -1
  132. package/dest/logs/index.js +3 -1
  133. package/dest/logs/log_filter.d.ts +4 -1
  134. package/dest/logs/log_filter.d.ts.map +1 -1
  135. package/dest/logs/log_filter.js +2 -1
  136. package/dest/logs/message_context.d.ts +4 -7
  137. package/dest/logs/message_context.d.ts.map +1 -1
  138. package/dest/logs/message_context.js +23 -9
  139. package/dest/logs/pending_tagged_log.d.ts +2 -3
  140. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  141. package/dest/logs/pending_tagged_log.js +2 -2
  142. package/dest/logs/pre_tag.d.ts +16 -11
  143. package/dest/logs/pre_tag.d.ts.map +1 -1
  144. package/dest/logs/pre_tag.js +2 -2
  145. package/dest/logs/private_log.js +1 -1
  146. package/dest/logs/public_log.d.ts +4 -3
  147. package/dest/logs/public_log.d.ts.map +1 -1
  148. package/dest/logs/public_log.js +9 -2
  149. package/dest/logs/shared_secret_derivation.d.ts +11 -10
  150. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  151. package/dest/logs/shared_secret_derivation.js +15 -9
  152. package/dest/logs/siloed_tag.d.ts +8 -3
  153. package/dest/logs/siloed_tag.d.ts.map +1 -1
  154. package/dest/logs/siloed_tag.js +11 -2
  155. package/dest/logs/tag.js +1 -1
  156. package/dest/logs/tagging_index_range.d.ts +40 -0
  157. package/dest/logs/tagging_index_range.d.ts.map +1 -0
  158. package/dest/logs/tagging_index_range.js +8 -0
  159. package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
  160. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  161. package/dest/logs/tx_scoped_l2_log.js +7 -0
  162. package/dest/messaging/l1_to_l2_message.d.ts +3 -2
  163. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  164. package/dest/messaging/l1_to_l2_message.js +11 -13
  165. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  166. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  167. package/dest/messaging/l2_to_l1_membership.js +69 -26
  168. package/dest/noir/index.d.ts +3 -3
  169. package/dest/noir/index.d.ts.map +1 -1
  170. package/dest/note/note_dao.d.ts +1 -1
  171. package/dest/note/note_dao.d.ts.map +1 -1
  172. package/dest/note/note_dao.js +1 -4
  173. package/dest/p2p/attestation_utils.d.ts +11 -1
  174. package/dest/p2p/attestation_utils.d.ts.map +1 -1
  175. package/dest/p2p/attestation_utils.js +45 -0
  176. package/dest/p2p/block_proposal.d.ts +2 -2
  177. package/dest/p2p/block_proposal.d.ts.map +1 -1
  178. package/dest/p2p/block_proposal.js +1 -1
  179. package/dest/p2p/checkpoint_proposal.d.ts +2 -7
  180. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  181. package/dest/p2p/checkpoint_proposal.js +14 -24
  182. package/dest/p2p/client_type.d.ts +2 -5
  183. package/dest/p2p/client_type.d.ts.map +1 -1
  184. package/dest/p2p/client_type.js +0 -7
  185. package/dest/p2p/index.d.ts +1 -2
  186. package/dest/p2p/index.d.ts.map +1 -1
  187. package/dest/p2p/index.js +0 -1
  188. package/dest/p2p/peer_error.d.ts +3 -1
  189. package/dest/p2p/peer_error.d.ts.map +1 -1
  190. package/dest/p2p/peer_error.js +5 -0
  191. package/dest/p2p/topic_type.d.ts +3 -4
  192. package/dest/p2p/topic_type.d.ts.map +1 -1
  193. package/dest/p2p/topic_type.js +7 -24
  194. package/dest/parity/parity_base_private_inputs.js +1 -1
  195. package/dest/proofs/chonk_proof.d.ts +1 -1
  196. package/dest/proofs/chonk_proof.d.ts.map +1 -1
  197. package/dest/proofs/chonk_proof.js +7 -1
  198. package/dest/rollup/base_rollup_hints.js +2 -2
  199. package/dest/rollup/block_root_rollup_private_inputs.js +5 -5
  200. package/dest/rollup/checkpoint_rollup_public_inputs.js +1 -1
  201. package/dest/rollup/checkpoint_root_rollup_private_inputs.js +3 -3
  202. package/dest/rollup/root_rollup_public_inputs.js +1 -1
  203. package/dest/rollup/tree_snapshot_diff_hints.js +2 -2
  204. package/dest/slashing/tally.d.ts +7 -2
  205. package/dest/slashing/tally.d.ts.map +1 -1
  206. package/dest/slashing/tally.js +30 -2
  207. package/dest/tests/factories.d.ts +3 -1
  208. package/dest/tests/factories.d.ts.map +1 -1
  209. package/dest/tests/factories.js +9 -1
  210. package/dest/tests/mocks.d.ts +5 -3
  211. package/dest/tests/mocks.d.ts.map +1 -1
  212. package/dest/tests/mocks.js +20 -15
  213. package/dest/tx/block_header.d.ts +3 -1
  214. package/dest/tx/block_header.d.ts.map +1 -1
  215. package/dest/tx/block_header.js +4 -0
  216. package/dest/tx/capsule.d.ts +6 -2
  217. package/dest/tx/capsule.d.ts.map +1 -1
  218. package/dest/tx/capsule.js +9 -3
  219. package/dest/tx/private_execution_result.d.ts +6 -6
  220. package/dest/tx/private_execution_result.d.ts.map +1 -1
  221. package/dest/tx/private_execution_result.js +6 -6
  222. package/dest/tx/profiling.d.ts +14 -2
  223. package/dest/tx/profiling.d.ts.map +1 -1
  224. package/dest/tx/profiling.js +13 -3
  225. package/dest/tx/protocol_contracts.js +2 -2
  226. package/dest/tx/simulated_tx.d.ts +63 -77
  227. package/dest/tx/simulated_tx.d.ts.map +1 -1
  228. package/dest/tx/simulated_tx.js +7 -4
  229. package/dest/tx/tx.d.ts +6 -5
  230. package/dest/tx/tx.d.ts.map +1 -1
  231. package/dest/tx/tx.js +18 -6
  232. package/dest/tx/tx_receipt.d.ts +29 -6
  233. package/dest/tx/tx_receipt.d.ts.map +1 -1
  234. package/dest/tx/tx_receipt.js +23 -19
  235. package/dest/tx/validator/error_texts.d.ts +9 -1
  236. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  237. package/dest/tx/validator/error_texts.js +10 -0
  238. package/dest/update-checker/index.d.ts +3 -2
  239. package/dest/update-checker/index.d.ts.map +1 -1
  240. package/dest/update-checker/index.js +2 -1
  241. package/dest/update-checker/package_version.d.ts +3 -0
  242. package/dest/update-checker/package_version.d.ts.map +1 -0
  243. package/dest/update-checker/package_version.js +24 -0
  244. package/dest/update-checker/version_checker.d.ts +25 -0
  245. package/dest/update-checker/version_checker.d.ts.map +1 -0
  246. package/dest/update-checker/version_checker.js +50 -0
  247. package/dest/validators/errors.d.ts +6 -1
  248. package/dest/validators/errors.d.ts.map +1 -1
  249. package/dest/validators/errors.js +7 -0
  250. package/dest/versioning/versioning.d.ts +4 -2
  251. package/dest/versioning/versioning.d.ts.map +1 -1
  252. package/dest/versioning/versioning.js +4 -1
  253. package/dest/vks/vk_data.js +1 -1
  254. package/package.json +10 -10
  255. package/src/abi/abi.ts +78 -2
  256. package/src/abi/buffer.ts +25 -4
  257. package/src/abi/decoder.ts +36 -82
  258. package/src/abi/encoder.ts +49 -6
  259. package/src/abi/event_metadata_definition.ts +2 -0
  260. package/src/abi/function_selector.ts +1 -1
  261. package/src/abi/function_signature_decoder.ts +77 -0
  262. package/src/abi/index.ts +1 -0
  263. package/src/abi/selector.ts +1 -1
  264. package/src/abi/utils.ts +25 -0
  265. package/src/avm/avm_accumulated_data.ts +6 -6
  266. package/src/avm/avm_circuit_public_inputs.ts +4 -4
  267. package/src/avm/revert_code.ts +26 -25
  268. package/src/block/l2_block.ts +13 -1
  269. package/src/block/l2_block_source.ts +16 -7
  270. package/src/block/l2_block_stream/interfaces.ts +6 -2
  271. package/src/block/l2_block_stream/l2_block_stream.ts +21 -0
  272. package/src/checkpoint/checkpoint.ts +12 -3
  273. package/src/checkpoint/index.ts +1 -0
  274. package/src/checkpoint/validate.ts +230 -0
  275. package/src/config/sequencer-config.ts +6 -1
  276. package/src/epoch-helpers/index.ts +22 -0
  277. package/src/gas/README.md +123 -0
  278. package/src/gas/gas_fees.ts +7 -1
  279. package/src/gas/gas_settings.ts +65 -12
  280. package/src/hash/hash.ts +34 -0
  281. package/src/interfaces/allowed_element.ts +29 -9
  282. package/src/interfaces/archiver.ts +3 -2
  283. package/src/interfaces/aztec-node-debug.ts +40 -0
  284. package/src/interfaces/aztec-node.ts +24 -5
  285. package/src/interfaces/block-builder.ts +60 -14
  286. package/src/interfaces/client.ts +1 -0
  287. package/src/interfaces/configs.ts +25 -8
  288. package/src/interfaces/merkle_tree_operations.ts +8 -18
  289. package/src/interfaces/p2p.ts +2 -13
  290. package/src/interfaces/prover-client.ts +8 -0
  291. package/src/interfaces/validator.ts +19 -3
  292. package/src/interfaces/world_state.ts +4 -3
  293. package/src/kernel/claimed_length_array.ts +2 -2
  294. package/src/kernel/hints/build_note_hash_read_request_hints.ts +14 -18
  295. package/src/kernel/hints/build_nullifier_read_request_hints.ts +15 -18
  296. package/src/kernel/hints/build_transient_data_hints.ts +17 -2
  297. package/src/kernel/hints/private_kernel_reset_hints.ts +5 -2
  298. package/src/kernel/hints/read_request_hints.ts +3 -3
  299. package/src/kernel/padded_side_effects.ts +3 -3
  300. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
  301. package/src/kernel/private_to_avm_accumulated_data.ts +4 -4
  302. package/src/kernel/private_to_public_accumulated_data.ts +10 -10
  303. package/src/kernel/private_to_rollup_accumulated_data.ts +5 -5
  304. package/src/logs/debug_log_store.ts +54 -0
  305. package/src/logs/{directional_app_tagging_secret.ts → extended_directional_app_tagging_secret.ts} +41 -22
  306. package/src/logs/index.ts +3 -1
  307. package/src/logs/log_filter.ts +5 -0
  308. package/src/logs/message_context.ts +17 -7
  309. package/src/logs/pending_tagged_log.ts +1 -3
  310. package/src/logs/pre_tag.ts +5 -5
  311. package/src/logs/private_log.ts +1 -1
  312. package/src/logs/public_log.ts +15 -3
  313. package/src/logs/shared_secret_derivation.ts +21 -10
  314. package/src/logs/siloed_tag.ts +14 -3
  315. package/src/logs/tag.ts +1 -1
  316. package/src/logs/tagging_index_range.ts +24 -0
  317. package/src/logs/tx_scoped_l2_log.ts +16 -0
  318. package/src/messaging/l1_to_l2_message.ts +12 -9
  319. package/src/messaging/l2_to_l1_membership.ts +98 -33
  320. package/src/noir/index.ts +2 -2
  321. package/src/note/note_dao.ts +1 -4
  322. package/src/p2p/attestation_utils.ts +56 -0
  323. package/src/p2p/block_proposal.ts +1 -1
  324. package/src/p2p/checkpoint_proposal.ts +24 -38
  325. package/src/p2p/client_type.ts +0 -6
  326. package/src/p2p/index.ts +0 -1
  327. package/src/p2p/peer_error.ts +7 -0
  328. package/src/p2p/topic_type.ts +8 -15
  329. package/src/parity/parity_base_private_inputs.ts +1 -1
  330. package/src/proofs/chonk_proof.ts +9 -1
  331. package/src/rollup/base_rollup_hints.ts +2 -2
  332. package/src/rollup/block_root_rollup_private_inputs.ts +8 -8
  333. package/src/rollup/checkpoint_rollup_public_inputs.ts +2 -2
  334. package/src/rollup/checkpoint_root_rollup_private_inputs.ts +4 -4
  335. package/src/rollup/root_rollup_public_inputs.ts +2 -2
  336. package/src/rollup/tree_snapshot_diff_hints.ts +5 -5
  337. package/src/slashing/tally.ts +34 -1
  338. package/src/tests/factories.ts +10 -1
  339. package/src/tests/mocks.ts +26 -11
  340. package/src/tx/block_header.ts +6 -0
  341. package/src/tx/capsule.ts +10 -2
  342. package/src/tx/private_execution_result.ts +5 -5
  343. package/src/tx/profiling.ts +11 -2
  344. package/src/tx/protocol_contracts.ts +2 -2
  345. package/src/tx/simulated_tx.ts +14 -3
  346. package/src/tx/tx.ts +20 -11
  347. package/src/tx/tx_receipt.ts +28 -16
  348. package/src/tx/validator/error_texts.ts +12 -0
  349. package/src/update-checker/index.ts +2 -1
  350. package/src/update-checker/package_version.ts +30 -0
  351. package/src/update-checker/version_checker.ts +65 -0
  352. package/src/validators/errors.ts +9 -0
  353. package/src/versioning/versioning.ts +4 -1
  354. package/src/vks/vk_data.ts +1 -1
  355. package/dest/ha-signing/config.d.ts +0 -101
  356. package/dest/ha-signing/config.d.ts.map +0 -1
  357. package/dest/ha-signing/config.js +0 -92
  358. package/dest/ha-signing/index.d.ts +0 -3
  359. package/dest/ha-signing/index.d.ts.map +0 -1
  360. package/dest/ha-signing/index.js +0 -2
  361. package/dest/ha-signing/types.d.ts +0 -85
  362. package/dest/ha-signing/types.d.ts.map +0 -1
  363. package/dest/ha-signing/types.js +0 -32
  364. package/dest/logs/directional_app_tagging_secret.d.ts +0 -40
  365. package/dest/logs/directional_app_tagging_secret.d.ts.map +0 -1
  366. package/dest/update-checker/update-checker.d.ts +0 -49
  367. package/dest/update-checker/update-checker.d.ts.map +0 -1
  368. package/dest/update-checker/update-checker.js +0 -130
  369. package/src/ha-signing/config.ts +0 -149
  370. package/src/ha-signing/index.ts +0 -18
  371. package/src/ha-signing/types.ts +0 -112
  372. package/src/update-checker/update-checker.ts +0 -166
@@ -1,13 +1,32 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
3
 
3
4
  import { AztecAddress } from '../aztec-address/index.js';
4
- import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
5
- import { isAztecAddressStruct, parseSignedInt } from './utils.js';
5
+ import type { AbiType } from './abi.js';
6
+ import { FunctionSelector } from './function_selector.js';
7
+ import {
8
+ isAztecAddressStruct,
9
+ isEthAddressStruct,
10
+ isFunctionSelectorStruct,
11
+ isOptionStruct,
12
+ isWrappedFieldStruct,
13
+ parseSignedInt,
14
+ } from './utils.js';
6
15
 
7
16
  /**
8
17
  * The type of our decoded ABI.
9
18
  */
10
- export type AbiDecoded = bigint | boolean | string | AztecAddress | AbiDecoded[] | { [key: string]: AbiDecoded };
19
+ export type AbiDecoded =
20
+ | bigint
21
+ | boolean
22
+ | string
23
+ | AztecAddress
24
+ | EthAddress
25
+ | FunctionSelector
26
+ | Fr
27
+ | AbiDecoded[]
28
+ | { [key: string]: AbiDecoded }
29
+ | undefined;
11
30
 
12
31
  /**
13
32
  * Decodes values using a provided ABI.
@@ -51,6 +70,20 @@ class AbiDecoder {
51
70
  if (isAztecAddressStruct(abiType)) {
52
71
  return new AztecAddress(this.getNextField().toBuffer());
53
72
  }
73
+ if (isEthAddressStruct(abiType)) {
74
+ return EthAddress.fromField(this.getNextField());
75
+ }
76
+ if (isFunctionSelectorStruct(abiType)) {
77
+ return FunctionSelector.fromField(this.getNextField());
78
+ }
79
+ if (isWrappedFieldStruct(abiType)) {
80
+ return this.getNextField();
81
+ }
82
+ if (isOptionStruct(abiType)) {
83
+ const isSome = this.decodeNext(abiType.fields[0].type);
84
+ const value = this.decodeNext(abiType.fields[1].type);
85
+ return isSome ? value : undefined;
86
+ }
54
87
 
55
88
  for (const field of abiType.fields) {
56
89
  struct[field.name] = this.decodeNext(field.type);
@@ -111,82 +144,3 @@ class AbiDecoder {
111
144
  export function decodeFromAbi(typ: AbiType[], buffer: Fr[]) {
112
145
  return new AbiDecoder(typ, buffer.slice()).decode();
113
146
  }
114
-
115
- /**
116
- * Decodes the signature of a function from the name and parameters.
117
- */
118
- export class FunctionSignatureDecoder {
119
- private separator: string;
120
- constructor(
121
- private name: string,
122
- private parameters: ABIParameter[],
123
- private includeNames = false,
124
- ) {
125
- this.separator = includeNames ? ', ' : ',';
126
- }
127
-
128
- /**
129
- * Decodes a single function parameter type for the function signature.
130
- * @param param - The parameter type to decode.
131
- * @returns A string representing the parameter type.
132
- */
133
- private getParameterType(param: AbiType): string {
134
- switch (param.kind) {
135
- case 'field':
136
- return 'Field';
137
- case 'integer':
138
- if (param.sign === 'signed') {
139
- throw new Error('Unsupported type: signed integer');
140
- }
141
- return `u${param.width}`;
142
- case 'boolean':
143
- return 'bool';
144
- case 'array':
145
- return `[${this.getParameterType(param.type)};${param.length}]`;
146
- case 'string':
147
- return `str<${param.length}>`;
148
- case 'struct':
149
- return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
150
- default:
151
- throw new Error(`Unsupported type: ${param.kind}`);
152
- }
153
- }
154
-
155
- /**
156
- * Decodes a single function parameter for the function signature.
157
- * @param param - The parameter to decode.
158
- * @returns A string representing the parameter type and optionally its name.
159
- */
160
- private decodeParameter(param: ABIVariable): string {
161
- const type = this.getParameterType(param.type);
162
- return this.includeNames ? `${param.name}: ${type}` : type;
163
- }
164
-
165
- /**
166
- * Decodes all the parameters and build the function signature
167
- * @returns The function signature.
168
- */
169
- public decode(): string {
170
- return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
171
- }
172
- }
173
-
174
- /**
175
- * Decodes a function signature from the name and parameters.
176
- * @param name - The name of the function.
177
- * @param parameters - The parameters of the function.
178
- * @returns - The function signature.
179
- */
180
- export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
181
- return new FunctionSignatureDecoder(name, parameters).decode();
182
- }
183
-
184
- /**
185
- * Decodes a function signature from the name and parameters including parameter names.
186
- * @param name - The name of the function.
187
- * @param parameters - The parameters of the function.
188
- * @returns - The user-friendly function signature.
189
- */
190
- export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
191
- return new FunctionSignatureDecoder(name, parameters, true).decode();
192
- }
@@ -1,7 +1,13 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  import type { AbiType, FunctionAbi } from './abi.js';
4
- import { isAddressStruct, isBoundedVecStruct, isFunctionSelectorStruct, isWrappedFieldStruct } from './utils.js';
4
+ import {
5
+ isAddressStruct,
6
+ isBoundedVecStruct,
7
+ isFunctionSelectorStruct,
8
+ isOptionStruct,
9
+ isWrappedFieldStruct,
10
+ } from './utils.js';
5
11
 
6
12
  /**
7
13
  * Encodes arguments for a function call.
@@ -43,6 +49,32 @@ class ArgumentEncoder {
43
49
  * @param name - Name.
44
50
  */
45
51
  private encodeArgument(abiType: AbiType, arg: any, name?: string) {
52
+ if (isOptionStruct(abiType)) {
53
+ const optionType = abiType as Extract<AbiType, { kind: 'struct' }>;
54
+ const [isSomeField, valueField] = optionType.fields;
55
+
56
+ if (arg === undefined || arg === null) {
57
+ this.encodeArgument(isSomeField.type, false, `${name}._is_some`);
58
+ this.#encodeDefaultValue(valueField.type);
59
+ return;
60
+ }
61
+
62
+ if (typeof arg === 'object' && '_is_some' in arg) {
63
+ this.encodeArgument(isSomeField.type, arg._is_some, `${name}._is_some`);
64
+
65
+ if (arg._is_some) {
66
+ this.encodeArgument(valueField.type, arg._value, `${name}._value`);
67
+ } else {
68
+ this.#encodeDefaultValue(valueField.type);
69
+ }
70
+ return;
71
+ }
72
+
73
+ this.encodeArgument(isSomeField.type, true, `${name}._is_some`);
74
+ this.encodeArgument(valueField.type, arg, `${name}._value`);
75
+ return;
76
+ }
77
+
46
78
  if (arg === undefined || arg == null) {
47
79
  throw new Error(`Undefined argument ${name ?? 'unnamed'} of type ${abiType.kind}`);
48
80
  }
@@ -123,14 +155,17 @@ class ArgumentEncoder {
123
155
  }
124
156
  break;
125
157
  }
126
- case 'integer':
127
- if (typeof arg === 'string') {
128
- const value = BigInt(arg);
129
- this.flattened.push(new Fr(value));
158
+ case 'integer': {
159
+ const value = BigInt(arg);
160
+ if (abiType.sign === 'signed' && value < 0n) {
161
+ // Convert negative values to two's complement representation
162
+ const twosComplement = value + (1n << BigInt(abiType.width));
163
+ this.flattened.push(new Fr(twosComplement));
130
164
  } else {
131
- this.flattened.push(new Fr(arg));
165
+ this.flattened.push(new Fr(value));
132
166
  }
133
167
  break;
168
+ }
134
169
  default:
135
170
  throw new Error(`Unsupported type: ${abiType.kind}`);
136
171
  }
@@ -224,6 +259,14 @@ class ArgumentEncoder {
224
259
  this.encodeArgument(lenField.type, arg.length, 'len');
225
260
  }
226
261
  }
262
+
263
+ /**
264
+ * Appends the flattened zero value for an ABI type.
265
+ * Option::None still serializes the wrapped value, so we need to zero-fill its footprint.
266
+ */
267
+ #encodeDefaultValue(abiType: AbiType) {
268
+ this.flattened.push(...new Array(ArgumentEncoder.typeSize(abiType)).fill(Fr.ZERO));
269
+ }
227
270
  }
228
271
 
229
272
  /**
@@ -1,8 +1,10 @@
1
1
  import type { AbiType } from './abi.js';
2
2
  import type { EventSelector } from './event_selector.js';
3
3
 
4
+ /** Metadata for a contract event, used to decode emitted event logs back into structured data. */
4
5
  export type EventMetadataDefinition = {
5
6
  eventSelector: EventSelector;
6
7
  abiType: AbiType;
8
+ /** Names of the event's struct members (not serialized Noir Field elements). */
7
9
  fieldNames: string[];
8
10
  };
@@ -6,7 +6,7 @@ import { type ZodFor, hexSchemaFor } from '@aztec/foundation/schemas';
6
6
  import { BufferReader, FieldReader, TypeRegistry } from '@aztec/foundation/serialize';
7
7
 
8
8
  import type { ABIParameter } from './abi.js';
9
- import { decodeFunctionSignature } from './decoder.js';
9
+ import { decodeFunctionSignature } from './function_signature_decoder.js';
10
10
  import { Selector } from './selector.js';
11
11
 
12
12
  /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
@@ -0,0 +1,77 @@
1
+ import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
2
+
3
+ /**
4
+ * Decodes the signature of a function from the name and parameters.
5
+ */
6
+ export class FunctionSignatureDecoder {
7
+ private separator: string;
8
+ constructor(
9
+ private name: string,
10
+ private parameters: ABIParameter[],
11
+ private includeNames = false,
12
+ ) {
13
+ this.separator = includeNames ? ', ' : ',';
14
+ }
15
+
16
+ /**
17
+ * Decodes a single function parameter type for the function signature.
18
+ * @param param - The parameter type to decode.
19
+ * @returns A string representing the parameter type.
20
+ */
21
+ private getParameterType(param: AbiType): string {
22
+ switch (param.kind) {
23
+ case 'field':
24
+ return 'Field';
25
+ case 'integer':
26
+ return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
27
+ case 'boolean':
28
+ return 'bool';
29
+ case 'array':
30
+ return `[${this.getParameterType(param.type)};${param.length}]`;
31
+ case 'string':
32
+ return `str<${param.length}>`;
33
+ case 'struct':
34
+ return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
35
+ default:
36
+ throw new Error(`Unsupported type: ${param.kind}`);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Decodes a single function parameter for the function signature.
42
+ * @param param - The parameter to decode.
43
+ * @returns A string representing the parameter type and optionally its name.
44
+ */
45
+ private decodeParameter(param: ABIVariable): string {
46
+ const type = this.getParameterType(param.type);
47
+ return this.includeNames ? `${param.name}: ${type}` : type;
48
+ }
49
+
50
+ /**
51
+ * Decodes all the parameters and build the function signature
52
+ * @returns The function signature.
53
+ */
54
+ public decode(): string {
55
+ return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Decodes a function signature from the name and parameters.
61
+ * @param name - The name of the function.
62
+ * @param parameters - The parameters of the function.
63
+ * @returns - The function signature.
64
+ */
65
+ export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
66
+ return new FunctionSignatureDecoder(name, parameters).decode();
67
+ }
68
+
69
+ /**
70
+ * Decodes a function signature from the name and parameters including parameter names.
71
+ * @param name - The name of the function.
72
+ * @param parameters - The parameters of the function.
73
+ * @returns - The user-friendly function signature.
74
+ */
75
+ export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
76
+ return new FunctionSignatureDecoder(name, parameters, true).decode();
77
+ }
package/src/abi/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './abi.js';
2
2
  export * from './buffer.js';
3
3
  export * from './decoder.js';
4
+ export * from './function_signature_decoder.js';
4
5
  export * from './encoder.js';
5
6
  export * from './authorization_selector.js';
6
7
  export * from './event_metadata_definition.js';
@@ -4,7 +4,7 @@ import { bufferToHex } from '@aztec/foundation/string';
4
4
 
5
5
  import { inspect } from 'util';
6
6
 
7
- /** A selector is the first 4 bytes of the hash of a signature. */
7
+ /** A selector is the low 4 bytes of the poseidon2 hash of a signature. */
8
8
  export abstract class Selector {
9
9
  /** The size of the selector in bytes. */
10
10
  public static SIZE = 4;
package/src/abi/utils.ts CHANGED
@@ -81,6 +81,31 @@ export function isBoundedVecStruct(abiType: AbiType) {
81
81
  );
82
82
  }
83
83
 
84
+ /**
85
+ * Returns whether the ABI type is Noir's std::option::Option lowered to a struct.
86
+ * @param abiType - Type to check.
87
+ * @returns A boolean indicating whether the ABI type is an Option struct.
88
+ */
89
+ export function isOptionStruct(abiType: AbiType) {
90
+ return (
91
+ abiType.kind === 'struct' &&
92
+ abiType.path === 'std::option::Option' &&
93
+ abiType.fields.length === 2 &&
94
+ abiType.fields[0].name === '_is_some' &&
95
+ abiType.fields[1].name === '_value'
96
+ );
97
+ }
98
+
99
+ /**
100
+ * Returns whether `null` or `undefined` can be mapped to a valid ABI value for this type.
101
+ *
102
+ * @param abiType - Type to check.
103
+ * @returns A boolean indicating whether nullish values are valid shorthand for this ABI type.
104
+ */
105
+ export function canBeMappedFromNullOrUndefined(abiType: AbiType) {
106
+ return isOptionStruct(abiType);
107
+ }
108
+
84
109
  /**
85
110
  * Returns a bigint by parsing a serialized 2's complement signed int.
86
111
  * @param b - The signed int as a buffer
@@ -88,11 +88,11 @@ export class AvmAccumulatedData {
88
88
  static fromBuffer(buffer: Buffer | BufferReader) {
89
89
  const reader = BufferReader.asReader(buffer);
90
90
  return new this(
91
- reader.readArray(MAX_NOTE_HASHES_PER_TX, Fr),
92
- reader.readArray(MAX_NULLIFIERS_PER_TX, Fr),
93
- reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
91
+ reader.readTuple(MAX_NOTE_HASHES_PER_TX, Fr),
92
+ reader.readTuple(MAX_NULLIFIERS_PER_TX, Fr),
93
+ reader.readTuple(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
94
94
  reader.readObject(FlatPublicLogs),
95
- reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
95
+ reader.readTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
96
96
  );
97
97
  }
98
98
 
@@ -115,9 +115,9 @@ export class AvmAccumulatedData {
115
115
  return new this(
116
116
  reader.readFieldArray(MAX_NOTE_HASHES_PER_TX),
117
117
  reader.readFieldArray(MAX_NULLIFIERS_PER_TX),
118
- reader.readArray(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
118
+ reader.readTuple(MAX_L2_TO_L1_MSGS_PER_TX, ScopedL2ToL1Message),
119
119
  reader.readObject(FlatPublicLogs),
120
- reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
120
+ reader.readTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite),
121
121
  );
122
122
  }
123
123
 
@@ -143,8 +143,8 @@ export class AvmCircuitPublicInputs {
143
143
  reader.readObject(AztecAddress),
144
144
  reader.readObject(Fr),
145
145
  reader.readObject(PublicCallRequestArrayLengths),
146
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
147
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
146
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
147
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
148
148
  reader.readObject(PublicCallRequest),
149
149
  reader.readObject(PrivateToAvmAccumulatedDataArrayLengths),
150
150
  reader.readObject(PrivateToAvmAccumulatedDataArrayLengths),
@@ -206,8 +206,8 @@ export class AvmCircuitPublicInputs {
206
206
  AztecAddress.fromFields(reader),
207
207
  reader.readField(),
208
208
  PublicCallRequestArrayLengths.fromFields(reader),
209
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
210
- reader.readArray(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
209
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
210
+ reader.readTuple(MAX_ENQUEUED_CALLS_PER_TX, PublicCallRequest),
211
211
  PublicCallRequest.fromFields(reader),
212
212
  PrivateToAvmAccumulatedDataArrayLengths.fromFields(reader),
213
213
  PrivateToAvmAccumulatedDataArrayLengths.fromFields(reader),
@@ -5,20 +5,17 @@ import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
5
5
  import { inspect } from 'util';
6
6
  import { z } from 'zod';
7
7
 
8
+ /** Whether a transaction's public execution reverted. */
8
9
  export enum RevertCodeEnum {
10
+ /** All phases completed successfully; no state was rolled back. */
9
11
  OK = 0,
10
- APP_LOGIC_REVERTED = 1,
11
- TEARDOWN_REVERTED = 2,
12
- BOTH_REVERTED = 3,
12
+ /** One or more revertible phases reverted; their state changes were discarded. */
13
+ REVERTED = 1,
13
14
  }
14
15
 
15
- function isRevertCodeEnum(value: number): value is RevertCodeEnum {
16
- return (
17
- (value as RevertCodeEnum) === RevertCodeEnum.OK ||
18
- (value as RevertCodeEnum) === RevertCodeEnum.APP_LOGIC_REVERTED ||
19
- (value as RevertCodeEnum) === RevertCodeEnum.TEARDOWN_REVERTED ||
20
- (value as RevertCodeEnum) === RevertCodeEnum.BOTH_REVERTED
21
- );
16
+ /** Returns a valid RevertCodeEnum, coercing any value >= 1 to REVERTED. */
17
+ function toRevertCodeEnum(value: number): RevertCodeEnum {
18
+ return value >= 1 ? RevertCodeEnum.REVERTED : RevertCodeEnum.OK;
22
19
  }
23
20
 
24
21
  /**
@@ -30,9 +27,13 @@ export class RevertCode {
30
27
  this.code = e.valueOf();
31
28
  }
32
29
  static readonly OK: RevertCode = new RevertCode(RevertCodeEnum.OK);
33
- static readonly APP_LOGIC_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.APP_LOGIC_REVERTED);
34
- static readonly TEARDOWN_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.TEARDOWN_REVERTED);
35
- static readonly BOTH_REVERTED: RevertCode = new RevertCode(RevertCodeEnum.BOTH_REVERTED);
30
+ static readonly REVERTED: RevertCode = new RevertCode(RevertCodeEnum.REVERTED);
31
+ /** @deprecated Use REVERTED instead. */
32
+ static readonly APP_LOGIC_REVERTED: RevertCode = RevertCode.REVERTED;
33
+ /** @deprecated Use REVERTED instead. */
34
+ static readonly TEARDOWN_REVERTED: RevertCode = RevertCode.REVERTED;
35
+ /** @deprecated Use REVERTED instead. */
36
+ static readonly BOTH_REVERTED: RevertCode = RevertCode.REVERTED;
36
37
 
37
38
  public getCode(): RevertCodeEnum {
38
39
  return this.code;
@@ -50,12 +51,8 @@ export class RevertCode {
50
51
  switch (this.code as RevertCodeEnum) {
51
52
  case RevertCodeEnum.OK:
52
53
  return 'OK';
53
- case RevertCodeEnum.APP_LOGIC_REVERTED:
54
- return 'Application logic reverted';
55
- case RevertCodeEnum.TEARDOWN_REVERTED:
56
- return 'Teardown reverted';
57
- case RevertCodeEnum.BOTH_REVERTED:
58
- return 'Both reverted';
54
+ case RevertCodeEnum.REVERTED:
55
+ return 'Reverted';
59
56
  default:
60
57
  return `Unknown RevertCode: ${this.code}`;
61
58
  }
@@ -66,7 +63,11 @@ export class RevertCode {
66
63
  }
67
64
 
68
65
  static get schema(): ZodFor<RevertCode> {
69
- return z.nativeEnum(RevertCodeEnum).transform(value => new RevertCode(value));
66
+ return z
67
+ .number()
68
+ .int()
69
+ .min(0)
70
+ .transform(value => new RevertCode(toRevertCodeEnum(value)));
70
71
  }
71
72
 
72
73
  /**
@@ -81,10 +82,10 @@ export class RevertCode {
81
82
  return obj;
82
83
  }
83
84
  const code = typeof obj === 'number' ? obj : (obj.code ?? obj);
84
- if (!isRevertCodeEnum(code)) {
85
+ if (typeof code !== 'number' || code < 0) {
85
86
  throw new Error(`Invalid RevertCode: ${code}`);
86
87
  }
87
- return new RevertCode(code);
88
+ return new RevertCode(toRevertCodeEnum(code));
88
89
  }
89
90
 
90
91
  /**
@@ -116,10 +117,10 @@ export class RevertCode {
116
117
  }
117
118
 
118
119
  public static fromNumber(code: number): RevertCode {
119
- if (!isRevertCodeEnum(code)) {
120
+ if (code < 0) {
120
121
  throw new Error(`Invalid RevertCode: ${code}`);
121
122
  }
122
- return new RevertCode(code);
123
+ return new RevertCode(toRevertCodeEnum(code));
123
124
  }
124
125
 
125
126
  public static fromField(field: Fr): RevertCode {
@@ -137,7 +138,7 @@ export class RevertCode {
137
138
  return RevertCode.fromNumber(code);
138
139
  }
139
140
 
140
- private static readonly NUM_OPTIONS = 4;
141
+ private static readonly NUM_OPTIONS = 2;
141
142
  static random(): RevertCode {
142
143
  return new RevertCode(Math.floor(Math.random() * RevertCode.NUM_OPTIONS));
143
144
  }
@@ -1,4 +1,5 @@
1
1
  import { type BlockBlobData, encodeBlockBlobData } from '@aztec/blob-lib/encoding';
2
+ import { DA_GAS_PER_FIELD } from '@aztec/constants';
2
3
  import {
3
4
  BlockNumber,
4
5
  CheckpointNumber,
@@ -175,7 +176,7 @@ export class L2Block {
175
176
  } & Partial<Parameters<typeof BlockHeader.random>[0]> = {},
176
177
  ): Promise<L2Block> {
177
178
  const archive = new AppendOnlyTreeSnapshot(Fr.random(), blockNumber + 1);
178
- const header = BlockHeader.random({ blockNumber, ...blockHeaderOverrides });
179
+ const header = BlockHeader.random({ ...blockHeaderOverrides, blockNumber });
179
180
  const body = await Body.random({ txsPerBlock, makeTxOptions, ...txOptions });
180
181
  return new L2Block(archive, header, body, checkpointNumber, indexWithinCheckpoint);
181
182
  }
@@ -221,4 +222,15 @@ export class L2Block {
221
222
  timestamp: this.header.globalVariables.timestamp,
222
223
  };
223
224
  }
225
+
226
+ /**
227
+ * Compute how much DA gas this block uses.
228
+ *
229
+ * @remarks This assumes DA gas is computed solely based on the number of blob fields in transactions.
230
+ * This may change in the future, but we cannot access the actual DA gas used in a block since it's not exposed
231
+ * in the L2BlockHeader, so we have to rely on recomputing it.
232
+ */
233
+ computeDAGasUsed(): number {
234
+ return this.body.txEffects.reduce((total, txEffect) => total + txEffect.getNumBlobFields(), 0) * DA_GAS_PER_FIELD;
235
+ }
224
236
  }
@@ -49,6 +49,12 @@ export interface L2BlockSource {
49
49
  */
50
50
  getBlockNumber(): Promise<BlockNumber>;
51
51
 
52
+ /**
53
+ * Gets the number of the latest L2 checkpoint processed by the block source implementation.
54
+ * @returns The number of the latest L2 checkpoint processed by the block source implementation.
55
+ */
56
+ getCheckpointNumber(): Promise<CheckpointNumber>;
57
+
52
58
  /**
53
59
  * Gets the number of the latest L2 block proven seen by the block source implementation.
54
60
  * @returns The number of the latest L2 block proven seen by the block source implementation.
@@ -62,9 +68,8 @@ export interface L2BlockSource {
62
68
  getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
63
69
 
64
70
  /**
65
- * Computes the finalized block number based on the proven block number.
66
- * A block is considered finalized when it's 2 epochs behind the proven block.
67
- * TODO(#13569): Compute proper finalized block number based on L1 finalized block.
71
+ * Returns the finalized L2 block number. A block is finalized when it was proven
72
+ * in an L1 block that has itself been finalized on Ethereum.
68
73
  * @returns The finalized block number.
69
74
  */
70
75
  getFinalizedL2BlockNumber(): Promise<BlockNumber>;
@@ -170,14 +175,18 @@ export interface L2BlockSource {
170
175
  getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
171
176
 
172
177
  /**
173
- * Returns the current L2 slot number based on the currently synced L1 timestamp.
178
+ * Returns the last L2 slot number for which we have all L1 data needed to build the next checkpoint.
179
+ * Determined by the max of two signals: L1 block sync progress and latest synced checkpoint slot.
180
+ * The checkpoint signal handles missed L1 blocks, since a published checkpoint seals the message tree
181
+ * for the next checkpoint via the inbox LAG mechanism.
174
182
  */
175
- getL2SlotNumber(): Promise<SlotNumber | undefined>;
183
+ getSyncedL2SlotNumber(): Promise<SlotNumber | undefined>;
176
184
 
177
185
  /**
178
- * Returns the current L2 epoch number based on the currently synced L1 timestamp.
186
+ * Returns the last L2 epoch number that has been fully synchronized from L1.
187
+ * An epoch is fully synced when all its L2 slots have been fully synced.
179
188
  */
180
- getL2EpochNumber(): Promise<EpochNumber | undefined>;
189
+ getSyncedL2EpochNumber(): Promise<EpochNumber | undefined>;
181
190
 
182
191
  /**
183
192
  * Returns all checkpointed block headers for a given epoch.
@@ -2,10 +2,14 @@ import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.
2
2
  import type { L2Block } from '../l2_block.js';
3
3
  import type { CheckpointId, L2BlockId, L2Tips } from '../l2_block_source.js';
4
4
 
5
+ /** Provides the current chain tips. Implemented by world-state, l2-tips-store, and AztecNode. */
6
+ export interface L2TipsProvider {
7
+ getL2Tips(): Promise<L2Tips>;
8
+ }
9
+
5
10
  /** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
6
- export interface L2BlockStreamLocalDataProvider {
11
+ export interface L2BlockStreamLocalDataProvider extends L2TipsProvider {
7
12
  getL2BlockHash(number: number): Promise<string | undefined>;
8
- getL2Tips(): Promise<L2Tips>;
9
13
  }
10
14
 
11
15
  /** Interface to a handler of events emitted. */
@@ -109,6 +109,27 @@ export class L2BlockStream {
109
109
 
110
110
  let nextBlockNumber = latestBlockNumber + 1;
111
111
  let nextCheckpointToEmit = CheckpointNumber(localTips.checkpointed.checkpoint.number + 1);
112
+
113
+ // When startingBlock is set, also skip ahead for checkpoints.
114
+ if (
115
+ this.opts.startingBlock !== undefined &&
116
+ this.opts.startingBlock >= 1 &&
117
+ nextCheckpointToEmit <= sourceTips.checkpointed.checkpoint.number
118
+ ) {
119
+ const startingBlockCheckpoints = await this.l2BlockSource.getCheckpointedBlocks(
120
+ BlockNumber(this.opts.startingBlock),
121
+ 1,
122
+ );
123
+ if (startingBlockCheckpoints.length > 0) {
124
+ nextCheckpointToEmit = CheckpointNumber(
125
+ Math.max(nextCheckpointToEmit, startingBlockCheckpoints[0].checkpointNumber),
126
+ );
127
+ } else {
128
+ // startingBlock is past all checkpointed blocks; skip Loop 1 entirely.
129
+ nextCheckpointToEmit = CheckpointNumber(sourceTips.checkpointed.checkpoint.number + 1);
130
+ }
131
+ }
132
+
112
133
  if (this.opts.skipFinalized) {
113
134
  // When skipping finalized blocks we need to provide reliable reorg detection while fetching as few blocks as
114
135
  // possible. Finalized blocks cannot be reorged by definition, so we can skip most of them. We do need the very