@aztec/stdlib 1.2.1 → 2.0.0-nightly.20250813

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 (324) hide show
  1. package/dest/abi/abi.d.ts +0 -67
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +1 -14
  4. package/dest/abi/authorization_selector.d.ts +52 -0
  5. package/dest/abi/authorization_selector.d.ts.map +1 -0
  6. package/dest/abi/authorization_selector.js +70 -0
  7. package/dest/abi/contract_artifact.d.ts.map +1 -1
  8. package/dest/abi/contract_artifact.js +0 -40
  9. package/dest/abi/decoder.d.ts.map +1 -1
  10. package/dest/abi/decoder.js +3 -6
  11. package/dest/abi/index.d.ts +1 -0
  12. package/dest/abi/index.d.ts.map +1 -1
  13. package/dest/abi/index.js +1 -0
  14. package/dest/avm/avm.d.ts +278 -412
  15. package/dest/avm/avm.d.ts.map +1 -1
  16. package/dest/avm/avm.js +12 -12
  17. package/dest/avm/avm_proving_request.d.ts +160 -186
  18. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  19. package/dest/block/l2_block.d.ts +8 -0
  20. package/dest/block/l2_block.d.ts.map +1 -1
  21. package/dest/block/l2_block.js +9 -0
  22. package/dest/block/l2_block_source.d.ts +446 -2
  23. package/dest/block/l2_block_source.d.ts.map +1 -1
  24. package/dest/block/l2_block_source.js +29 -0
  25. package/dest/block/proposal/committee_attestation.d.ts +3 -1
  26. package/dest/block/proposal/committee_attestation.d.ts.map +1 -1
  27. package/dest/block/proposal/committee_attestation.js +3 -0
  28. package/dest/block/published_l2_block.d.ts +2 -1
  29. package/dest/block/published_l2_block.d.ts.map +1 -1
  30. package/dest/block/published_l2_block.js +6 -1
  31. package/dest/contract/contract_instance.d.ts +3 -3
  32. package/dest/contract/contract_instance.d.ts.map +1 -1
  33. package/dest/contract/contract_instance.js +3 -3
  34. package/dest/contract/interfaces/contract_class.d.ts +2 -2
  35. package/dest/contract/interfaces/protocol_contract_addresses.d.ts +9 -9
  36. package/dest/contract/interfaces/protocol_contract_addresses.d.ts.map +1 -1
  37. package/dest/contract/interfaces/protocol_contract_addresses.js +4 -4
  38. package/dest/contract/private_function_membership_proof.d.ts +1 -1
  39. package/dest/contract/private_function_membership_proof.js +1 -1
  40. package/dest/contract/utility_function_membership_proof.d.ts +1 -1
  41. package/dest/contract/utility_function_membership_proof.js +1 -1
  42. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +20 -0
  43. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -0
  44. package/dest/{shared_mutable/shared_mutable_values.js → delayed_public_mutable/delayed_public_mutable_values.js} +9 -9
  45. package/dest/{shared_mutable/shared_mutable_values_with_hash.d.ts → delayed_public_mutable/delayed_public_mutable_values_with_hash.d.ts} +6 -6
  46. package/dest/delayed_public_mutable/delayed_public_mutable_values_with_hash.d.ts.map +1 -0
  47. package/dest/delayed_public_mutable/delayed_public_mutable_values_with_hash.js +30 -0
  48. package/dest/delayed_public_mutable/index.d.ts +5 -0
  49. package/dest/delayed_public_mutable/index.d.ts.map +1 -0
  50. package/dest/delayed_public_mutable/index.js +4 -0
  51. package/dest/delayed_public_mutable/scheduled_delay_change.d.ts.map +1 -0
  52. package/dest/delayed_public_mutable/scheduled_value_change.d.ts.map +1 -0
  53. package/dest/gas/gas.d.ts +1 -0
  54. package/dest/gas/gas.d.ts.map +1 -1
  55. package/dest/gas/gas.js +3 -0
  56. package/dest/hash/hash.d.ts.map +1 -1
  57. package/dest/hash/hash.js +1 -4
  58. package/dest/interfaces/archiver.d.ts.map +1 -1
  59. package/dest/interfaces/archiver.js +4 -2
  60. package/dest/interfaces/aztec-node-admin.d.ts +210 -8
  61. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  62. package/dest/interfaces/aztec-node-admin.js +8 -3
  63. package/dest/interfaces/configs.d.ts +27 -0
  64. package/dest/interfaces/configs.d.ts.map +1 -1
  65. package/dest/interfaces/configs.js +6 -1
  66. package/dest/interfaces/get_logs_response.d.ts +1 -1
  67. package/dest/interfaces/proving-job.d.ts +166 -192
  68. package/dest/interfaces/proving-job.d.ts.map +1 -1
  69. package/dest/interfaces/pxe.d.ts +3 -1
  70. package/dest/interfaces/pxe.d.ts.map +1 -1
  71. package/dest/interfaces/pxe.js +1 -1
  72. package/dest/interfaces/server.d.ts +1 -1
  73. package/dest/interfaces/server.d.ts.map +1 -1
  74. package/dest/interfaces/server.js +1 -1
  75. package/dest/interfaces/slasher.d.ts +21 -0
  76. package/dest/interfaces/slasher.d.ts.map +1 -1
  77. package/dest/interfaces/slasher.js +6 -1
  78. package/dest/interfaces/tx_provider.d.ts +24 -0
  79. package/dest/interfaces/tx_provider.d.ts.map +1 -0
  80. package/dest/kernel/claimed_length_array.d.ts +34 -0
  81. package/dest/kernel/claimed_length_array.d.ts.map +1 -0
  82. package/dest/kernel/claimed_length_array.js +58 -0
  83. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -6
  84. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  85. package/dest/kernel/hints/build_note_hash_read_request_hints.js +18 -20
  86. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +7 -10
  87. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  88. package/dest/kernel/hints/build_nullifier_read_request_hints.js +17 -32
  89. package/dest/kernel/hints/build_transient_data_hints.d.ts +4 -3
  90. package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
  91. package/dest/kernel/hints/build_transient_data_hints.js +9 -10
  92. package/dest/kernel/hints/index.d.ts +1 -2
  93. package/dest/kernel/hints/index.d.ts.map +1 -1
  94. package/dest/kernel/hints/index.js +1 -2
  95. package/dest/kernel/hints/note_hash_read_request_hints.d.ts.map +1 -1
  96. package/dest/kernel/hints/note_hash_read_request_hints.js +4 -4
  97. package/dest/kernel/hints/nullifier_read_request_hints.d.ts.map +1 -1
  98. package/dest/kernel/hints/nullifier_read_request_hints.js +4 -4
  99. package/dest/kernel/hints/private_kernel_reset_hints.d.ts +5 -5
  100. package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
  101. package/dest/kernel/hints/private_kernel_reset_hints.js +9 -9
  102. package/dest/kernel/hints/read_request_hints.d.ts +17 -17
  103. package/dest/kernel/hints/read_request_hints.d.ts.map +1 -1
  104. package/dest/kernel/hints/read_request_hints.js +28 -28
  105. package/dest/kernel/hints/{transient_data_index_hint.d.ts → transient_data_squashing_hint.d.ts} +5 -5
  106. package/dest/kernel/hints/transient_data_squashing_hint.d.ts.map +1 -0
  107. package/dest/kernel/hints/{transient_data_index_hint.js → transient_data_squashing_hint.js} +5 -5
  108. package/dest/kernel/index.d.ts +1 -0
  109. package/dest/kernel/index.d.ts.map +1 -1
  110. package/dest/kernel/index.js +1 -0
  111. package/dest/kernel/private_accumulated_data.d.ts +16 -15
  112. package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
  113. package/dest/kernel/private_accumulated_data.js +3 -3
  114. package/dest/kernel/private_call_data.d.ts +4 -4
  115. package/dest/kernel/private_call_data.d.ts.map +1 -1
  116. package/dest/kernel/private_call_data.js +2 -2
  117. package/dest/kernel/private_circuit_public_inputs.d.ts +26 -25
  118. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  119. package/dest/kernel/private_circuit_public_inputs.js +33 -15
  120. package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +9 -0
  121. package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
  122. package/dest/kernel/private_kernel_circuit_public_inputs.js +8 -4
  123. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +10 -1
  124. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
  125. package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +9 -6
  126. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +11 -4
  127. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
  128. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +20 -18
  129. package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts +4 -4
  130. package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts.map +1 -1
  131. package/dest/kernel/private_to_public_kernel_circuit_public_inputs.js +9 -10
  132. package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts +11 -11
  133. package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts.map +1 -1
  134. package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.js +11 -12
  135. package/dest/kernel/private_validation_requests.d.ts +8 -20
  136. package/dest/kernel/private_validation_requests.d.ts.map +1 -1
  137. package/dest/kernel/private_validation_requests.js +9 -21
  138. package/dest/kernel/utils/order_and_comparison.d.ts +0 -3
  139. package/dest/kernel/utils/order_and_comparison.d.ts.map +1 -1
  140. package/dest/kernel/utils/order_and_comparison.js +0 -19
  141. package/dest/logs/extended_public_log.d.ts +1 -1
  142. package/dest/logs/shared_secret_derivation.d.ts +1 -1
  143. package/dest/logs/shared_secret_derivation.js +1 -1
  144. package/dest/messaging/l2_to_l1_membership.d.ts +4 -1
  145. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  146. package/dest/messaging/l2_to_l1_membership.js +49 -54
  147. package/dest/messaging/l2_to_l1_message.d.ts +2 -0
  148. package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
  149. package/dest/messaging/l2_to_l1_message.js +7 -0
  150. package/dest/note/notes_filter.d.ts +5 -2
  151. package/dest/note/notes_filter.d.ts.map +1 -1
  152. package/dest/note/notes_filter.js +1 -1
  153. package/dest/p2p/attestation_utils.d.ts +10 -0
  154. package/dest/p2p/attestation_utils.d.ts.map +1 -0
  155. package/dest/p2p/attestation_utils.js +21 -0
  156. package/dest/p2p/block_attestation.d.ts +3 -4
  157. package/dest/p2p/block_attestation.d.ts.map +1 -1
  158. package/dest/p2p/block_attestation.js +3 -4
  159. package/dest/p2p/block_proposal.d.ts +8 -1
  160. package/dest/p2p/block_proposal.d.ts.map +1 -1
  161. package/dest/p2p/block_proposal.js +21 -8
  162. package/dest/p2p/consensus_payload.d.ts +3 -11
  163. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  164. package/dest/p2p/consensus_payload.js +13 -22
  165. package/dest/p2p/index.d.ts +1 -0
  166. package/dest/p2p/index.d.ts.map +1 -1
  167. package/dest/p2p/index.js +1 -0
  168. package/dest/p2p/topic_type.d.ts.map +1 -1
  169. package/dest/p2p/topic_type.js +5 -3
  170. package/dest/rollup/block_root_rollup.d.ts +1 -1
  171. package/dest/slashing/index.d.ts +51 -0
  172. package/dest/slashing/index.d.ts.map +1 -0
  173. package/dest/slashing/index.js +54 -0
  174. package/dest/stats/stats.d.ts +2 -2
  175. package/dest/stats/stats.d.ts.map +1 -1
  176. package/dest/tests/factories.d.ts +0 -2
  177. package/dest/tests/factories.d.ts.map +1 -1
  178. package/dest/tests/factories.js +25 -24
  179. package/dest/tests/mocks.d.ts +2 -0
  180. package/dest/tests/mocks.d.ts.map +1 -1
  181. package/dest/tests/mocks.js +31 -22
  182. package/dest/tx/index.d.ts +0 -1
  183. package/dest/tx/index.d.ts.map +1 -1
  184. package/dest/tx/index.js +0 -1
  185. package/dest/tx/private_execution_result.d.ts +2 -2
  186. package/dest/tx/private_execution_result.d.ts.map +1 -1
  187. package/dest/tx/private_execution_result.js +11 -11
  188. package/dest/tx/processed_tx.d.ts +2 -2
  189. package/dest/tx/processed_tx.d.ts.map +1 -1
  190. package/dest/tx/processed_tx.js +4 -4
  191. package/dest/tx/proven_tx.d.ts +1 -1
  192. package/dest/tx/proven_tx.d.ts.map +1 -1
  193. package/dest/tx/proven_tx.js +7 -3
  194. package/dest/tx/simulated_tx.d.ts +11 -17
  195. package/dest/tx/simulated_tx.d.ts.map +1 -1
  196. package/dest/tx/simulated_tx.js +12 -12
  197. package/dest/tx/tx.d.ts +25 -25
  198. package/dest/tx/tx.d.ts.map +1 -1
  199. package/dest/tx/tx.js +60 -48
  200. package/dest/tx/tx_effect.d.ts +2 -2
  201. package/dest/tx/tx_effect.d.ts.map +1 -1
  202. package/dest/tx/tx_effect.js +3 -18
  203. package/dest/tx/tx_execution_request.js +2 -2
  204. package/dest/tx/tx_hash.d.ts +7 -0
  205. package/dest/tx/tx_hash.d.ts.map +1 -1
  206. package/dest/tx/tx_hash.js +19 -1
  207. package/dest/tx/tx_request.d.ts +5 -5
  208. package/dest/tx/tx_request.d.ts.map +1 -1
  209. package/dest/tx/tx_request.js +7 -7
  210. package/dest/tx/validator/error_texts.d.ts +1 -0
  211. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  212. package/dest/tx/validator/error_texts.js +1 -0
  213. package/dest/tx/validator/tx_validator.d.ts +6 -4
  214. package/dest/tx/validator/tx_validator.d.ts.map +1 -1
  215. package/dest/tx/validator/tx_validator.js +3 -0
  216. package/dest/versioning/versioning.d.ts.map +1 -1
  217. package/dest/vks/verification_key.d.ts.map +1 -1
  218. package/dest/vks/verification_key.js +4 -4
  219. package/package.json +10 -9
  220. package/src/abi/abi.ts +0 -38
  221. package/src/abi/authorization_selector.ts +95 -0
  222. package/src/abi/contract_artifact.ts +0 -49
  223. package/src/abi/decoder.ts +3 -6
  224. package/src/abi/index.ts +1 -0
  225. package/src/avm/avm.ts +7 -9
  226. package/src/block/l2_block.ts +18 -0
  227. package/src/block/l2_block_source.ts +70 -1
  228. package/src/block/proposal/committee_attestation.ts +5 -1
  229. package/src/block/published_l2_block.ts +14 -5
  230. package/src/contract/contract_instance.ts +3 -3
  231. package/src/contract/interfaces/protocol_contract_addresses.ts +5 -10
  232. package/src/contract/private_function_membership_proof.ts +1 -1
  233. package/src/contract/utility_function_membership_proof.ts +1 -1
  234. package/src/{shared_mutable/shared_mutable_values.ts → delayed_public_mutable/delayed_public_mutable_values.ts} +10 -10
  235. package/src/delayed_public_mutable/delayed_public_mutable_values_with_hash.ts +38 -0
  236. package/src/delayed_public_mutable/index.ts +4 -0
  237. package/src/gas/gas.ts +4 -0
  238. package/src/hash/hash.ts +1 -4
  239. package/src/interfaces/archiver.ts +3 -1
  240. package/src/interfaces/aztec-node-admin.ts +18 -11
  241. package/src/interfaces/configs.ts +17 -0
  242. package/src/interfaces/pxe.ts +4 -2
  243. package/src/interfaces/server.ts +1 -1
  244. package/src/interfaces/slasher.ts +11 -0
  245. package/src/interfaces/tx_provider.ts +16 -0
  246. package/src/kernel/claimed_length_array.ts +104 -0
  247. package/src/kernel/hints/build_note_hash_read_request_hints.ts +28 -30
  248. package/src/kernel/hints/build_nullifier_read_request_hints.ts +28 -59
  249. package/src/kernel/hints/build_transient_data_hints.ts +12 -14
  250. package/src/kernel/hints/index.ts +1 -2
  251. package/src/kernel/hints/note_hash_read_request_hints.ts +4 -16
  252. package/src/kernel/hints/nullifier_read_request_hints.ts +4 -16
  253. package/src/kernel/hints/private_kernel_reset_hints.ts +7 -7
  254. package/src/kernel/hints/read_request_hints.ts +22 -22
  255. package/src/kernel/hints/{transient_data_index_hint.ts → transient_data_squashing_hint.ts} +5 -5
  256. package/src/kernel/index.ts +1 -0
  257. package/src/kernel/private_accumulated_data.ts +23 -23
  258. package/src/kernel/private_call_data.ts +3 -3
  259. package/src/kernel/private_circuit_public_inputs.ts +92 -68
  260. package/src/kernel/private_kernel_circuit_public_inputs.ts +9 -1
  261. package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +13 -4
  262. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +20 -20
  263. package/src/kernel/private_to_public_kernel_circuit_public_inputs.ts +7 -7
  264. package/src/kernel/private_to_rollup_kernel_circuit_public_inputs.ts +16 -10
  265. package/src/kernel/private_validation_requests.ts +19 -50
  266. package/src/kernel/utils/order_and_comparison.ts +0 -25
  267. package/src/logs/shared_secret_derivation.ts +1 -1
  268. package/src/messaging/l2_to_l1_membership.ts +76 -85
  269. package/src/messaging/l2_to_l1_message.ts +9 -0
  270. package/src/note/notes_filter.ts +6 -3
  271. package/src/p2p/attestation_utils.ts +35 -0
  272. package/src/p2p/block_attestation.ts +3 -4
  273. package/src/p2p/block_proposal.ts +23 -5
  274. package/src/p2p/consensus_payload.ts +10 -29
  275. package/src/p2p/index.ts +1 -0
  276. package/src/p2p/topic_type.ts +3 -1
  277. package/src/slashing/index.ts +74 -0
  278. package/src/stats/stats.ts +2 -2
  279. package/src/tests/factories.ts +37 -27
  280. package/src/tests/mocks.ts +24 -22
  281. package/src/tx/index.ts +0 -1
  282. package/src/tx/private_execution_result.ts +11 -9
  283. package/src/tx/processed_tx.ts +6 -6
  284. package/src/tx/proven_tx.ts +7 -8
  285. package/src/tx/simulated_tx.ts +13 -19
  286. package/src/tx/tx.ts +70 -57
  287. package/src/tx/tx_effect.ts +5 -20
  288. package/src/tx/tx_execution_request.ts +2 -2
  289. package/src/tx/tx_hash.ts +21 -1
  290. package/src/tx/tx_request.ts +7 -6
  291. package/src/tx/validator/error_texts.ts +1 -0
  292. package/src/tx/validator/tx_validator.ts +5 -0
  293. package/src/versioning/versioning.ts +0 -3
  294. package/src/vks/verification_key.ts +4 -7
  295. package/dest/interfaces/tx-collector.d.ts +0 -15
  296. package/dest/interfaces/tx-collector.d.ts.map +0 -1
  297. package/dest/kernel/hints/rollup_validation_requests.d.ts +0 -34
  298. package/dest/kernel/hints/rollup_validation_requests.d.ts.map +0 -1
  299. package/dest/kernel/hints/rollup_validation_requests.js +0 -55
  300. package/dest/kernel/hints/transient_data_index_hint.d.ts.map +0 -1
  301. package/dest/shared_mutable/index.d.ts +0 -5
  302. package/dest/shared_mutable/index.d.ts.map +0 -1
  303. package/dest/shared_mutable/index.js +0 -4
  304. package/dest/shared_mutable/scheduled_delay_change.d.ts.map +0 -1
  305. package/dest/shared_mutable/scheduled_value_change.d.ts.map +0 -1
  306. package/dest/shared_mutable/shared_mutable_values.d.ts +0 -20
  307. package/dest/shared_mutable/shared_mutable_values.d.ts.map +0 -1
  308. package/dest/shared_mutable/shared_mutable_values_with_hash.d.ts.map +0 -1
  309. package/dest/shared_mutable/shared_mutable_values_with_hash.js +0 -30
  310. package/dest/tx/include_by_timestamp.d.ts +0 -54
  311. package/dest/tx/include_by_timestamp.d.ts.map +0 -1
  312. package/dest/tx/include_by_timestamp.js +0 -72
  313. package/src/interfaces/tx-collector.ts +0 -17
  314. package/src/kernel/hints/rollup_validation_requests.ts +0 -71
  315. package/src/shared_mutable/index.ts +0 -4
  316. package/src/shared_mutable/shared_mutable_values_with_hash.ts +0 -38
  317. package/src/tx/include_by_timestamp.ts +0 -90
  318. /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.d.ts +0 -0
  319. /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.js +0 -0
  320. /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_value_change.d.ts +0 -0
  321. /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_value_change.js +0 -0
  322. /package/dest/interfaces/{tx-collector.js → tx_provider.js} +0 -0
  323. /package/src/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.ts +0 -0
  324. /package/src/{shared_mutable → delayed_public_mutable}/scheduled_value_change.ts +0 -0
@@ -2,14 +2,14 @@ import { GeneratorIndex, PRIVATE_TO_ROLLUP_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH }
2
2
  import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
3
3
  import type { Fr } from '@aztec/foundation/fields';
4
4
  import { bufferSchemaFor } from '@aztec/foundation/schemas';
5
- import { BufferReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
5
+ import { BufferReader, bigintToUInt64BE, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
6
6
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
7
7
  import type { FieldsOf } from '@aztec/foundation/types';
8
8
 
9
9
  import { AztecAddress } from '../aztec-address/index.js';
10
10
  import { Gas } from '../gas/gas.js';
11
11
  import { TxConstantData } from '../tx/tx_constant_data.js';
12
- import { RollupValidationRequests } from './hints/rollup_validation_requests.js';
12
+ import type { UInt64 } from '../types/index.js';
13
13
  import { PrivateToRollupAccumulatedData } from './private_to_rollup_accumulated_data.js';
14
14
 
15
15
  /**
@@ -22,10 +22,6 @@ export class PrivateToRollupKernelCircuitPublicInputs {
22
22
  * Data which is not modified by the circuits.
23
23
  */
24
24
  public constants: TxConstantData,
25
- /**
26
- * Validation requests accumulated from private and public execution to be completed by the rollup.
27
- */
28
- public rollupValidationRequests: RollupValidationRequests,
29
25
  /**
30
26
  * Data accumulated from both public and private circuits.
31
27
  */
@@ -38,6 +34,10 @@ export class PrivateToRollupKernelCircuitPublicInputs {
38
34
  * The address of the fee payer for the transaction.
39
35
  */
40
36
  public feePayer: AztecAddress,
37
+ /**
38
+ * The timestamp by which the transaction must be included in a block.
39
+ */
40
+ public includeByTimestamp: UInt64,
41
41
  ) {}
42
42
 
43
43
  getNonEmptyNullifiers() {
@@ -45,7 +45,13 @@ export class PrivateToRollupKernelCircuitPublicInputs {
45
45
  }
46
46
 
47
47
  toBuffer() {
48
- return serializeToBuffer(this.constants, this.rollupValidationRequests, this.end, this.gasUsed, this.feePayer);
48
+ return serializeToBuffer(
49
+ this.constants,
50
+ this.end,
51
+ this.gasUsed,
52
+ this.feePayer,
53
+ bigintToUInt64BE(this.includeByTimestamp),
54
+ );
49
55
  }
50
56
 
51
57
  /**
@@ -57,20 +63,20 @@ export class PrivateToRollupKernelCircuitPublicInputs {
57
63
  const reader = BufferReader.asReader(buffer);
58
64
  return new PrivateToRollupKernelCircuitPublicInputs(
59
65
  reader.readObject(TxConstantData),
60
- reader.readObject(RollupValidationRequests),
61
66
  reader.readObject(PrivateToRollupAccumulatedData),
62
67
  reader.readObject(Gas),
63
68
  reader.readObject(AztecAddress),
69
+ reader.readUInt64(),
64
70
  );
65
71
  }
66
72
 
67
73
  static empty() {
68
74
  return new PrivateToRollupKernelCircuitPublicInputs(
69
75
  TxConstantData.empty(),
70
- RollupValidationRequests.empty(),
71
76
  PrivateToRollupAccumulatedData.empty(),
72
77
  Gas.empty(),
73
78
  AztecAddress.ZERO,
79
+ 0n,
74
80
  );
75
81
  }
76
82
 
@@ -88,7 +94,7 @@ export class PrivateToRollupKernelCircuitPublicInputs {
88
94
  }
89
95
 
90
96
  static getFields(fields: FieldsOf<PrivateToRollupKernelCircuitPublicInputs>) {
91
- return [fields.constants, fields.rollupValidationRequests, fields.end, fields.gasUsed, fields.feePayer] as const;
97
+ return [fields.constants, fields.end, fields.gasUsed, fields.feePayer, fields.includeByTimestamp] as const;
92
98
  }
93
99
 
94
100
  /** Creates an instance from a hex string. */
@@ -3,17 +3,14 @@ import {
3
3
  MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
4
4
  MAX_NULLIFIER_READ_REQUESTS_PER_TX,
5
5
  } from '@aztec/constants';
6
- import { makeTuple } from '@aztec/foundation/array';
7
- import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection';
8
- import type { Fr } from '@aztec/foundation/fields';
9
- import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
6
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
10
7
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
11
8
 
12
9
  import { inspect } from 'util';
13
10
 
14
11
  import { ScopedKeyValidationRequestAndGenerator } from '../kernel/hints/scoped_key_validation_request_and_generator.js';
12
+ import { ClaimedLengthArray, ClaimedLengthArrayFromBuffer } from './claimed_length_array.js';
15
13
  import { ScopedReadRequest } from './hints/read_request.js';
16
- import { RollupValidationRequests } from './hints/rollup_validation_requests.js';
17
14
  import { OptionalNumber } from './utils/optional_number.js';
18
15
 
19
16
  /**
@@ -21,23 +18,18 @@ import { OptionalNumber } from './utils/optional_number.js';
21
18
  */
22
19
  export class PrivateValidationRequests {
23
20
  constructor(
24
- /**
25
- * Validation requests that cannot be fulfilled in the current context (private or public), and must be instead be
26
- * forwarded to the rollup for it to take care of them.
27
- */
28
- public forRollup: RollupValidationRequests,
29
21
  /**
30
22
  * All the read requests made in this transaction.
31
23
  */
32
- public noteHashReadRequests: Tuple<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
24
+ public noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
33
25
  /**
34
26
  * All the nullifier read requests made in this transaction.
35
27
  */
36
- public nullifierReadRequests: Tuple<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
28
+ public nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
37
29
  /**
38
30
  * All the key validation requests made in this transaction.
39
31
  */
40
- public scopedKeyValidationRequestsAndGenerators: Tuple<
32
+ public scopedKeyValidationRequestsAndGenerators: ClaimedLengthArray<
41
33
  ScopedKeyValidationRequestAndGenerator,
42
34
  typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX
43
35
  >,
@@ -51,17 +43,15 @@ export class PrivateValidationRequests {
51
43
 
52
44
  getSize() {
53
45
  return (
54
- this.forRollup.getSize() +
55
- arraySerializedSizeOfNonEmpty(this.noteHashReadRequests) +
56
- arraySerializedSizeOfNonEmpty(this.nullifierReadRequests) +
57
- arraySerializedSizeOfNonEmpty(this.scopedKeyValidationRequestsAndGenerators) +
46
+ this.noteHashReadRequests.getSize() +
47
+ this.nullifierReadRequests.getSize() +
48
+ this.scopedKeyValidationRequestsAndGenerators.getSize() +
58
49
  this.splitCounter.getSize()
59
50
  );
60
51
  }
61
52
 
62
53
  toBuffer() {
63
54
  return serializeToBuffer(
64
- this.forRollup,
65
55
  this.noteHashReadRequests,
66
56
  this.nullifierReadRequests,
67
57
  this.scopedKeyValidationRequestsAndGenerators,
@@ -73,17 +63,6 @@ export class PrivateValidationRequests {
73
63
  return bufferToHex(this.toBuffer());
74
64
  }
75
65
 
76
- static fromFields(fields: Fr[] | FieldReader) {
77
- const reader = FieldReader.asReader(fields);
78
- return new PrivateValidationRequests(
79
- reader.readObject(RollupValidationRequests),
80
- reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest),
81
- reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest),
82
- reader.readArray(MAX_KEY_VALIDATION_REQUESTS_PER_TX, ScopedKeyValidationRequestAndGenerator),
83
- reader.readObject(OptionalNumber),
84
- );
85
- }
86
-
87
66
  /**
88
67
  * Deserializes from a buffer or reader, corresponding to a write in cpp.
89
68
  * @param buffer - Buffer or reader to read from.
@@ -92,10 +71,11 @@ export class PrivateValidationRequests {
92
71
  static fromBuffer(buffer: Buffer | BufferReader) {
93
72
  const reader = BufferReader.asReader(buffer);
94
73
  return new PrivateValidationRequests(
95
- reader.readObject(RollupValidationRequests),
96
- reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest),
97
- reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest),
98
- reader.readArray(MAX_KEY_VALIDATION_REQUESTS_PER_TX, ScopedKeyValidationRequestAndGenerator),
74
+ reader.readObject(ClaimedLengthArrayFromBuffer(ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_TX)),
75
+ reader.readObject(ClaimedLengthArrayFromBuffer(ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_TX)),
76
+ reader.readObject(
77
+ ClaimedLengthArrayFromBuffer(ScopedKeyValidationRequestAndGenerator, MAX_KEY_VALIDATION_REQUESTS_PER_TX),
78
+ ),
99
79
  reader.readObject(OptionalNumber),
100
80
  );
101
81
  }
@@ -111,29 +91,18 @@ export class PrivateValidationRequests {
111
91
 
112
92
  static empty() {
113
93
  return new PrivateValidationRequests(
114
- RollupValidationRequests.empty(),
115
- makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest.empty),
116
- makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest.empty),
117
- makeTuple(MAX_KEY_VALIDATION_REQUESTS_PER_TX, ScopedKeyValidationRequestAndGenerator.empty),
94
+ ClaimedLengthArray.empty(ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_TX),
95
+ ClaimedLengthArray.empty(ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_TX),
96
+ ClaimedLengthArray.empty(ScopedKeyValidationRequestAndGenerator, MAX_KEY_VALIDATION_REQUESTS_PER_TX),
118
97
  OptionalNumber.empty(),
119
98
  );
120
99
  }
121
100
 
122
101
  [inspect.custom]() {
123
102
  return `PrivateValidationRequests {
124
- forRollup: ${inspect(this.forRollup)},
125
- noteHashReadRequests: [${this.noteHashReadRequests
126
- .filter(x => !x.isEmpty())
127
- .map(h => inspect(h))
128
- .join(', ')}],
129
- nullifierReadRequests: [${this.nullifierReadRequests
130
- .filter(x => !x.isEmpty())
131
- .map(h => inspect(h))
132
- .join(', ')}],
133
- scopedKeyValidationRequestsAndGenerators: [${this.scopedKeyValidationRequestsAndGenerators
134
- .filter(x => !x.isEmpty())
135
- .map(h => inspect(h))
136
- .join(', ')}],
103
+ noteHashReadRequests: ${inspect(this.noteHashReadRequests)},
104
+ nullifierReadRequests: ${inspect(this.nullifierReadRequests)},
105
+ scopedKeyValidationRequestsAndGenerators: ${inspect(this.scopedKeyValidationRequestsAndGenerators)},
137
106
  splitCounter: ${this.splitCounter.getSize()}
138
107
  `;
139
108
  }
@@ -17,23 +17,6 @@ export function countAccumulatedItems<T extends IsEmpty>(arr: T[]) {
17
17
  }, 0);
18
18
  }
19
19
 
20
- // Merges two arrays of length N into an array of length N.
21
- export function mergeAccumulatedData<T extends IsEmpty, N extends number>(
22
- arr0: Tuple<T, N>,
23
- arr1: Tuple<T, N>,
24
- length: N = arr0.length as N, // Need this for ts to infer the return Tuple length.
25
- ): Tuple<T, N> {
26
- const numNonEmptyItems0 = countAccumulatedItems(arr0);
27
- const numNonEmptyItems1 = countAccumulatedItems(arr1);
28
- if (numNonEmptyItems0 + numNonEmptyItems1 > length) {
29
- throw new Error('Combined non-empty items exceeded the maximum allowed.');
30
- }
31
-
32
- const arr = [...arr0] as Tuple<T, N>;
33
- arr1.slice(0, numNonEmptyItems1).forEach((item, i) => (arr[i + numNonEmptyItems0] = item));
34
- return arr;
35
- }
36
-
37
20
  // Sort items by a provided compare function. All empty items are padded to the right.
38
21
  function genericSort<T extends IsEmpty, N extends number>(
39
22
  arr: Tuple<T, N>,
@@ -61,11 +44,3 @@ export function sortByCounter<T extends Ordered & IsEmpty, N extends number>(
61
44
  ): Tuple<T, N> {
62
45
  return genericSort(arr, compareByCounter, ascending);
63
46
  }
64
-
65
- export function isEmptyArray<T extends IsEmpty>(arr: T[]): boolean {
66
- return arr.every(item => item.isEmpty());
67
- }
68
-
69
- export function getNonEmptyItems<T extends IsEmpty>(arr: T[]): T[] {
70
- return arr.filter(item => !item.isEmpty());
71
- }
@@ -13,7 +13,7 @@ import type { PublicKey } from '../keys/public_key.js';
13
13
  * @returns A derived shared secret.
14
14
  * @throws If the publicKey is zero.
15
15
  *
16
- * TODO(#12656): This function is kept around because of the getSharedSecret oracle. Nuke this once returning
16
+ * TODO(#12656): This function is kept around because of the utilityGetSharedSecret oracle. Nuke this once returning
17
17
  * the app-siloed secret.
18
18
  */
19
19
  export async function deriveEcdhSharedSecret(secretKey: GrumpkinScalar, publicKey: PublicKey): Promise<Point> {
@@ -1,13 +1,26 @@
1
- import { SHA256Trunc } from '@aztec/foundation/crypto';
2
1
  import { Fr } from '@aztec/foundation/fields';
3
- import { MerkleTreeCalculator, SiblingPath, UnbalancedMerkleTreeCalculator } from '@aztec/foundation/trees';
2
+ import {
3
+ SiblingPath,
4
+ UnbalancedMerkleTreeCalculator,
5
+ computeUnbalancedMerkleTreeRoot,
6
+ findLeafLevelAndIndex,
7
+ getMaxUnbalancedTreeDepth,
8
+ } from '@aztec/foundation/trees';
9
+
10
+ async function createOutHashTree(messages: Fr[]) {
11
+ const messageSubtreeHeight = getMaxUnbalancedTreeDepth(messages.length);
12
+ const calculator = UnbalancedMerkleTreeCalculator.create(messageSubtreeHeight);
13
+ await calculator.appendLeaves(messages.map(msg => msg.toBuffer()));
14
+ return calculator;
15
+ }
4
16
 
5
17
  export interface MessageRetrieval {
6
18
  getL2ToL1Messages(l2BlockNumber: number): Promise<Fr[][] | undefined>;
7
19
  }
8
20
 
9
21
  export type L2ToL1MembershipWitness = {
10
- l2MessageIndex: bigint;
22
+ root: Fr;
23
+ leafIndex: bigint;
11
24
  siblingPath: SiblingPath<number>;
12
25
  };
13
26
 
@@ -16,98 +29,76 @@ export async function computeL2ToL1MembershipWitness(
16
29
  l2BlockNumber: number,
17
30
  message: Fr,
18
31
  ): Promise<L2ToL1MembershipWitness | undefined> {
19
- const messagesPerTx = await messageRetriever.getL2ToL1Messages(l2BlockNumber);
20
- if (!messagesPerTx) {
32
+ const messagesForAllTxs = await messageRetriever.getL2ToL1Messages(l2BlockNumber);
33
+ if (!messagesForAllTxs) {
21
34
  return undefined;
22
35
  }
23
36
 
24
- // Find index of message in subtree and index of tx in a block
25
- let messageIndexInTx = -1,
26
- txIndex = -1;
27
- {
28
- txIndex = messagesPerTx.findIndex(messages => {
29
- const idx = messages.findIndex(msg => msg.equals(message));
30
- messageIndexInTx = Math.max(messageIndexInTx, idx);
31
- return idx !== -1;
32
- });
33
- }
37
+ return computeL2ToL1MembershipWitnessFromMessagesForAllTxs(messagesForAllTxs, message);
38
+ }
39
+
40
+ export async function computeL2ToL1MembershipWitnessFromMessagesForAllTxs(
41
+ messagesForAllTxs: Fr[][],
42
+ message: Fr,
43
+ ): Promise<L2ToL1MembershipWitness> {
44
+ // Find index of message in subtree and index of tx in a block.
45
+ let messageIndexInTx = -1;
46
+ const txIndex = messagesForAllTxs.findIndex(messages => {
47
+ messageIndexInTx = messages.findIndex(msg => msg.equals(message));
48
+ return messageIndexInTx !== -1;
49
+ });
34
50
 
35
51
  if (txIndex === -1) {
36
52
  throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
37
53
  }
38
54
 
39
- const hasher = new SHA256Trunc();
40
-
41
- // Get the message path in subtree and message subtree height
42
- let messagePathInSubtree: SiblingPath<number>;
43
- let messageSubtreeHeight: number;
44
- {
45
- const txMessages = messagesPerTx[txIndex];
46
- messageSubtreeHeight = txMessages.length <= 1 ? 1 : Math.ceil(Math.log2(txMessages.length));
47
- const calculator: MerkleTreeCalculator = await MerkleTreeCalculator.create(
48
- messageSubtreeHeight,
49
- Buffer.alloc(32, 0), // Zero leaf
50
- (lhs: Buffer, rhs: Buffer) => Promise.resolve(hasher.hash(lhs, rhs)),
51
- );
52
-
53
- const tree = await calculator.computeTree(txMessages.map(msg => msg.toBuffer()));
54
- const tempPath = tree.getSiblingPath(messageIndexInTx);
55
- messagePathInSubtree = new SiblingPath(tempPath.length, tempPath);
56
- }
57
-
58
- // If the number of txs is 1 we are dealing with a special case where the tx subtree itself is the whole block's
59
- // l2 to l1 message tree.
60
- const numTransactions = messagesPerTx.length;
61
- if (numTransactions === 1) {
62
- return {
63
- l2MessageIndex: BigInt(messageIndexInTx),
64
- siblingPath: messagePathInSubtree,
65
- };
66
- }
67
-
68
- // Calculate roots for all tx subtrees
69
- const txSubtreeRoots = await Promise.all(
70
- messagesPerTx.map(async (messages, _) => {
71
- // For a tx with no messages, we have to set an out hash of 0 to match what the circuit does.
72
- if (messages.length === 0) {
73
- return Fr.ZERO;
74
- }
75
-
76
- const txTreeHeight = messages.length <= 1 ? 1 : Math.ceil(Math.log2(messages.length));
77
- const calculator: MerkleTreeCalculator = await MerkleTreeCalculator.create(
78
- txTreeHeight,
79
- Buffer.alloc(32, 0), // Zero leaf
80
- (lhs: Buffer, rhs: Buffer) => Promise.resolve(hasher.hash(lhs, rhs)),
81
- );
82
-
83
- const root = await calculator.computeTreeRoot(messages.map(msg => msg.toBuffer()));
84
- return Fr.fromBuffer(root);
85
- }),
86
- );
87
-
88
- // Construct the top tree and compute the combined path
89
- let combinedPath: Buffer[];
90
- {
91
- const topTreeHeight = Math.ceil(Math.log2(txSubtreeRoots.length));
92
- // The root of this tree is the out_hash calculated in Noir => we truncate to match Noir's SHA
93
- const topTree = UnbalancedMerkleTreeCalculator.create(topTreeHeight, (lhs: Buffer, rhs: Buffer) =>
94
- Promise.resolve(hasher.hash(lhs, rhs)),
95
- );
96
- await topTree.appendLeaves(txSubtreeRoots.map(f => f.toBuffer()));
97
-
98
- const txPathInTopTree = await topTree.getSiblingPath(txSubtreeRoots[txIndex].toBigInt());
99
- // Append subtree path to top tree path
100
- combinedPath = messagePathInSubtree.toBufferArray().concat(txPathInTopTree.toBufferArray());
101
- }
102
-
103
- // Append binary index of subtree path to binary index of top tree path
104
- const combinedIndex = parseInt(
105
- txIndex.toString(2).concat(messageIndexInTx.toString(2).padStart(messageSubtreeHeight, '0')),
106
- 2,
107
- );
55
+ // Get the txOutHash and the sibling path of the message in the tx subtree.
56
+ const txMessages = messagesForAllTxs[txIndex];
57
+ const txOutHashTree = await createOutHashTree(txMessages);
58
+ const txOutHash = txOutHashTree.getRoot();
59
+ const messagePathInSubtree = await txOutHashTree.getSiblingPath(message);
60
+
61
+ // Calculate txOutHash for all txs.
62
+ const txSubtreeRoots = messagesForAllTxs.map((messages, i) => {
63
+ // For a tx with no messages, we have to set an out hash of 0 to match what the circuit does.
64
+ if (messages.length === 0) {
65
+ return Fr.ZERO;
66
+ }
67
+
68
+ if (i === txIndex) {
69
+ return Fr.fromBuffer(txOutHash);
70
+ }
71
+
72
+ const root = computeUnbalancedMerkleTreeRoot(messages.map(msg => msg.toBuffer()));
73
+ return Fr.fromBuffer(root);
74
+ });
75
+
76
+ // Construct the top tree.
77
+ // The leaves of this tree are the txOutHashes.
78
+ // The root of this tree is the out_hash calculated in the circuit.
79
+ const topTree = await createOutHashTree(txSubtreeRoots);
80
+ const root = Fr.fromBuffer(topTree.getRoot());
81
+
82
+ // Compute the combined sibling path by appending the tx subtree path to the top tree path.
83
+ const txPathInTopTree = await topTree.getSiblingPath(txOutHash);
84
+ const combinedPath = messagePathInSubtree.toBufferArray().concat(txPathInTopTree.toBufferArray());
85
+
86
+ // Compute the combined index.
87
+ // It is the index of the message in the balanced tree at its current height.
88
+ const txLeafPosition = findLeafLevelAndIndex(messagesForAllTxs.length, txIndex);
89
+ const messageLeafPosition = findLeafLevelAndIndex(txMessages.length, messageIndexInTx);
90
+ const numLeavesInLeftSubtrees = txLeafPosition.indexAtLevel * (1 << messageLeafPosition.level);
91
+ const combinedIndex = numLeavesInLeftSubtrees + messageLeafPosition.indexAtLevel;
108
92
 
109
93
  return {
110
- l2MessageIndex: BigInt(combinedIndex),
94
+ root,
95
+ leafIndex: BigInt(combinedIndex),
111
96
  siblingPath: new SiblingPath(combinedPath.length, combinedPath),
112
97
  };
113
98
  }
99
+
100
+ export function getL2ToL1MessageLeafId(
101
+ membershipWitness: Pick<L2ToL1MembershipWitness, 'leafIndex' | 'siblingPath'>,
102
+ ): bigint {
103
+ return 2n ** BigInt(membershipWitness.siblingPath.pathSize) + membershipWitness.leafIndex;
104
+ }
@@ -203,4 +203,13 @@ export class ScopedCountedL2ToL1Message {
203
203
  toBuffer(): Buffer {
204
204
  return serializeToBuffer(this.inner, this.contractAddress);
205
205
  }
206
+
207
+ static fromFields(fields: Fr[] | FieldReader) {
208
+ const reader = FieldReader.asReader(fields);
209
+ return new ScopedCountedL2ToL1Message(reader.readObject(CountedL2ToL1Message), reader.readObject(AztecAddress));
210
+ }
211
+
212
+ toFields(): Fr[] {
213
+ return serializeToFields(this.inner, this.contractAddress);
214
+ }
206
215
  }
@@ -12,10 +12,13 @@ import { NoteStatus } from './note_status.js';
12
12
  * @remarks This filter is applied as an intersection of all its params.
13
13
  */
14
14
  export type NotesFilter = {
15
+ /**
16
+ * The contract address the note belongs to.
17
+ * @remarks Providing a contract address is required as we need that information to trigger private state sync.
18
+ */
19
+ contractAddress: AztecAddress;
15
20
  /** Hash of a transaction from which to fetch the notes. */
16
21
  txHash?: TxHash;
17
- /** The contract address the note belongs to. */
18
- contractAddress?: AztecAddress;
19
22
  /** The specific storage location of the note on the contract. */
20
23
  storageSlot?: Fr;
21
24
  /** The recipient of the note (whose public key was used to encrypt the note). */
@@ -29,8 +32,8 @@ export type NotesFilter = {
29
32
  };
30
33
 
31
34
  export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
35
+ contractAddress: schemas.AztecAddress,
32
36
  txHash: TxHash.schema.optional(),
33
- contractAddress: schemas.AztecAddress.optional(),
34
37
  storageSlot: schemas.Fr.optional(),
35
38
  recipient: schemas.AztecAddress.optional(),
36
39
  status: z.nativeEnum(NoteStatus).optional(),
@@ -0,0 +1,35 @@
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+
3
+ import { CommitteeAttestation } from '../block/index.js';
4
+ import type { BlockAttestation } from './block_attestation.js';
5
+
6
+ /**
7
+ * Returns attestation signatures in the order of a series of provided ethereum addresses
8
+ * The rollup smart contract expects attestations to appear in the order of the committee
9
+ * @todo: perform this logic within the memory attestation store instead?
10
+ */
11
+ export function orderAttestations(
12
+ attestations: BlockAttestation[],
13
+ orderAddresses: EthAddress[],
14
+ ): CommitteeAttestation[] {
15
+ // Create a map of sender addresses to BlockAttestations
16
+ const attestationMap = new Map<string, CommitteeAttestation>();
17
+
18
+ for (const attestation of attestations) {
19
+ const sender = attestation.getSender();
20
+ if (sender) {
21
+ attestationMap.set(
22
+ sender.toString(),
23
+ CommitteeAttestation.fromAddressAndSignature(sender, attestation.signature),
24
+ );
25
+ }
26
+ }
27
+
28
+ // Create the ordered array based on the orderAddresses, else return an empty attestation
29
+ const orderedAttestations = orderAddresses.map(address => {
30
+ const addressString = address.toString();
31
+ return attestationMap.get(addressString) || CommitteeAttestation.fromAddress(address);
32
+ });
33
+
34
+ return orderedAttestations;
35
+ }
@@ -66,10 +66,9 @@ export class BlockAttestation extends Gossipable {
66
66
  return this.payload.header.slotNumber;
67
67
  }
68
68
 
69
- /**Get sender
70
- *
71
- * Lazily evaluate and cache the sender of the attestation
72
- * @returns The sender of the attestation
69
+ /**
70
+ * Lazily evaluate and cache the signer of the attestation
71
+ * @returns The signer of the attestation
73
72
  */
74
73
  getSender(): EthAddress {
75
74
  if (!this.sender) {
@@ -5,6 +5,8 @@ import { Signature } from '@aztec/foundation/eth-signature';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
7
7
 
8
+ import type { BlockInfo } from '../block/l2_block.js';
9
+ import { TxHash } from '../tx/index.js';
8
10
  import { Tx } from '../tx/tx.js';
9
11
  import type { UInt32 } from '../types/index.js';
10
12
  import { ConsensusPayload } from './consensus_payload.js';
@@ -47,6 +49,9 @@ export class BlockProposal extends Gossipable {
47
49
  /** The signer of the BlockProposal over the header of the new block*/
48
50
  public readonly signature: Signature,
49
51
 
52
+ /** The sequence of transactions in the block */
53
+ public readonly txHashes: TxHash[],
54
+
50
55
  // Note(md): this is placed after the txs payload in order to be backwards compatible with previous versions
51
56
  /** The transactions in the block */
52
57
  public readonly txs?: Tx[],
@@ -66,9 +71,19 @@ export class BlockProposal extends Gossipable {
66
71
  return this.payload.header.slotNumber;
67
72
  }
68
73
 
74
+ toBlockInfo(): BlockInfo {
75
+ return {
76
+ blockNumber: this.blockNumber,
77
+ slotNumber: this.slotNumber.toNumber(),
78
+ archive: this.archive.toString(),
79
+ txCount: this.txHashes.length,
80
+ };
81
+ }
82
+
69
83
  static async createProposalFromSigner(
70
84
  blockNumber: UInt32,
71
85
  payload: ConsensusPayload,
86
+ txHashes: TxHash[],
72
87
  // Note(md): Provided separately to tx hashes such that this function can be optional
73
88
  txs: Tx[] | undefined,
74
89
  payloadSigner: (payload: Buffer32) => Promise<Signature>,
@@ -76,7 +91,7 @@ export class BlockProposal extends Gossipable {
76
91
  const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
77
92
  const sig = await payloadSigner(hashed);
78
93
 
79
- return new BlockProposal(blockNumber, payload, sig, txs);
94
+ return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
80
95
  }
81
96
 
82
97
  /**Get Sender
@@ -97,7 +112,7 @@ export class BlockProposal extends Gossipable {
97
112
  }
98
113
 
99
114
  toBuffer(): Buffer {
100
- const buffer: any[] = [this.blockNumber, this.payload, this.signature];
115
+ const buffer: any[] = [this.blockNumber, this.payload, this.signature, this.txHashes.length, this.txHashes];
101
116
  if (this.txs) {
102
117
  buffer.push(this.txs.length);
103
118
  buffer.push(this.txs);
@@ -111,13 +126,14 @@ export class BlockProposal extends Gossipable {
111
126
  const blockNumber = reader.readNumber();
112
127
  const payload = reader.readObject(ConsensusPayload);
113
128
  const sig = reader.readObject(Signature);
129
+ const txHashes = reader.readArray(reader.readNumber(), TxHash);
114
130
 
115
131
  if (!reader.isEmpty()) {
116
132
  const txs = reader.readArray(reader.readNumber(), Tx);
117
- return new BlockProposal(blockNumber, payload, sig, txs);
133
+ return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
118
134
  }
119
135
 
120
- return new BlockProposal(blockNumber, payload, sig);
136
+ return new BlockProposal(blockNumber, payload, sig, txHashes);
121
137
  }
122
138
 
123
139
  getSize(): number {
@@ -125,7 +141,9 @@ export class BlockProposal extends Gossipable {
125
141
  4 /* blockNumber */ +
126
142
  this.payload.getSize() +
127
143
  this.signature.getSize() +
128
- (this.txs ? this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) : 0)
144
+ 4 /* txHashes.length */ +
145
+ this.txHashes.length * TxHash.SIZE +
146
+ (this.txs ? 4 /* txs.length */ + this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) : 0)
129
147
  );
130
148
  }
131
149
  }