@aztec/stdlib 0.0.1-commit.5914bae → 0.0.1-commit.59a0419c6

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 (366) hide show
  1. package/dest/abi/abi.d.ts +191 -26
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +4 -45
  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/encoder.d.ts +1 -1
  7. package/dest/abi/encoder.d.ts.map +1 -1
  8. package/dest/abi/encoder.js +32 -6
  9. package/dest/abi/event_selector.d.ts +3 -6
  10. package/dest/abi/event_selector.d.ts.map +1 -1
  11. package/dest/abi/function_selector.d.ts +3 -6
  12. package/dest/abi/function_selector.d.ts.map +1 -1
  13. package/dest/abi/function_selector.js +1 -3
  14. package/dest/abi/note_selector.d.ts +3 -6
  15. package/dest/abi/note_selector.d.ts.map +1 -1
  16. package/dest/abi/note_selector.js +1 -3
  17. package/dest/avm/avm_accumulated_data.js +2 -2
  18. package/dest/avm/avm_circuit_public_inputs.js +2 -2
  19. package/dest/aztec-address/index.d.ts +3 -6
  20. package/dest/aztec-address/index.d.ts.map +1 -1
  21. package/dest/aztec-address/index.js +2 -4
  22. package/dest/block/block_data.d.ts +8 -8
  23. package/dest/block/block_data.d.ts.map +1 -1
  24. package/dest/block/block_data.js +2 -2
  25. package/dest/block/block_hash.d.ts +11 -10
  26. package/dest/block/block_hash.d.ts.map +1 -1
  27. package/dest/block/block_hash.js +10 -9
  28. package/dest/block/l2_block_info.d.ts +6 -5
  29. package/dest/block/l2_block_info.d.ts.map +1 -1
  30. package/dest/block/l2_block_info.js +6 -5
  31. package/dest/block/l2_block_source.d.ts +80 -3
  32. package/dest/block/l2_block_source.d.ts.map +1 -1
  33. package/dest/block/l2_block_source.js +1 -0
  34. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  35. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  36. package/dest/block/l2_block_stream/l2_tips_store_base.js +18 -5
  37. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  38. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  39. package/dest/block/test/l2_tips_store_test_suite.js +4 -3
  40. package/dest/checkpoint/checkpoint.d.ts +7 -1
  41. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  42. package/dest/checkpoint/checkpoint.js +9 -1
  43. package/dest/checkpoint/checkpoint_data.d.ts +71 -5
  44. package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
  45. package/dest/checkpoint/checkpoint_data.js +10 -0
  46. package/dest/config/chain-config.d.ts +1 -1
  47. package/dest/config/chain-config.d.ts.map +1 -1
  48. package/dest/config/chain-config.js +7 -1
  49. package/dest/config/index.d.ts +2 -1
  50. package/dest/config/index.d.ts.map +1 -1
  51. package/dest/config/index.js +1 -0
  52. package/dest/config/pipelining-config.d.ts +19 -0
  53. package/dest/config/pipelining-config.d.ts.map +1 -0
  54. package/dest/config/pipelining-config.js +18 -0
  55. package/dest/config/sequencer-config.d.ts +4 -2
  56. package/dest/config/sequencer-config.d.ts.map +1 -1
  57. package/dest/config/sequencer-config.js +11 -3
  58. package/dest/contract/contract_address.d.ts +3 -3
  59. package/dest/contract/contract_address.js +4 -4
  60. package/dest/contract/contract_class_id.d.ts +2 -2
  61. package/dest/contract/contract_class_id.js +2 -2
  62. package/dest/contract/index.d.ts +1 -3
  63. package/dest/contract/index.d.ts.map +1 -1
  64. package/dest/contract/index.js +0 -2
  65. package/dest/contract/interfaces/contract_class.d.ts +3 -156
  66. package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
  67. package/dest/contract/interfaces/contract_class.js +1 -28
  68. package/dest/contract/private_function.d.ts +1 -1
  69. package/dest/contract/private_function.d.ts.map +1 -1
  70. package/dest/contract/private_function.js +2 -4
  71. package/dest/epoch-helpers/index.d.ts +3 -1
  72. package/dest/epoch-helpers/index.d.ts.map +1 -1
  73. package/dest/epoch-helpers/index.js +3 -0
  74. package/dest/file-store/factory.d.ts +4 -3
  75. package/dest/file-store/factory.d.ts.map +1 -1
  76. package/dest/file-store/factory.js +2 -2
  77. package/dest/file-store/http.d.ts +9 -2
  78. package/dest/file-store/http.d.ts.map +1 -1
  79. package/dest/file-store/http.js +20 -9
  80. package/dest/file-store/index.d.ts +2 -1
  81. package/dest/file-store/index.d.ts.map +1 -1
  82. package/dest/gas/fee_math.d.ts +49 -0
  83. package/dest/gas/fee_math.d.ts.map +1 -0
  84. package/dest/gas/fee_math.js +80 -0
  85. package/dest/gas/gas_fees.d.ts +5 -1
  86. package/dest/gas/gas_fees.d.ts.map +1 -1
  87. package/dest/gas/gas_fees.js +10 -1
  88. package/dest/gas/index.d.ts +2 -1
  89. package/dest/gas/index.d.ts.map +1 -1
  90. package/dest/gas/index.js +1 -0
  91. package/dest/ha-signing/config.d.ts +136 -0
  92. package/dest/ha-signing/config.d.ts.map +1 -0
  93. package/dest/ha-signing/config.js +98 -0
  94. package/dest/ha-signing/index.d.ts +4 -0
  95. package/dest/ha-signing/index.d.ts.map +1 -0
  96. package/dest/ha-signing/index.js +3 -0
  97. package/dest/ha-signing/local_config.d.ts +63 -0
  98. package/dest/ha-signing/local_config.d.ts.map +1 -0
  99. package/dest/ha-signing/local_config.js +24 -0
  100. package/dest/ha-signing/types.d.ts +90 -0
  101. package/dest/ha-signing/types.d.ts.map +1 -0
  102. package/dest/ha-signing/types.js +39 -0
  103. package/dest/hash/hash.d.ts +16 -1
  104. package/dest/hash/hash.d.ts.map +1 -1
  105. package/dest/hash/hash.js +32 -0
  106. package/dest/interfaces/archiver.d.ts +11 -1
  107. package/dest/interfaces/archiver.d.ts.map +1 -1
  108. package/dest/interfaces/archiver.js +6 -2
  109. package/dest/interfaces/aztec-node-admin.d.ts +21 -20
  110. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  111. package/dest/interfaces/aztec-node-admin.js +3 -3
  112. package/dest/interfaces/aztec-node.d.ts +10 -1
  113. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  114. package/dest/interfaces/aztec-node.js +2 -0
  115. package/dest/interfaces/l2_logs_source.d.ts +5 -3
  116. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  117. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  118. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  119. package/dest/interfaces/prover-client.d.ts +1 -1
  120. package/dest/interfaces/prover-client.d.ts.map +1 -1
  121. package/dest/interfaces/prover-client.js +0 -3
  122. package/dest/interfaces/proving-job.d.ts +200 -200
  123. package/dest/interfaces/slasher.d.ts +1 -10
  124. package/dest/interfaces/slasher.d.ts.map +1 -1
  125. package/dest/interfaces/slasher.js +0 -2
  126. package/dest/interfaces/validator.d.ts +49 -40
  127. package/dest/interfaces/validator.d.ts.map +1 -1
  128. package/dest/interfaces/validator.js +2 -3
  129. package/dest/kernel/claimed_length_array.js +1 -1
  130. package/dest/kernel/hints/private_kernel_reset_hints.d.ts +1 -1
  131. package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
  132. package/dest/kernel/padded_side_effects.js +1 -1
  133. package/dest/kernel/private_to_avm_accumulated_data.js +2 -2
  134. package/dest/kernel/private_to_public_accumulated_data.js +2 -2
  135. package/dest/kernel/private_to_rollup_accumulated_data.js +1 -1
  136. package/dest/kv-store/config.d.ts +17 -0
  137. package/dest/kv-store/config.d.ts.map +1 -0
  138. package/dest/kv-store/config.js +26 -0
  139. package/dest/kv-store/index.d.ts +2 -0
  140. package/dest/kv-store/index.d.ts.map +1 -0
  141. package/dest/kv-store/index.js +1 -0
  142. package/dest/l1-contracts/index.d.ts +2 -2
  143. package/dest/l1-contracts/index.d.ts.map +1 -1
  144. package/dest/l1-contracts/index.js +1 -1
  145. package/dest/logs/log_id.d.ts +1 -1
  146. package/dest/logs/log_id.d.ts.map +1 -1
  147. package/dest/logs/log_id.js +1 -2
  148. package/dest/logs/private_log.js +1 -1
  149. package/dest/logs/public_log.d.ts +1 -1
  150. package/dest/logs/public_log.d.ts.map +1 -1
  151. package/dest/logs/public_log.js +1 -7
  152. package/dest/logs/siloed_tag.d.ts +5 -7
  153. package/dest/logs/siloed_tag.d.ts.map +1 -1
  154. package/dest/logs/siloed_tag.js +4 -0
  155. package/dest/logs/tag.d.ts +5 -6
  156. package/dest/logs/tag.d.ts.map +1 -1
  157. package/dest/logs/tag.js +4 -0
  158. package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
  159. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  160. package/dest/p2p/block_proposal.d.ts +7 -9
  161. package/dest/p2p/block_proposal.d.ts.map +1 -1
  162. package/dest/p2p/block_proposal.js +5 -10
  163. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  164. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  165. package/dest/p2p/checkpoint_attestation.js +2 -7
  166. package/dest/p2p/checkpoint_proposal.d.ts +9 -11
  167. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  168. package/dest/p2p/checkpoint_proposal.js +6 -25
  169. package/dest/p2p/gossipable.d.ts +4 -4
  170. package/dest/p2p/gossipable.d.ts.map +1 -1
  171. package/dest/parity/parity_base_private_inputs.d.ts +7 -3
  172. package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
  173. package/dest/parity/parity_base_private_inputs.js +7 -5
  174. package/dest/parity/parity_public_inputs.d.ts +7 -3
  175. package/dest/parity/parity_public_inputs.d.ts.map +1 -1
  176. package/dest/parity/parity_public_inputs.js +6 -3
  177. package/dest/proofs/chonk_proof.d.ts +46 -2
  178. package/dest/proofs/chonk_proof.d.ts.map +1 -1
  179. package/dest/proofs/chonk_proof.js +84 -15
  180. package/dest/rollup/base_rollup_hints.js +2 -2
  181. package/dest/rollup/block_headers_hash.d.ts +1 -1
  182. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  183. package/dest/rollup/block_headers_hash.js +8 -2
  184. package/dest/rollup/block_root_rollup_private_inputs.js +5 -5
  185. package/dest/rollup/checkpoint_rollup_public_inputs.js +1 -1
  186. package/dest/rollup/checkpoint_root_rollup_private_inputs.js +3 -3
  187. package/dest/rollup/root_rollup_public_inputs.js +1 -1
  188. package/dest/rollup/tree_snapshot_diff_hints.js +2 -2
  189. package/dest/slashing/index.d.ts +2 -3
  190. package/dest/slashing/index.d.ts.map +1 -1
  191. package/dest/slashing/index.js +1 -2
  192. package/dest/slashing/serialization.d.ts +2 -6
  193. package/dest/slashing/serialization.d.ts.map +1 -1
  194. package/dest/slashing/serialization.js +0 -60
  195. package/dest/slashing/types.d.ts +4 -90
  196. package/dest/slashing/types.d.ts.map +1 -1
  197. package/dest/slashing/types.js +0 -14
  198. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  199. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  200. package/dest/slashing/{tally.js → votes.js} +1 -1
  201. package/dest/tests/factories.d.ts +3 -10
  202. package/dest/tests/factories.d.ts.map +1 -1
  203. package/dest/tests/factories.js +18 -45
  204. package/dest/tests/mocks.d.ts +1 -1
  205. package/dest/tests/mocks.d.ts.map +1 -1
  206. package/dest/tests/mocks.js +12 -17
  207. package/dest/timetable/index.d.ts +51 -1
  208. package/dest/timetable/index.d.ts.map +1 -1
  209. package/dest/timetable/index.js +204 -14
  210. package/dest/trees/nullifier_leaf.d.ts +2 -1
  211. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  212. package/dest/trees/nullifier_leaf.js +3 -0
  213. package/dest/tx/block_header.d.ts +2 -2
  214. package/dest/tx/block_header.d.ts.map +1 -1
  215. package/dest/tx/block_header.js +1 -1
  216. package/dest/tx/fee_provider.d.ts +10 -0
  217. package/dest/tx/fee_provider.d.ts.map +1 -0
  218. package/dest/tx/fee_provider.js +1 -0
  219. package/dest/tx/global_variable_builder.d.ts +3 -4
  220. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  221. package/dest/tx/index.d.ts +2 -1
  222. package/dest/tx/index.d.ts.map +1 -1
  223. package/dest/tx/index.js +1 -0
  224. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  225. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  226. package/dest/tx/indexed_tx_effect.js +1 -2
  227. package/dest/tx/protocol_contracts.js +2 -2
  228. package/dest/tx/simulated_tx.d.ts +151 -26
  229. package/dest/tx/simulated_tx.d.ts.map +1 -1
  230. package/dest/tx/tx.d.ts +3 -3
  231. package/dest/tx/tx.d.ts.map +1 -1
  232. package/dest/types/shared.d.ts +1 -10
  233. package/dest/types/shared.d.ts.map +1 -1
  234. package/dest/types/shared.js +0 -9
  235. package/dest/vks/verification_key.d.ts +2 -137
  236. package/dest/vks/verification_key.d.ts.map +1 -1
  237. package/dest/vks/verification_key.js +5 -126
  238. package/dest/vks/vk_data.js +1 -1
  239. package/dest/world-state/genesis_data.d.ts +11 -0
  240. package/dest/world-state/genesis_data.d.ts.map +1 -0
  241. package/dest/world-state/genesis_data.js +4 -0
  242. package/dest/world-state/index.d.ts +2 -1
  243. package/dest/world-state/index.d.ts.map +1 -1
  244. package/dest/world-state/index.js +1 -0
  245. package/dest/world-state/world_state_revision.d.ts +8 -1
  246. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  247. package/dest/world-state/world_state_revision.js +7 -1
  248. package/package.json +11 -10
  249. package/src/abi/abi.ts +14 -67
  250. package/src/abi/authorization_selector.ts +2 -8
  251. package/src/abi/encoder.ts +42 -6
  252. package/src/abi/event_selector.ts +2 -8
  253. package/src/abi/function_selector.ts +3 -12
  254. package/src/abi/note_selector.ts +3 -12
  255. package/src/avm/avm_accumulated_data.ts +6 -6
  256. package/src/avm/avm_circuit_public_inputs.ts +4 -4
  257. package/src/aztec-address/index.ts +4 -10
  258. package/src/block/block_data.ts +3 -4
  259. package/src/block/block_hash.ts +21 -14
  260. package/src/block/l2_block_info.ts +8 -6
  261. package/src/block/l2_block_source.ts +10 -2
  262. package/src/block/l2_block_stream/l2_tips_store_base.ts +25 -13
  263. package/src/block/test/l2_tips_store_test_suite.ts +9 -2
  264. package/src/checkpoint/checkpoint.ts +11 -1
  265. package/src/checkpoint/checkpoint_data.ts +40 -4
  266. package/src/config/chain-config.ts +7 -1
  267. package/src/config/index.ts +1 -0
  268. package/src/config/pipelining-config.ts +31 -0
  269. package/src/config/sequencer-config.ts +17 -4
  270. package/src/contract/contract_address.ts +4 -4
  271. package/src/contract/contract_class_id.ts +2 -2
  272. package/src/contract/index.ts +0 -2
  273. package/src/contract/interfaces/contract_class.ts +2 -82
  274. package/src/contract/private_function.ts +3 -1
  275. package/src/epoch-helpers/index.ts +5 -0
  276. package/src/file-store/factory.ts +13 -4
  277. package/src/file-store/http.ts +29 -10
  278. package/src/file-store/index.ts +1 -0
  279. package/src/gas/README.md +31 -0
  280. package/src/gas/fee_math.ts +120 -0
  281. package/src/gas/gas_fees.ts +17 -4
  282. package/src/gas/index.ts +1 -0
  283. package/src/ha-signing/config.ts +159 -0
  284. package/src/ha-signing/index.ts +29 -0
  285. package/src/ha-signing/local_config.ts +46 -0
  286. package/src/ha-signing/types.ts +126 -0
  287. package/src/hash/hash.ts +27 -0
  288. package/src/interfaces/archiver.ts +11 -1
  289. package/src/interfaces/aztec-node-admin.ts +5 -7
  290. package/src/interfaces/aztec-node.ts +15 -0
  291. package/src/interfaces/l2_logs_source.ts +4 -1
  292. package/src/interfaces/merkle_tree_operations.ts +3 -2
  293. package/src/interfaces/prover-client.ts +2 -5
  294. package/src/interfaces/slasher.ts +0 -6
  295. package/src/interfaces/validator.ts +53 -44
  296. package/src/kernel/claimed_length_array.ts +2 -2
  297. package/src/kernel/hints/private_kernel_reset_hints.ts +2 -5
  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_to_avm_accumulated_data.ts +4 -4
  301. package/src/kernel/private_to_public_accumulated_data.ts +10 -10
  302. package/src/kernel/private_to_rollup_accumulated_data.ts +5 -5
  303. package/src/kv-store/config.ts +36 -0
  304. package/src/kv-store/index.ts +1 -0
  305. package/src/l1-contracts/index.ts +1 -1
  306. package/src/logs/log_id.ts +1 -2
  307. package/src/logs/private_log.ts +1 -1
  308. package/src/logs/public_log.ts +1 -11
  309. package/src/logs/siloed_tag.ts +8 -9
  310. package/src/logs/tag.ts +8 -8
  311. package/src/messaging/l1_to_l2_message_source.ts +3 -1
  312. package/src/p2p/block_proposal.ts +14 -10
  313. package/src/p2p/checkpoint_attestation.ts +5 -9
  314. package/src/p2p/checkpoint_proposal.ts +22 -37
  315. package/src/p2p/gossipable.ts +4 -4
  316. package/src/parity/parity_base_private_inputs.ts +10 -4
  317. package/src/parity/parity_public_inputs.ts +9 -2
  318. package/src/proofs/chonk_proof.ts +90 -12
  319. package/src/rollup/base_rollup_hints.ts +2 -2
  320. package/src/rollup/block_headers_hash.ts +11 -2
  321. package/src/rollup/block_root_rollup_private_inputs.ts +8 -8
  322. package/src/rollup/checkpoint_rollup_public_inputs.ts +2 -2
  323. package/src/rollup/checkpoint_root_rollup_private_inputs.ts +4 -4
  324. package/src/rollup/root_rollup_public_inputs.ts +2 -2
  325. package/src/rollup/tree_snapshot_diff_hints.ts +5 -5
  326. package/src/slashing/index.ts +1 -2
  327. package/src/slashing/serialization.ts +1 -81
  328. package/src/slashing/types.ts +3 -35
  329. package/src/slashing/{tally.ts → votes.ts} +1 -1
  330. package/src/tests/factories.ts +18 -53
  331. package/src/tests/mocks.ts +14 -10
  332. package/src/timetable/index.ts +293 -13
  333. package/src/trees/nullifier_leaf.ts +4 -0
  334. package/src/tx/block_header.ts +2 -2
  335. package/src/tx/fee_provider.ts +10 -0
  336. package/src/tx/global_variable_builder.ts +2 -3
  337. package/src/tx/index.ts +1 -0
  338. package/src/tx/indexed_tx_effect.ts +1 -2
  339. package/src/tx/protocol_contracts.ts +2 -2
  340. package/src/tx/tx.ts +2 -2
  341. package/src/types/shared.ts +0 -10
  342. package/src/vks/verification_key.ts +5 -184
  343. package/src/vks/vk_data.ts +1 -1
  344. package/src/world-state/genesis_data.ts +15 -0
  345. package/src/world-state/index.ts +1 -0
  346. package/src/world-state/world_state_revision.ts +9 -1
  347. package/dest/abi/mocked_keys.d.ts +0 -2
  348. package/dest/abi/mocked_keys.d.ts.map +0 -1
  349. package/dest/abi/mocked_keys.js +0 -1
  350. package/dest/contract/private_function_membership_proof.d.ts +0 -32
  351. package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
  352. package/dest/contract/private_function_membership_proof.js +0 -124
  353. package/dest/contract/utility_function_membership_proof.d.ts +0 -27
  354. package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
  355. package/dest/contract/utility_function_membership_proof.js +0 -87
  356. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  357. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  358. package/dest/l1-contracts/slash_factory.js +0 -158
  359. package/dest/slashing/empire.d.ts +0 -31
  360. package/dest/slashing/empire.d.ts.map +0 -1
  361. package/dest/slashing/empire.js +0 -87
  362. package/src/abi/mocked_keys.ts +0 -2
  363. package/src/contract/private_function_membership_proof.ts +0 -167
  364. package/src/contract/utility_function_membership_proof.ts +0 -118
  365. package/src/l1-contracts/slash_factory.ts +0 -180
  366. package/src/slashing/empire.ts +0 -104
@@ -42,79 +42,6 @@ const PrivateFunctionSchema = zodFor<PrivateFunction>()(
42
42
  }),
43
43
  );
44
44
 
45
- /** Private function definition with executable bytecode. */
46
- export interface ExecutablePrivateFunction extends PrivateFunction {
47
- /** ACIR and Brillig bytecode */
48
- bytecode: Buffer;
49
- }
50
-
51
- const ExecutablePrivateFunctionSchema = zodFor<ExecutablePrivateFunction>()(
52
- PrivateFunctionSchema.and(z.object({ bytecode: schemas.Buffer })),
53
- );
54
-
55
- /** Utility function definition. */
56
- export interface UtilityFunction {
57
- /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
58
- selector: FunctionSelector;
59
- /** Brillig. */
60
- bytecode: Buffer;
61
- }
62
-
63
- const UtilityFunctionSchema = zodFor<UtilityFunction>()(
64
- z.object({
65
- selector: FunctionSelector.schema,
66
- bytecode: schemas.Buffer,
67
- }),
68
- );
69
-
70
- /** Sibling paths and sibling commitments for proving membership of a private function within a contract class. */
71
- export type PrivateFunctionMembershipProof = {
72
- artifactMetadataHash: Fr;
73
- functionMetadataHash: Fr;
74
- utilityFunctionsTreeRoot: Fr;
75
- privateFunctionTreeSiblingPath: Fr[];
76
- privateFunctionTreeLeafIndex: number;
77
- artifactTreeSiblingPath: Fr[];
78
- artifactTreeLeafIndex: number;
79
- };
80
-
81
- const PrivateFunctionMembershipProofSchema = zodFor<PrivateFunctionMembershipProof>()(
82
- z.object({
83
- artifactMetadataHash: schemas.Fr,
84
- functionMetadataHash: schemas.Fr,
85
- utilityFunctionsTreeRoot: schemas.Fr,
86
- privateFunctionTreeSiblingPath: z.array(schemas.Fr),
87
- privateFunctionTreeLeafIndex: schemas.Integer,
88
- artifactTreeSiblingPath: z.array(schemas.Fr),
89
- artifactTreeLeafIndex: schemas.Integer,
90
- }),
91
- );
92
-
93
- /** A private function with a membership proof. */
94
- export type ExecutablePrivateFunctionWithMembershipProof = ExecutablePrivateFunction & PrivateFunctionMembershipProof;
95
-
96
- /** Sibling paths and commitments for proving membership of a utility function within a contract class. */
97
- export type UtilityFunctionMembershipProof = {
98
- artifactMetadataHash: Fr;
99
- functionMetadataHash: Fr;
100
- privateFunctionsArtifactTreeRoot: Fr;
101
- artifactTreeSiblingPath: Fr[];
102
- artifactTreeLeafIndex: number;
103
- };
104
-
105
- const UtilityFunctionMembershipProofSchema = zodFor<UtilityFunctionMembershipProof>()(
106
- z.object({
107
- artifactMetadataHash: schemas.Fr,
108
- functionMetadataHash: schemas.Fr,
109
- privateFunctionsArtifactTreeRoot: schemas.Fr,
110
- artifactTreeSiblingPath: z.array(schemas.Fr),
111
- artifactTreeLeafIndex: schemas.Integer,
112
- }),
113
- );
114
-
115
- /** A utility function with a membership proof. */
116
- export type UtilityFunctionWithMembershipProof = UtilityFunction & UtilityFunctionMembershipProof;
117
-
118
45
  export const ContractClassSchema = zodFor<ContractClass>()(
119
46
  z.object({
120
47
  version: z.literal(VERSION),
@@ -143,11 +70,8 @@ export const ContractClassWithIdSchema = zodFor<ContractClassWithId>()(
143
70
  }),
144
71
  );
145
72
 
146
- /** A contract class with public bytecode information, and optional private and utility functions. */
147
- export type ContractClassPublic = {
148
- privateFunctions: ExecutablePrivateFunctionWithMembershipProof[];
149
- utilityFunctions: UtilityFunctionWithMembershipProof[];
150
- } & Pick<ContractClassCommitments, 'id' | 'privateFunctionsRoot'> &
73
+ /** A contract class with public bytecode information. */
74
+ export type ContractClassPublic = Pick<ContractClassCommitments, 'id' | 'privateFunctionsRoot'> &
151
75
  Omit<ContractClass, 'privateFunctions'>;
152
76
 
153
77
  export type ContractClassPublicWithCommitment = ContractClassPublic &
@@ -158,8 +82,6 @@ export const ContractClassPublicSchema = zodFor<ContractClassPublic>()(
158
82
  .object({
159
83
  id: schemas.Fr,
160
84
  privateFunctionsRoot: schemas.Fr,
161
- privateFunctions: z.array(ExecutablePrivateFunctionSchema.and(PrivateFunctionMembershipProofSchema)),
162
- utilityFunctions: z.array(UtilityFunctionSchema.and(UtilityFunctionMembershipProofSchema)),
163
85
  })
164
86
  .and(ContractClassSchema.omit({ privateFunctions: true })),
165
87
  );
@@ -179,8 +101,6 @@ export function contractClassPublicFromPlainObject(obj: any): ContractClassPubli
179
101
  version: 1,
180
102
  artifactHash: Fr.fromPlainObject(obj.artifactHash),
181
103
  privateFunctionsRoot: Fr.fromPlainObject(obj.privateFunctionsRoot),
182
- privateFunctions: [],
183
- utilityFunctions: [],
184
104
  packedBytecode: obj.packedBytecode instanceof Buffer ? obj.packedBytecode : Buffer.from(obj.packedBytecode),
185
105
  };
186
106
  }
@@ -3,6 +3,7 @@ import { poseidon2Hash, poseidon2HashWithSeparator } from '@aztec/foundation/cry
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { type MerkleTree, MerkleTreeCalculator } from '@aztec/foundation/trees';
5
5
 
6
+ import { computeMerkleHash } from '../hash/hash.js';
6
7
  import type { PrivateFunction } from './interfaces/contract_class.js';
7
8
 
8
9
  // Memoize the merkle tree calculators to avoid re-computing the zero-hash for each level in each call
@@ -42,7 +43,8 @@ async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator>
42
43
  privateFunctionTreeCalculator = await MerkleTreeCalculator.create(
43
44
  FUNCTION_TREE_HEIGHT,
44
45
  functionTreeZeroLeaf,
45
- async (left, right) => (await poseidon2Hash([left, right])).toBuffer() as Buffer<ArrayBuffer>,
46
+ async (left, right) =>
47
+ (await computeMerkleHash(Fr.fromBuffer(left), Fr.fromBuffer(right))).toBuffer() as Buffer<ArrayBuffer>,
46
48
  );
47
49
  }
48
50
  return privateFunctionTreeCalculator;
@@ -162,6 +162,11 @@ export function getProofSubmissionDeadlineTimestamp(
162
162
  return getTimestampForSlot(deadlineSlot, constants);
163
163
  }
164
164
 
165
+ /** Computes the quorum size required for a committee (⌊2n/3⌋ + 1). */
166
+ export function computeQuorum(committeeSize: number): number {
167
+ return Math.floor((committeeSize * 2) / 3) + 1;
168
+ }
169
+
165
170
  /** Returns the timestamp to start building a block for a given L2 slot. Computed as the start timestamp of the slot minus one L1 slot duration. */
166
171
  export function getSlotStartBuildTimestamp(
167
172
  slotNumber: SlotNumber,
@@ -1,7 +1,7 @@
1
1
  import { type Logger, createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { GoogleCloudFileStore } from './gcs.js';
4
- import { HttpFileStore } from './http.js';
4
+ import { HttpFileStore, type HttpFileStoreOptions } from './http.js';
5
5
  import type { FileStore, ReadOnlyFileStore } from './interface.js';
6
6
  import { LocalFileStore } from './local.js';
7
7
  import { S3FileStore } from './s3.js';
@@ -59,17 +59,26 @@ export async function createFileStore(
59
59
  }
60
60
  }
61
61
 
62
- export async function createReadOnlyFileStore(config: string, logger?: Logger): Promise<ReadOnlyFileStore>;
63
- export async function createReadOnlyFileStore(config: undefined, logger?: Logger): Promise<undefined>;
62
+ export async function createReadOnlyFileStore(
63
+ config: string,
64
+ logger?: Logger,
65
+ options?: HttpFileStoreOptions,
66
+ ): Promise<ReadOnlyFileStore>;
67
+ export async function createReadOnlyFileStore(
68
+ config: undefined,
69
+ logger?: Logger,
70
+ options?: HttpFileStoreOptions,
71
+ ): Promise<undefined>;
64
72
  export async function createReadOnlyFileStore(
65
73
  config: string | undefined,
66
74
  logger = createLogger('stdlib:file-store'),
75
+ options?: HttpFileStoreOptions,
67
76
  ): Promise<ReadOnlyFileStore | undefined> {
68
77
  if (config === undefined) {
69
78
  return undefined;
70
79
  } else if (config.startsWith('http://') || config.startsWith('https://')) {
71
80
  logger.info(`Creating read-only HTTP file store at ${config}`);
72
- return new HttpFileStore(config, logger);
81
+ return new HttpFileStore(config, logger, options);
73
82
  } else {
74
83
  return await createFileStore(config, logger);
75
84
  }
@@ -10,6 +10,14 @@ import { pipeline } from 'stream/promises';
10
10
 
11
11
  import type { ReadOnlyFileStore } from './interface.js';
12
12
 
13
+ /** Options for configuring HttpFileStore behavior. */
14
+ export interface HttpFileStoreOptions {
15
+ /** Retry backoff intervals in seconds. Empty array disables retries. Default: [1, 1, 3]. */
16
+ retryBackoff?: number[];
17
+ /** Request timeout in milliseconds. Default: no timeout (axios default). */
18
+ timeoutMs?: number;
19
+ }
20
+
13
21
  export class HttpFileStore implements ReadOnlyFileStore {
14
22
  private readonly axiosInstance: AxiosInstance;
15
23
  private readonly fetch: <T>(config: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
@@ -17,17 +25,28 @@ export class HttpFileStore implements ReadOnlyFileStore {
17
25
  constructor(
18
26
  private readonly baseUrl: string,
19
27
  private readonly log: Logger = createLogger('stdlib:http-file-store'),
28
+ options?: HttpFileStoreOptions,
20
29
  ) {
21
- this.axiosInstance = axios.create();
22
- this.fetch = async <T>(config: AxiosRequestConfig) => {
23
- return await retry(
24
- () => this.axiosInstance.request<T>(config),
25
- `Fetching ${config.url}`,
26
- makeBackoff([1, 1, 3]),
27
- this.log,
28
- /*failSilently=*/ true,
29
- );
30
- };
30
+ this.axiosInstance = axios.create({
31
+ ...(options?.timeoutMs !== undefined && { timeout: options.timeoutMs }),
32
+ });
33
+
34
+ const retryBackoff = options?.retryBackoff ?? [1, 1, 3];
35
+ if (retryBackoff.length > 0) {
36
+ this.fetch = async <T>(config: AxiosRequestConfig) => {
37
+ return await retry(
38
+ () => this.axiosInstance.request<T>(config),
39
+ `Fetching ${config.url}`,
40
+ makeBackoff(retryBackoff),
41
+ this.log,
42
+ /*failSilently=*/ true,
43
+ );
44
+ };
45
+ } else {
46
+ this.fetch = async <T>(config: AxiosRequestConfig) => {
47
+ return await this.axiosInstance.request<T>(config);
48
+ };
49
+ }
31
50
  }
32
51
 
33
52
  public async read(pathOrUrl: string): Promise<Buffer> {
@@ -1,2 +1,3 @@
1
1
  export * from './interface.js';
2
2
  export * from './factory.js';
3
+ export { type HttpFileStoreOptions } from './http.js';
package/src/gas/README.md CHANGED
@@ -84,6 +84,37 @@ else → use post (new fees)
84
84
  **Net effect**: L1 fee changes reach L2 with a 2-slot delay and can update at most once
85
85
  every 5 slots.
86
86
 
87
+ ### Worked Example
88
+
89
+ Suppose the oracle is updated at slot 10 with new L1 fees. Here is the timeline:
90
+
91
+ ```
92
+ Slot Oracle state Active fees Notes
93
+ ──── ──────────────────── ──────────── ──────────────────────────────────
94
+ 10 pre=A, post=B, soc=12 A Update queued. slotOfChange = 10 + LAG = 12.
95
+ 11 (same) A Still before slotOfChange → pre (A).
96
+ 12 (same) B slot >= slotOfChange → post (B) activates.
97
+ 13 (same) B B remains active.
98
+ 14 (same) B B remains active.
99
+ 15 Update allowed again B Earliest next update: soc + (LIFETIME - LAG)
100
+ = 12 + 3 = 15.
101
+ ```
102
+
103
+ Key observations:
104
+
105
+ 1. **Slots 10-11**: The old fees (A) are still in effect. Transactions submitted during
106
+ these slots see the old L1 cost. This is the **LAG** window — it gives pending
107
+ transactions 2 slots to land before fees change.
108
+
109
+ 2. **Slot 12**: The new fees (B) activate. Any checkpoint proposed at slot >= 12 uses B
110
+ for its sequencer/prover cost calculation.
111
+
112
+ 3. **Slots 12-14**: No new oracle update is accepted. The system is in a **cooldown**
113
+ period of `LIFETIME - LAG = 3` slots after the transition.
114
+
115
+ 4. **Slot 15**: A new oracle update can be queued (earliest `acceptableSlot`). If
116
+ triggered, the new values would activate at slot 15 + LAG = 17.
117
+
87
118
  ## Fee Asset Price
88
119
 
89
120
  Fees are computed in ETH internally but converted to the fee asset (Fee Juice) via
@@ -0,0 +1,120 @@
1
+ /**
2
+ * TypeScript port of fee computation logic from FeeLib.sol.
3
+ * Used to predict worst-case min fees over a future window of L2 slots.
4
+ */
5
+
6
+ // Constants matching FeeLib.sol
7
+ export const MINIMUM_CONGESTION_MULTIPLIER = 1_000_000_000n;
8
+ export const L1_GAS_PER_CHECKPOINT_PROPOSED = 300_000n;
9
+ export const L1_GAS_PER_EPOCH_VERIFIED = 3_600_000n;
10
+ export const BLOBS_PER_CHECKPOINT = 3n;
11
+ export const BLOB_GAS_PER_BLOB = 2n ** 17n;
12
+ export const MAGIC_CONGESTION_VALUE_MULTIPLIER = 854_700_854n;
13
+ export const MAGIC_CONGESTION_VALUE_DIVISOR = 100_000_000n;
14
+ export const ETH_PER_FEE_ASSET_PRECISION = 1_000_000_000_000n;
15
+ export const MIN_ETH_PER_FEE_ASSET = 100n;
16
+
17
+ /** Number of L2 slots of lag before new oracle values activate. Defines the prediction window. */
18
+ export const FEE_ORACLE_LAG = 2;
19
+
20
+ /** Expected mana usage per checkpoint for fee prediction. */
21
+ export enum ManaUsageEstimate {
22
+ /** No usage — fees decrease as congestion drains. */
23
+ None = 'none',
24
+ /** Target usage — congestion stays roughly flat (steady state). */
25
+ Target = 'target',
26
+ /** Limit usage (2x target) — worst case, congestion grows maximally. */
27
+ Limit = 'limit',
28
+ }
29
+
30
+ /** Parameters for computing the mana min fee at a given point in time. */
31
+ export type ManaMinFeeParams = {
32
+ l1BaseFee: bigint;
33
+ l1BlobFee: bigint;
34
+ manaTarget: bigint;
35
+ epochDuration: bigint;
36
+ provingCostPerManaEth: bigint;
37
+ excessMana: bigint;
38
+ ethPerFeeAsset: bigint;
39
+ };
40
+
41
+ /**
42
+ * Taylor series approximation of `factor * e^(numerator/denominator)`.
43
+ * Direct port of FeeLib.sol fakeExponential (EIP-4844 style).
44
+ */
45
+ export function fakeExponential(factor: bigint, numerator: bigint, denominator: bigint): bigint {
46
+ let i = 1n;
47
+ let output = 0n;
48
+ let numeratorAccumulator = factor * denominator;
49
+ while (numeratorAccumulator > 0n) {
50
+ output += numeratorAccumulator;
51
+ numeratorAccumulator = (numeratorAccumulator * numerator) / (denominator * i);
52
+ i += 1n;
53
+ }
54
+ return output / denominator;
55
+ }
56
+
57
+ /** Computes excess mana for the next checkpoint, clamped to zero. */
58
+ export function computeExcessMana(prevExcessMana: bigint, prevManaUsed: bigint, manaTarget: bigint): bigint {
59
+ const sum = prevExcessMana + prevManaUsed;
60
+ return sum > manaTarget ? sum - manaTarget : 0n;
61
+ }
62
+
63
+ /** Computes the congestion multiplier from excess mana (1e9 = no congestion). */
64
+ export function computeCongestionMultiplier(excessMana: bigint, manaTarget: bigint): bigint {
65
+ const denominator = (manaTarget * MAGIC_CONGESTION_VALUE_MULTIPLIER) / MAGIC_CONGESTION_VALUE_DIVISOR;
66
+ const cappedNumerator = excessMana < denominator * 100n ? excessMana : denominator * 100n;
67
+ return fakeExponential(MINIMUM_CONGESTION_MULTIPLIER, cappedNumerator, denominator);
68
+ }
69
+
70
+ /** Ceiling division for positive bigints. */
71
+ function ceilDiv(a: bigint, b: bigint): bigint {
72
+ return (a + b - 1n) / b;
73
+ }
74
+
75
+ /** Converts an ETH value to fee asset value using ethPerFeeAsset (1e12 precision). */
76
+ function toFeeAsset(ethValue: bigint, ethPerFeeAsset: bigint): bigint {
77
+ if (ethPerFeeAsset === 0n) {
78
+ return 0n;
79
+ }
80
+ return ceilDiv(ethValue * ETH_PER_FEE_ASSET_PRECISION, ethPerFeeAsset);
81
+ }
82
+
83
+ /**
84
+ * Computes the full mana min fee (sequencer + prover + congestion) in fee asset terms.
85
+ * Mirrors FeeLib.getManaMinFeeComponentsAt + summedMinFee.
86
+ */
87
+ export function computeManaMinFee(params: ManaMinFeeParams): bigint {
88
+ const { l1BaseFee, l1BlobFee, manaTarget, epochDuration, provingCostPerManaEth, excessMana, ethPerFeeAsset } = params;
89
+
90
+ if (manaTarget === 0n) {
91
+ return 0n;
92
+ }
93
+
94
+ // Sequencer cost per mana (in ETH)
95
+ const ethUsed = L1_GAS_PER_CHECKPOINT_PROPOSED * l1BaseFee + BLOBS_PER_CHECKPOINT * BLOB_GAS_PER_BLOB * l1BlobFee;
96
+ const sequencerCostEth = ceilDiv(ethUsed, manaTarget);
97
+
98
+ // Prover cost per mana (in ETH): L1 verification gas + governance-set proving cost
99
+ const proverCostEth =
100
+ ceilDiv(ceilDiv(L1_GAS_PER_EPOCH_VERIFIED * l1BaseFee, epochDuration), manaTarget) + provingCostPerManaEth;
101
+
102
+ // Total base cost in ETH (congestion is computed on this)
103
+ const totalEth = sequencerCostEth + proverCostEth;
104
+
105
+ // Congestion multiplier and cost (in ETH)
106
+ const congestionMul = computeCongestionMultiplier(excessMana, manaTarget);
107
+ const congestionCostEth = (totalEth * congestionMul) / MINIMUM_CONGESTION_MULTIPLIER - totalEth;
108
+
109
+ // Convert all components to fee asset
110
+ const clampedEthPerFeeAsset = ethPerFeeAsset < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : ethPerFeeAsset;
111
+ const sequencerCost = toFeeAsset(sequencerCostEth, clampedEthPerFeeAsset);
112
+ const proverCost = toFeeAsset(proverCostEth, clampedEthPerFeeAsset);
113
+ const congestionCost = toFeeAsset(congestionCostEth, clampedEthPerFeeAsset);
114
+
115
+ const total = sequencerCost + proverCost + congestionCost;
116
+
117
+ // Cap at uint128 max (matching FeeLib.summedMinFee)
118
+ const UINT128_MAX = (1n << 128n) - 1n;
119
+ return total < UINT128_MAX ? total : UINT128_MAX;
120
+ }
@@ -15,6 +15,17 @@ import { z } from 'zod';
15
15
  import type { UInt128 } from '../types/shared.js';
16
16
  import type { GasDimensions } from './gas.js';
17
17
 
18
+ /**
19
+ * Multiplies a bigint by a non-integer scalar and returns the ceiling of the result.
20
+ * Avoids converting the bigint to Number (which loses precision above 2^53) by instead
21
+ * scaling the scalar into a bigint rational and performing ceiling division.
22
+ */
23
+ function bigintMulCeil(value: bigint, scalar: number): bigint {
24
+ const SCALE = 1_000_000_000_000n; // 1e12
25
+ const scaledScalar = BigInt(Math.round(scalar * 1e12));
26
+ return (value * scaledScalar + SCALE - 1n) / SCALE;
27
+ }
28
+
18
29
  /** Gas prices for each dimension. */
19
30
  export class GasFees {
20
31
  public readonly feePerDaGas: UInt128;
@@ -60,10 +71,7 @@ export class GasFees {
60
71
  const s = BigInt(scalar);
61
72
  return new GasFees(this.feePerDaGas * s, this.feePerL2Gas * s);
62
73
  } else {
63
- return new GasFees(
64
- BigInt(Math.ceil(Number(this.feePerDaGas) * scalar)),
65
- BigInt(Math.ceil(Number(this.feePerL2Gas) * scalar)),
66
- );
74
+ return new GasFees(bigintMulCeil(this.feePerDaGas, scalar), bigintMulCeil(this.feePerL2Gas, scalar));
67
75
  }
68
76
  }
69
77
 
@@ -126,3 +134,8 @@ export class GasFees {
126
134
  return `GasFees { feePerDaGas=${this.feePerDaGas} feePerL2Gas=${this.feePerL2Gas} }`;
127
135
  }
128
136
  }
137
+
138
+ /** Provides projected minimum gas fees for the next block. */
139
+ export interface BlockMinFeesProvider {
140
+ getCurrentMinFees(): Promise<GasFees>;
141
+ }
package/src/gas/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './fee_math.js';
1
2
  export * from './gas.js';
2
3
  export * from './gas_fees.js';
3
4
  export * from './gas_settings.js';
@@ -0,0 +1,159 @@
1
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
+ import {
3
+ type ConfigMappingsType,
4
+ SecretValue,
5
+ booleanConfigHelper,
6
+ getConfigFromMappings,
7
+ getDefaultConfig,
8
+ numberConfigHelper,
9
+ optionalNumberConfigHelper,
10
+ secretStringConfigHelper,
11
+ } from '@aztec/foundation/config';
12
+ import { EthAddress } from '@aztec/foundation/eth-address';
13
+ import type { ZodFor } from '@aztec/foundation/schemas';
14
+
15
+ import { z } from 'zod';
16
+
17
+ /**
18
+ * Base signing protection configuration shared by both HA (Postgres) and local (LMDB) signers.
19
+ */
20
+ export interface BaseSignerConfig {
21
+ /** L1 contract addresses (rollup address required) */
22
+ l1Contracts: Pick<L1ContractAddresses, 'rollupAddress'>;
23
+ /** Unique identifier for this node */
24
+ nodeId: string;
25
+ /** How long to wait between polls when a duty is being signed (ms) */
26
+ pollingIntervalMs: number;
27
+ /** Maximum time to wait for a duty being signed to complete (ms) */
28
+ signingTimeoutMs: number;
29
+ /** Maximum age of a stuck duty in ms (defaults to 2x hardcoded Aztec slot duration if not set) */
30
+ maxStuckDutiesAgeMs?: number;
31
+ /** Optional: clean up old duties after this many hours (disabled if not set) */
32
+ cleanupOldDutiesAfterHours?: number;
33
+ }
34
+
35
+ export const baseSignerConfigMappings: ConfigMappingsType<BaseSignerConfig> = {
36
+ l1Contracts: {
37
+ description: 'L1 contract addresses (rollup address required)',
38
+ nested: {
39
+ rollupAddress: {
40
+ description: 'The Ethereum address of the rollup contract (must be set programmatically)',
41
+ parseEnv: (val: string) => EthAddress.fromString(val),
42
+ },
43
+ },
44
+ },
45
+ nodeId: {
46
+ env: 'VALIDATOR_HA_NODE_ID',
47
+ description: 'The unique identifier for this node',
48
+ defaultValue: '',
49
+ },
50
+ pollingIntervalMs: {
51
+ env: 'VALIDATOR_HA_POLLING_INTERVAL_MS',
52
+ description: 'The number of ms to wait between polls when a duty is being signed',
53
+ ...numberConfigHelper(100),
54
+ },
55
+ signingTimeoutMs: {
56
+ env: 'VALIDATOR_HA_SIGNING_TIMEOUT_MS',
57
+ description: 'The maximum time to wait for a duty being signed to complete',
58
+ ...numberConfigHelper(3_000),
59
+ },
60
+ maxStuckDutiesAgeMs: {
61
+ env: 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS',
62
+ description: 'The maximum age of a stuck duty in ms (defaults to 2x Aztec slot duration)',
63
+ ...optionalNumberConfigHelper(),
64
+ },
65
+ cleanupOldDutiesAfterHours: {
66
+ env: 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H',
67
+ description: 'Optional: clean up old duties after this many hours (disabled if not set)',
68
+ ...optionalNumberConfigHelper(),
69
+ },
70
+ };
71
+
72
+ export const BaseSignerConfigSchema = z.object({
73
+ l1Contracts: z.object({ rollupAddress: z.instanceof(EthAddress) }),
74
+ nodeId: z.string(),
75
+ pollingIntervalMs: z.number().min(0),
76
+ signingTimeoutMs: z.number().min(0),
77
+ maxStuckDutiesAgeMs: z.number().min(0).optional(),
78
+ cleanupOldDutiesAfterHours: z.number().min(0).optional(),
79
+ }) satisfies ZodFor<BaseSignerConfig>;
80
+
81
+ /**
82
+ * Configuration for the Validator HA Signer.
83
+ *
84
+ * Extends BaseSignerConfig with a flag to enable HA mode and Postgres connection settings.
85
+ */
86
+ export interface ValidatorHASignerConfig extends BaseSignerConfig {
87
+ /** Whether HA signing / slashing protection is enabled */
88
+ haSigningEnabled: boolean;
89
+ /**
90
+ * PostgreSQL connection string
91
+ * Format: postgresql://user:password@host:port/database
92
+ */
93
+ databaseUrl?: SecretValue<string>;
94
+ /** Maximum number of clients in the pool (default: 10) */
95
+ poolMaxCount?: number;
96
+ /** Minimum number of clients in the pool (default: 0) */
97
+ poolMinCount?: number;
98
+ /** Idle timeout in milliseconds (default: 10000) */
99
+ poolIdleTimeoutMs?: number;
100
+ /** Connection timeout in milliseconds (default: 0, no timeout) */
101
+ poolConnectionTimeoutMs?: number;
102
+ }
103
+
104
+ export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASignerConfig> = {
105
+ ...baseSignerConfigMappings,
106
+ haSigningEnabled: {
107
+ env: 'VALIDATOR_HA_SIGNING_ENABLED',
108
+ description: 'Whether HA signing / slashing protection is enabled',
109
+ ...booleanConfigHelper(false),
110
+ },
111
+ databaseUrl: {
112
+ env: 'VALIDATOR_HA_DATABASE_URL',
113
+ description:
114
+ 'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)',
115
+ ...secretStringConfigHelper(),
116
+ },
117
+ poolMaxCount: {
118
+ env: 'VALIDATOR_HA_POOL_MAX',
119
+ description: 'Maximum number of clients in the pool',
120
+ ...numberConfigHelper(10),
121
+ },
122
+ poolMinCount: {
123
+ env: 'VALIDATOR_HA_POOL_MIN',
124
+ description: 'Minimum number of clients in the pool',
125
+ ...numberConfigHelper(0),
126
+ },
127
+ poolIdleTimeoutMs: {
128
+ env: 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS',
129
+ description: 'Idle timeout in milliseconds',
130
+ ...numberConfigHelper(10_000),
131
+ },
132
+ poolConnectionTimeoutMs: {
133
+ env: 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS',
134
+ description: 'Connection timeout in milliseconds (0 means no timeout)',
135
+ ...numberConfigHelper(0),
136
+ },
137
+ };
138
+
139
+ export const defaultValidatorHASignerConfig: ValidatorHASignerConfig = getDefaultConfig(
140
+ validatorHASignerConfigMappings,
141
+ );
142
+
143
+ /**
144
+ * Returns the validator HA signer configuration from environment variables.
145
+ * Note: If an environment variable is not set, the default value is used.
146
+ * @returns The validator HA signer configuration.
147
+ */
148
+ export function getConfigEnvVars(): ValidatorHASignerConfig {
149
+ return getConfigFromMappings<ValidatorHASignerConfig>(validatorHASignerConfigMappings);
150
+ }
151
+
152
+ export const ValidatorHASignerConfigSchema = BaseSignerConfigSchema.extend({
153
+ haSigningEnabled: z.boolean(),
154
+ databaseUrl: SecretValue.schema(z.string()).optional(),
155
+ poolMaxCount: z.number().min(0).optional(),
156
+ poolMinCount: z.number().min(0).optional(),
157
+ poolIdleTimeoutMs: z.number().min(0).optional(),
158
+ poolConnectionTimeoutMs: z.number().min(0).optional(),
159
+ }) satisfies ZodFor<ValidatorHASignerConfig>;
@@ -0,0 +1,29 @@
1
+ export {
2
+ type BaseSignerConfig,
3
+ BaseSignerConfigSchema,
4
+ baseSignerConfigMappings,
5
+ type ValidatorHASignerConfig,
6
+ ValidatorHASignerConfigSchema,
7
+ defaultValidatorHASignerConfig,
8
+ getConfigEnvVars,
9
+ validatorHASignerConfigMappings,
10
+ } from './config.js';
11
+ export {
12
+ type LocalSignerConfig,
13
+ LocalSignerConfigSchema,
14
+ getLocalSignerConfigEnvVars,
15
+ localSignerConfigMappings,
16
+ } from './local_config.js';
17
+ export {
18
+ DutyType,
19
+ type AttestationSigningContext,
20
+ type BlockProposalSigningContext,
21
+ type CheckpointProposalSigningContext,
22
+ type HAProtectedSigningContext,
23
+ type NoHAProtectionSigningContext,
24
+ type SigningContext,
25
+ type VoteSigningContext,
26
+ getBlockNumberFromSigningContext,
27
+ getCheckpointNumberFromSigningContext,
28
+ isHAProtectedContext,
29
+ } from './types.js';
@@ -0,0 +1,46 @@
1
+ import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
2
+ import { zodFor } from '@aztec/foundation/schemas';
3
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
4
+
5
+ import { z } from 'zod';
6
+
7
+ import { type BaseSignerConfig, BaseSignerConfigSchema, baseSignerConfigMappings } from './config.js';
8
+
9
+ /**
10
+ * Configuration for local (single-node) slashing protection.
11
+ *
12
+ * Combines the base signing protection fields (shared with HA mode) with
13
+ * DataStoreConfig for the local LMDB backing store, plus a per-store map-size
14
+ * override. Used when HA signing is disabled.
15
+ */
16
+ export type LocalSignerConfig = BaseSignerConfig &
17
+ DataStoreConfig & {
18
+ /** Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb. */
19
+ signingProtectionMapSizeKb?: number;
20
+ };
21
+
22
+ export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> = {
23
+ ...baseSignerConfigMappings,
24
+ ...dataConfigMappings,
25
+ signingProtectionMapSizeKb: {
26
+ env: 'SIGNING_PROTECTION_MAP_SIZE_KB',
27
+ description:
28
+ 'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
29
+ parseEnv: (val: string) => +val,
30
+ },
31
+ };
32
+
33
+ export const LocalSignerConfigSchema = zodFor<LocalSignerConfig>()(
34
+ BaseSignerConfigSchema.extend({
35
+ dataDirectory: z.string().optional(),
36
+ dataStoreMapSizeKb: z.number(),
37
+ signingProtectionMapSizeKb: z.number().optional(),
38
+ }),
39
+ );
40
+
41
+ /**
42
+ * Returns the local signer configuration from environment variables.
43
+ */
44
+ export function getLocalSignerConfigEnvVars(): LocalSignerConfig {
45
+ return getConfigFromMappings<LocalSignerConfig>(localSignerConfigMappings);
46
+ }