@aztec/stdlib 0.0.1-commit.f504929 → 0.0.1-commit.f650c0a5c

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 +138 -1
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +10 -2
  4. package/dest/abi/buffer.d.ts +14 -4
  5. package/dest/abi/buffer.d.ts.map +1 -1
  6. package/dest/abi/buffer.js +25 -4
  7. package/dest/abi/decoder.d.ts +5 -44
  8. package/dest/abi/decoder.d.ts.map +1 -1
  9. package/dest/abi/decoder.js +12 -67
  10. package/dest/abi/function_selector.js +1 -1
  11. package/dest/abi/function_signature_decoder.d.ts +43 -0
  12. package/dest/abi/function_signature_decoder.d.ts.map +1 -0
  13. package/dest/abi/function_signature_decoder.js +66 -0
  14. package/dest/abi/index.d.ts +2 -1
  15. package/dest/abi/index.d.ts.map +1 -1
  16. package/dest/abi/index.js +1 -0
  17. package/dest/abi/selector.d.ts +2 -2
  18. package/dest/abi/selector.d.ts.map +1 -1
  19. package/dest/abi/selector.js +1 -1
  20. package/dest/avm/avm.d.ts +300 -300
  21. package/dest/avm/revert_code.d.ts +8 -18
  22. package/dest/avm/revert_code.d.ts.map +1 -1
  23. package/dest/avm/revert_code.js +15 -30
  24. package/dest/block/l2_block.d.ts +9 -1
  25. package/dest/block/l2_block.d.ts.map +1 -1
  26. package/dest/block/l2_block.js +12 -2
  27. package/dest/block/l2_block_source.d.ts +95 -10
  28. package/dest/block/l2_block_source.d.ts.map +1 -1
  29. package/dest/block/l2_block_source.js +1 -0
  30. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  31. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  32. package/dest/block/l2_block_stream/l2_tips_store_base.js +17 -4
  33. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  34. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  35. package/dest/block/test/l2_tips_store_test_suite.js +3 -2
  36. package/dest/checkpoint/checkpoint.d.ts +8 -1
  37. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  38. package/dest/checkpoint/checkpoint.js +18 -5
  39. package/dest/checkpoint/checkpoint_data.d.ts +71 -5
  40. package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
  41. package/dest/checkpoint/checkpoint_data.js +10 -0
  42. package/dest/checkpoint/index.d.ts +2 -1
  43. package/dest/checkpoint/index.d.ts.map +1 -1
  44. package/dest/checkpoint/index.js +1 -0
  45. package/dest/checkpoint/validate.d.ts +36 -0
  46. package/dest/checkpoint/validate.d.ts.map +1 -0
  47. package/dest/checkpoint/validate.js +120 -0
  48. package/dest/config/index.d.ts +2 -1
  49. package/dest/config/index.d.ts.map +1 -1
  50. package/dest/config/index.js +1 -0
  51. package/dest/config/pipelining-config.d.ts +19 -0
  52. package/dest/config/pipelining-config.d.ts.map +1 -0
  53. package/dest/config/pipelining-config.js +18 -0
  54. package/dest/config/sequencer-config.d.ts +2 -2
  55. package/dest/config/sequencer-config.d.ts.map +1 -1
  56. package/dest/config/sequencer-config.js +1 -2
  57. package/dest/contract/contract_address.d.ts +3 -3
  58. package/dest/contract/contract_address.js +3 -3
  59. package/dest/contract/contract_class_id.d.ts +2 -2
  60. package/dest/contract/contract_class_id.js +2 -2
  61. package/dest/contract/index.d.ts +1 -3
  62. package/dest/contract/index.d.ts.map +1 -1
  63. package/dest/contract/index.js +0 -2
  64. package/dest/contract/interfaces/contract_class.d.ts +3 -156
  65. package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
  66. package/dest/contract/interfaces/contract_class.js +1 -28
  67. package/dest/epoch-helpers/index.d.ts +11 -1
  68. package/dest/epoch-helpers/index.d.ts.map +1 -1
  69. package/dest/epoch-helpers/index.js +16 -2
  70. package/dest/file-store/factory.d.ts +4 -3
  71. package/dest/file-store/factory.d.ts.map +1 -1
  72. package/dest/file-store/factory.js +2 -2
  73. package/dest/file-store/http.d.ts +9 -2
  74. package/dest/file-store/http.d.ts.map +1 -1
  75. package/dest/file-store/http.js +20 -9
  76. package/dest/file-store/index.d.ts +2 -1
  77. package/dest/file-store/index.d.ts.map +1 -1
  78. package/dest/gas/gas_settings.d.ts +40 -3
  79. package/dest/gas/gas_settings.d.ts.map +1 -1
  80. package/dest/gas/gas_settings.js +50 -6
  81. package/dest/ha-signing/config.d.ts +49 -14
  82. package/dest/ha-signing/config.d.ts.map +1 -1
  83. package/dest/ha-signing/config.js +20 -15
  84. package/dest/ha-signing/index.d.ts +3 -2
  85. package/dest/ha-signing/index.d.ts.map +1 -1
  86. package/dest/ha-signing/index.js +2 -1
  87. package/dest/ha-signing/local_config.d.ts +63 -0
  88. package/dest/ha-signing/local_config.d.ts.map +1 -0
  89. package/dest/ha-signing/local_config.js +24 -0
  90. package/dest/hash/hash.d.ts +19 -1
  91. package/dest/hash/hash.d.ts.map +1 -1
  92. package/dest/hash/hash.js +29 -0
  93. package/dest/interfaces/allowed_element.d.ts +25 -1
  94. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  95. package/dest/interfaces/allowed_element.js +8 -2
  96. package/dest/interfaces/archiver.d.ts +1 -1
  97. package/dest/interfaces/archiver.d.ts.map +1 -1
  98. package/dest/interfaces/archiver.js +6 -3
  99. package/dest/interfaces/aztec-node-admin.d.ts +73 -23
  100. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  101. package/dest/interfaces/aztec-node-admin.js +3 -3
  102. package/dest/interfaces/aztec-node.d.ts +12 -6
  103. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  104. package/dest/interfaces/aztec-node.js +5 -2
  105. package/dest/interfaces/block-builder.d.ts +38 -11
  106. package/dest/interfaces/block-builder.d.ts.map +1 -1
  107. package/dest/interfaces/block-builder.js +12 -5
  108. package/dest/interfaces/configs.d.ts +47 -7
  109. package/dest/interfaces/configs.d.ts.map +1 -1
  110. package/dest/interfaces/configs.js +3 -1
  111. package/dest/interfaces/l2_logs_source.d.ts +5 -3
  112. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  113. package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
  114. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  115. package/dest/interfaces/prover-client.d.ts +6 -1
  116. package/dest/interfaces/prover-client.d.ts.map +1 -1
  117. package/dest/interfaces/prover-client.js +7 -1
  118. package/dest/interfaces/proving-job.d.ts +34 -34
  119. package/dest/interfaces/slasher.d.ts +1 -10
  120. package/dest/interfaces/slasher.d.ts.map +1 -1
  121. package/dest/interfaces/slasher.js +0 -2
  122. package/dest/interfaces/validator.d.ts +103 -35
  123. package/dest/interfaces/validator.d.ts.map +1 -1
  124. package/dest/interfaces/validator.js +7 -5
  125. package/dest/interfaces/world_state.d.ts +5 -4
  126. package/dest/interfaces/world_state.d.ts.map +1 -1
  127. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
  128. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
  129. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
  130. package/dest/kv-store/config.d.ts +17 -0
  131. package/dest/kv-store/config.d.ts.map +1 -0
  132. package/dest/kv-store/config.js +26 -0
  133. package/dest/kv-store/index.d.ts +2 -0
  134. package/dest/kv-store/index.d.ts.map +1 -0
  135. package/dest/kv-store/index.js +1 -0
  136. package/dest/l1-contracts/index.d.ts +2 -2
  137. package/dest/l1-contracts/index.d.ts.map +1 -1
  138. package/dest/l1-contracts/index.js +1 -1
  139. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  140. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  141. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  142. package/dest/logs/index.d.ts +2 -1
  143. package/dest/logs/index.d.ts.map +1 -1
  144. package/dest/logs/index.js +1 -0
  145. package/dest/logs/log_filter.d.ts +4 -1
  146. package/dest/logs/log_filter.d.ts.map +1 -1
  147. package/dest/logs/log_filter.js +2 -1
  148. package/dest/logs/message_context.d.ts +4 -7
  149. package/dest/logs/message_context.d.ts.map +1 -1
  150. package/dest/logs/message_context.js +23 -9
  151. package/dest/logs/pending_tagged_log.d.ts +2 -3
  152. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  153. package/dest/logs/pending_tagged_log.js +2 -2
  154. package/dest/logs/shared_secret_derivation.d.ts +11 -10
  155. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  156. package/dest/logs/shared_secret_derivation.js +15 -9
  157. package/dest/logs/siloed_tag.d.ts +4 -1
  158. package/dest/logs/siloed_tag.d.ts.map +1 -1
  159. package/dest/logs/siloed_tag.js +7 -3
  160. package/dest/logs/tagging_index_range.d.ts +40 -0
  161. package/dest/logs/tagging_index_range.d.ts.map +1 -0
  162. package/dest/logs/tagging_index_range.js +8 -0
  163. package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
  164. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  165. package/dest/logs/tx_scoped_l2_log.js +7 -0
  166. package/dest/messaging/l1_to_l2_message.d.ts +3 -2
  167. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  168. package/dest/messaging/l1_to_l2_message.js +11 -13
  169. package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
  170. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  171. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  172. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  173. package/dest/messaging/l2_to_l1_membership.js +69 -26
  174. package/dest/noir/index.d.ts +3 -3
  175. package/dest/noir/index.d.ts.map +1 -1
  176. package/dest/note/note_dao.d.ts +1 -1
  177. package/dest/note/note_dao.d.ts.map +1 -1
  178. package/dest/note/note_dao.js +1 -4
  179. package/dest/p2p/checkpoint_proposal.d.ts +2 -7
  180. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  181. package/dest/p2p/checkpoint_proposal.js +3 -25
  182. package/dest/p2p/peer_error.d.ts +3 -1
  183. package/dest/p2p/peer_error.d.ts.map +1 -1
  184. package/dest/p2p/peer_error.js +5 -0
  185. package/dest/proofs/chonk_proof.d.ts +46 -2
  186. package/dest/proofs/chonk_proof.d.ts.map +1 -1
  187. package/dest/proofs/chonk_proof.js +85 -10
  188. package/dest/slashing/index.d.ts +2 -3
  189. package/dest/slashing/index.d.ts.map +1 -1
  190. package/dest/slashing/index.js +1 -2
  191. package/dest/slashing/serialization.d.ts +2 -6
  192. package/dest/slashing/serialization.d.ts.map +1 -1
  193. package/dest/slashing/serialization.js +0 -60
  194. package/dest/slashing/types.d.ts +4 -90
  195. package/dest/slashing/types.d.ts.map +1 -1
  196. package/dest/slashing/types.js +0 -14
  197. package/dest/slashing/{tally.d.ts → votes.d.ts} +5 -6
  198. package/dest/slashing/votes.d.ts.map +1 -0
  199. package/dest/slashing/{tally.js → votes.js} +19 -10
  200. package/dest/tests/factories.d.ts +2 -4
  201. package/dest/tests/factories.d.ts.map +1 -1
  202. package/dest/tests/factories.js +11 -28
  203. package/dest/tests/mocks.d.ts +4 -2
  204. package/dest/tests/mocks.d.ts.map +1 -1
  205. package/dest/tests/mocks.js +26 -26
  206. package/dest/timetable/index.d.ts +2 -1
  207. package/dest/timetable/index.d.ts.map +1 -1
  208. package/dest/timetable/index.js +6 -2
  209. package/dest/tx/block_header.d.ts +3 -1
  210. package/dest/tx/block_header.d.ts.map +1 -1
  211. package/dest/tx/block_header.js +4 -0
  212. package/dest/tx/capsule.d.ts +6 -2
  213. package/dest/tx/capsule.d.ts.map +1 -1
  214. package/dest/tx/capsule.js +9 -3
  215. package/dest/tx/global_variable_builder.d.ts +14 -2
  216. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  217. package/dest/tx/private_execution_result.d.ts +6 -6
  218. package/dest/tx/private_execution_result.d.ts.map +1 -1
  219. package/dest/tx/private_execution_result.js +6 -6
  220. package/dest/tx/profiling.d.ts +14 -2
  221. package/dest/tx/profiling.d.ts.map +1 -1
  222. package/dest/tx/profiling.js +13 -3
  223. package/dest/tx/simulated_tx.d.ts +111 -3
  224. package/dest/tx/simulated_tx.d.ts.map +1 -1
  225. package/dest/tx/simulated_tx.js +2 -2
  226. package/dest/tx/tx.d.ts +6 -5
  227. package/dest/tx/tx.d.ts.map +1 -1
  228. package/dest/tx/tx.js +18 -6
  229. package/dest/tx/tx_receipt.d.ts +14 -5
  230. package/dest/tx/tx_receipt.d.ts.map +1 -1
  231. package/dest/tx/tx_receipt.js +14 -18
  232. package/dest/tx/validator/error_texts.d.ts +8 -1
  233. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  234. package/dest/tx/validator/error_texts.js +9 -0
  235. package/dest/update-checker/index.d.ts +3 -2
  236. package/dest/update-checker/index.d.ts.map +1 -1
  237. package/dest/update-checker/index.js +2 -1
  238. package/dest/update-checker/package_version.d.ts +3 -0
  239. package/dest/update-checker/package_version.d.ts.map +1 -0
  240. package/dest/update-checker/package_version.js +24 -0
  241. package/dest/update-checker/version_checker.d.ts +25 -0
  242. package/dest/update-checker/version_checker.d.ts.map +1 -0
  243. package/dest/update-checker/version_checker.js +50 -0
  244. package/dest/validators/errors.d.ts +6 -1
  245. package/dest/validators/errors.d.ts.map +1 -1
  246. package/dest/validators/errors.js +7 -0
  247. package/dest/versioning/versioning.d.ts +4 -2
  248. package/dest/versioning/versioning.d.ts.map +1 -1
  249. package/dest/versioning/versioning.js +4 -1
  250. package/dest/world-state/genesis_data.d.ts +11 -0
  251. package/dest/world-state/genesis_data.d.ts.map +1 -0
  252. package/dest/world-state/genesis_data.js +4 -0
  253. package/dest/world-state/index.d.ts +2 -1
  254. package/dest/world-state/index.d.ts.map +1 -1
  255. package/dest/world-state/index.js +1 -0
  256. package/package.json +10 -9
  257. package/src/abi/abi.ts +25 -2
  258. package/src/abi/buffer.ts +25 -4
  259. package/src/abi/decoder.ts +23 -78
  260. package/src/abi/function_selector.ts +1 -1
  261. package/src/abi/function_signature_decoder.ts +77 -0
  262. package/src/abi/index.ts +1 -0
  263. package/src/abi/selector.ts +1 -1
  264. package/src/avm/revert_code.ts +25 -39
  265. package/src/block/l2_block.ts +13 -1
  266. package/src/block/l2_block_source.ts +26 -9
  267. package/src/block/l2_block_stream/l2_tips_store_base.ts +24 -12
  268. package/src/block/test/l2_tips_store_test_suite.ts +8 -1
  269. package/src/checkpoint/checkpoint.ts +23 -4
  270. package/src/checkpoint/checkpoint_data.ts +40 -4
  271. package/src/checkpoint/index.ts +1 -0
  272. package/src/checkpoint/validate.ts +230 -0
  273. package/src/config/index.ts +1 -0
  274. package/src/config/pipelining-config.ts +31 -0
  275. package/src/config/sequencer-config.ts +2 -2
  276. package/src/contract/contract_address.ts +3 -3
  277. package/src/contract/contract_class_id.ts +2 -2
  278. package/src/contract/index.ts +0 -2
  279. package/src/contract/interfaces/contract_class.ts +2 -82
  280. package/src/epoch-helpers/index.ts +27 -0
  281. package/src/file-store/factory.ts +13 -4
  282. package/src/file-store/http.ts +29 -10
  283. package/src/file-store/index.ts +1 -0
  284. package/src/gas/README.md +123 -0
  285. package/src/gas/gas_settings.ts +65 -12
  286. package/src/ha-signing/config.ts +45 -38
  287. package/src/ha-signing/index.ts +9 -0
  288. package/src/ha-signing/local_config.ts +46 -0
  289. package/src/hash/hash.ts +34 -0
  290. package/src/interfaces/allowed_element.ts +28 -4
  291. package/src/interfaces/archiver.ts +6 -3
  292. package/src/interfaces/aztec-node-admin.ts +5 -7
  293. package/src/interfaces/aztec-node.ts +24 -5
  294. package/src/interfaces/block-builder.ts +56 -13
  295. package/src/interfaces/configs.ts +15 -4
  296. package/src/interfaces/l2_logs_source.ts +4 -1
  297. package/src/interfaces/merkle_tree_operations.ts +8 -18
  298. package/src/interfaces/prover-client.ts +8 -0
  299. package/src/interfaces/slasher.ts +0 -6
  300. package/src/interfaces/validator.ts +47 -33
  301. package/src/interfaces/world_state.ts +4 -3
  302. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
  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/extended_directional_app_tagging_secret.ts +19 -8
  307. package/src/logs/index.ts +1 -0
  308. package/src/logs/log_filter.ts +5 -0
  309. package/src/logs/message_context.ts +17 -7
  310. package/src/logs/pending_tagged_log.ts +1 -3
  311. package/src/logs/shared_secret_derivation.ts +21 -10
  312. package/src/logs/siloed_tag.ts +7 -2
  313. package/src/logs/tagging_index_range.ts +24 -0
  314. package/src/logs/tx_scoped_l2_log.ts +16 -0
  315. package/src/messaging/l1_to_l2_message.ts +12 -9
  316. package/src/messaging/l1_to_l2_message_source.ts +3 -1
  317. package/src/messaging/l2_to_l1_membership.ts +98 -33
  318. package/src/noir/index.ts +2 -2
  319. package/src/note/note_dao.ts +1 -4
  320. package/src/p2p/checkpoint_proposal.ts +8 -38
  321. package/src/p2p/peer_error.ts +7 -0
  322. package/src/proofs/chonk_proof.ts +91 -5
  323. package/src/slashing/index.ts +1 -2
  324. package/src/slashing/serialization.ts +1 -81
  325. package/src/slashing/types.ts +3 -35
  326. package/src/slashing/{tally.ts → votes.ts} +22 -4
  327. package/src/tests/factories.ts +5 -34
  328. package/src/tests/mocks.ts +31 -18
  329. package/src/timetable/index.ts +7 -2
  330. package/src/tx/block_header.ts +6 -0
  331. package/src/tx/capsule.ts +10 -2
  332. package/src/tx/global_variable_builder.ts +15 -0
  333. package/src/tx/private_execution_result.ts +5 -5
  334. package/src/tx/profiling.ts +11 -2
  335. package/src/tx/simulated_tx.ts +5 -1
  336. package/src/tx/tx.ts +20 -11
  337. package/src/tx/tx_receipt.ts +18 -16
  338. package/src/tx/validator/error_texts.ts +11 -0
  339. package/src/update-checker/index.ts +2 -1
  340. package/src/update-checker/package_version.ts +30 -0
  341. package/src/update-checker/version_checker.ts +65 -0
  342. package/src/validators/errors.ts +9 -0
  343. package/src/versioning/versioning.ts +4 -1
  344. package/src/world-state/genesis_data.ts +15 -0
  345. package/src/world-state/index.ts +1 -0
  346. package/dest/contract/private_function_membership_proof.d.ts +0 -32
  347. package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
  348. package/dest/contract/private_function_membership_proof.js +0 -124
  349. package/dest/contract/utility_function_membership_proof.d.ts +0 -27
  350. package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
  351. package/dest/contract/utility_function_membership_proof.js +0 -87
  352. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  353. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  354. package/dest/l1-contracts/slash_factory.js +0 -158
  355. package/dest/slashing/empire.d.ts +0 -31
  356. package/dest/slashing/empire.d.ts.map +0 -1
  357. package/dest/slashing/empire.js +0 -87
  358. package/dest/slashing/tally.d.ts.map +0 -1
  359. package/dest/update-checker/update-checker.d.ts +0 -49
  360. package/dest/update-checker/update-checker.d.ts.map +0 -1
  361. package/dest/update-checker/update-checker.js +0 -130
  362. package/src/contract/private_function_membership_proof.ts +0 -167
  363. package/src/contract/utility_function_membership_proof.ts +0 -118
  364. package/src/l1-contracts/slash_factory.ts +0 -180
  365. package/src/slashing/empire.ts +0 -104
  366. package/src/update-checker/update-checker.ts +0 -166
@@ -11,7 +11,7 @@ import { PrivateCircuitPublicInputs } from '../kernel/private_circuit_public_inp
11
11
  import type { IsEmpty } from '../kernel/utils/interfaces.js';
12
12
  import { sortByCounter } from '../kernel/utils/order_and_comparison.js';
13
13
  import { ContractClassLog, ContractClassLogFields } from '../logs/contract_class_log.js';
14
- import { type PreTag, PreTagSchema } from '../logs/pre_tag.js';
14
+ import { type TaggingIndexRange, TaggingIndexRangeSchema } from '../logs/tagging_index_range.js';
15
15
  import { Note } from '../note/note.js';
16
16
  import { type ZodFor, mapSchema, schemas } from '../schemas/index.js';
17
17
  import { HashedValues } from './hashed_values.js';
@@ -137,8 +137,8 @@ export class PrivateCallExecutionResult {
137
137
  public returnValues: Fr[],
138
138
  /** The offchain effects emitted during execution of this function call via the `emit_offchain_effect` oracle. */
139
139
  public offchainEffects: { data: Fr[] }[],
140
- /** The pre-tags used in this tx to compute tags for private logs */
141
- public preTags: PreTag[],
140
+ /** The tagging index ranges used in this tx to compute tags for private logs */
141
+ public taggingIndexRanges: TaggingIndexRange[],
142
142
  /** The nested executions. */
143
143
  public nestedExecutionResults: PrivateCallExecutionResult[],
144
144
  /**
@@ -161,7 +161,7 @@ export class PrivateCallExecutionResult {
161
161
  noteHashNullifierCounterMap: mapSchema(z.coerce.number(), z.number()),
162
162
  returnValues: z.array(schemas.Fr),
163
163
  offchainEffects: z.array(z.object({ data: z.array(schemas.Fr) })),
164
- preTags: z.array(PreTagSchema),
164
+ taggingIndexRanges: z.array(TaggingIndexRangeSchema),
165
165
  nestedExecutionResults: z.array(z.lazy(() => PrivateCallExecutionResult.schema)),
166
166
  contractClassLogs: z.array(CountedContractClassLog.schema),
167
167
  })
@@ -178,7 +178,7 @@ export class PrivateCallExecutionResult {
178
178
  fields.noteHashNullifierCounterMap,
179
179
  fields.returnValues,
180
180
  fields.offchainEffects,
181
- fields.preTags,
181
+ fields.taggingIndexRanges,
182
182
  fields.nestedExecutionResults,
183
183
  fields.contractClassLogs,
184
184
  );
@@ -3,6 +3,7 @@ import { type ZodFor, optional, schemas } from '@aztec/foundation/schemas';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
+ import { AztecAddress } from '../aztec-address/index.js';
6
7
  import type { AztecNode } from '../interfaces/aztec-node.js';
7
8
  import { type PrivateExecutionStep, PrivateExecutionStepSchema } from '../kernel/private_kernel_prover_output.js';
8
9
 
@@ -160,6 +161,9 @@ export class TxProfileResult {
160
161
  export class UtilityExecutionResult {
161
162
  constructor(
162
163
  public result: Fr[],
164
+ public offchainEffects: { data: Fr[]; contractAddress: AztecAddress }[],
165
+ /** Timestamp of the anchor block used during utility execution. */
166
+ public anchorBlockTimestamp: bigint,
163
167
  public stats?: SimulationStats,
164
168
  ) {}
165
169
 
@@ -167,13 +171,18 @@ export class UtilityExecutionResult {
167
171
  return z
168
172
  .object({
169
173
  result: z.array(schemas.Fr),
174
+ offchainEffects: z.array(z.object({ data: z.array(schemas.Fr), contractAddress: AztecAddress.schema })),
175
+ anchorBlockTimestamp: schemas.BigInt,
170
176
  stats: optional(SimulationStatsSchema),
171
177
  })
172
- .transform(({ result, stats }) => new UtilityExecutionResult(result, stats));
178
+ .transform(
179
+ ({ result, offchainEffects, anchorBlockTimestamp, stats }) =>
180
+ new UtilityExecutionResult(result, offchainEffects, anchorBlockTimestamp, stats),
181
+ );
173
182
  }
174
183
 
175
184
  static random(): UtilityExecutionResult {
176
- return new UtilityExecutionResult([Fr.random()], {
185
+ return new UtilityExecutionResult([Fr.random()], [], 0n, {
177
186
  nodeRPCCalls: {
178
187
  perMethod: { getBlockHeader: { times: [1] } },
179
188
  roundTrips: {
@@ -38,7 +38,11 @@ export type ContractOverrides = Record<
38
38
  * set, it *must* be run without the kernel circuits, or validations will fail
39
39
  */
40
40
  export class SimulationOverrides {
41
- constructor(public contracts?: ContractOverrides) {}
41
+ public contracts?: ContractOverrides;
42
+
43
+ constructor(contracts: ContractOverrides = {}) {
44
+ this.contracts = Object.keys(contracts).length > 0 ? contracts : undefined;
45
+ }
42
46
 
43
47
  static get schema() {
44
48
  return z
package/src/tx/tx.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { DA_GAS_PER_FIELD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
1
2
  import { Buffer32 } from '@aztec/foundation/buffer';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import type { ZodFor } from '@aztec/foundation/schemas';
4
5
  import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
5
- import type { FieldsOf } from '@aztec/foundation/types';
6
+ import { type FieldsOf, unfreeze } from '@aztec/foundation/types';
6
7
 
7
8
  import { z } from 'zod';
8
9
 
@@ -264,16 +265,24 @@ export class Tx extends Gossipable {
264
265
  }
265
266
 
266
267
  /**
267
- * Estimates the tx size based on its private effects. Note that the actual size of the tx
268
- * after processing will probably be larger, as public execution would generate more data.
268
+ * Returns the number of fields this tx's effects will occupy in the blob,
269
+ * based on its private side effects only. Accurate for txs without public calls.
270
+ * For txs with public calls, the actual size will be larger due to public execution outputs.
269
271
  */
270
- getEstimatedPrivateTxEffectsSize() {
271
- return (
272
- this.data.getNonEmptyNoteHashes().length * Fr.SIZE_IN_BYTES +
273
- this.data.getNonEmptyNullifiers().length * Fr.SIZE_IN_BYTES +
274
- this.data.getEmittedPrivateLogsLength() * Fr.SIZE_IN_BYTES +
275
- this.data.getEmittedContractClassLogsLength() * Fr.SIZE_IN_BYTES
276
- );
272
+ getPrivateTxEffectsSizeInFields(): number {
273
+ // 3 fields overhead: tx_start_marker, tx_hash, tx_fee.
274
+ // TX_DA_GAS_OVERHEAD is defined as N * DA_GAS_PER_FIELD, so this division is always exact.
275
+ const overheadFields = TX_DA_GAS_OVERHEAD / DA_GAS_PER_FIELD;
276
+ const noteHashes = this.data.getNonEmptyNoteHashes().length;
277
+ const nullifiers = this.data.getNonEmptyNullifiers().length;
278
+ const l2ToL1Msgs = this.data.getNonEmptyL2ToL1Msgs().length;
279
+ // Each private log occupies (emittedLength + 1) fields: content + length field
280
+ const privateLogFields = this.data.getNonEmptyPrivateLogs().reduce((acc, log) => acc + log.emittedLength + 1, 0);
281
+ // Each contract class log occupies (length + 1) fields: content + contract address
282
+ const contractClassLogFields = this.data
283
+ .getNonEmptyContractClassLogsHashes()
284
+ .reduce((acc, log) => acc + log.logHash.length + 1, 0);
285
+ return overheadFields + noteHashes + nullifiers + l2ToL1Msgs + privateLogFields + contractClassLogFields;
277
286
  }
278
287
 
279
288
  /**
@@ -309,7 +318,7 @@ export class Tx extends Gossipable {
309
318
 
310
319
  /** Recomputes the tx hash. Used for testing purposes only when a property of the tx was mutated. */
311
320
  public async recomputeHash(): Promise<TxHash> {
312
- (this as any).txHash = await Tx.computeTxHash(this);
321
+ unfreeze(this).txHash = await Tx.computeTxHash(this);
313
322
  return this.txHash;
314
323
  }
315
324
 
@@ -1,4 +1,4 @@
1
- import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
1
+ import { BlockNumber, BlockNumberSchema, EpochNumber, EpochNumberSchema } from '@aztec/foundation/branded-types';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
@@ -15,7 +15,7 @@ export enum TxStatus {
15
15
  PROPOSED = 'proposed',
16
16
  CHECKPOINTED = 'checkpointed',
17
17
  PROVEN = 'proven',
18
- FINALIZED = 'finalized', // TODO(#13569): Implement finalized status properly
18
+ FINALIZED = 'finalized',
19
19
  }
20
20
 
21
21
  /** Tx status sorted by finalization progress. */
@@ -31,9 +31,16 @@ export const SortedTxStatuses: TxStatus[] = [
31
31
  /** Execution result - only set when tx is in a block. */
32
32
  export enum TxExecutionResult {
33
33
  SUCCESS = 'success',
34
- APP_LOGIC_REVERTED = 'app_logic_reverted',
35
- TEARDOWN_REVERTED = 'teardown_reverted',
36
- BOTH_REVERTED = 'both_reverted',
34
+ REVERTED = 'reverted',
35
+ /** @deprecated Use REVERTED instead. */
36
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
37
+ APP_LOGIC_REVERTED = 'reverted',
38
+ /** @deprecated Use REVERTED instead. */
39
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
40
+ TEARDOWN_REVERTED = 'reverted',
41
+ /** @deprecated Use REVERTED instead. */
42
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
43
+ BOTH_REVERTED = 'reverted',
37
44
  }
38
45
 
39
46
  /**
@@ -58,6 +65,8 @@ export class TxReceipt {
58
65
  public blockHash?: BlockHash,
59
66
  /** The block number in which the transaction was included. */
60
67
  public blockNumber?: BlockNumber,
68
+ /** The epoch number in which the transaction was included. */
69
+ public epochNumber?: EpochNumber,
61
70
  /**
62
71
  * Debug logs collected during public function execution. Served only when the node is in test mode and placed on
63
72
  * the receipt only because it's a convenient place for it (the logs are printed out by the wallet when a mined
@@ -109,6 +118,7 @@ export class TxReceipt {
109
118
  error: z.string().optional(),
110
119
  blockHash: BlockHash.schema.optional(),
111
120
  blockNumber: BlockNumberSchema.optional(),
121
+ epochNumber: EpochNumberSchema.optional(),
112
122
  transactionFee: schemas.BigInt.optional(),
113
123
  debugLogs: z.array(DebugLog.schema).optional(),
114
124
  })
@@ -123,6 +133,7 @@ export class TxReceipt {
123
133
  transactionFee?: bigint;
124
134
  blockHash?: BlockHash;
125
135
  blockNumber?: BlockNumber;
136
+ epochNumber?: EpochNumber;
126
137
  debugLogs?: DebugLog[];
127
138
  }) {
128
139
  return new TxReceipt(
@@ -133,21 +144,12 @@ export class TxReceipt {
133
144
  fields.transactionFee,
134
145
  fields.blockHash,
135
146
  fields.blockNumber,
147
+ fields.epochNumber,
136
148
  fields.debugLogs,
137
149
  );
138
150
  }
139
151
 
140
152
  public static executionResultFromRevertCode(revertCode: RevertCode): TxExecutionResult {
141
- if (revertCode.equals(RevertCode.OK)) {
142
- return TxExecutionResult.SUCCESS;
143
- } else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
144
- return TxExecutionResult.APP_LOGIC_REVERTED;
145
- } else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
146
- return TxExecutionResult.TEARDOWN_REVERTED;
147
- } else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
148
- return TxExecutionResult.BOTH_REVERTED;
149
- } else {
150
- throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
151
- }
153
+ return revertCode.isOK() ? TxExecutionResult.SUCCESS : TxExecutionResult.REVERTED;
152
154
  }
153
155
  }
@@ -7,6 +7,9 @@ export const TX_ERROR_GAS_LIMIT_TOO_HIGH = 'Gas limit is higher than the amount
7
7
  // Phases
8
8
  export const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = 'Setup function not on allow list';
9
9
  export const TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT = 'Setup function targets unknown contract';
10
+ export const TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER = 'Setup only_self function called with incorrect msg_sender';
11
+ export const TX_ERROR_SETUP_NULL_MSG_SENDER = 'Setup function called with null msg sender';
12
+ export const TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH = 'Setup function called with wrong calldata length';
10
13
 
11
14
  // Nullifiers
12
15
  export const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = 'Duplicate nullifier in tx';
@@ -38,5 +41,13 @@ export const TX_ERROR_SIZE_ABOVE_LIMIT = 'Transaction size above size limit';
38
41
  // Block header
39
42
  export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
40
43
 
44
+ // Contract instance
45
+ export const TX_ERROR_INCORRECT_CONTRACT_ADDRESS = 'Incorrect contract instance deployment address';
46
+ export const TX_ERROR_MALFORMED_CONTRACT_INSTANCE_LOG = 'Failed to parse contract instance deployment log';
47
+
48
+ // Contract class
49
+ export const TX_ERROR_INCORRECT_CONTRACT_CLASS_ID = 'Incorrect contract class id';
50
+ export const TX_ERROR_MALFORMED_CONTRACT_CLASS_LOG = 'Failed to parse contract class registration log';
51
+
41
52
  // General
42
53
  export const TX_ERROR_DURING_VALIDATION = 'Unexpected error during validation';
@@ -1 +1,2 @@
1
- export { UpdateChecker, getPackageVersion } from './update-checker.js';
1
+ export * from './package_version.js';
2
+ export * from './version_checker.js';
@@ -0,0 +1,30 @@
1
+ import { fileURLToPath } from '@aztec/foundation/url';
2
+
3
+ import { readFileSync } from 'fs';
4
+ import { dirname, resolve } from 'path';
5
+
6
+ /** Returns the package version from the release-please manifest or the package.json, or undefined if not found. */
7
+ export function getPackageVersion(): string | undefined {
8
+ const dir = dirname(fileURLToPath(import.meta.url));
9
+
10
+ // Try the release-please manifest first (works in dev/repo checkout).
11
+ try {
12
+ const releasePleaseManifestPath = resolve(dir, '../../../../.release-please-manifest.json');
13
+ return JSON.parse(readFileSync(releasePleaseManifestPath).toString())['.'];
14
+ } catch {
15
+ // Not in a repo checkout, fall through.
16
+ }
17
+
18
+ // Fall back to the stdlib package.json version (works in npm-installed packages).
19
+ try {
20
+ const packageJsonPath = resolve(dir, '../../package.json');
21
+ const version = JSON.parse(readFileSync(packageJsonPath).toString()).version;
22
+ if (version && version !== '0.1.0') {
23
+ return version;
24
+ }
25
+ } catch {
26
+ // No package.json found either.
27
+ }
28
+
29
+ return undefined;
30
+ }
@@ -0,0 +1,65 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { RunningPromise } from '@aztec/foundation/promise';
3
+
4
+ import { EventEmitter } from 'node:events';
5
+
6
+ export type EventMap = {
7
+ newVersion: [{ name: string; currentVersion: string; latestVersion: string }];
8
+ };
9
+
10
+ export type VersionCheck = {
11
+ name: string;
12
+ currentVersion: string;
13
+ getLatestVersion: () => Promise<string | undefined>;
14
+ };
15
+
16
+ export class VersionChecker extends EventEmitter<EventMap> {
17
+ private runningPromise: RunningPromise;
18
+ constructor(
19
+ private checks: Array<VersionCheck>,
20
+ intervalCheckMs = 60_000,
21
+ private logger = createLogger('version_checker'),
22
+ ) {
23
+ super();
24
+ this.runningPromise = new RunningPromise(this.run, logger, intervalCheckMs);
25
+ }
26
+
27
+ public start(): void {
28
+ if (this.runningPromise.isRunning()) {
29
+ this.logger.warn('VersionChecker is already running');
30
+ return;
31
+ }
32
+
33
+ this.runningPromise.start();
34
+ this.logger.info('Version check started');
35
+ }
36
+
37
+ public trigger(): Promise<void> {
38
+ return this.runningPromise.trigger();
39
+ }
40
+
41
+ public async stop(): Promise<void> {
42
+ if (!this.runningPromise.isRunning()) {
43
+ this.logger.warn('VersionChecker is not running');
44
+ return;
45
+ }
46
+
47
+ await this.runningPromise.stop();
48
+ this.logger.info('Version checker stopped');
49
+ }
50
+
51
+ private run = async () => {
52
+ await Promise.allSettled(this.checks.map(check => this.checkVersion(check)));
53
+ };
54
+
55
+ private async checkVersion({ name, currentVersion, getLatestVersion }: VersionCheck): Promise<void> {
56
+ try {
57
+ const latestVersion = await getLatestVersion();
58
+ if (latestVersion && latestVersion !== currentVersion) {
59
+ this.emit('newVersion', { name, latestVersion, currentVersion });
60
+ }
61
+ } catch (err) {
62
+ this.logger.warn(`Error checking for new ${name} versions: ${err}`, { err });
63
+ }
64
+ }
65
+ }
@@ -36,6 +36,15 @@ export class FailedToReExecuteTransactionsError extends ValidatorError {
36
36
  }
37
37
  }
38
38
 
39
+ export class ReExInitialStateMismatchError extends ValidatorError {
40
+ constructor(
41
+ public readonly expectedArchiveRoot: Fr,
42
+ public readonly actualArchiveRoot: Fr,
43
+ ) {
44
+ super('Re-execution initial state mismatch');
45
+ }
46
+ }
47
+
39
48
  export class ReExStateMismatchError extends ValidatorError {
40
49
  constructor(
41
50
  public readonly expectedArchiveRoot: Fr,
@@ -115,7 +115,7 @@ export function validatePartialComponentVersionsMatch(
115
115
  }
116
116
 
117
117
  /** Returns a Koa middleware that injects the versioning info as headers. */
118
- export function getVersioningMiddleware(versions: Partial<ComponentsVersions>) {
118
+ export function getVersioningMiddleware(versions: Partial<ComponentsVersions>, opts?: { packageVersion?: string }) {
119
119
  return async (ctx: Koa.Context, next: () => Promise<void>) => {
120
120
  try {
121
121
  await next();
@@ -128,6 +128,9 @@ export function getVersioningMiddleware(versions: Partial<ComponentsVersions>) {
128
128
  ctx.set(`x-aztec-${key}`, value.toString());
129
129
  }
130
130
  }
131
+ if (opts?.packageVersion) {
132
+ ctx.set('x-aztec-packageVersion', opts.packageVersion);
133
+ }
131
134
  }
132
135
  };
133
136
  }
@@ -0,0 +1,15 @@
1
+ import type { PublicDataTreeLeaf } from '../trees/index.js';
2
+
3
+ /** Data used to initialize the genesis block, including prefilled public state and an optional timestamp. */
4
+ export type GenesisData = {
5
+ /** Public data tree leaves to pre-populate in the genesis state (e.g. fee juice balances). */
6
+ prefilledPublicData: PublicDataTreeLeaf[];
7
+ /** Timestamp for the genesis block header. Defaults to 0 (canonical empty genesis) in production. */
8
+ genesisTimestamp: bigint;
9
+ };
10
+
11
+ /** An empty genesis data with no prefilled state and a zero timestamp. */
12
+ export const EMPTY_GENESIS_DATA: GenesisData = {
13
+ prefilledPublicData: [],
14
+ genesisTimestamp: 0n,
15
+ };
@@ -1 +1,2 @@
1
+ export * from './genesis_data.js';
1
2
  export * from './world_state_revision.js';
@@ -1,32 +0,0 @@
1
- import { type ContractArtifact, FunctionSelector } from '../abi/index.js';
2
- import type { ContractClassPublic, ExecutablePrivateFunctionWithMembershipProof, PrivateFunctionMembershipProof } from './interfaces/index.js';
3
- /**
4
- * Creates a membership proof for a private function in a contract class, to be verified via `isValidPrivateFunctionMembershipProof`.
5
- * @param selector - Selector of the function to create the proof for.
6
- * @param artifact - Artifact of the contract class where the function is defined.
7
- */
8
- export declare function createPrivateFunctionMembershipProof(selector: FunctionSelector, artifact: ContractArtifact): Promise<PrivateFunctionMembershipProof>;
9
- /**
10
- * Verifies that a private function with a membership proof as emitted by the ClassRegistry contract is valid,
11
- * as defined in the protocol specs at contract-deployment/classes:
12
- *
13
- * ```
14
- * // Load contract class from local db
15
- * contract_class = db.get_contract_class(contract_class_id)
16
- *
17
- * // Compute function leaf and assert it belongs to the private functions tree
18
- * function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
19
- * computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
20
- * assert computed_private_function_tree_root == contract_class.private_functions_root
21
- *
22
- * // Compute artifact leaf and assert it belongs to the artifact
23
- * artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
24
- * computed_artifact_private_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path)
25
- * computed_artifact_hash = sha256(computed_artifact_private_function_tree_root, utility_functions_artifact_tree_root, artifact_metadata_hash)
26
- * assert computed_artifact_hash == contract_class.artifact_hash
27
- * ```
28
- * @param fn - Function to check membership proof for.
29
- * @param contractClass - In which contract class the function is expected to be.
30
- */
31
- export declare function isValidPrivateFunctionMembershipProof(fn: ExecutablePrivateFunctionWithMembershipProof, contractClass: Pick<ContractClassPublic, 'privateFunctionsRoot' | 'artifactHash'>): Promise<boolean>;
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvcHJpdmF0ZV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFnQixNQUFNLGlCQUFpQixDQUFDO0FBVXhGLE9BQU8sS0FBSyxFQUNWLG1CQUFtQixFQUNuQiw0Q0FBNEMsRUFDNUMsOEJBQThCLEVBQy9CLE1BQU0sdUJBQXVCLENBQUM7QUFHL0I7Ozs7R0FJRztBQUNILHdCQUFzQixvQ0FBb0MsQ0FDeEQsUUFBUSxFQUFFLGdCQUFnQixFQUMxQixRQUFRLEVBQUUsZ0JBQWdCLEdBQ3pCLE9BQU8sQ0FBQyw4QkFBOEIsQ0FBQyxDQTREekM7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBcUJHO0FBQ0gsd0JBQXNCLHFDQUFxQyxDQUN6RCxFQUFFLEVBQUUsNENBQTRDLEVBQ2hELGFBQWEsRUFBRSxJQUFJLENBQUMsbUJBQW1CLEVBQUUsc0JBQXNCLEdBQUcsY0FBYyxDQUFDLG9CQWtEbEYifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"private_function_membership_proof.d.ts","sourceRoot":"","sources":["../../src/contract/private_function_membership_proof.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AAUxF,OAAO,KAAK,EACV,mBAAmB,EACnB,4CAA4C,EAC5C,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAG/B;;;;GAIG;AACH,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CA4DzC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,4CAA4C,EAChD,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,GAAG,cAAc,CAAC,oBAkDlF"}
@@ -1,124 +0,0 @@
1
- import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { createLogger } from '@aztec/foundation/log';
4
- import { computeRootFromSiblingPath } from '@aztec/foundation/trees';
5
- import { FunctionSelector, FunctionType } from '../abi/index.js';
6
- import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPreimage, computeFunctionArtifactHash, computeFunctionMetadataHash, getArtifactMerkleTreeHasher } from './artifact_hash.js';
7
- import { getContractClassPrivateFunctionFromArtifact } from './contract_class.js';
8
- import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './private_function.js';
9
- /**
10
- * Creates a membership proof for a private function in a contract class, to be verified via `isValidPrivateFunctionMembershipProof`.
11
- * @param selector - Selector of the function to create the proof for.
12
- * @param artifact - Artifact of the contract class where the function is defined.
13
- */ export async function createPrivateFunctionMembershipProof(selector, artifact) {
14
- const log = createLogger('circuits:function_membership_proof');
15
- // Locate private function definition and artifact
16
- const privateFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE);
17
- const privateFunctionsFromArtifact = await Promise.all(privateFunctions.map(getContractClassPrivateFunctionFromArtifact));
18
- const privateFunction = privateFunctionsFromArtifact.find((fn)=>fn.selector.equals(selector));
19
- const privateFunctionsAndSelectors = await Promise.all(privateFunctions.map(async (fn)=>({
20
- fn,
21
- selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
22
- })));
23
- const privateFunctionArtifact = privateFunctionsAndSelectors.find((fnAndSelector)=>selector.equals(fnAndSelector.selector))?.fn;
24
- if (!privateFunction || !privateFunctionArtifact) {
25
- throw new Error(`Private function with selector ${selector.toString()} not found`);
26
- }
27
- // Compute preimage for the artifact hash
28
- const { utilityFunctionRoot: utilityFunctionsTreeRoot, metadataHash: artifactMetadataHash } = await computeArtifactHashPreimage(artifact);
29
- // We need two sibling paths because private function information is split across two trees:
30
- // The "private function tree" captures the selectors and verification keys, and is used in the kernel circuit for verifying the proof generated by the app circuit.
31
- const functionLeaf = await computePrivateFunctionLeaf(privateFunction);
32
- const functionsTree = await computePrivateFunctionsTree(privateFunctionsFromArtifact);
33
- const functionsTreeLeafIndex = functionsTree.getIndex(functionLeaf);
34
- const functionsTreeSiblingPath = functionsTree.getSiblingPath(functionsTreeLeafIndex).map(Fr.fromBuffer);
35
- // And the "artifact tree" captures function bytecode and metadata, and is used by the pxe to check that its executing the code it's supposed to be executing, but it never goes into circuits.
36
- const functionMetadataHash = computeFunctionMetadataHash(privateFunctionArtifact);
37
- const functionArtifactHash = await computeFunctionArtifactHash({
38
- ...privateFunctionArtifact,
39
- functionMetadataHash
40
- });
41
- const artifactTree = await computeArtifactFunctionTree(artifact, FunctionType.PRIVATE);
42
- const artifactTreeLeafIndex = artifactTree.getIndex(functionArtifactHash.toBuffer());
43
- const artifactTreeSiblingPath = artifactTree.getSiblingPath(artifactTreeLeafIndex).map(Fr.fromBuffer);
44
- log.debug(`Computed proof for private function with selector ${selector.toString()}`, {
45
- functionArtifactHash,
46
- functionMetadataHash,
47
- functionLeaf: '0x' + functionLeaf.toString('hex'),
48
- artifactMetadataHash,
49
- privateFunctionsTreeRoot: '0x' + functionsTree.root.toString('hex'),
50
- utilityFunctionsTreeRoot,
51
- artifactFunctionTreeSiblingPath: artifactTreeSiblingPath.map((fr)=>fr.toString()).join(','),
52
- privateFunctionTreeSiblingPath: functionsTreeSiblingPath.map((fr)=>fr.toString()).join(',')
53
- });
54
- return {
55
- artifactTreeSiblingPath,
56
- artifactTreeLeafIndex,
57
- artifactMetadataHash,
58
- functionMetadataHash,
59
- utilityFunctionsTreeRoot,
60
- privateFunctionTreeSiblingPath: functionsTreeSiblingPath,
61
- privateFunctionTreeLeafIndex: functionsTreeLeafIndex
62
- };
63
- }
64
- /**
65
- * Verifies that a private function with a membership proof as emitted by the ClassRegistry contract is valid,
66
- * as defined in the protocol specs at contract-deployment/classes:
67
- *
68
- * ```
69
- * // Load contract class from local db
70
- * contract_class = db.get_contract_class(contract_class_id)
71
- *
72
- * // Compute function leaf and assert it belongs to the private functions tree
73
- * function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
74
- * computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
75
- * assert computed_private_function_tree_root == contract_class.private_functions_root
76
- *
77
- * // Compute artifact leaf and assert it belongs to the artifact
78
- * artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
79
- * computed_artifact_private_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path)
80
- * computed_artifact_hash = sha256(computed_artifact_private_function_tree_root, utility_functions_artifact_tree_root, artifact_metadata_hash)
81
- * assert computed_artifact_hash == contract_class.artifact_hash
82
- * ```
83
- * @param fn - Function to check membership proof for.
84
- * @param contractClass - In which contract class the function is expected to be.
85
- */ export async function isValidPrivateFunctionMembershipProof(fn, contractClass) {
86
- const log = createLogger('circuits:function_membership_proof');
87
- // Check private function tree membership
88
- const functionLeaf = await computePrivateFunctionLeaf(fn);
89
- const rootBuffer = await computeRootFromSiblingPath(functionLeaf, fn.privateFunctionTreeSiblingPath.map((fr)=>fr.toBuffer()), fn.privateFunctionTreeLeafIndex, async (left, right)=>(await poseidon2Hash([
90
- left,
91
- right
92
- ])).toBuffer());
93
- const computedPrivateFunctionTreeRoot = Fr.fromBuffer(rootBuffer);
94
- if (!contractClass.privateFunctionsRoot.equals(computedPrivateFunctionTreeRoot)) {
95
- log.debug(`Private function tree root mismatch`, {
96
- expectedPrivateFunctionTreeRoot: contractClass.privateFunctionsRoot,
97
- computedPrivateFunctionTreeRoot: computedPrivateFunctionTreeRoot,
98
- computedFunctionLeaf: '0x' + functionLeaf.toString('hex')
99
- });
100
- return false;
101
- }
102
- // Check artifact hash
103
- const functionArtifactHash = await computeFunctionArtifactHash(fn);
104
- const computedArtifactPrivateFunctionTreeRootBuffer = await computeRootFromSiblingPath(functionArtifactHash.toBuffer(), fn.artifactTreeSiblingPath.map((fr)=>fr.toBuffer()), fn.artifactTreeLeafIndex, getArtifactMerkleTreeHasher());
105
- const computedArtifactPrivateFunctionTreeRoot = Fr.fromBuffer(computedArtifactPrivateFunctionTreeRootBuffer);
106
- const computedArtifactHash = await computeArtifactHash({
107
- privateFunctionRoot: computedArtifactPrivateFunctionTreeRoot,
108
- utilityFunctionRoot: fn.utilityFunctionsTreeRoot,
109
- metadataHash: fn.artifactMetadataHash
110
- });
111
- if (!contractClass.artifactHash.equals(computedArtifactHash)) {
112
- log.debug(`Artifact hash mismatch`, {
113
- expected: contractClass.artifactHash,
114
- computedArtifactHash,
115
- computedFunctionArtifactHash: functionArtifactHash,
116
- computedArtifactPrivateFunctionTreeRoot,
117
- utilityFunctionRoot: fn.utilityFunctionsTreeRoot,
118
- metadataHash: fn.artifactMetadataHash,
119
- artifactFunctionTreeSiblingPath: fn.artifactTreeSiblingPath.map((fr)=>fr.toString()).join(',')
120
- });
121
- return false;
122
- }
123
- return true;
124
- }
@@ -1,27 +0,0 @@
1
- import { type ContractArtifact, FunctionSelector } from '../abi/index.js';
2
- import type { ContractClassPublic, UtilityFunctionMembershipProof, UtilityFunctionWithMembershipProof } from './interfaces/index.js';
3
- /**
4
- * Creates a membership proof for a utility function in a contract class, to be verified via `isValidUtilityFunctionMembershipProof`.
5
- * @param selector - Selector of the function to create the proof for.
6
- * @param artifact - Artifact of the contract class where the function is defined.
7
- */
8
- export declare function createUtilityFunctionMembershipProof(selector: FunctionSelector, artifact: ContractArtifact): Promise<UtilityFunctionMembershipProof>;
9
- /**
10
- * Verifies that a utility function with a membership proof as emitted by the ClassRegistry contract is valid,
11
- * as defined in the protocol specs at contract-deployment/classes:
12
- *
13
- * ```
14
- * // Load contract class from local db
15
- * contract_class = db.get_contract_class(contract_class_id)
16
- *
17
- * // Compute artifact leaf and assert it belongs to the artifact
18
- * artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
19
- * computed_artifact_utility_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path, artifact_function_tree_leaf_index)
20
- * computed_artifact_hash = sha256(private_functions_artifact_tree_root, computed_artifact_utility_function_tree_root, artifact_metadata_hash)
21
- * assert computed_artifact_hash == contract_class.artifact_hash
22
- * ```
23
- * @param fn - Function to check membership proof for.
24
- * @param contractClass - In which contract class the function is expected to be.
25
- */
26
- export declare function isValidUtilityFunctionMembershipProof(fn: UtilityFunctionWithMembershipProof, contractClass: Pick<ContractClassPublic, 'artifactHash'>): Promise<boolean>;
27
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0eV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvdXRpbGl0eV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFnQixNQUFNLGlCQUFpQixDQUFDO0FBU3hGLE9BQU8sS0FBSyxFQUNWLG1CQUFtQixFQUNuQiw4QkFBOEIsRUFDOUIsa0NBQWtDLEVBQ25DLE1BQU0sdUJBQXVCLENBQUM7QUFFL0I7Ozs7R0FJRztBQUNILHdCQUFzQixvQ0FBb0MsQ0FDeEQsUUFBUSxFQUFFLGdCQUFnQixFQUMxQixRQUFRLEVBQUUsZ0JBQWdCLEdBQ3pCLE9BQU8sQ0FBQyw4QkFBOEIsQ0FBQyxDQXNDekM7QUFFRDs7Ozs7Ozs7Ozs7Ozs7OztHQWdCRztBQUNILHdCQUFzQixxQ0FBcUMsQ0FDekQsRUFBRSxFQUFFLGtDQUFrQyxFQUN0QyxhQUFhLEVBQUUsSUFBSSxDQUFDLG1CQUFtQixFQUFFLGNBQWMsQ0FBQyxvQkErQnpEIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"utility_function_membership_proof.d.ts","sourceRoot":"","sources":["../../src/contract/utility_function_membership_proof.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AASxF,OAAO,KAAK,EACV,mBAAmB,EACnB,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAsCzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,kCAAkC,EACtC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,oBA+BzD"}