@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
@@ -3,22 +3,22 @@ import type { EventSelector } from '@aztec/stdlib/abi';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { siloNullifier } from '@aztec/stdlib/hash';
5
5
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
6
- import { MerkleTreeId } from '@aztec/stdlib/trees';
7
- import type { TxHash } from '@aztec/stdlib/tx';
6
+ import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
8
7
 
9
- import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
10
8
  import { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
11
9
 
12
10
  export class EventService {
13
11
  constructor(
14
- private readonly anchorBlockStore: AnchorBlockStore,
12
+ private readonly anchorBlockHeader: BlockHeader,
15
13
  private readonly aztecNode: AztecNode,
16
14
  private readonly privateEventStore: PrivateEventStore,
15
+ private readonly jobId: string,
17
16
  ) {}
18
17
 
19
- public async deliverEvent(
18
+ public async validateAndStoreEvent(
20
19
  contractAddress: AztecAddress,
21
20
  selector: EventSelector,
21
+ randomness: Fr,
22
22
  content: Fr[],
23
23
  eventCommitment: Fr,
24
24
  txHash: TxHash,
@@ -28,50 +28,44 @@ export class EventService {
28
28
  // (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
29
29
  // maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
30
30
  // since `fetchTaggedLogs` only processes logs up to the synced block.
31
- const [syncedBlockHeader, siloedEventCommitment, txEffect] = await Promise.all([
32
- this.anchorBlockStore.getBlockHeader(),
31
+ const [siloedEventCommitment, txEffect] = await Promise.all([
33
32
  siloNullifier(contractAddress, eventCommitment),
34
33
  this.aztecNode.getTxEffect(txHash),
35
34
  ]);
36
35
 
37
- const syncedBlockNumber = syncedBlockHeader.getBlockNumber();
36
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
38
37
 
39
38
  if (!txEffect) {
40
39
  throw new Error(`Could not find tx effect for tx hash ${txHash}`);
41
40
  }
42
41
 
43
- if (txEffect.l2BlockNumber > syncedBlockNumber) {
44
- throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
42
+ if (txEffect.l2BlockNumber > anchorBlockNumber) {
43
+ throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
45
44
  }
46
45
 
47
- const eventInTx = txEffect.data.nullifiers.some(n => n.equals(siloedEventCommitment));
48
- if (!eventInTx) {
46
+ // Find the index of the event commitment in the nullifiers array to determine event ordering within the tx
47
+ const eventIndexInTx = txEffect.data.nullifiers.findIndex(n => n.equals(siloedEventCommitment));
48
+ if (eventIndexInTx === -1) {
49
49
  throw new Error(
50
50
  `Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present in tx ${txHash}`,
51
51
  );
52
52
  }
53
53
 
54
- const [nullifierIndex] = await this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
55
- siloedEventCommitment,
56
- ]);
57
-
58
- if (nullifierIndex === undefined) {
59
- throw new Error(
60
- `Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present on the nullifier tree at block ${syncedBlockNumber} (from tx ${txHash})`,
61
- );
62
- }
63
-
64
54
  return this.privateEventStore.storePrivateEventLog(
65
55
  selector,
56
+ randomness,
66
57
  content,
67
- Number(nullifierIndex.data), // Index of the event commitment in the nullifier tree
58
+ siloedEventCommitment,
68
59
  {
69
60
  contractAddress,
70
61
  scope,
71
62
  txHash,
72
- l2BlockNumber: nullifierIndex.l2BlockNumber, // Block number in which the event was emitted
73
- l2BlockHash: nullifierIndex.l2BlockHash, // Block hash in which the event was emitted
63
+ l2BlockNumber: txEffect.l2BlockNumber,
64
+ l2BlockHash: txEffect.l2BlockHash,
65
+ txIndexInBlock: txEffect.txIndexInBlock,
66
+ eventIndexInTx,
74
67
  },
68
+ this.jobId,
75
69
  );
76
70
  }
77
71
  }
@@ -2,13 +2,12 @@ import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
2
2
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
3
3
  import { BlockNumber } from '@aztec/foundation/branded-types';
4
4
 
5
- import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
6
5
  import type { PrivateEventStoreFilter } from '../storage/private_event_store/private_event_store.js';
7
6
 
8
7
  export class PrivateEventFilterValidator {
9
- constructor(private anchorBlockStore: AnchorBlockStore) {}
8
+ constructor(private lastBlock: BlockNumber) {}
10
9
 
11
- async validate(filter: PrivateEventFilter): Promise<PrivateEventStoreFilter> {
10
+ validate(filter: PrivateEventFilter): PrivateEventStoreFilter {
12
11
  let { fromBlock, toBlock } = filter;
13
12
 
14
13
  // Block range filters in Aztec Node are defined as closed-open intervals [fromBlock, toBlock), so
@@ -16,9 +15,8 @@ export class PrivateEventFilterValidator {
16
15
  // We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
17
16
  // the first block to the latest known block.
18
17
  if (!fromBlock || !toBlock) {
19
- const lastKnownBlock = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
20
18
  fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
21
- toBlock = toBlock ?? BlockNumber(lastKnownBlock + 1);
19
+ toBlock = toBlock ?? BlockNumber(this.lastBlock + 1);
22
20
  }
23
21
 
24
22
  if (filter.scopes.length === 0) {
@@ -0,0 +1,150 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto/random';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
+
5
+ /**
6
+ * Interface that stores must implement to support staged writes.
7
+ */
8
+ export interface StagedStore {
9
+ /** Unique name identifying this store (used for tracking staged stores from JobCoordinator) */
10
+ readonly storeName: string;
11
+
12
+ /**
13
+ * Commits staged data to main storage.
14
+ * Should be called within a transaction for atomicity.
15
+ *
16
+ * @param jobId - The job identifier
17
+ */
18
+ commit(jobId: string): Promise<void>;
19
+
20
+ /**
21
+ * Discards staged data without committing.
22
+ * Called on abort.
23
+ *
24
+ * @param jobId - The job identifier
25
+ */
26
+ discardStaged(jobId: string): Promise<void>;
27
+ }
28
+
29
+ /**
30
+ * JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
31
+ *
32
+ * It uses a staged writes pattern:
33
+ * 1. When a job begins, a unique job ID is created
34
+ * 2. During the job, all writes go to staging (keyed by job ID)
35
+ * 3. On commit, staging is promoted to main storage
36
+ * 4. On abort, staged data is discarded
37
+ *
38
+ * Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
39
+ * orchestrate concurrent jobs. Right now it doesn't make a difference because we're
40
+ * using a job queue with concurrency=1.
41
+ */
42
+ export class JobCoordinator {
43
+ private readonly log: Logger;
44
+
45
+ /** The underlying KV store */
46
+ kvStore: AztecAsyncKVStore;
47
+
48
+ #currentJobId: string | undefined;
49
+ #stores: Map<string, StagedStore> = new Map();
50
+
51
+ constructor(kvStore: AztecAsyncKVStore, bindings?: LoggerBindings) {
52
+ this.kvStore = kvStore;
53
+ this.log = createLogger('pxe:job_coordinator', bindings);
54
+ }
55
+
56
+ /**
57
+ * Registers a staged store.
58
+ * Must be called during initialization for all stores that need staging support.
59
+ */
60
+ registerStore(store: StagedStore): void {
61
+ if (this.#stores.has(store.storeName)) {
62
+ throw new Error(`Store "${store.storeName}" is already registered`);
63
+ }
64
+ this.#stores.set(store.storeName, store);
65
+ this.log.debug(`Registered staged store: ${store.storeName}`);
66
+ }
67
+
68
+ /**
69
+ * Registers multiple staged stores.
70
+ */
71
+ registerStores(stores: StagedStore[]): void {
72
+ for (const store of stores) {
73
+ this.registerStore(store);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Begins a new job and returns a job ID for staged writes.
79
+ *
80
+ * @returns Job ID to pass to store operations
81
+ */
82
+ beginJob(): string {
83
+ if (this.#currentJobId) {
84
+ throw new Error(
85
+ `Cannot begin job: job ${this.#currentJobId} is already in progress. ` +
86
+ `This should not happen - ensure jobs are properly committed or aborted.`,
87
+ );
88
+ }
89
+
90
+ const jobId = randomBytes(8).toString('hex');
91
+ this.#currentJobId = jobId;
92
+
93
+ this.log.debug(`Started job ${jobId}`);
94
+ return jobId;
95
+ }
96
+
97
+ /**
98
+ * Commits a job by promoting all staged data to main storage.
99
+ *
100
+ * @param jobId - The job ID returned from beginJob
101
+ */
102
+ async commitJob(jobId: string): Promise<void> {
103
+ if (!this.#currentJobId || this.#currentJobId !== jobId) {
104
+ throw new Error(
105
+ `Cannot commit job ${jobId}: no matching job in progress. ` + `Current job: ${this.#currentJobId ?? 'none'}`,
106
+ );
107
+ }
108
+
109
+ this.log.debug(`Committing job ${jobId}`);
110
+
111
+ // Commit all stores atomically in a single transaction.
112
+ // Each store's commit is a no-op if it has no staged data (but that's up to each store to handle).
113
+ await this.kvStore.transactionAsync(async () => {
114
+ for (const store of this.#stores.values()) {
115
+ await store.commit(jobId);
116
+ }
117
+ });
118
+
119
+ this.#currentJobId = undefined;
120
+ this.log.debug(`Job ${jobId} committed successfully`);
121
+ }
122
+
123
+ /**
124
+ * Aborts a job by discarding all staged data.
125
+ *
126
+ * @param jobId - The job ID returned from beginJob
127
+ */
128
+ async abortJob(jobId: string): Promise<void> {
129
+ if (!this.#currentJobId || this.#currentJobId !== jobId) {
130
+ // Job may have already been aborted or never started properly
131
+ this.log.warn(`Abort called for job ${jobId} but current job is ${this.#currentJobId ?? 'none'}`);
132
+ }
133
+
134
+ this.log.debug(`Aborting job ${jobId}`);
135
+
136
+ for (const store of this.#stores.values()) {
137
+ await store.discardStaged(jobId);
138
+ }
139
+
140
+ this.#currentJobId = undefined;
141
+ this.log.debug(`Job ${jobId} aborted`);
142
+ }
143
+
144
+ /**
145
+ * Checks if there's a job currently in progress.
146
+ */
147
+ hasJobInProgress(): boolean {
148
+ return this.#currentJobId !== undefined;
149
+ }
150
+ }
@@ -1,32 +1,40 @@
1
1
  import type { Fr } from '@aztec/foundation/curves/bn254';
2
- import { createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
3
  import type { KeyStore } from '@aztec/key-store';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { CompleteAddress } from '@aztec/stdlib/contract';
6
5
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
7
6
  import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
7
+ import type { BlockHeader } from '@aztec/stdlib/tx';
8
8
 
9
+ import type { AccessScopes } from '../access_scopes.js';
9
10
  import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
10
11
  import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
11
12
  import { AddressStore } from '../storage/address_store/address_store.js';
12
- import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
13
13
  import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
14
14
  import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
15
15
  import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
16
- import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
16
+ import {
17
+ getAllPrivateLogsByTags,
18
+ getAllPublicLogsByTagsFromContract,
19
+ loadPrivateLogsForSenderRecipientPair,
20
+ } from '../tagging/index.js';
17
21
 
18
22
  export class LogService {
19
- private log = createLogger('log_service');
23
+ private log: Logger;
20
24
 
21
25
  constructor(
22
26
  private readonly aztecNode: AztecNode,
23
- private readonly anchorBlockStore: AnchorBlockStore,
27
+ private readonly anchorBlockHeader: BlockHeader,
24
28
  private readonly keyStore: KeyStore,
25
29
  private readonly capsuleStore: CapsuleStore,
26
30
  private readonly recipientTaggingStore: RecipientTaggingStore,
27
31
  private readonly senderAddressBookStore: SenderAddressBookStore,
28
32
  private readonly addressStore: AddressStore,
29
- ) {}
33
+ private readonly jobId: string,
34
+ bindings?: LoggerBindings,
35
+ ) {
36
+ this.log = createLogger('pxe:log_service', bindings);
37
+ }
30
38
 
31
39
  public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
32
40
  return await Promise.all(
@@ -48,10 +56,16 @@ export class LogService {
48
56
  }
49
57
 
50
58
  async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
51
- const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [tag]);
52
- const logsForTag = logs[0];
59
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
60
+ const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
61
+ this.aztecNode,
62
+ contractAddress,
63
+ [tag],
64
+ anchorBlockHash,
65
+ );
66
+ const logsForTag = allLogsPerTag[0];
53
67
 
54
- if (logsForTag.length == 0) {
68
+ if (logsForTag.length === 0) {
55
69
  return null;
56
70
  } else if (logsForTag.length > 1) {
57
71
  // TODO(#11627): handle this case
@@ -71,10 +85,11 @@ export class LogService {
71
85
  }
72
86
 
73
87
  async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
74
- const logs = await this.aztecNode.getPrivateLogsByTags([siloedTag]);
75
- const logsForTag = logs[0];
88
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
89
+ const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
90
+ const logsForTag = allLogsPerTag[0];
76
91
 
77
- if (logsForTag.length == 0) {
92
+ if (logsForTag.length === 0) {
78
93
  return null;
79
94
  } else if (logsForTag.length > 1) {
80
95
  // TODO(#11627): handle this case
@@ -93,18 +108,15 @@ export class LogService {
93
108
  );
94
109
  }
95
110
 
96
- public async syncTaggedLogs(
97
- contractAddress: AztecAddress,
98
- pendingTaggedLogArrayBaseSlot: Fr,
99
- scopes?: AztecAddress[],
100
- ) {
101
- this.log.verbose('Searching for tagged logs', { contract: contractAddress });
111
+ public async fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes: AccessScopes) {
112
+ this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
102
113
 
103
114
  // We only load logs from block up to and including the anchor block number
104
- const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
115
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
116
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
105
117
 
106
118
  // Determine recipients: use scopes if provided, otherwise get all accounts
107
- const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
119
+ const recipients = scopes !== 'ALL_SCOPES' && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
108
120
 
109
121
  // For each recipient, fetch secrets, load logs, and store them.
110
122
  // We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
@@ -122,6 +134,8 @@ export class LogService {
122
134
  this.aztecNode,
123
135
  this.recipientTaggingStore,
124
136
  anchorBlockNumber,
137
+ anchorBlockHash,
138
+ this.jobId,
125
139
  ),
126
140
  ),
127
141
  );
@@ -141,7 +155,10 @@ export class LogService {
141
155
  contractAddress: AztecAddress,
142
156
  recipient: AztecAddress,
143
157
  ): Promise<DirectionalAppTaggingSecret[]> {
144
- const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
158
+ const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
159
+ if (!recipientCompleteAddress) {
160
+ return [];
161
+ }
145
162
  const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
146
163
 
147
164
  // We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
@@ -186,17 +203,6 @@ export class LogService {
186
203
  });
187
204
 
188
205
  // TODO: This looks like it could belong more at the oracle interface level
189
- return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
190
- }
191
-
192
- async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
193
- const completeAddress = await this.addressStore.getCompleteAddress(account);
194
- if (!completeAddress) {
195
- throw new Error(
196
- `No public key registered for address ${account}.
197
- Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
198
- );
199
- }
200
- return completeAddress;
206
+ return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
201
207
  }
202
208
  }
@@ -5,16 +5,17 @@ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdli
5
5
  import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
6
6
  import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
7
7
  import { MerkleTreeId } from '@aztec/stdlib/trees';
8
- import type { TxHash } from '@aztec/stdlib/tx';
8
+ import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
9
9
 
10
- import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
10
+ import type { AccessScopes } from '../access_scopes.js';
11
11
  import type { NoteStore } from '../storage/note_store/note_store.js';
12
12
 
13
13
  export class NoteService {
14
14
  constructor(
15
15
  private readonly noteStore: NoteStore,
16
16
  private readonly aztecNode: AztecNode,
17
- private readonly anchorBlockStore: AnchorBlockStore,
17
+ private readonly anchorBlockHeader: BlockHeader,
18
+ private readonly jobId: string,
18
19
  ) {}
19
20
 
20
21
  /**
@@ -31,17 +32,20 @@ export class NoteService {
31
32
  owner: AztecAddress | undefined,
32
33
  storageSlot: Fr,
33
34
  status: NoteStatus,
34
- scopes?: AztecAddress[],
35
+ scopes: AccessScopes,
35
36
  ) {
36
- const noteDaos = await this.noteStore.getNotes({
37
- contractAddress,
38
- owner,
39
- storageSlot,
40
- status,
41
- scopes,
42
- });
37
+ const noteDaos = await this.noteStore.getNotes(
38
+ {
39
+ contractAddress,
40
+ owner,
41
+ storageSlot,
42
+ status,
43
+ scopes,
44
+ },
45
+ this.jobId,
46
+ );
43
47
  return noteDaos.map(
44
- ({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index }) => ({
48
+ ({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
45
49
  contractAddress,
46
50
  owner,
47
51
  storageSlot,
@@ -49,9 +53,8 @@ export class NoteService {
49
53
  noteNonce,
50
54
  note,
51
55
  noteHash,
56
+ isPending: false, // Note service deals only with settled notes
52
57
  siloedNullifier,
53
- // PXE can use this index to get full MembershipWitness
54
- index,
55
58
  }),
56
59
  );
57
60
  }
@@ -68,10 +71,10 @@ export class NoteService {
68
71
  *
69
72
  * @param contractAddress - The contract whose notes should be checked and nullified.
70
73
  */
71
- public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
72
- const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
74
+ public async syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void> {
75
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
73
76
 
74
- const contractNotes = await this.noteStore.getNotes({ contractAddress });
77
+ const contractNotes = await this.noteStore.getNotes({ contractAddress, scopes }, this.jobId);
75
78
 
76
79
  if (contractNotes.length === 0) {
77
80
  return;
@@ -92,7 +95,7 @@ export class NoteService {
92
95
  const nullifierIndexes = (
93
96
  await Promise.all(
94
97
  nullifierBatches.map(batch =>
95
- this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, batch),
98
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
96
99
  ),
97
100
  )
98
101
  ).flat();
@@ -105,10 +108,10 @@ export class NoteService {
105
108
  })
106
109
  .filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
107
110
 
108
- await this.noteStore.applyNullifiers(foundNullifiers);
111
+ await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
109
112
  }
110
113
 
111
- public async deliverNote(
114
+ public async validateAndStoreNote(
112
115
  contractAddress: AztecAddress,
113
116
  owner: AztecAddress,
114
117
  storageSlot: Fr,
@@ -139,41 +142,32 @@ export class NoteService {
139
142
  // number which *should* be recent enough to be available, even for non-archive nodes.
140
143
  // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
141
144
  // logs up to the synced block making this only an additional safety check.
142
- const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
145
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
146
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
143
147
 
144
148
  // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
145
149
  // of other contracts, which would constitute a security breach.
146
150
  const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
147
151
  const siloedNullifier = await siloNullifier(contractAddress, nullifier);
148
152
 
149
- const txEffect = await this.aztecNode.getTxEffect(txHash);
153
+ const [txEffect, [nullifierIndex]] = await Promise.all([
154
+ this.aztecNode.getTxEffect(txHash),
155
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
156
+ ]);
150
157
  if (!txEffect) {
151
158
  throw new Error(`Could not find tx effect for tx hash ${txHash}`);
152
159
  }
153
160
 
154
- if (txEffect.l2BlockNumber > syncedBlockNumber) {
155
- throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
161
+ if (txEffect.l2BlockNumber > anchorBlockNumber) {
162
+ throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
156
163
  }
157
164
 
158
- const noteInTx = txEffect.data.noteHashes.some(nh => nh.equals(uniqueNoteHash));
159
- if (!noteInTx) {
165
+ // Find the index of the note hash in the noteHashes array to determine note ordering within the tx
166
+ const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
167
+ if (noteIndexInTx === -1) {
160
168
  throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
161
169
  }
162
170
 
163
- // We store notes by their index in the global note hash tree, which has the convenient side effect of validating
164
- // note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
165
- // queries in a single round-trip.
166
- const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
167
- this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]),
168
- this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
169
- ]);
170
-
171
- if (uniqueNoteHashTreeIndexInBlock === undefined) {
172
- throw new Error(
173
- `Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`,
174
- );
175
- }
176
-
177
171
  const noteDao = new NoteDao(
178
172
  new Note(content),
179
173
  contractAddress,
@@ -184,17 +178,19 @@ export class NoteService {
184
178
  noteHash,
185
179
  siloedNullifier,
186
180
  txHash,
187
- uniqueNoteHashTreeIndexInBlock.l2BlockNumber,
188
- uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(),
189
- uniqueNoteHashTreeIndexInBlock.data,
181
+ txEffect.l2BlockNumber,
182
+ txEffect.l2BlockHash.toString(),
183
+ txEffect.txIndexInBlock,
184
+ noteIndexInTx,
190
185
  );
191
186
 
192
187
  // The note was found by `recipient`, so we use that as the scope when storing the note.
193
- await this.noteStore.addNotes([noteDao], recipient);
188
+ await this.noteStore.addNotes([noteDao], recipient, this.jobId);
194
189
 
195
190
  if (nullifierIndex !== undefined) {
191
+ // We found nullifier index which implies that the note has already been nullified.
196
192
  const { data: _, ...blockHashAndNum } = nullifierIndex;
197
- await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
193
+ await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
198
194
  }
199
195
  }
200
196
  }
@@ -0,0 +1,26 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { NoteStatus } from '@aztec/stdlib/note';
4
+
5
+ import type { AccessScopes } from './access_scopes.js';
6
+
7
+ /**
8
+ * A filter used to fetch notes.
9
+ * @remarks This filter is applied as an intersection of all its params.
10
+ */
11
+ export type NotesFilter = {
12
+ /**
13
+ * The contract address the note belongs to.
14
+ * @remarks Providing a contract address is required as we need that information to trigger private state sync.
15
+ */
16
+ contractAddress: AztecAddress;
17
+ /** The owner of the note. */
18
+ owner?: AztecAddress;
19
+ /** The specific storage location of the note on the contract. */
20
+ storageSlot?: Fr;
21
+ /** The status of the note. Defaults to 'ACTIVE'. */
22
+ status?: NoteStatus;
23
+ /** The siloed nullifier for the note. */
24
+ siloedNullifier?: Fr;
25
+ scopes: AccessScopes;
26
+ };
@@ -4,8 +4,9 @@
4
4
  ///
5
5
  /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 5;
7
+ export const ORACLE_VERSION = 12;
8
8
 
9
9
  /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
10
- /// which in turn implies that you need to update the ORACLE_VERSION constant.
11
- export const ORACLE_INTERFACE_HASH = 'd603c17a97034d978ca453d2bce3aacae139539dee28bbc46e8f8c7177a348ec';
10
+ /// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
11
+ /// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
12
+ export const ORACLE_INTERFACE_HASH = '666a8a7fc697f72b29dbf0ae7464db269cf5afa019acac8861f814543147dbb4';