@aztec/pxe 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c

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 (266) hide show
  1. package/dest/access_scopes.d.ts +9 -0
  2. package/dest/access_scopes.d.ts.map +1 -0
  3. package/dest/access_scopes.js +6 -0
  4. package/dest/bin/check_oracle_version.js +1 -1
  5. package/dest/block_synchronizer/block_synchronizer.d.ts +13 -5
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  7. package/dest/block_synchronizer/block_synchronizer.js +74 -20
  8. package/dest/config/index.d.ts +3 -1
  9. package/dest/config/index.d.ts.map +1 -1
  10. package/dest/config/index.js +17 -0
  11. package/dest/config/package_info.js +1 -1
  12. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  13. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  15. package/dest/contract_function_simulator/contract_function_simulator.d.ts +57 -34
  16. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/contract_function_simulator.js +197 -82
  18. package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
  19. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/execution_note_cache.js +45 -28
  21. package/dest/contract_function_simulator/index.d.ts +2 -2
  22. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/index.js +1 -1
  24. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
  25. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -4
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  30. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  31. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  33. package/dest/contract_function_simulator/oracle/interfaces.d.ts +17 -13
  34. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  36. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
  38. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
  40. package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -10
  41. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/oracle/oracle.js +67 -44
  43. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
  44. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
  46. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -50
  47. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  48. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +83 -54
  49. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +67 -33
  50. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +131 -110
  52. package/dest/contract_logging.d.ts +22 -0
  53. package/dest/contract_logging.d.ts.map +1 -0
  54. package/dest/contract_logging.js +23 -0
  55. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  56. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  57. package/dest/contract_sync/contract_sync_service.js +97 -0
  58. package/dest/contract_sync/helpers.d.ts +29 -0
  59. package/dest/contract_sync/helpers.d.ts.map +1 -0
  60. package/dest/contract_sync/helpers.js +55 -0
  61. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  62. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  63. package/dest/debug/pxe_debug_utils.js +28 -17
  64. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  65. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  66. package/dest/entrypoints/client/bundle/index.js +3 -0
  67. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  68. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  69. package/dest/entrypoints/client/bundle/utils.js +31 -8
  70. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  71. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  72. package/dest/entrypoints/client/lazy/index.js +3 -0
  73. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  74. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  75. package/dest/entrypoints/client/lazy/utils.js +32 -9
  76. package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
  77. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  78. package/dest/entrypoints/server/index.d.ts +5 -1
  79. package/dest/entrypoints/server/index.d.ts.map +1 -1
  80. package/dest/entrypoints/server/index.js +4 -0
  81. package/dest/entrypoints/server/utils.d.ts +1 -1
  82. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/server/utils.js +39 -16
  84. package/dest/events/event_service.d.ts +6 -6
  85. package/dest/events/event_service.d.ts.map +1 -1
  86. package/dest/events/event_service.js +19 -22
  87. package/dest/events/private_event_filter_validator.d.ts +5 -5
  88. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  89. package/dest/events/private_event_filter_validator.js +5 -6
  90. package/dest/job_coordinator/job_coordinator.d.ts +75 -0
  91. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  92. package/dest/job_coordinator/job_coordinator.js +94 -0
  93. package/dest/logs/log_service.d.ts +8 -5
  94. package/dest/logs/log_service.d.ts.map +1 -1
  95. package/dest/logs/log_service.js +28 -30
  96. package/dest/notes/note_service.d.ts +10 -9
  97. package/dest/notes/note_service.d.ts.map +1 -1
  98. package/dest/notes/note_service.js +34 -38
  99. package/dest/notes_filter.d.ts +25 -0
  100. package/dest/notes_filter.d.ts.map +1 -0
  101. package/dest/notes_filter.js +4 -0
  102. package/dest/oracle_version.d.ts +3 -3
  103. package/dest/oracle_version.d.ts.map +1 -1
  104. package/dest/oracle_version.js +4 -3
  105. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  106. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  107. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  108. package/dest/private_kernel/hints/index.d.ts +3 -3
  109. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  110. package/dest/private_kernel/hints/index.js +2 -2
  111. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  112. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  113. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +16 -10
  114. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  115. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  116. package/dest/private_kernel/private_kernel_execution_prover.js +12 -13
  117. package/dest/private_kernel/private_kernel_oracle.d.ts +24 -24
  118. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  119. package/dest/private_kernel/private_kernel_oracle.js +94 -2
  120. package/dest/pxe.d.ts +76 -58
  121. package/dest/pxe.d.ts.map +1 -1
  122. package/dest/pxe.js +149 -138
  123. package/dest/storage/address_store/address_store.d.ts +1 -1
  124. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  125. package/dest/storage/address_store/address_store.js +12 -11
  126. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  127. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  128. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  129. package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
  130. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  131. package/dest/storage/capsule_store/capsule_store.js +130 -23
  132. package/dest/storage/contract_store/contract_store.d.ts +42 -16
  133. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  134. package/dest/storage/contract_store/contract_store.js +157 -84
  135. package/dest/storage/metadata.d.ts +1 -1
  136. package/dest/storage/metadata.js +1 -1
  137. package/dest/storage/note_store/note_store.d.ts +50 -51
  138. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  139. package/dest/storage/note_store/note_store.js +284 -263
  140. package/dest/storage/note_store/stored_note.d.ts +16 -0
  141. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  142. package/dest/storage/note_store/stored_note.js +43 -0
  143. package/dest/storage/private_event_store/private_event_store.d.ts +47 -7
  144. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  145. package/dest/storage/private_event_store/private_event_store.js +231 -73
  146. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  147. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  148. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  149. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
  150. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  151. package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
  152. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  153. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  154. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  155. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
  156. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  157. package/dest/storage/tagging_store/sender_tagging_store.js +253 -101
  158. package/dest/tagging/constants.d.ts +2 -0
  159. package/dest/tagging/constants.d.ts.map +1 -0
  160. package/dest/tagging/constants.js +10 -0
  161. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  162. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  163. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  164. package/dest/tagging/index.d.ts +3 -2
  165. package/dest/tagging/index.d.ts.map +1 -1
  166. package/dest/tagging/index.js +2 -10
  167. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
  168. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  169. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +12 -12
  170. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  171. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
  172. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  173. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
  174. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
  175. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  176. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
  177. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  178. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  179. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  180. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -2
  181. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  182. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +10 -5
  183. package/package.json +27 -18
  184. package/src/access_scopes.ts +9 -0
  185. package/src/bin/check_oracle_version.ts +1 -0
  186. package/src/block_synchronizer/block_synchronizer.ts +93 -32
  187. package/src/config/index.ts +14 -0
  188. package/src/config/package_info.ts +1 -1
  189. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  190. package/src/contract_function_simulator/contract_function_simulator.ts +350 -143
  191. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  192. package/src/contract_function_simulator/index.ts +1 -1
  193. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -2
  194. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  195. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  196. package/src/contract_function_simulator/oracle/interfaces.ts +22 -12
  197. package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
  198. package/src/contract_function_simulator/oracle/oracle.ts +79 -47
  199. package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
  200. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +119 -137
  201. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +198 -115
  202. package/src/contract_logging.ts +39 -0
  203. package/src/contract_sync/contract_sync_service.ts +152 -0
  204. package/src/contract_sync/helpers.ts +98 -0
  205. package/src/debug/pxe_debug_utils.ts +63 -18
  206. package/src/entrypoints/client/bundle/index.ts +3 -0
  207. package/src/entrypoints/client/bundle/utils.ts +23 -16
  208. package/src/entrypoints/client/lazy/index.ts +3 -0
  209. package/src/entrypoints/client/lazy/utils.ts +24 -17
  210. package/src/entrypoints/pxe_creation_options.ts +4 -2
  211. package/src/entrypoints/server/index.ts +4 -0
  212. package/src/entrypoints/server/utils.ts +33 -41
  213. package/src/events/event_service.ts +19 -25
  214. package/src/events/private_event_filter_validator.ts +3 -5
  215. package/src/job_coordinator/job_coordinator.ts +150 -0
  216. package/src/logs/log_service.ts +40 -34
  217. package/src/notes/note_service.ts +41 -45
  218. package/src/notes_filter.ts +26 -0
  219. package/src/oracle_version.ts +4 -3
  220. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  221. package/src/private_kernel/hints/index.ts +2 -2
  222. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +39 -28
  223. package/src/private_kernel/private_kernel_execution_prover.ts +15 -14
  224. package/src/private_kernel/private_kernel_oracle.ts +116 -36
  225. package/src/pxe.ts +280 -209
  226. package/src/storage/address_store/address_store.ts +15 -15
  227. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  228. package/src/storage/capsule_store/capsule_store.ts +159 -23
  229. package/src/storage/contract_store/contract_store.ts +186 -96
  230. package/src/storage/metadata.ts +1 -1
  231. package/src/storage/note_store/note_store.ts +326 -320
  232. package/src/storage/note_store/stored_note.ts +48 -0
  233. package/src/storage/private_event_store/private_event_store.ts +301 -79
  234. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  235. package/src/storage/tagging_store/recipient_tagging_store.ts +106 -20
  236. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  237. package/src/storage/tagging_store/sender_tagging_store.ts +294 -109
  238. package/src/tagging/constants.ts +10 -0
  239. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  240. package/src/tagging/index.ts +2 -11
  241. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +25 -11
  242. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  243. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
  244. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +10 -7
  245. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
  246. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
  247. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  248. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  249. package/dest/contract_function_simulator/proxied_node.js +0 -27
  250. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  251. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  252. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  253. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  254. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  255. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  256. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  257. package/dest/public_storage/public_storage_service.d.ts +0 -24
  258. package/dest/public_storage/public_storage_service.d.ts.map +0 -1
  259. package/dest/public_storage/public_storage_service.js +0 -26
  260. package/dest/tree_membership/tree_membership_service.d.ts +0 -52
  261. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  262. package/dest/tree_membership/tree_membership_service.js +0 -84
  263. package/src/contract_function_simulator/proxied_node.ts +0 -33
  264. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
  265. package/src/public_storage/public_storage_service.ts +0 -33
  266. package/src/tree_membership/tree_membership_service.ts +0 -112
@@ -1,4 +1,4 @@
1
- import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
1
+ import { MAX_TX_LIFETIME } from '@aztec/constants';
2
2
  import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
3
3
  import type { UInt64 } from '@aztec/stdlib/types';
4
4
 
@@ -8,12 +8,12 @@ const ROUNDED_DURATIONS = [
8
8
  1, // 1 second
9
9
  ];
10
10
 
11
- function roundTimestamp(blockTimestamp: bigint, includeByTimestamp: bigint): UInt64 {
11
+ function roundTimestamp(blockTimestamp: bigint, expirationTimestamp: bigint): UInt64 {
12
12
  return ROUNDED_DURATIONS.reduce((timestamp, duration) => {
13
13
  if (timestamp <= blockTimestamp) {
14
14
  // The timestamp must be greater than the block timestamp.
15
15
  // If it is too small, round it down again using a smaller duration.
16
- const totalDuration = includeByTimestamp - blockTimestamp;
16
+ const totalDuration = expirationTimestamp - blockTimestamp;
17
17
  const roundedDuration = totalDuration - (totalDuration % BigInt(duration));
18
18
  return blockTimestamp + roundedDuration;
19
19
  }
@@ -21,36 +21,36 @@ function roundTimestamp(blockTimestamp: bigint, includeByTimestamp: bigint): UIn
21
21
  }, 0n);
22
22
  }
23
23
 
24
- export function computeTxIncludeByTimestamp(
24
+ export function computeTxExpirationTimestamp(
25
25
  previousKernel: PrivateKernelCircuitPublicInputs,
26
- maxDuration = MAX_INCLUDE_BY_TIMESTAMP_DURATION,
26
+ txLifetime = MAX_TX_LIFETIME,
27
27
  ): UInt64 {
28
- if (maxDuration > MAX_INCLUDE_BY_TIMESTAMP_DURATION) {
28
+ if (txLifetime > MAX_TX_LIFETIME) {
29
29
  throw new Error(
30
- `Custom max duration cannot be greater than the max allowed. Max allowed: ${MAX_INCLUDE_BY_TIMESTAMP_DURATION}. Custom value: ${maxDuration}.`,
30
+ `Custom tx lifetime cannot be greater than the max allowed. Max allowed: ${MAX_TX_LIFETIME}. Custom value: ${txLifetime}.`,
31
31
  );
32
32
  }
33
33
 
34
34
  const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
35
- const maxTimestamp = anchorBlockTimestamp + BigInt(maxDuration);
36
- const includeByTimestamp = previousKernel.includeByTimestamp;
35
+ const maxTimestamp = anchorBlockTimestamp + BigInt(txLifetime);
36
+ const expirationTimestamp = previousKernel.expirationTimestamp;
37
37
 
38
- // If the includeByTimestamp set during the tx execution is greater than or equal to the max allowed duration,
38
+ // If the expirationTimestamp set during the tx execution is greater than or equal to the max allowed duration,
39
39
  // use the maximum allowed timestamp.
40
40
  // Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
41
- if (includeByTimestamp >= maxTimestamp) {
41
+ if (expirationTimestamp >= maxTimestamp) {
42
42
  return maxTimestamp;
43
43
  }
44
44
 
45
45
  // Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
46
46
  // This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
47
- const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, includeByTimestamp);
47
+ const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, expirationTimestamp);
48
48
 
49
49
  // The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
50
50
  // Future blocks will have a greater timestamp, so the tx would never be included.
51
51
  if (roundedTimestamp <= anchorBlockTimestamp) {
52
52
  throw new Error(
53
- `Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestamp}.`,
53
+ `Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestamp}.`,
54
54
  );
55
55
  }
56
56
 
@@ -1,2 +1,2 @@
1
- export * from './build_private_kernel_reset_private_inputs.js';
2
- export * from './compute_tx_include_by_timestamp.js';
1
+ export * from './private_kernel_reset_private_inputs_builder.js';
2
+ export * from './compute_tx_expiration_timestamp.js';
@@ -26,7 +26,7 @@ import {
26
26
  type PrivateKernelSimulateOutput,
27
27
  ReadRequestActionEnum,
28
28
  ReadRequestResetActions,
29
- type ScopedKeyValidationRequestAndGenerator,
29
+ type ScopedKeyValidationRequestAndSeparator,
30
30
  ScopedNoteHash,
31
31
  ScopedNullifier,
32
32
  ScopedReadRequest,
@@ -68,9 +68,9 @@ function getNullifierMembershipWitnessResolver(oracle: PrivateKernelOracle) {
68
68
  };
69
69
  }
70
70
 
71
- async function getMasterSecretKeysAndAppKeyGenerators(
71
+ async function getMasterSecretKeysAndKeyTypeDomainSeparators(
72
72
  keyValidationRequests: ClaimedLengthArray<
73
- ScopedKeyValidationRequestAndGenerator,
73
+ ScopedKeyValidationRequestAndSeparator,
74
74
  typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX
75
75
  >,
76
76
  numRequestsToVerify: number,
@@ -138,7 +138,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
138
138
  }
139
139
  }
140
140
 
141
- async build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>) {
141
+ async build(oracle: PrivateKernelOracle) {
142
142
  if (privateKernelResetDimensionNames.every(name => !this.requestedDimensions[name])) {
143
143
  throw new Error('Reset is not required.');
144
144
  }
@@ -157,16 +157,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
157
157
  allowRemainder,
158
158
  );
159
159
 
160
- const previousVkMembershipWitness = await oracle.getVkMembershipWitness(
161
- this.previousKernelOutput.verificationKey.keyAsFields,
162
- );
163
- const vkData = new VkData(
164
- this.previousKernelOutput.verificationKey,
165
- Number(previousVkMembershipWitness.leafIndex),
166
- previousVkMembershipWitness.siblingPath,
167
- );
168
- const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
169
-
170
160
  this.reduceReadRequestActions(
171
161
  this.noteHashResetActions,
172
162
  dimensions.NOTE_HASH_PENDING_READ,
@@ -178,30 +168,51 @@ export class PrivateKernelResetPrivateInputsBuilder {
178
168
  dimensions.NULLIFIER_SETTLED_READ,
179
169
  );
180
170
 
181
- // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
182
- const paddedSideEffects = PaddedSideEffects.empty();
183
-
184
- return new PrivateKernelResetCircuitPrivateInputs(
185
- previousKernelData,
186
- paddedSideEffects,
187
- new PrivateKernelResetHints(
188
- await buildNoteHashReadRequestHintsFromResetActions(
171
+ // Execute all the expensive node querying operations in parallel.
172
+ const [previousVkMembershipWitness, noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints] =
173
+ await Promise.all([
174
+ oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields),
175
+ buildNoteHashReadRequestHintsFromResetActions<
176
+ typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
177
+ typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX
178
+ >(
189
179
  oracle,
190
180
  this.previousKernel.validationRequests.noteHashReadRequests,
191
181
  this.previousKernel.end.noteHashes,
192
182
  this.noteHashResetActions,
193
- noteHashLeafIndexMap,
194
183
  ),
195
- await buildNullifierReadRequestHintsFromResetActions(
184
+ buildNullifierReadRequestHintsFromResetActions<
185
+ typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
186
+ typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX
187
+ >(
196
188
  { getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle) },
197
189
  this.previousKernel.validationRequests.nullifierReadRequests,
198
190
  this.nullifierResetActions,
199
191
  ),
200
- await getMasterSecretKeysAndAppKeyGenerators(
201
- this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators,
192
+ getMasterSecretKeysAndKeyTypeDomainSeparators(
193
+ this.previousKernel.validationRequests.scopedKeyValidationRequestsAndSeparators,
202
194
  dimensions.KEY_VALIDATION,
203
195
  oracle,
204
196
  ),
197
+ ]);
198
+
199
+ const vkData = new VkData(
200
+ this.previousKernelOutput.verificationKey,
201
+ Number(previousVkMembershipWitness.leafIndex),
202
+ previousVkMembershipWitness.siblingPath,
203
+ );
204
+ const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
205
+
206
+ // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
207
+ const paddedSideEffects = PaddedSideEffects.empty();
208
+
209
+ return new PrivateKernelResetCircuitPrivateInputs(
210
+ previousKernelData,
211
+ paddedSideEffects,
212
+ new PrivateKernelResetHints(
213
+ noteHashReadRequestHints,
214
+ nullifierReadRequestHints,
215
+ keyValidationHints,
205
216
  this.transientDataSquashingHints,
206
217
  ),
207
218
  dimensions,
@@ -346,8 +357,8 @@ export class PrivateKernelResetPrivateInputsBuilder {
346
357
  }
347
358
 
348
359
  private needsResetNullifierKeys() {
349
- const numCurr = this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators.claimedLength;
350
- const numNext = this.nextIteration ? this.nextIteration.keyValidationRequestsAndGenerators.claimedLength : 0;
360
+ const numCurr = this.previousKernel.validationRequests.scopedKeyValidationRequestsAndSeparators.claimedLength;
361
+ const numNext = this.nextIteration ? this.nextIteration.keyValidationRequestsAndSeparators.claimedLength : 0;
351
362
  const maxAmountToKeep = !this.nextIteration ? 0 : MAX_KEY_VALIDATION_REQUESTS_PER_TX;
352
363
  if (numCurr + numNext <= maxAmountToKeep) {
353
364
  return false;
@@ -1,6 +1,6 @@
1
1
  import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { createLogger } from '@aztec/foundation/log';
3
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
4
4
  import { pushTestData } from '@aztec/foundation/testing';
5
5
  import { Timer } from '@aztec/foundation/timer';
6
6
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
@@ -28,13 +28,12 @@ import {
28
28
  type PrivateCallExecutionResult,
29
29
  type PrivateExecutionResult,
30
30
  TxRequest,
31
- collectNoteHashLeafIndexMap,
32
31
  collectNoteHashNullifierCounterMap,
33
32
  getFinalMinRevertibleSideEffectCounter,
34
33
  } from '@aztec/stdlib/tx';
35
34
  import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
36
35
 
37
- import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
36
+ import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
38
37
  import type { PrivateKernelOracle } from './private_kernel_oracle.js';
39
38
 
40
39
  const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
@@ -57,13 +56,16 @@ export interface PrivateKernelExecutionProverConfig {
57
56
  * inform state tree updates.
58
57
  */
59
58
  export class PrivateKernelExecutionProver {
60
- private log = createLogger('pxe:private-kernel-execution-prover');
59
+ private log: Logger;
61
60
 
62
61
  constructor(
63
62
  private oracle: PrivateKernelOracle,
64
63
  private proofCreator: PrivateKernelProver,
65
64
  private fakeProofs = false,
66
- ) {}
65
+ bindings?: LoggerBindings,
66
+ ) {
67
+ this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
68
+ }
67
69
 
68
70
  /**
69
71
  * Generate a proof for a given transaction request and execution result.
@@ -101,7 +103,6 @@ export class PrivateKernelExecutionProver {
101
103
 
102
104
  const executionSteps: PrivateExecutionStep[] = [];
103
105
 
104
- const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
105
106
  const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
106
107
  const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
107
108
  const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
@@ -116,7 +117,7 @@ export class PrivateKernelExecutionProver {
116
117
  );
117
118
  while (resetBuilder.needsReset()) {
118
119
  const witgenTimer = new Timer();
119
- const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
120
+ const privateInputs = await resetBuilder.build(this.oracle);
120
121
  output = generateWitnesses
121
122
  ? await this.proofCreator.generateResetOutput(privateInputs)
122
123
  : await this.proofCreator.simulateReset(privateInputs);
@@ -224,7 +225,7 @@ export class PrivateKernelExecutionProver {
224
225
  );
225
226
  while (resetBuilder.needsReset()) {
226
227
  const witgenTimer = new Timer();
227
- const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
228
+ const privateInputs = await resetBuilder.build(this.oracle);
228
229
  output = generateWitnesses
229
230
  ? await this.proofCreator.generateResetOutput(privateInputs)
230
231
  : await this.proofCreator.simulateReset(privateInputs);
@@ -259,20 +260,20 @@ export class PrivateKernelExecutionProver {
259
260
  // TODO: Enable padding once we better understand the final amounts to pad to.
260
261
  const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
261
262
 
262
- // Use the aggregated includeByTimestamp set throughout the tx execution.
263
- // TODO: Call `computeTxIncludeByTimestamp` to round the value down and reduce precision, improving privacy.
264
- const includeByTimestampUpperBound = previousKernelData.publicInputs.includeByTimestamp;
263
+ // Use the aggregated expirationTimestamp set throughout the tx execution.
264
+ // TODO: Call `computeTxExpirationTimestamp` to round the value down and reduce precision, improving privacy.
265
+ const expirationTimestampUpperBound = previousKernelData.publicInputs.expirationTimestamp;
265
266
  const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
266
- if (includeByTimestampUpperBound <= anchorBlockTimestamp) {
267
+ if (expirationTimestampUpperBound <= anchorBlockTimestamp) {
267
268
  throw new Error(
268
- `Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestampUpperBound}.`,
269
+ `Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestampUpperBound}.`,
269
270
  );
270
271
  }
271
272
 
272
273
  const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
273
274
  previousKernelData,
274
275
  paddedSideEffectAmounts,
275
- includeByTimestampUpperBound,
276
+ expirationTimestampUpperBound,
276
277
  );
277
278
 
278
279
  const witgenTimer = new Timer();
@@ -1,72 +1,152 @@
1
- import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
1
+ import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
4
4
  import { MembershipWitness } from '@aztec/foundation/trees';
5
+ import type { KeyStore } from '@aztec/key-store';
6
+ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
7
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
8
  import type { FunctionSelector } from '@aztec/stdlib/abi';
6
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
+ import { BlockHash } from '@aztec/stdlib/block';
11
+ import { type ContractInstanceWithAddress, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
12
+ import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
13
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
14
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
15
  import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
8
- import type { PublicKeys } from '@aztec/stdlib/keys';
9
16
  import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
10
17
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
11
18
 
19
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
20
+
12
21
  /**
13
22
  * Provides functionality needed by the private kernel for interacting with our state trees.
14
- * This is either PrivateKernelOracleImpl, or a mocked test implementation.
15
23
  */
16
- export interface PrivateKernelOracle {
24
+ export class PrivateKernelOracle {
25
+ constructor(
26
+ private contractStore: ContractStore,
27
+ private keyStore: KeyStore,
28
+ private node: AztecNode,
29
+ private blockHash: BlockHash,
30
+ ) {}
31
+
17
32
  /** Retrieves the preimage of a contract address from the registered contract instances db. */
18
- getContractAddressPreimage(address: AztecAddress): Promise<{
19
- saltedInitializationHash: Fr;
20
- publicKeys: PublicKeys;
21
- currentContractClassId: Fr;
22
- originalContractClassId: Fr;
23
- }>;
33
+ public async getContractAddressPreimage(
34
+ address: AztecAddress,
35
+ ): Promise<ContractInstanceWithAddress & { saltedInitializationHash: Fr }> {
36
+ const instance = await this.contractStore.getContractInstance(address);
37
+ if (!instance) {
38
+ throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
39
+ }
40
+ return {
41
+ saltedInitializationHash: await computeSaltedInitializationHash(instance),
42
+ ...instance,
43
+ };
44
+ }
24
45
 
25
46
  /** Retrieves the preimage of a contract class id from the contract classes db. */
26
- getContractClassIdPreimage(
27
- contractClassId: Fr,
28
- ): Promise<{ artifactHash: Fr; publicBytecodeCommitment: Fr; privateFunctionsRoot: Fr }>;
47
+ public async getContractClassIdPreimage(contractClassId: Fr) {
48
+ const contractClass = await this.contractStore.getContractClassWithPreimage(contractClassId);
49
+ if (!contractClass) {
50
+ throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
51
+ }
52
+ return {
53
+ artifactHash: contractClass.artifactHash,
54
+ privateFunctionsRoot: contractClass.privateFunctionsRoot,
55
+ publicBytecodeCommitment: contractClass.publicBytecodeCommitment,
56
+ };
57
+ }
29
58
 
30
- /**
31
- * Returns a membership witness with the sibling path and leaf index in our private functions tree.
32
- */
33
- getFunctionMembershipWitness(
59
+ /** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
60
+ public async getFunctionMembershipWitness(
34
61
  contractClassId: Fr,
35
62
  selector: FunctionSelector,
36
- ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
63
+ ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
64
+ const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
65
+ if (!membershipWitness) {
66
+ throw new Error(
67
+ `Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
68
+ );
69
+ }
70
+ return membershipWitness;
71
+ }
37
72
 
38
73
  /**
39
74
  * Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
40
75
  * Used to validate the previous kernel's verification key.
41
76
  */
42
- getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
77
+ public getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>> {
78
+ const leafIndex = getVKIndex(vk);
79
+ return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
80
+ }
43
81
 
44
- /**
45
- * Returns a membership witness with the sibling path and leaf index in our private function indexed merkle tree.
46
- */ getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
82
+ /** Returns a membership witness with the sibling path and leaf index in our note hash tree. */
83
+ getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
84
+ return this.node.getNoteHashMembershipWitness(this.blockHash, noteHash);
85
+ }
47
86
 
48
- /**
49
- * Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
50
- */
51
- getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
52
- /**
53
- * Returns the root of our note hash merkle tree.
54
- */
55
- getNoteHashTreeRoot(): Promise<Fr>;
87
+ /** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
88
+ getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
89
+ return this.node.getNullifierMembershipWitness(this.blockHash, nullifier);
90
+ }
91
+
92
+ /** Returns the root of our note hash merkle tree. */
93
+ async getNoteHashTreeRoot(): Promise<Fr> {
94
+ const header = await this.node.getBlockHeader(this.blockHash);
95
+ if (!header) {
96
+ throw new Error(`No block header found for block hash ${this.blockHash}`);
97
+ }
98
+ return header.state.partial.noteHashTree.root;
99
+ }
56
100
 
57
101
  /**
58
102
  * Retrieves the sk_m corresponding to the pk_m.
59
103
  * @throws If the provided public key is not associated with any of the registered accounts.
60
- * @param pkM - The master public key to get secret key for.
104
+ * @param masterPublicKey - The master public key to get secret key for.
61
105
  * @returns A Promise that resolves to sk_m.
62
106
  * @dev Used when feeding the sk_m to the kernel circuit for keys verification.
63
107
  */
64
- getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
108
+ public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
109
+ return this.keyStore.getMasterSecretKey(masterPublicKey);
110
+ }
65
111
 
66
112
  /** Use debug data to get the function name corresponding to a selector. */
67
- getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
113
+ public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
114
+ return this.contractStore.getDebugFunctionName(contractAddress, selector);
115
+ }
116
+
117
+ /**
118
+ * Returns a membership witness and leaf index to our public data indexed merkle tree,
119
+ * along with an associated DelayedPublicMutable containing the class ID to update.
120
+ */
121
+ public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
122
+ const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
123
+ await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
124
+
125
+ const hashLeafSlot = await computePublicDataTreeLeafSlot(
126
+ ProtocolContractAddress.ContractInstanceRegistry,
127
+ delayedPublicMutableHashSlot,
128
+ );
129
+ const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockHash, hashLeafSlot);
130
+
131
+ if (!updatedClassIdWitness) {
132
+ throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
133
+ }
134
+
135
+ const readStorage = (storageSlot: Fr) =>
136
+ this.node.getPublicStorageAt(this.blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
137
+ const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
138
+ delayedPublicMutableSlot,
139
+ readStorage,
140
+ );
68
141
 
69
- /** Returns a membership witness and leaf index to our public data indexed merkle tree,
70
- * along with an associated DelayedPublicMutable containing the class ID to update. */
71
- getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
142
+ return new UpdatedClassIdHints(
143
+ new MembershipWitness(
144
+ PUBLIC_DATA_TREE_HEIGHT,
145
+ updatedClassIdWitness.index,
146
+ updatedClassIdWitness.siblingPath.toTuple(),
147
+ ),
148
+ updatedClassIdWitness.leafPreimage,
149
+ delayedPublicMutableValues,
150
+ );
151
+ }
72
152
  }