@aztec/stdlib 0.0.1-commit.b1c78909e → 0.0.1-commit.b2a5d0dd1

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 (437) hide show
  1. package/dest/abi/abi.d.ts +138 -1
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +10 -2
  4. package/dest/abi/authorization_selector.d.ts +3 -6
  5. package/dest/abi/authorization_selector.d.ts.map +1 -1
  6. package/dest/abi/buffer.d.ts +14 -4
  7. package/dest/abi/buffer.d.ts.map +1 -1
  8. package/dest/abi/buffer.js +25 -4
  9. package/dest/abi/decoder.d.ts +5 -44
  10. package/dest/abi/decoder.d.ts.map +1 -1
  11. package/dest/abi/decoder.js +12 -67
  12. package/dest/abi/encoder.d.ts +1 -1
  13. package/dest/abi/encoder.d.ts.map +1 -1
  14. package/dest/abi/encoder.js +32 -6
  15. package/dest/abi/event_selector.d.ts +3 -6
  16. package/dest/abi/event_selector.d.ts.map +1 -1
  17. package/dest/abi/function_selector.d.ts +3 -6
  18. package/dest/abi/function_selector.d.ts.map +1 -1
  19. package/dest/abi/function_selector.js +2 -4
  20. package/dest/abi/function_signature_decoder.d.ts +43 -0
  21. package/dest/abi/function_signature_decoder.d.ts.map +1 -0
  22. package/dest/abi/function_signature_decoder.js +66 -0
  23. package/dest/abi/index.d.ts +2 -1
  24. package/dest/abi/index.d.ts.map +1 -1
  25. package/dest/abi/index.js +1 -0
  26. package/dest/abi/note_selector.d.ts +3 -6
  27. package/dest/abi/note_selector.d.ts.map +1 -1
  28. package/dest/abi/note_selector.js +1 -3
  29. package/dest/abi/selector.d.ts +2 -2
  30. package/dest/abi/selector.d.ts.map +1 -1
  31. package/dest/abi/selector.js +1 -1
  32. package/dest/avm/revert_code.d.ts +8 -18
  33. package/dest/avm/revert_code.d.ts.map +1 -1
  34. package/dest/avm/revert_code.js +15 -30
  35. package/dest/aztec-address/index.d.ts +3 -6
  36. package/dest/aztec-address/index.d.ts.map +1 -1
  37. package/dest/aztec-address/index.js +2 -4
  38. package/dest/block/block_data.d.ts +8 -8
  39. package/dest/block/block_data.d.ts.map +1 -1
  40. package/dest/block/block_data.js +2 -2
  41. package/dest/block/block_hash.d.ts +11 -10
  42. package/dest/block/block_hash.d.ts.map +1 -1
  43. package/dest/block/block_hash.js +10 -9
  44. package/dest/block/l2_block_info.d.ts +6 -5
  45. package/dest/block/l2_block_info.d.ts.map +1 -1
  46. package/dest/block/l2_block_info.js +6 -5
  47. package/dest/block/l2_block_source.d.ts +84 -5
  48. package/dest/block/l2_block_source.d.ts.map +1 -1
  49. package/dest/block/l2_block_source.js +1 -0
  50. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  51. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  52. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  53. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  54. package/dest/block/l2_block_stream/l2_tips_store_base.js +18 -5
  55. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  56. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  57. package/dest/block/test/l2_tips_store_test_suite.js +4 -3
  58. package/dest/checkpoint/checkpoint.d.ts +7 -1
  59. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  60. package/dest/checkpoint/checkpoint.js +9 -1
  61. package/dest/checkpoint/checkpoint_data.d.ts +71 -5
  62. package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
  63. package/dest/checkpoint/checkpoint_data.js +10 -0
  64. package/dest/checkpoint/validate.js +2 -2
  65. package/dest/config/chain-config.d.ts +1 -1
  66. package/dest/config/chain-config.d.ts.map +1 -1
  67. package/dest/config/chain-config.js +7 -1
  68. package/dest/config/index.d.ts +2 -1
  69. package/dest/config/index.d.ts.map +1 -1
  70. package/dest/config/index.js +1 -0
  71. package/dest/config/pipelining-config.d.ts +19 -0
  72. package/dest/config/pipelining-config.d.ts.map +1 -0
  73. package/dest/config/pipelining-config.js +18 -0
  74. package/dest/config/sequencer-config.d.ts +2 -2
  75. package/dest/config/sequencer-config.d.ts.map +1 -1
  76. package/dest/config/sequencer-config.js +10 -3
  77. package/dest/contract/contract_address.d.ts +3 -3
  78. package/dest/contract/contract_address.js +3 -3
  79. package/dest/contract/contract_class_id.d.ts +2 -2
  80. package/dest/contract/contract_class_id.js +2 -2
  81. package/dest/contract/index.d.ts +1 -3
  82. package/dest/contract/index.d.ts.map +1 -1
  83. package/dest/contract/index.js +0 -2
  84. package/dest/contract/interfaces/contract_class.d.ts +3 -156
  85. package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
  86. package/dest/contract/interfaces/contract_class.js +1 -28
  87. package/dest/contract/private_function.d.ts +1 -1
  88. package/dest/contract/private_function.d.ts.map +1 -1
  89. package/dest/contract/private_function.js +2 -4
  90. package/dest/epoch-helpers/index.d.ts +7 -1
  91. package/dest/epoch-helpers/index.d.ts.map +1 -1
  92. package/dest/epoch-helpers/index.js +12 -0
  93. package/dest/file-store/factory.d.ts +4 -3
  94. package/dest/file-store/factory.d.ts.map +1 -1
  95. package/dest/file-store/factory.js +2 -2
  96. package/dest/file-store/http.d.ts +9 -2
  97. package/dest/file-store/http.d.ts.map +1 -1
  98. package/dest/file-store/http.js +20 -9
  99. package/dest/file-store/index.d.ts +2 -1
  100. package/dest/file-store/index.d.ts.map +1 -1
  101. package/dest/gas/fee_math.d.ts +49 -0
  102. package/dest/gas/fee_math.d.ts.map +1 -0
  103. package/dest/gas/fee_math.js +80 -0
  104. package/dest/gas/gas_fees.d.ts +5 -1
  105. package/dest/gas/gas_fees.d.ts.map +1 -1
  106. package/dest/gas/gas_fees.js +10 -1
  107. package/dest/gas/gas_settings.d.ts +40 -3
  108. package/dest/gas/gas_settings.d.ts.map +1 -1
  109. package/dest/gas/gas_settings.js +50 -6
  110. package/dest/gas/index.d.ts +2 -1
  111. package/dest/gas/index.d.ts.map +1 -1
  112. package/dest/gas/index.js +1 -0
  113. package/dest/ha-signing/config.d.ts +6 -6
  114. package/dest/ha-signing/config.d.ts.map +1 -1
  115. package/dest/ha-signing/config.js +4 -3
  116. package/dest/ha-signing/index.d.ts +2 -2
  117. package/dest/ha-signing/index.d.ts.map +1 -1
  118. package/dest/ha-signing/index.js +1 -1
  119. package/dest/ha-signing/local_config.js +1 -1
  120. package/dest/ha-signing/types.d.ts +37 -32
  121. package/dest/ha-signing/types.d.ts.map +1 -1
  122. package/dest/ha-signing/types.js +13 -6
  123. package/dest/hash/hash.d.ts +34 -1
  124. package/dest/hash/hash.d.ts.map +1 -1
  125. package/dest/hash/hash.js +61 -0
  126. package/dest/interfaces/archiver.d.ts +11 -1
  127. package/dest/interfaces/archiver.d.ts.map +1 -1
  128. package/dest/interfaces/archiver.js +6 -2
  129. package/dest/interfaces/aztec-node-admin.d.ts +12 -17
  130. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  131. package/dest/interfaces/aztec-node-admin.js +3 -3
  132. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  133. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  134. package/dest/interfaces/aztec-node-debug.js +18 -0
  135. package/dest/interfaces/aztec-node.d.ts +12 -2
  136. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  137. package/dest/interfaces/aztec-node.js +4 -0
  138. package/dest/interfaces/block-builder.d.ts +31 -7
  139. package/dest/interfaces/block-builder.d.ts.map +1 -1
  140. package/dest/interfaces/block-builder.js +6 -4
  141. package/dest/interfaces/client.d.ts +2 -1
  142. package/dest/interfaces/client.d.ts.map +1 -1
  143. package/dest/interfaces/client.js +1 -0
  144. package/dest/interfaces/configs.d.ts +7 -2
  145. package/dest/interfaces/configs.d.ts.map +1 -1
  146. package/dest/interfaces/configs.js +1 -0
  147. package/dest/interfaces/l2_logs_source.d.ts +5 -3
  148. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  149. package/dest/interfaces/merkle_tree_operations.d.ts +12 -21
  150. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  151. package/dest/interfaces/prover-client.d.ts +1 -1
  152. package/dest/interfaces/prover-client.d.ts.map +1 -1
  153. package/dest/interfaces/prover-client.js +1 -4
  154. package/dest/interfaces/proving-job.d.ts +200 -200
  155. package/dest/interfaces/slasher.d.ts +1 -10
  156. package/dest/interfaces/slasher.d.ts.map +1 -1
  157. package/dest/interfaces/slasher.js +0 -2
  158. package/dest/interfaces/validator.d.ts +15 -26
  159. package/dest/interfaces/validator.d.ts.map +1 -1
  160. package/dest/interfaces/validator.js +0 -1
  161. package/dest/interfaces/world_state.d.ts +5 -4
  162. package/dest/interfaces/world_state.d.ts.map +1 -1
  163. package/dest/l1-contracts/index.d.ts +2 -2
  164. package/dest/l1-contracts/index.d.ts.map +1 -1
  165. package/dest/l1-contracts/index.js +1 -1
  166. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  167. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  168. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  169. package/dest/logs/index.d.ts +2 -1
  170. package/dest/logs/index.d.ts.map +1 -1
  171. package/dest/logs/index.js +1 -0
  172. package/dest/logs/log_filter.d.ts +4 -1
  173. package/dest/logs/log_filter.d.ts.map +1 -1
  174. package/dest/logs/log_filter.js +2 -1
  175. package/dest/logs/log_id.d.ts +1 -1
  176. package/dest/logs/log_id.d.ts.map +1 -1
  177. package/dest/logs/log_id.js +1 -2
  178. package/dest/logs/message_context.d.ts +4 -7
  179. package/dest/logs/message_context.d.ts.map +1 -1
  180. package/dest/logs/message_context.js +23 -9
  181. package/dest/logs/pending_tagged_log.d.ts +2 -3
  182. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  183. package/dest/logs/pending_tagged_log.js +2 -2
  184. package/dest/logs/shared_secret_derivation.d.ts +11 -10
  185. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  186. package/dest/logs/shared_secret_derivation.js +15 -9
  187. package/dest/logs/siloed_tag.d.ts +8 -7
  188. package/dest/logs/siloed_tag.d.ts.map +1 -1
  189. package/dest/logs/siloed_tag.js +11 -3
  190. package/dest/logs/tag.d.ts +5 -6
  191. package/dest/logs/tag.d.ts.map +1 -1
  192. package/dest/logs/tag.js +4 -0
  193. package/dest/logs/tagging_index_range.d.ts +40 -0
  194. package/dest/logs/tagging_index_range.d.ts.map +1 -0
  195. package/dest/logs/tagging_index_range.js +8 -0
  196. package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
  197. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  198. package/dest/logs/tx_scoped_l2_log.js +7 -0
  199. package/dest/messaging/l1_to_l2_message.d.ts +3 -2
  200. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  201. package/dest/messaging/l1_to_l2_message.js +11 -13
  202. package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
  203. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  204. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  205. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  206. package/dest/messaging/l2_to_l1_membership.js +69 -26
  207. package/dest/noir/index.d.ts +3 -3
  208. package/dest/noir/index.d.ts.map +1 -1
  209. package/dest/note/note_dao.d.ts +1 -1
  210. package/dest/note/note_dao.d.ts.map +1 -1
  211. package/dest/note/note_dao.js +1 -4
  212. package/dest/p2p/block_proposal.d.ts +6 -8
  213. package/dest/p2p/block_proposal.d.ts.map +1 -1
  214. package/dest/p2p/block_proposal.js +4 -9
  215. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  216. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  217. package/dest/p2p/checkpoint_attestation.js +2 -7
  218. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  219. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  220. package/dest/p2p/checkpoint_proposal.js +5 -22
  221. package/dest/p2p/gossipable.d.ts +4 -4
  222. package/dest/p2p/gossipable.d.ts.map +1 -1
  223. package/dest/proofs/chonk_proof.d.ts +46 -2
  224. package/dest/proofs/chonk_proof.d.ts.map +1 -1
  225. package/dest/proofs/chonk_proof.js +85 -10
  226. package/dest/rollup/block_headers_hash.d.ts +1 -1
  227. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  228. package/dest/rollup/block_headers_hash.js +8 -2
  229. package/dest/slashing/index.d.ts +2 -3
  230. package/dest/slashing/index.d.ts.map +1 -1
  231. package/dest/slashing/index.js +1 -2
  232. package/dest/slashing/serialization.d.ts +2 -6
  233. package/dest/slashing/serialization.d.ts.map +1 -1
  234. package/dest/slashing/serialization.js +0 -60
  235. package/dest/slashing/types.d.ts +4 -90
  236. package/dest/slashing/types.d.ts.map +1 -1
  237. package/dest/slashing/types.js +0 -14
  238. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  239. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  240. package/dest/slashing/{tally.js → votes.js} +1 -1
  241. package/dest/tests/factories.d.ts +3 -10
  242. package/dest/tests/factories.d.ts.map +1 -1
  243. package/dest/tests/factories.js +12 -35
  244. package/dest/tests/mocks.d.ts +1 -1
  245. package/dest/tests/mocks.d.ts.map +1 -1
  246. package/dest/tests/mocks.js +14 -19
  247. package/dest/timetable/index.d.ts +51 -1
  248. package/dest/timetable/index.d.ts.map +1 -1
  249. package/dest/timetable/index.js +204 -14
  250. package/dest/trees/nullifier_leaf.d.ts +2 -1
  251. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  252. package/dest/trees/nullifier_leaf.js +3 -0
  253. package/dest/tx/block_header.d.ts +2 -2
  254. package/dest/tx/block_header.d.ts.map +1 -1
  255. package/dest/tx/block_header.js +1 -1
  256. package/dest/tx/capsule.d.ts +6 -2
  257. package/dest/tx/capsule.d.ts.map +1 -1
  258. package/dest/tx/capsule.js +9 -3
  259. package/dest/tx/fee_provider.d.ts +10 -0
  260. package/dest/tx/fee_provider.d.ts.map +1 -0
  261. package/dest/tx/fee_provider.js +1 -0
  262. package/dest/tx/global_variable_builder.d.ts +3 -4
  263. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  264. package/dest/tx/index.d.ts +2 -1
  265. package/dest/tx/index.d.ts.map +1 -1
  266. package/dest/tx/index.js +1 -0
  267. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  268. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  269. package/dest/tx/indexed_tx_effect.js +1 -2
  270. package/dest/tx/private_execution_result.d.ts +6 -6
  271. package/dest/tx/private_execution_result.d.ts.map +1 -1
  272. package/dest/tx/private_execution_result.js +6 -6
  273. package/dest/tx/profiling.d.ts +14 -2
  274. package/dest/tx/profiling.d.ts.map +1 -1
  275. package/dest/tx/profiling.js +13 -3
  276. package/dest/tx/simulated_tx.d.ts +112 -4
  277. package/dest/tx/simulated_tx.d.ts.map +1 -1
  278. package/dest/tx/simulated_tx.js +3 -3
  279. package/dest/tx/tx.d.ts +3 -3
  280. package/dest/tx/tx.d.ts.map +1 -1
  281. package/dest/tx/tx_receipt.d.ts +14 -5
  282. package/dest/tx/tx_receipt.d.ts.map +1 -1
  283. package/dest/tx/tx_receipt.js +14 -18
  284. package/dest/tx/validator/error_texts.d.ts +5 -1
  285. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  286. package/dest/tx/validator/error_texts.js +6 -0
  287. package/dest/types/shared.d.ts +1 -10
  288. package/dest/types/shared.d.ts.map +1 -1
  289. package/dest/types/shared.js +0 -9
  290. package/dest/update-checker/package_version.d.ts +2 -2
  291. package/dest/update-checker/package_version.d.ts.map +1 -1
  292. package/dest/update-checker/package_version.js +16 -3
  293. package/dest/versioning/versioning.d.ts +4 -2
  294. package/dest/versioning/versioning.d.ts.map +1 -1
  295. package/dest/versioning/versioning.js +4 -1
  296. package/dest/vks/verification_key.d.ts +2 -137
  297. package/dest/vks/verification_key.d.ts.map +1 -1
  298. package/dest/vks/verification_key.js +5 -126
  299. package/dest/world-state/genesis_data.d.ts +11 -0
  300. package/dest/world-state/genesis_data.d.ts.map +1 -0
  301. package/dest/world-state/genesis_data.js +4 -0
  302. package/dest/world-state/index.d.ts +2 -1
  303. package/dest/world-state/index.d.ts.map +1 -1
  304. package/dest/world-state/index.js +1 -0
  305. package/dest/world-state/world_state_revision.d.ts +8 -1
  306. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  307. package/dest/world-state/world_state_revision.js +7 -1
  308. package/package.json +8 -8
  309. package/src/abi/abi.ts +25 -2
  310. package/src/abi/authorization_selector.ts +2 -8
  311. package/src/abi/buffer.ts +25 -4
  312. package/src/abi/decoder.ts +23 -78
  313. package/src/abi/encoder.ts +42 -6
  314. package/src/abi/event_selector.ts +2 -8
  315. package/src/abi/function_selector.ts +4 -13
  316. package/src/abi/function_signature_decoder.ts +77 -0
  317. package/src/abi/index.ts +1 -0
  318. package/src/abi/note_selector.ts +3 -12
  319. package/src/abi/selector.ts +1 -1
  320. package/src/avm/revert_code.ts +25 -39
  321. package/src/aztec-address/index.ts +4 -10
  322. package/src/block/block_data.ts +3 -4
  323. package/src/block/block_hash.ts +21 -14
  324. package/src/block/l2_block_info.ts +8 -6
  325. package/src/block/l2_block_source.ts +14 -4
  326. package/src/block/l2_block_stream/interfaces.ts +6 -2
  327. package/src/block/l2_block_stream/l2_tips_store_base.ts +25 -13
  328. package/src/block/test/l2_tips_store_test_suite.ts +9 -2
  329. package/src/checkpoint/checkpoint.ts +11 -1
  330. package/src/checkpoint/checkpoint_data.ts +40 -4
  331. package/src/checkpoint/validate.ts +2 -2
  332. package/src/config/chain-config.ts +7 -1
  333. package/src/config/index.ts +1 -0
  334. package/src/config/pipelining-config.ts +31 -0
  335. package/src/config/sequencer-config.ts +14 -4
  336. package/src/contract/contract_address.ts +3 -3
  337. package/src/contract/contract_class_id.ts +2 -2
  338. package/src/contract/index.ts +0 -2
  339. package/src/contract/interfaces/contract_class.ts +2 -82
  340. package/src/contract/private_function.ts +3 -1
  341. package/src/epoch-helpers/index.ts +24 -0
  342. package/src/file-store/factory.ts +13 -4
  343. package/src/file-store/http.ts +29 -10
  344. package/src/file-store/index.ts +1 -0
  345. package/src/gas/README.md +154 -0
  346. package/src/gas/fee_math.ts +120 -0
  347. package/src/gas/gas_fees.ts +17 -4
  348. package/src/gas/gas_settings.ts +65 -12
  349. package/src/gas/index.ts +1 -0
  350. package/src/ha-signing/config.ts +5 -2
  351. package/src/ha-signing/index.ts +3 -1
  352. package/src/ha-signing/local_config.ts +1 -1
  353. package/src/ha-signing/types.ts +48 -34
  354. package/src/hash/hash.ts +61 -0
  355. package/src/interfaces/archiver.ts +11 -1
  356. package/src/interfaces/aztec-node-admin.ts +5 -7
  357. package/src/interfaces/aztec-node-debug.ts +40 -0
  358. package/src/interfaces/aztec-node.ts +25 -1
  359. package/src/interfaces/block-builder.ts +37 -8
  360. package/src/interfaces/client.ts +1 -0
  361. package/src/interfaces/configs.ts +4 -1
  362. package/src/interfaces/l2_logs_source.ts +4 -1
  363. package/src/interfaces/merkle_tree_operations.ts +11 -20
  364. package/src/interfaces/prover-client.ts +3 -6
  365. package/src/interfaces/slasher.ts +0 -6
  366. package/src/interfaces/validator.ts +16 -13
  367. package/src/interfaces/world_state.ts +4 -3
  368. package/src/l1-contracts/index.ts +1 -1
  369. package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
  370. package/src/logs/index.ts +1 -0
  371. package/src/logs/log_filter.ts +5 -0
  372. package/src/logs/log_id.ts +1 -2
  373. package/src/logs/message_context.ts +17 -7
  374. package/src/logs/pending_tagged_log.ts +1 -3
  375. package/src/logs/shared_secret_derivation.ts +21 -10
  376. package/src/logs/siloed_tag.ts +15 -11
  377. package/src/logs/tag.ts +8 -8
  378. package/src/logs/tagging_index_range.ts +24 -0
  379. package/src/logs/tx_scoped_l2_log.ts +16 -0
  380. package/src/messaging/l1_to_l2_message.ts +12 -9
  381. package/src/messaging/l1_to_l2_message_source.ts +3 -1
  382. package/src/messaging/l2_to_l1_membership.ts +98 -33
  383. package/src/noir/index.ts +2 -2
  384. package/src/note/note_dao.ts +1 -4
  385. package/src/p2p/block_proposal.ts +13 -9
  386. package/src/p2p/checkpoint_attestation.ts +5 -9
  387. package/src/p2p/checkpoint_proposal.ts +19 -31
  388. package/src/p2p/gossipable.ts +4 -4
  389. package/src/proofs/chonk_proof.ts +91 -5
  390. package/src/rollup/block_headers_hash.ts +11 -2
  391. package/src/slashing/index.ts +1 -2
  392. package/src/slashing/serialization.ts +1 -81
  393. package/src/slashing/types.ts +3 -35
  394. package/src/slashing/{tally.ts → votes.ts} +1 -1
  395. package/src/tests/factories.ts +6 -43
  396. package/src/tests/mocks.ts +16 -12
  397. package/src/timetable/index.ts +293 -13
  398. package/src/trees/nullifier_leaf.ts +4 -0
  399. package/src/tx/block_header.ts +2 -2
  400. package/src/tx/capsule.ts +10 -2
  401. package/src/tx/fee_provider.ts +10 -0
  402. package/src/tx/global_variable_builder.ts +2 -3
  403. package/src/tx/index.ts +1 -0
  404. package/src/tx/indexed_tx_effect.ts +1 -2
  405. package/src/tx/private_execution_result.ts +5 -5
  406. package/src/tx/profiling.ts +11 -2
  407. package/src/tx/simulated_tx.ts +6 -2
  408. package/src/tx/tx.ts +2 -2
  409. package/src/tx/tx_receipt.ts +17 -15
  410. package/src/tx/validator/error_texts.ts +8 -0
  411. package/src/types/shared.ts +0 -10
  412. package/src/update-checker/package_version.ts +19 -6
  413. package/src/versioning/versioning.ts +4 -1
  414. package/src/vks/verification_key.ts +5 -184
  415. package/src/world-state/genesis_data.ts +15 -0
  416. package/src/world-state/index.ts +1 -0
  417. package/src/world-state/world_state_revision.ts +9 -1
  418. package/dest/abi/mocked_keys.d.ts +0 -2
  419. package/dest/abi/mocked_keys.d.ts.map +0 -1
  420. package/dest/abi/mocked_keys.js +0 -1
  421. package/dest/contract/private_function_membership_proof.d.ts +0 -32
  422. package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
  423. package/dest/contract/private_function_membership_proof.js +0 -124
  424. package/dest/contract/utility_function_membership_proof.d.ts +0 -27
  425. package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
  426. package/dest/contract/utility_function_membership_proof.js +0 -87
  427. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  428. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  429. package/dest/l1-contracts/slash_factory.js +0 -158
  430. package/dest/slashing/empire.d.ts +0 -31
  431. package/dest/slashing/empire.d.ts.map +0 -1
  432. package/dest/slashing/empire.js +0 -87
  433. package/src/abi/mocked_keys.ts +0 -2
  434. package/src/contract/private_function_membership_proof.ts +0 -167
  435. package/src/contract/utility_function_membership_proof.ts +0 -118
  436. package/src/l1-contracts/slash_factory.ts +0 -180
  437. package/src/slashing/empire.ts +0 -104
@@ -1,6 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './interfaces.js';
3
3
  export * from './helpers.js';
4
- export * from './empire.js';
5
- export * from './tally.js';
4
+ export * from './votes.js';
6
5
  export * from './serialization.js';
@@ -1,15 +1,7 @@
1
- import { times } from '@aztec/foundation/collection';
2
1
  import { EthAddress } from '@aztec/foundation/eth-address';
3
2
  import { BufferReader, bigintToUInt64BE, bigintToUInt128BE, serializeToBuffer } from '@aztec/foundation/serialize';
4
3
 
5
- import type {
6
- Offense,
7
- OffenseType,
8
- SlashPayload,
9
- SlashPayloadRound,
10
- ValidatorSlash,
11
- ValidatorSlashOffense,
12
- } from './types.js';
4
+ import type { Offense, OffenseType } from './types.js';
13
5
 
14
6
  export function serializeOffense(offense: Offense): Buffer {
15
7
  return serializeToBuffer(
@@ -29,75 +21,3 @@ export function deserializeOffense(buffer: Buffer): Offense {
29
21
 
30
22
  return { validator, amount, offenseType: offense, epochOrSlot };
31
23
  }
32
-
33
- function serializeValidatorSlashOffense(offense: ValidatorSlashOffense): Buffer {
34
- return serializeToBuffer(bigintToUInt64BE(offense.epochOrSlot), offense.offenseType);
35
- }
36
-
37
- function deserializeValidatorSlashOffense(buffer: Buffer | BufferReader): ValidatorSlashOffense {
38
- const reader = BufferReader.asReader(buffer);
39
- return {
40
- epochOrSlot: reader.readUInt64(),
41
- offenseType: reader.readNumber() as OffenseType,
42
- };
43
- }
44
-
45
- function serializeValidatorSlash(slash: ValidatorSlash): Buffer {
46
- return serializeToBuffer(
47
- slash.validator,
48
- bigintToUInt128BE(slash.amount),
49
- slash.offenses.length,
50
- slash.offenses.map(serializeValidatorSlashOffense),
51
- );
52
- }
53
-
54
- function deserializeValidatorSlash(buffer: Buffer | BufferReader): ValidatorSlash {
55
- const reader = BufferReader.asReader(buffer);
56
- const validator = reader.readObject(EthAddress);
57
- const amount = reader.readUInt128();
58
- const offensesCount = reader.readNumber();
59
- const offenses = times(offensesCount, () => deserializeValidatorSlashOffense(reader));
60
-
61
- return { validator, amount, offenses };
62
- }
63
-
64
- export function serializeSlashPayload(payload: SlashPayload): Buffer {
65
- return serializeToBuffer(
66
- payload.address,
67
- payload.slashes.length,
68
- payload.slashes.map(serializeValidatorSlash),
69
- bigintToUInt64BE(payload.timestamp),
70
- );
71
- }
72
-
73
- export function deserializeSlashPayload(buffer: Buffer): SlashPayload {
74
- const reader = BufferReader.asReader(buffer);
75
- const address = reader.readObject(EthAddress);
76
- const slashesCount = reader.readNumber();
77
- const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
78
- const timestamp = reader.readUInt64();
79
- return { address, slashes, timestamp };
80
- }
81
-
82
- export function serializeSlashPayloadRound(payload: SlashPayloadRound): Buffer {
83
- return serializeToBuffer(
84
- payload.address,
85
- payload.slashes.length,
86
- payload.slashes.map(serializeValidatorSlash),
87
- bigintToUInt64BE(payload.timestamp),
88
- Number(payload.votes),
89
- bigintToUInt64BE(payload.round),
90
- );
91
- }
92
-
93
- export function deserializeSlashPayloadRound(buffer: Buffer): SlashPayloadRound {
94
- const reader = BufferReader.asReader(buffer);
95
- const address = reader.readObject(EthAddress);
96
- const slashesCount = reader.readNumber();
97
- const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
98
- const timestamp = reader.readUInt64();
99
- const votes = BigInt(reader.readNumber());
100
- const round = reader.readUInt64();
101
-
102
- return { address, slashes, timestamp, votes, round };
103
- }
@@ -126,45 +126,13 @@ export type ValidatorSlash = {
126
126
  offenses: ValidatorSlashOffense[];
127
127
  };
128
128
 
129
- /** Slash payload as published by the empire slash proposer */
130
- export type SlashPayload = {
131
- address: EthAddress;
132
- slashes: ValidatorSlash[];
133
- timestamp: bigint;
134
- };
135
-
136
- /** Slash payload with round information from empire slash proposer */
137
- export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
138
-
139
- export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
140
- z.object({
141
- address: schemas.EthAddress,
142
- timestamp: schemas.BigInt,
143
- votes: schemas.BigInt,
144
- round: schemas.BigInt,
145
- slashes: z.array(
146
- z.object({
147
- validator: schemas.EthAddress,
148
- amount: schemas.BigInt,
149
- offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
150
- }),
151
- ),
152
- }),
153
- );
154
-
155
- /** Votes for a validator slash in the consensus slash proposer */
129
+ /** Votes for a validator slash in the slashing proposer */
156
130
  export type ValidatorSlashVote = number;
157
131
 
158
132
  export type ProposerSlashAction =
159
- /** Create a new slash payload on an empire-based slash proposer */
160
- | { type: 'create-empire-payload'; data: ValidatorSlash[] }
161
- /** Vote for a slashing payload on an empire-based slash proposer */
162
- | { type: 'vote-empire-payload'; payload: EthAddress }
163
- /** Execute a slashing payload on an empire-based slash proposer */
164
- | { type: 'execute-empire-payload'; round: bigint }
165
- /** Vote for offenses on a consensus slashing proposer */
133
+ /** Vote for offenses on the slashing proposer */
166
134
  | { type: 'vote-offenses'; votes: ValidatorSlashVote[]; committees: EthAddress[][]; round: bigint }
167
- /** Execute a slashing round on a consensus slashing proposer */
135
+ /** Execute a slashing round on the slashing proposer */
168
136
  | { type: 'execute-slash'; committees: EthAddress[][]; round: bigint };
169
137
 
170
138
  export type ProposerSlashActionType = ProposerSlashAction['type'];
@@ -28,7 +28,7 @@ export function getSlashConsensusVotesFromOffenses(
28
28
  targetCommitteeSize: number;
29
29
  maxSlashedValidators?: number;
30
30
  },
31
- logger: Logger = createLogger('slasher:tally'),
31
+ logger: Logger = createLogger('slasher:votes'),
32
32
  ): ValidatorSlashVote[] {
33
33
  const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
34
34
 
@@ -92,10 +92,8 @@ import {
92
92
  type ContractClassPublic,
93
93
  ContractDeploymentData,
94
94
  type ContractInstanceWithAddress,
95
- type ExecutablePrivateFunctionWithMembershipProof,
96
95
  type PrivateFunction,
97
96
  SerializableContractInstance,
98
- type UtilityFunctionWithMembershipProof,
99
97
  computeContractClassId,
100
98
  computePublicBytecodeCommitment,
101
99
  } from '../contract/index.js';
@@ -178,7 +176,7 @@ import { TxHash } from '../tx/tx_hash.js';
178
176
  import { TxRequest } from '../tx/tx_request.js';
179
177
  import { Vector } from '../types/index.js';
180
178
  import { VkData } from '../vks/index.js';
181
- import { VerificationKey, VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
179
+ import { VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
182
180
 
183
181
  /**
184
182
  * Creates an arbitrary side effect object with the given seed.
@@ -234,7 +232,7 @@ export function makeTxContext(seed: number = 1): TxContext {
234
232
  * Creates a default instance of gas settings. No seed value is used to ensure we allocate a sensible amount of gas for testing.
235
233
  */
236
234
  export function makeGasSettings() {
237
- return GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) });
235
+ return GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) });
238
236
  }
239
237
 
240
238
  /**
@@ -575,14 +573,6 @@ export function makeVerificationKeyAsFields(size: number): VerificationKeyAsFiel
575
573
  return VerificationKeyAsFields.makeFake(size);
576
574
  }
577
575
 
578
- /**
579
- * Creates arbitrary/mocked verification key.
580
- * @returns A verification key object
581
- */
582
- export function makeVerificationKey(): VerificationKey {
583
- return VerificationKey.makeFake();
584
- }
585
-
586
576
  /**
587
577
  * Creates an arbitrary point in a curve.
588
578
  * @param seed - Seed to generate the point values.
@@ -1183,35 +1173,6 @@ export function makePublicTxBaseRollupPrivateInputs(seed = 0) {
1183
1173
  });
1184
1174
  }
1185
1175
 
1186
- export function makeExecutablePrivateFunctionWithMembershipProof(
1187
- seed = 0,
1188
- ): ExecutablePrivateFunctionWithMembershipProof {
1189
- return {
1190
- selector: makeSelector(seed),
1191
- bytecode: makeBytes(100, seed + 1),
1192
- artifactTreeSiblingPath: makeTuple(3, fr, seed + 2),
1193
- artifactTreeLeafIndex: seed + 2,
1194
- privateFunctionTreeSiblingPath: makeTuple(3, fr, seed + 3),
1195
- privateFunctionTreeLeafIndex: seed + 3,
1196
- artifactMetadataHash: fr(seed + 4),
1197
- functionMetadataHash: fr(seed + 5),
1198
- utilityFunctionsTreeRoot: fr(seed + 6),
1199
- vkHash: fr(seed + 7),
1200
- };
1201
- }
1202
-
1203
- export function makeUtilityFunctionWithMembershipProof(seed = 0): UtilityFunctionWithMembershipProof {
1204
- return {
1205
- selector: makeSelector(seed),
1206
- bytecode: makeBytes(100, seed + 1),
1207
- artifactTreeSiblingPath: makeTuple(3, fr, seed + 2),
1208
- artifactTreeLeafIndex: seed + 2,
1209
- artifactMetadataHash: fr(seed + 4),
1210
- functionMetadataHash: fr(seed + 5),
1211
- privateFunctionsArtifactTreeRoot: fr(seed + 6),
1212
- };
1213
- }
1214
-
1215
1176
  export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer): Promise<ContractClassPublic> {
1216
1177
  const artifactHash = fr(seed + 1);
1217
1178
  const privateFunctionsRoot = fr(seed + 3);
@@ -1223,8 +1184,6 @@ export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer)
1223
1184
  artifactHash,
1224
1185
  packedBytecode,
1225
1186
  privateFunctionsRoot,
1226
- privateFunctions: [],
1227
- utilityFunctions: [],
1228
1187
  version: 1,
1229
1188
  };
1230
1189
  }
@@ -1748,6 +1707,10 @@ export function makeL2Tips(
1748
1707
  block: { number: bn, hash },
1749
1708
  checkpoint: { number: cpn, hash: cph },
1750
1709
  },
1710
+ proposedCheckpoint: {
1711
+ block: { number: bn, hash },
1712
+ checkpoint: { number: cpn, hash: cph },
1713
+ },
1751
1714
  proven: {
1752
1715
  block: { number: bn, hash },
1753
1716
  checkpoint: { number: cpn, hash: cph },
@@ -134,7 +134,7 @@ export const mockTx = async (
134
134
  const data = PrivateKernelTailCircuitPublicInputs.empty();
135
135
  const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
136
136
  data.constants.anchorBlockHeader = anchorBlockHeader;
137
- data.constants.txContext.gasSettings = GasSettings.default({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
137
+ data.constants.txContext.gasSettings = GasSettings.fallback({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
138
138
  data.feePayer = feePayer ?? (await AztecAddress.random());
139
139
  data.gasUsed = gasUsed;
140
140
  data.constants.txContext.chainId = chainId;
@@ -200,7 +200,7 @@ export async function mockProcessedTx({
200
200
  db,
201
201
  chainId = Fr.ZERO,
202
202
  version = Fr.ZERO,
203
- gasSettings = GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) }),
203
+ gasSettings = GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) }),
204
204
  vkTreeRoot = Fr.ZERO,
205
205
  protocolContracts = makeProtocolContracts(seed + 0x100),
206
206
  globalVariables = GlobalVariables.empty(),
@@ -587,6 +587,7 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
587
587
 
588
588
  return BlockProposal.createProposalFromSigner(
589
589
  blockHeader,
590
+ CheckpointNumber(1),
590
591
  indexWithinCheckpoint,
591
592
  inHash,
592
593
  archiveRoot,
@@ -596,28 +597,31 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
596
597
  );
597
598
  };
598
599
 
599
- export const makeCheckpointProposal = (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
600
- const blockHeader = options?.lastBlock?.blockHeader ?? makeBlockHeader(1);
600
+ export const makeCheckpointProposal = async (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
601
601
  const checkpointHeader = options?.checkpointHeader ?? makeCheckpointHeader(1);
602
602
  const archiveRoot = options?.archiveRoot ?? Fr.random();
603
603
  const feeAssetPriceModifier = options?.feeAssetPriceModifier ?? 0n;
604
604
  const signer = options?.signer ?? Secp256k1Signer.random();
605
605
 
606
- // Build lastBlock info if provided
607
- const lastBlockInfo = options?.lastBlock
608
- ? {
609
- blockHeader,
610
- indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4), // Last block in a 5-block checkpoint
611
- txHashes: options.lastBlock.txHashes ?? [0, 1, 2, 3, 4, 5].map(() => TxHash.random()),
606
+ // Build a signed block proposal if lastBlock options are provided
607
+ const lastBlockProposal = options?.lastBlock
608
+ ? await makeBlockProposal({
609
+ blockHeader: options.lastBlock.blockHeader,
610
+ indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4),
611
+ inHash: checkpointHeader.inHash,
612
+ archiveRoot,
613
+ txHashes: options.lastBlock.txHashes,
612
614
  txs: options.lastBlock.txs,
613
- }
615
+ signer,
616
+ })
614
617
  : undefined;
615
618
 
616
619
  return CheckpointProposal.createProposalFromSigner(
617
620
  checkpointHeader,
618
621
  archiveRoot,
622
+ CheckpointNumber(1),
619
623
  feeAssetPriceModifier,
620
- lastBlockInfo,
624
+ lastBlockProposal,
621
625
  payload => Promise.resolve(signer.signMessage(payload)),
622
626
  );
623
627
  };
@@ -25,6 +25,219 @@ export const DEFAULT_L1_PUBLISHING_TIME = 12;
25
25
  /** Minimum execution time for building a block in seconds */
26
26
  export const MIN_EXECUTION_TIME = 2;
27
27
 
28
+ export type CheckpointTimingConfig = {
29
+ aztecSlotDuration: number;
30
+ ethereumSlotDuration?: number;
31
+ blockDuration?: number;
32
+ checkpointAssembleTime?: number;
33
+ checkpointInitializationTime?: number;
34
+ l1PublishingTime?: number;
35
+ minExecutionTime?: number;
36
+ p2pPropagationTime?: number;
37
+ pipelining?: boolean;
38
+ };
39
+
40
+ export interface CheckpointTiming {
41
+ readonly aztecSlotDuration: number;
42
+ readonly blockDuration: number | undefined;
43
+ readonly checkpointAssembleTime: number;
44
+ readonly checkpointInitializationTime: number;
45
+ readonly l1PublishingTime: number;
46
+ readonly minExecutionTime: number;
47
+ readonly p2pPropagationTime: number;
48
+ readonly checkpointFinalizationTime: number;
49
+ readonly pipeliningAttestationGracePeriod: number;
50
+ readonly timeReservedAtEnd: number;
51
+ readonly minimumBuildSlotWork: number;
52
+ readonly initializeDeadline: number;
53
+ readonly checkpointAssemblyDeadline: number;
54
+ readonly checkpointAttestationStartDeadline: number;
55
+ readonly checkpointAttestationDeadline: number;
56
+ readonly checkpointPublishingDeadline: number;
57
+
58
+ calculateMaxBlocksPerSlot(): number;
59
+ }
60
+
61
+ export interface PipelinedCheckpointTiming extends CheckpointTiming {
62
+ readonly proposalWindowIntoTargetSlot: number;
63
+ readonly attestationWindowIntoTargetSlot: number;
64
+ }
65
+
66
+ /**
67
+ * Shared base for checkpoint timing implementations.
68
+ *
69
+ * This class owns the common inputs and formulas used by both pipelined and
70
+ * non-pipelined scheduling. Variant-specific deadline math is delegated to the
71
+ * concrete subclasses below.
72
+ */
73
+ abstract class BaseCheckpointTiming implements CheckpointTiming {
74
+ public readonly aztecSlotDuration: number;
75
+ public readonly blockDuration: number | undefined;
76
+ public readonly checkpointAssembleTime: number;
77
+ public readonly checkpointInitializationTime: number;
78
+ public readonly l1PublishingTime: number;
79
+ public readonly minExecutionTime: number;
80
+ public readonly p2pPropagationTime: number;
81
+
82
+ constructor(opts: CheckpointTimingConfig) {
83
+ this.aztecSlotDuration = opts.aztecSlotDuration;
84
+ this.blockDuration = opts.blockDuration;
85
+
86
+ this.checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
87
+ this.checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
88
+ this.l1PublishingTime = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
89
+ this.minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
90
+ this.p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
91
+ }
92
+
93
+ public get checkpointFinalizationTime(): number {
94
+ // Allow enough time to
95
+ // - build the checkpoint
96
+ // - Round-trip over p2p
97
+ // - Publish to L1
98
+ return this.checkpointAssembleTime + this.p2pPropagationTime * 2 + this.l1PublishingTime;
99
+ }
100
+
101
+ public get pipeliningAttestationGracePeriod(): number {
102
+ // Allow enough time to
103
+ // - build the block
104
+ // - pass it back over p2p
105
+ return (this.blockDuration ?? 0) + this.p2pPropagationTime;
106
+ }
107
+
108
+ public abstract get timeReservedAtEnd(): number;
109
+ public abstract get minimumBuildSlotWork(): number;
110
+
111
+ public get initializeDeadline(): number {
112
+ return this.aztecSlotDuration - this.minimumBuildSlotWork;
113
+ }
114
+
115
+ public abstract get checkpointAssemblyDeadline(): number;
116
+
117
+ public get checkpointAttestationStartDeadline(): number {
118
+ return this.checkpointAssemblyDeadline;
119
+ }
120
+
121
+ public abstract get checkpointAttestationDeadline(): number;
122
+ public abstract get checkpointPublishingDeadline(): number;
123
+
124
+ public calculateMaxBlocksPerSlot(): number {
125
+ if (!this.blockDuration) {
126
+ return 1;
127
+ }
128
+
129
+ const timeAvailableForBlocks = this.aztecSlotDuration - this.checkpointInitializationTime - this.timeReservedAtEnd;
130
+ return Math.floor(timeAvailableForBlocks / this.blockDuration);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Checkpoint timing model for the non-pipelined sequencer flow.
136
+ *
137
+ * In this mode, checkpoint assembly, attestation collection, and L1 publishing
138
+ * must all complete within the current Aztec slot.
139
+ */
140
+ class StandardCheckpointTimingModel extends BaseCheckpointTiming {
141
+ public get timeReservedAtEnd(): number {
142
+ return (this.blockDuration ?? 0) + this.checkpointFinalizationTime;
143
+ }
144
+
145
+ public get minimumBuildSlotWork(): number {
146
+ return this.checkpointInitializationTime + this.minExecutionTime * 2 + this.checkpointFinalizationTime;
147
+ }
148
+
149
+ public get checkpointAssemblyDeadline(): number {
150
+ return this.aztecSlotDuration - this.l1PublishingTime - 2 * this.p2pPropagationTime;
151
+ }
152
+
153
+ public get checkpointAttestationDeadline(): number {
154
+ return this.aztecSlotDuration - this.l1PublishingTime;
155
+ }
156
+
157
+ public get checkpointPublishingDeadline(): number {
158
+ return this.aztecSlotDuration - this.l1PublishingTime;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Checkpoint timing model for proposer pipelining.
164
+ *
165
+ * In this mode, the build work still starts in the current slot, but checkpoint
166
+ * assembly and attestation collection can extend into the target slot. The extra
167
+ * target-slot window getters are intended for consumers such as P2P validators
168
+ * that need to validate pipelined messages against wallclock time.
169
+ */
170
+ class PipelinedCheckpointTimingModel extends BaseCheckpointTiming implements PipelinedCheckpointTiming {
171
+ public get proposalWindowIntoTargetSlot(): number {
172
+ // Allow the p2p propagation time to receive a checkpoint proposal from leader
173
+ return this.p2pPropagationTime;
174
+ }
175
+
176
+ public get attestationWindowIntoTargetSlot(): number {
177
+ return this.aztecSlotDuration - this.l1PublishingTime;
178
+ }
179
+
180
+ public get timeReservedAtEnd(): number {
181
+ return this.checkpointAssembleTime + this.p2pPropagationTime;
182
+ }
183
+
184
+ public get minimumBuildSlotWork(): number {
185
+ return this.checkpointInitializationTime + this.minExecutionTime * 2;
186
+ }
187
+
188
+ public get checkpointAssemblyDeadline(): number {
189
+ // Allow enough time to
190
+ // - build all blocks
191
+ // - receive attestations
192
+ return this.aztecSlotDuration + this.pipeliningAttestationGracePeriod;
193
+ }
194
+
195
+ public get checkpointAttestationDeadline(): number {
196
+ // Allowed to be into the next wallclock slot minus the allocated l1 publishing time
197
+ return this.aztecSlotDuration * 2 - this.l1PublishingTime;
198
+ }
199
+
200
+ public get checkpointPublishingDeadline(): number {
201
+ // Allowed to be into the next wallclock slot minus the allocated l1 Publishing time
202
+ return this.aztecSlotDuration * 2 - this.l1PublishingTime;
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Creates a checkpoint timing model for the requested scheduling mode.
208
+ *
209
+ * Most callers should use this factory and depend only on the shared
210
+ * `CheckpointTiming` interface. The returned implementation is selected from
211
+ * `opts.pipelining`.
212
+ */
213
+ export function createCheckpointTimingModel(opts: CheckpointTimingConfig): CheckpointTiming {
214
+ validateCheckpointTimingConfig(opts);
215
+ const normalizedOpts = normalizeCheckpointTimingConfig(opts);
216
+
217
+ const timing = normalizedOpts.pipelining
218
+ ? new PipelinedCheckpointTimingModel(normalizedOpts)
219
+ : new StandardCheckpointTimingModel(normalizedOpts);
220
+ validateCheckpointTimingModel(timing);
221
+ return timing;
222
+ }
223
+
224
+ /**
225
+ * Creates a pipelined checkpoint timing model with target-slot window accessors.
226
+ *
227
+ * Use this when the caller specifically needs the pipelined-only timing surface,
228
+ * such as proposal or attestation acceptance windows into the target slot.
229
+ */
230
+ export function createPipelinedCheckpointTimingModel(
231
+ opts: Omit<CheckpointTimingConfig, 'pipelining'>,
232
+ ): PipelinedCheckpointTiming {
233
+ validateCheckpointTimingConfig(opts);
234
+ const normalizedOpts = normalizeCheckpointTimingConfig(opts);
235
+
236
+ const timing = new PipelinedCheckpointTimingModel(normalizedOpts);
237
+ validateCheckpointTimingModel(timing);
238
+ return timing;
239
+ }
240
+
28
241
  /**
29
242
  * Calculates the maximum number of blocks that can be built in a slot.
30
243
  * Used by both the sequencer timetable and p2p gossipsub scoring.
@@ -42,25 +255,92 @@ export function calculateMaxBlocksPerSlot(
42
255
  checkpointAssembleTime?: number;
43
256
  p2pPropagationTime?: number;
44
257
  l1PublishingTime?: number;
258
+ pipelining?: boolean;
45
259
  } = {},
46
260
  ): number {
47
- if (!blockDurationSec) {
48
- return 1; // Single block per slot
261
+ return createCheckpointTimingModel({
262
+ aztecSlotDuration: aztecSlotDurationSec,
263
+ blockDuration: blockDurationSec,
264
+ checkpointAssembleTime: opts.checkpointAssembleTime,
265
+ checkpointInitializationTime: opts.checkpointInitializationTime,
266
+ l1PublishingTime: opts.l1PublishingTime,
267
+ p2pPropagationTime: opts.p2pPropagationTime,
268
+ pipelining: opts.pipelining,
269
+ }).calculateMaxBlocksPerSlot();
270
+ }
271
+
272
+ function assertNonNegative(name: string, value: number): void {
273
+ if (value < 0) {
274
+ throw new Error(`${name} must be non-negative (got ${value})`);
49
275
  }
276
+ }
50
277
 
51
- const initOffset = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
52
- const assembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
53
- const p2pTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
54
- const l1Time = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
278
+ function validateCheckpointTimingConfig(opts: CheckpointTimingConfig): void {
279
+ if (opts.aztecSlotDuration <= 0) {
280
+ throw new Error(`aztecSlotDuration must be positive (got ${opts.aztecSlotDuration})`);
281
+ }
55
282
 
56
- // Calculate checkpoint finalization time (assembly + round-trip propagation + L1 publishing)
57
- const checkpointFinalizationTime = assembleTime + p2pTime * 2 + l1Time;
283
+ if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration <= 0) {
284
+ throw new Error(`ethereumSlotDuration must be positive when provided (got ${opts.ethereumSlotDuration})`);
285
+ }
58
286
 
59
- // Time reserved at end for last sub-slot (validator re-execution) + finalization
60
- const timeReservedAtEnd = blockDurationSec + checkpointFinalizationTime;
287
+ if (opts.blockDuration !== undefined && opts.blockDuration <= 0) {
288
+ throw new Error(`blockDuration must be positive when provided (got ${opts.blockDuration})`);
289
+ }
61
290
 
62
- // Time available for building blocks
63
- const timeAvailableForBlocks = aztecSlotDurationSec - initOffset - timeReservedAtEnd;
291
+ if (opts.minExecutionTime !== undefined && opts.minExecutionTime <= 0) {
292
+ throw new Error(`minExecutionTime must be positive when provided (got ${opts.minExecutionTime})`);
293
+ }
64
294
 
65
- return Math.max(1, Math.floor(timeAvailableForBlocks / blockDurationSec));
295
+ if (opts.checkpointAssembleTime !== undefined) {
296
+ assertNonNegative('checkpointAssembleTime', opts.checkpointAssembleTime);
297
+ }
298
+ if (opts.checkpointInitializationTime !== undefined) {
299
+ assertNonNegative('checkpointInitializationTime', opts.checkpointInitializationTime);
300
+ }
301
+ if (opts.l1PublishingTime !== undefined) {
302
+ assertNonNegative('l1PublishingTime', opts.l1PublishingTime);
303
+ }
304
+ if (opts.p2pPropagationTime !== undefined) {
305
+ assertNonNegative('p2pPropagationTime', opts.p2pPropagationTime);
306
+ }
307
+ }
308
+
309
+ function normalizeCheckpointTimingConfig(opts: CheckpointTimingConfig): CheckpointTimingConfig {
310
+ let checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
311
+ let checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
312
+ let minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
313
+ let p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
314
+
315
+ if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration < 8) {
316
+ p2pPropagationTime = 0;
317
+ checkpointAssembleTime = 0.5;
318
+ checkpointInitializationTime = 0.5;
319
+ minExecutionTime = 1;
320
+ }
321
+
322
+ if (opts.blockDuration !== undefined && minExecutionTime > opts.blockDuration) {
323
+ minExecutionTime = opts.blockDuration;
324
+ }
325
+
326
+ return {
327
+ ...opts,
328
+ checkpointAssembleTime,
329
+ checkpointInitializationTime,
330
+ minExecutionTime,
331
+ p2pPropagationTime,
332
+ };
333
+ }
334
+
335
+ function validateCheckpointTimingModel(model: CheckpointTiming): void {
336
+ if (model.blockDuration === undefined) {
337
+ return;
338
+ }
339
+
340
+ const timeAvailableForBlocks = model.aztecSlotDuration - model.checkpointInitializationTime - model.timeReservedAtEnd;
341
+ if (timeAvailableForBlocks < model.blockDuration) {
342
+ throw new Error(
343
+ `Invalid timing configuration: only ${timeAvailableForBlocks}s available for block building, which is less than one blockDuration (${model.blockDuration}s).`,
344
+ );
345
+ }
66
346
  }
@@ -86,6 +86,10 @@ export class NullifierLeafPreimage implements IndexedTreeLeafPreimage {
86
86
  ];
87
87
  }
88
88
 
89
+ isEmpty(): boolean {
90
+ return this.leaf.isEmpty() && this.nextKey.isZero() && this.nextIndex === 0n;
91
+ }
92
+
89
93
  toFields(): Fr[] {
90
94
  return this.toHashInputs().map(buf => Fr.fromBuffer(buf));
91
95
  }
@@ -172,8 +172,8 @@ export class BlockHeader {
172
172
  }
173
173
 
174
174
  /** Manually set the hash for this block header if already computed */
175
- setHash(hashed: Fr) {
176
- this._cachedHash = Promise.resolve(new BlockHash(hashed));
175
+ setHash(hashed: BlockHash) {
176
+ this._cachedHash = Promise.resolve(hashed);
177
177
  }
178
178
 
179
179
  /** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */