@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.dbf9cec

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 (226) 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 +9 -5
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  7. package/dest/block_synchronizer/block_synchronizer.js +62 -16
  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/contract_function_simulator.d.ts +54 -30
  13. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/contract_function_simulator.js +175 -74
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
  20. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
  21. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  23. package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -12
  24. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/oracle.d.ts +7 -5
  26. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/oracle.js +51 -29
  28. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  29. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
  31. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -36
  32. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +86 -30
  34. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +62 -30
  35. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +107 -88
  37. package/dest/contract_logging.d.ts +22 -0
  38. package/dest/contract_logging.d.ts.map +1 -0
  39. package/dest/contract_logging.js +23 -0
  40. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  41. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  42. package/dest/contract_sync/contract_sync_service.js +97 -0
  43. package/dest/contract_sync/helpers.d.ts +29 -0
  44. package/dest/contract_sync/helpers.d.ts.map +1 -0
  45. package/dest/contract_sync/helpers.js +55 -0
  46. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  47. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  48. package/dest/debug/pxe_debug_utils.js +28 -17
  49. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  50. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  51. package/dest/entrypoints/client/bundle/index.js +3 -0
  52. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  53. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  54. package/dest/entrypoints/client/bundle/utils.js +21 -7
  55. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  56. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  57. package/dest/entrypoints/client/lazy/index.js +3 -0
  58. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  59. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  60. package/dest/entrypoints/client/lazy/utils.js +22 -8
  61. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  62. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  63. package/dest/entrypoints/server/index.d.ts +4 -1
  64. package/dest/entrypoints/server/index.d.ts.map +1 -1
  65. package/dest/entrypoints/server/index.js +3 -0
  66. package/dest/entrypoints/server/utils.d.ts +1 -1
  67. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/server/utils.js +28 -9
  69. package/dest/events/event_service.d.ts +5 -6
  70. package/dest/events/event_service.d.ts.map +1 -1
  71. package/dest/events/event_service.js +6 -7
  72. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  73. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  74. package/dest/job_coordinator/job_coordinator.js +3 -2
  75. package/dest/logs/log_service.d.ts +7 -5
  76. package/dest/logs/log_service.d.ts.map +1 -1
  77. package/dest/logs/log_service.js +28 -32
  78. package/dest/notes/note_service.d.ts +9 -8
  79. package/dest/notes/note_service.d.ts.map +1 -1
  80. package/dest/notes/note_service.js +17 -16
  81. package/dest/notes_filter.d.ts +25 -0
  82. package/dest/notes_filter.d.ts.map +1 -0
  83. package/dest/notes_filter.js +4 -0
  84. package/dest/oracle_version.d.ts +3 -3
  85. package/dest/oracle_version.d.ts.map +1 -1
  86. package/dest/oracle_version.js +4 -3
  87. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  88. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  89. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  90. package/dest/private_kernel/hints/index.d.ts +1 -1
  91. package/dest/private_kernel/hints/index.js +1 -1
  92. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  93. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  94. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  95. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  96. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  97. package/dest/private_kernel/hints/test_utils.js +203 -0
  98. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  99. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  100. package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
  101. package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
  102. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  103. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  104. package/dest/pxe.d.ts +69 -23
  105. package/dest/pxe.d.ts.map +1 -1
  106. package/dest/pxe.js +104 -67
  107. package/dest/storage/address_store/address_store.d.ts +1 -1
  108. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  109. package/dest/storage/address_store/address_store.js +12 -11
  110. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  111. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  112. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  113. package/dest/storage/capsule_store/capsule_store.js +6 -8
  114. package/dest/storage/contract_store/contract_store.d.ts +42 -16
  115. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  116. package/dest/storage/contract_store/contract_store.js +157 -84
  117. package/dest/storage/metadata.d.ts +1 -1
  118. package/dest/storage/metadata.js +1 -1
  119. package/dest/storage/note_store/note_store.d.ts +47 -49
  120. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  121. package/dest/storage/note_store/note_store.js +278 -252
  122. package/dest/storage/note_store/stored_note.d.ts +16 -0
  123. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  124. package/dest/storage/note_store/stored_note.js +43 -0
  125. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  126. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  127. package/dest/storage/private_event_store/private_event_store.js +198 -147
  128. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  129. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  130. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  131. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  132. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  133. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  134. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  135. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  136. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  137. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  138. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  139. package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
  140. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  141. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  142. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  143. package/dest/tagging/index.d.ts +3 -2
  144. package/dest/tagging/index.d.ts.map +1 -1
  145. package/dest/tagging/index.js +2 -1
  146. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
  147. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  148. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  149. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  150. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
  151. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  152. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
  153. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
  154. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  155. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  156. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  157. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  158. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  159. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  160. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  161. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +20 -18
  162. package/package.json +25 -16
  163. package/src/access_scopes.ts +9 -0
  164. package/src/bin/check_oracle_version.ts +1 -0
  165. package/src/block_synchronizer/block_synchronizer.ts +76 -33
  166. package/src/config/index.ts +14 -0
  167. package/src/config/package_info.ts +1 -1
  168. package/src/contract_function_simulator/contract_function_simulator.ts +324 -137
  169. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  170. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +2 -2
  171. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  172. package/src/contract_function_simulator/oracle/interfaces.ts +20 -11
  173. package/src/contract_function_simulator/oracle/oracle.ts +56 -26
  174. package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
  175. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -110
  176. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +172 -95
  177. package/src/contract_logging.ts +39 -0
  178. package/src/contract_sync/contract_sync_service.ts +152 -0
  179. package/src/contract_sync/helpers.ts +98 -0
  180. package/src/debug/pxe_debug_utils.ts +63 -18
  181. package/src/entrypoints/client/bundle/index.ts +3 -0
  182. package/src/entrypoints/client/bundle/utils.ts +16 -15
  183. package/src/entrypoints/client/lazy/index.ts +3 -0
  184. package/src/entrypoints/client/lazy/utils.ts +17 -15
  185. package/src/entrypoints/pxe_creation_options.ts +2 -1
  186. package/src/entrypoints/server/index.ts +3 -0
  187. package/src/entrypoints/server/utils.ts +22 -26
  188. package/src/events/event_service.ts +5 -7
  189. package/src/job_coordinator/job_coordinator.ts +4 -3
  190. package/src/logs/log_service.ts +48 -39
  191. package/src/notes/note_service.ts +24 -22
  192. package/src/notes_filter.ts +26 -0
  193. package/src/oracle_version.ts +4 -3
  194. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  195. package/src/private_kernel/hints/index.ts +1 -1
  196. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  197. package/src/private_kernel/hints/test_utils.ts +325 -0
  198. package/src/private_kernel/private_kernel_execution_prover.ts +25 -15
  199. package/src/private_kernel/private_kernel_oracle.ts +9 -9
  200. package/src/pxe.ts +211 -112
  201. package/src/storage/address_store/address_store.ts +15 -15
  202. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  203. package/src/storage/capsule_store/capsule_store.ts +8 -8
  204. package/src/storage/contract_store/contract_store.ts +186 -96
  205. package/src/storage/metadata.ts +1 -1
  206. package/src/storage/note_store/note_store.ts +321 -318
  207. package/src/storage/note_store/stored_note.ts +48 -0
  208. package/src/storage/private_event_store/private_event_store.ts +250 -190
  209. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  210. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  211. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  212. package/src/storage/tagging_store/sender_tagging_store.ts +214 -130
  213. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  214. package/src/tagging/index.ts +2 -1
  215. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +17 -10
  216. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  217. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
  218. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +6 -9
  219. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
  220. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +23 -23
  221. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  222. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  223. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  224. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  225. package/dest/tree_membership/tree_membership_service.js +0 -75
  226. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -1,40 +1,53 @@
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
- import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
8
-
6
+ import {
7
+ ExtendedDirectionalAppTaggingSecret,
8
+ PendingTaggedLog,
9
+ SiloedTag,
10
+ Tag,
11
+ TxScopedL2Log,
12
+ } from '@aztec/stdlib/logs';
13
+ import type { BlockHeader } from '@aztec/stdlib/tx';
14
+
15
+ import type { AccessScopes } from '../access_scopes.js';
9
16
  import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
10
17
  import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
11
18
  import { AddressStore } from '../storage/address_store/address_store.js';
12
- import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
13
19
  import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
14
20
  import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
15
21
  import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
16
- import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
22
+ import {
23
+ getAllPrivateLogsByTags,
24
+ getAllPublicLogsByTagsFromContract,
25
+ loadPrivateLogsForSenderRecipientPair,
26
+ } from '../tagging/index.js';
17
27
 
18
28
  export class LogService {
19
- private log = createLogger('log_service');
29
+ private log: Logger;
20
30
 
21
31
  constructor(
22
32
  private readonly aztecNode: AztecNode,
23
- private readonly anchorBlockStore: AnchorBlockStore,
33
+ private readonly anchorBlockHeader: BlockHeader,
24
34
  private readonly keyStore: KeyStore,
25
35
  private readonly capsuleStore: CapsuleStore,
26
36
  private readonly recipientTaggingStore: RecipientTaggingStore,
27
37
  private readonly senderAddressBookStore: SenderAddressBookStore,
28
38
  private readonly addressStore: AddressStore,
29
39
  private readonly jobId: string,
30
- ) {}
40
+ bindings?: LoggerBindings,
41
+ ) {
42
+ this.log = createLogger('pxe:log_service', bindings);
43
+ }
31
44
 
32
45
  public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
33
46
  return await Promise.all(
34
47
  logRetrievalRequests.map(async request => {
35
48
  const [publicLog, privateLog] = await Promise.all([
36
49
  this.#getPublicLogByTag(request.tag, request.contractAddress),
37
- this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
50
+ this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
38
51
  ]);
39
52
 
40
53
  if (publicLog !== null && privateLog !== null) {
@@ -49,10 +62,16 @@ export class LogService {
49
62
  }
50
63
 
51
64
  async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
52
- const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [tag]);
53
- const logsForTag = logs[0];
65
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
66
+ const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
67
+ this.aztecNode,
68
+ contractAddress,
69
+ [tag],
70
+ anchorBlockHash,
71
+ );
72
+ const logsForTag = allLogsPerTag[0];
54
73
 
55
- if (logsForTag.length == 0) {
74
+ if (logsForTag.length === 0) {
56
75
  return null;
57
76
  } else if (logsForTag.length > 1) {
58
77
  // TODO(#11627): handle this case
@@ -72,10 +91,11 @@ export class LogService {
72
91
  }
73
92
 
74
93
  async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
75
- const logs = await this.aztecNode.getPrivateLogsByTags([siloedTag]);
76
- const logsForTag = logs[0];
94
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
95
+ const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
96
+ const logsForTag = allLogsPerTag[0];
77
97
 
78
- if (logsForTag.length == 0) {
98
+ if (logsForTag.length === 0) {
79
99
  return null;
80
100
  } else if (logsForTag.length > 1) {
81
101
  // TODO(#11627): handle this case
@@ -94,18 +114,15 @@ export class LogService {
94
114
  );
95
115
  }
96
116
 
97
- public async syncTaggedLogs(
98
- contractAddress: AztecAddress,
99
- pendingTaggedLogArrayBaseSlot: Fr,
100
- scopes?: AztecAddress[],
101
- ) {
102
- this.log.verbose('Searching for tagged logs', { contract: contractAddress });
117
+ public async fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes: AccessScopes) {
118
+ this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
103
119
 
104
120
  // We only load logs from block up to and including the anchor block number
105
- const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
121
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
122
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
106
123
 
107
124
  // Determine recipients: use scopes if provided, otherwise get all accounts
108
- const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
125
+ const recipients = scopes !== 'ALL_SCOPES' && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
109
126
 
110
127
  // For each recipient, fetch secrets, load logs, and store them.
111
128
  // We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
@@ -119,10 +136,10 @@ export class LogService {
119
136
  secrets.map(secret =>
120
137
  loadPrivateLogsForSenderRecipientPair(
121
138
  secret,
122
- contractAddress,
123
139
  this.aztecNode,
124
140
  this.recipientTaggingStore,
125
141
  anchorBlockNumber,
142
+ anchorBlockHash,
126
143
  this.jobId,
127
144
  ),
128
145
  ),
@@ -142,8 +159,11 @@ export class LogService {
142
159
  async #getSecretsForSenders(
143
160
  contractAddress: AztecAddress,
144
161
  recipient: AztecAddress,
145
- ): Promise<DirectionalAppTaggingSecret[]> {
146
- const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
162
+ ): Promise<ExtendedDirectionalAppTaggingSecret[]> {
163
+ const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
164
+ if (!recipientCompleteAddress) {
165
+ return [];
166
+ }
147
167
  const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
148
168
 
149
169
  // We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
@@ -157,7 +177,7 @@ export class LogService {
157
177
 
158
178
  return Promise.all(
159
179
  deduplicatedSenders.map(sender => {
160
- return DirectionalAppTaggingSecret.compute(
180
+ return ExtendedDirectionalAppTaggingSecret.compute(
161
181
  recipientCompleteAddress,
162
182
  recipientIvsk,
163
183
  sender,
@@ -190,15 +210,4 @@ export class LogService {
190
210
  // TODO: This looks like it could belong more at the oracle interface level
191
211
  return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
192
212
  }
193
-
194
- async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
195
- const completeAddress = await this.addressStore.getCompleteAddress(account);
196
- if (!completeAddress) {
197
- throw new Error(
198
- `No public key registered for address ${account}.
199
- 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`,
200
- );
201
- }
202
- return completeAddress;
203
- }
204
213
  }
@@ -1,21 +1,21 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import type { DataInBlock } from '@aztec/stdlib/block';
4
- import { L2BlockHash } from '@aztec/stdlib/block';
5
4
  import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
6
5
  import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
7
6
  import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
8
7
  import { MerkleTreeId } from '@aztec/stdlib/trees';
9
- import type { TxHash } from '@aztec/stdlib/tx';
8
+ import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
10
9
 
11
- import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
10
+ import type { AccessScopes } from '../access_scopes.js';
12
11
  import type { NoteStore } from '../storage/note_store/note_store.js';
13
12
 
14
13
  export class NoteService {
15
14
  constructor(
16
15
  private readonly noteStore: NoteStore,
17
16
  private readonly aztecNode: AztecNode,
18
- private readonly anchorBlockStore: AnchorBlockStore,
17
+ private readonly anchorBlockHeader: BlockHeader,
18
+ private readonly jobId: string,
19
19
  ) {}
20
20
 
21
21
  /**
@@ -32,15 +32,18 @@ export class NoteService {
32
32
  owner: AztecAddress | undefined,
33
33
  storageSlot: Fr,
34
34
  status: NoteStatus,
35
- scopes?: AztecAddress[],
35
+ scopes: AccessScopes,
36
36
  ) {
37
- const noteDaos = await this.noteStore.getNotes({
38
- contractAddress,
39
- owner,
40
- storageSlot,
41
- status,
42
- scopes,
43
- });
37
+ const noteDaos = await this.noteStore.getNotes(
38
+ {
39
+ contractAddress,
40
+ owner,
41
+ storageSlot,
42
+ status,
43
+ scopes,
44
+ },
45
+ this.jobId,
46
+ );
44
47
  return noteDaos.map(
45
48
  ({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
46
49
  contractAddress,
@@ -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 anchorBlockHash = L2BlockHash.fromField(await (await this.anchorBlockStore.getBlockHeader()).hash());
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;
@@ -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 storeNote(
114
+ public async validateAndStoreNote(
112
115
  contractAddress: AztecAddress,
113
116
  owner: AztecAddress,
114
117
  storageSlot: Fr,
@@ -139,9 +142,8 @@ 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 anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
143
- const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
144
- const anchorBlockHash = L2BlockHash.fromField(await anchorBlockHeader.hash());
145
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
146
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
145
147
 
146
148
  // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
147
149
  // of other contracts, which would constitute a security breach.
@@ -183,12 +185,12 @@ export class NoteService {
183
185
  );
184
186
 
185
187
  // The note was found by `recipient`, so we use that as the scope when storing the note.
186
- await this.noteStore.addNotes([noteDao], recipient);
188
+ await this.noteStore.addNotes([noteDao], recipient, this.jobId);
187
189
 
188
190
  if (nullifierIndex !== undefined) {
189
191
  // We found nullifier index which implies that the note has already been nullified.
190
192
  const { data: _, ...blockHashAndNum } = nullifierIndex;
191
- await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
193
+ await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
192
194
  }
193
195
  }
194
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 = 6;
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 = '8fb18d1fa560c4844b22c55a3e79c32ffcb71ded9ac409911470ee0296a84d72';
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';
@@ -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
1
  export * from './private_kernel_reset_private_inputs_builder.js';
2
- export * from './compute_tx_include_by_timestamp.js';
2
+ export * from './compute_tx_expiration_timestamp.js';