@aztec/pxe 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949

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 (224) 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/block_synchronizer/block_synchronizer.d.ts +4 -2
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  6. package/dest/block_synchronizer/block_synchronizer.js +7 -1
  7. package/dest/config/index.d.ts +2 -2
  8. package/dest/config/index.d.ts.map +1 -1
  9. package/dest/config/index.js +1 -1
  10. package/dest/config/package_info.js +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts +61 -31
  12. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/contract_function_simulator.js +200 -74
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  17. package/dest/contract_function_simulator/index.d.ts +2 -1
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +1 -0
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  26. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
  27. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
  28. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
  30. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
  33. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  35. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
  37. package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -44
  38. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/oracle.js +187 -106
  40. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  41. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +54 -79
  42. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +100 -87
  44. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +95 -53
  45. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +205 -106
  47. package/dest/contract_logging.d.ts +22 -0
  48. package/dest/contract_logging.d.ts.map +1 -0
  49. package/dest/contract_logging.js +23 -0
  50. package/dest/contract_sync/contract_sync_service.d.ts +45 -0
  51. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  52. package/dest/contract_sync/contract_sync_service.js +114 -0
  53. package/dest/contract_sync/helpers.d.ts +29 -0
  54. package/dest/contract_sync/helpers.d.ts.map +1 -0
  55. package/dest/contract_sync/{index.js → helpers.js} +13 -12
  56. package/dest/debug/pxe_debug_utils.d.ts +14 -10
  57. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  58. package/dest/debug/pxe_debug_utils.js +16 -15
  59. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  60. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  61. package/dest/entrypoints/client/bundle/index.js +3 -0
  62. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  63. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  64. package/dest/entrypoints/client/bundle/utils.js +11 -2
  65. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  66. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  67. package/dest/entrypoints/client/lazy/index.js +3 -0
  68. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  69. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  70. package/dest/entrypoints/client/lazy/utils.js +11 -2
  71. package/dest/entrypoints/server/index.d.ts +4 -2
  72. package/dest/entrypoints/server/index.d.ts.map +1 -1
  73. package/dest/entrypoints/server/index.js +3 -1
  74. package/dest/entrypoints/server/utils.js +9 -1
  75. package/dest/events/event_service.d.ts +4 -5
  76. package/dest/events/event_service.d.ts.map +1 -1
  77. package/dest/events/event_service.js +5 -6
  78. package/dest/logs/log_service.d.ts +6 -5
  79. package/dest/logs/log_service.d.ts.map +1 -1
  80. package/dest/logs/log_service.js +18 -28
  81. package/dest/messages/message_context_service.d.ts +17 -0
  82. package/dest/messages/message_context_service.d.ts.map +1 -0
  83. package/dest/messages/message_context_service.js +36 -0
  84. package/dest/notes/note_service.d.ts +7 -7
  85. package/dest/notes/note_service.d.ts.map +1 -1
  86. package/dest/notes/note_service.js +9 -9
  87. package/dest/notes_filter.d.ts +25 -0
  88. package/dest/notes_filter.d.ts.map +1 -0
  89. package/dest/notes_filter.js +4 -0
  90. package/dest/oracle_version.d.ts +3 -3
  91. package/dest/oracle_version.d.ts.map +1 -1
  92. package/dest/oracle_version.js +3 -3
  93. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  94. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  95. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  96. package/dest/private_kernel/hints/index.d.ts +1 -1
  97. package/dest/private_kernel/hints/index.js +1 -1
  98. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  99. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  100. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  101. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  102. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  103. package/dest/private_kernel/hints/test_utils.js +203 -0
  104. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  105. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  106. package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
  107. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  108. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  109. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  110. package/dest/pxe.d.ts +74 -24
  111. package/dest/pxe.d.ts.map +1 -1
  112. package/dest/pxe.js +124 -74
  113. package/dest/storage/address_store/address_store.d.ts +1 -1
  114. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  115. package/dest/storage/address_store/address_store.js +12 -11
  116. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  117. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  118. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  119. package/dest/storage/capsule_store/capsule_store.js +6 -8
  120. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  121. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  122. package/dest/storage/contract_store/contract_store.js +157 -72
  123. package/dest/storage/metadata.d.ts +1 -1
  124. package/dest/storage/metadata.js +1 -1
  125. package/dest/storage/note_store/note_store.d.ts +13 -3
  126. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  127. package/dest/storage/note_store/note_store.js +173 -131
  128. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  129. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  130. package/dest/storage/private_event_store/private_event_store.js +126 -101
  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 +29 -28
  138. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  139. package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
  140. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  141. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  142. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  143. package/dest/tagging/index.d.ts +3 -3
  144. package/dest/tagging/index.d.ts.map +1 -1
  145. package/dest/tagging/index.js +1 -1
  146. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -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 +6 -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 +12 -11
  153. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -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 +13 -7
  156. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  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 +20 -10
  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 +36 -24
  162. package/package.json +25 -16
  163. package/src/access_scopes.ts +9 -0
  164. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  165. package/src/config/index.ts +1 -1
  166. package/src/config/package_info.ts +1 -1
  167. package/src/contract_function_simulator/contract_function_simulator.ts +360 -137
  168. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  169. package/src/contract_function_simulator/index.ts +1 -0
  170. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
  171. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  172. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
  173. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
  174. package/src/contract_function_simulator/oracle/interfaces.ts +60 -60
  175. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
  176. package/src/contract_function_simulator/oracle/oracle.ts +198 -143
  177. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  178. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -184
  179. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +308 -122
  180. package/src/contract_logging.ts +39 -0
  181. package/src/contract_sync/contract_sync_service.ts +181 -0
  182. package/src/contract_sync/{index.ts → helpers.ts} +21 -21
  183. package/src/debug/pxe_debug_utils.ts +48 -18
  184. package/src/entrypoints/client/bundle/index.ts +3 -0
  185. package/src/entrypoints/client/bundle/utils.ts +12 -2
  186. package/src/entrypoints/client/lazy/index.ts +3 -0
  187. package/src/entrypoints/client/lazy/utils.ts +12 -2
  188. package/src/entrypoints/server/index.ts +3 -1
  189. package/src/entrypoints/server/utils.ts +7 -7
  190. package/src/events/event_service.ts +4 -6
  191. package/src/logs/log_service.ts +25 -35
  192. package/src/messages/message_context_service.ts +45 -0
  193. package/src/notes/note_service.ts +9 -10
  194. package/src/notes_filter.ts +26 -0
  195. package/src/oracle_version.ts +3 -3
  196. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  197. package/src/private_kernel/hints/index.ts +1 -1
  198. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  199. package/src/private_kernel/hints/test_utils.ts +325 -0
  200. package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
  201. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  202. package/src/pxe.ts +228 -125
  203. package/src/storage/address_store/address_store.ts +15 -15
  204. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  205. package/src/storage/capsule_store/capsule_store.ts +8 -8
  206. package/src/storage/contract_store/contract_store.ts +186 -76
  207. package/src/storage/metadata.ts +1 -1
  208. package/src/storage/note_store/note_store.ts +195 -153
  209. package/src/storage/private_event_store/private_event_store.ts +151 -128
  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 +287 -156
  213. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  214. package/src/tagging/index.ts +2 -2
  215. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -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 +10 -15
  218. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  219. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  220. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
  221. package/dest/contract_sync/index.d.ts +0 -23
  222. package/dest/contract_sync/index.d.ts.map +0 -1
  223. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  224. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
@@ -2,14 +2,20 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
2
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';
@@ -24,7 +30,7 @@ export class LogService {
24
30
 
25
31
  constructor(
26
32
  private readonly aztecNode: AztecNode,
27
- private readonly anchorBlockStore: AnchorBlockStore,
33
+ private readonly anchorBlockHeader: BlockHeader,
28
34
  private readonly keyStore: KeyStore,
29
35
  private readonly capsuleStore: CapsuleStore,
30
36
  private readonly recipientTaggingStore: RecipientTaggingStore,
@@ -41,7 +47,7 @@ export class LogService {
41
47
  logRetrievalRequests.map(async request => {
42
48
  const [publicLog, privateLog] = await Promise.all([
43
49
  this.#getPublicLogByTag(request.tag, request.contractAddress),
44
- this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
50
+ this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
45
51
  ]);
46
52
 
47
53
  if (publicLog !== null && privateLog !== null) {
@@ -56,8 +62,7 @@ export class LogService {
56
62
  }
57
63
 
58
64
  async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
59
- const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
60
- const anchorBlockHash = await anchorBlockHeader.hash();
65
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
61
66
  const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
62
67
  this.aztecNode,
63
68
  contractAddress,
@@ -86,8 +91,7 @@ export class LogService {
86
91
  }
87
92
 
88
93
  async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
89
- const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
90
- const anchorBlockHash = await anchorBlockHeader.hash();
94
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
91
95
  const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
92
96
  const logsForTag = allLogsPerTag[0];
93
97
 
@@ -110,20 +114,15 @@ export class LogService {
110
114
  );
111
115
  }
112
116
 
113
- public async syncTaggedLogs(
114
- contractAddress: AztecAddress,
115
- pendingTaggedLogArrayBaseSlot: Fr,
116
- scopes?: AztecAddress[],
117
- ) {
118
- 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()}`);
119
119
 
120
120
  // We only load logs from block up to and including the anchor block number
121
- const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
122
- const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
123
- const anchorBlockHash = await anchorBlockHeader.hash();
121
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
122
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
124
123
 
125
124
  // Determine recipients: use scopes if provided, otherwise get all accounts
126
- 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();
127
126
 
128
127
  // For each recipient, fetch secrets, load logs, and store them.
129
128
  // We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
@@ -137,7 +136,6 @@ export class LogService {
137
136
  secrets.map(secret =>
138
137
  loadPrivateLogsForSenderRecipientPair(
139
138
  secret,
140
- contractAddress,
141
139
  this.aztecNode,
142
140
  this.recipientTaggingStore,
143
141
  anchorBlockNumber,
@@ -161,8 +159,11 @@ export class LogService {
161
159
  async #getSecretsForSenders(
162
160
  contractAddress: AztecAddress,
163
161
  recipient: AztecAddress,
164
- ): Promise<DirectionalAppTaggingSecret[]> {
165
- const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
162
+ ): Promise<ExtendedDirectionalAppTaggingSecret[]> {
163
+ const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
164
+ if (!recipientCompleteAddress) {
165
+ return [];
166
+ }
166
167
  const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
167
168
 
168
169
  // We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
@@ -176,7 +177,7 @@ export class LogService {
176
177
 
177
178
  return Promise.all(
178
179
  deduplicatedSenders.map(sender => {
179
- return DirectionalAppTaggingSecret.compute(
180
+ return ExtendedDirectionalAppTaggingSecret.compute(
180
181
  recipientCompleteAddress,
181
182
  recipientIvsk,
182
183
  sender,
@@ -209,15 +210,4 @@ export class LogService {
209
210
  // TODO: This looks like it could belong more at the oracle interface level
210
211
  return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
211
212
  }
212
-
213
- async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
214
- const completeAddress = await this.addressStore.getCompleteAddress(account);
215
- if (!completeAddress) {
216
- throw new Error(
217
- `No public key registered for address ${account}.
218
- 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`,
219
- );
220
- }
221
- return completeAddress;
222
- }
223
213
  }
@@ -0,0 +1,45 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
+ import { TxHash } from '@aztec/stdlib/tx';
4
+
5
+ import { MessageTxContext } from '../contract_function_simulator/noir-structs/message_tx_context.js';
6
+
7
+ /** Resolves transaction hashes into the context needed to process messages. */
8
+ export class MessageContextService {
9
+ constructor(private readonly aztecNode: AztecNode) {}
10
+
11
+ /**
12
+ * Resolves a list of tx hashes into their message contexts.
13
+ *
14
+ * For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
15
+ * process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
16
+ * available, or in blocks beyond the anchor block.
17
+ */
18
+ resolveMessageContexts(txHashes: Fr[], anchorBlockNumber: number): Promise<(MessageTxContext | null)[]> {
19
+ // TODO: optimize, we might be hitting the node to get the same txHash repeatedly
20
+ return Promise.all(
21
+ txHashes.map(async txHashField => {
22
+ // A zero tx hash indicates a tx-less offchain message (e.g. one not tied to any onchain transaction).
23
+ // These messages don't have a transaction context to resolve, so we return null.
24
+ if (txHashField.isZero()) {
25
+ return null;
26
+ }
27
+
28
+ const txHash = TxHash.fromField(txHashField);
29
+ const txEffect = await this.aztecNode.getTxEffect(txHash);
30
+ if (!txEffect || txEffect.l2BlockNumber > anchorBlockNumber) {
31
+ return null;
32
+ }
33
+
34
+ // Every tx has at least one nullifier (the first nullifier derived from the tx hash). Hitting this condition
35
+ // would mean a buggy node, but since we need to access data.nullifiers[0], the defensive check does no harm.
36
+ const data = txEffect.data;
37
+ if (data.nullifiers.length === 0) {
38
+ throw new Error(`Tx effect for ${txHash} has no nullifiers`);
39
+ }
40
+
41
+ return new MessageTxContext(data.txHash, data.noteHashes, data.nullifiers[0]);
42
+ }),
43
+ );
44
+ }
45
+ }
@@ -5,16 +5,16 @@ 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
18
  private readonly jobId: string,
19
19
  ) {}
20
20
 
@@ -32,7 +32,7 @@ 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
37
  const noteDaos = await this.noteStore.getNotes(
38
38
  {
@@ -71,10 +71,10 @@ export class NoteService {
71
71
  *
72
72
  * @param contractAddress - The contract whose notes should be checked and nullified.
73
73
  */
74
- public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
75
- const anchorBlockHash = await (await this.anchorBlockStore.getBlockHeader()).hash();
74
+ public async syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void> {
75
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
76
76
 
77
- const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
77
+ const contractNotes = await this.noteStore.getNotes({ contractAddress, scopes }, this.jobId);
78
78
 
79
79
  if (contractNotes.length === 0) {
80
80
  return;
@@ -142,9 +142,8 @@ export class NoteService {
142
142
  // number which *should* be recent enough to be available, even for non-archive nodes.
143
143
  // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
144
144
  // logs up to the synced block making this only an additional safety check.
145
- const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
146
- const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
147
- const anchorBlockHash = await anchorBlockHeader.hash();
145
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
146
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
148
147
 
149
148
  // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
150
149
  // of other contracts, which would constitute a security breach.
@@ -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
+ };
@@ -2,11 +2,11 @@
2
2
  /// to version the oracle interface to ensure that developers get a reasonable error message if they use incompatible
3
3
  /// versions of Aztec.nr and PXE. The Noir counterpart is in `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
4
4
  ///
5
- /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
5
+ /// @dev Whenever a contract function or Noir test is run, the `aztec_utl_assertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 9;
7
+ export const ORACLE_VERSION = 18;
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
10
  /// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
11
11
  /// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
12
- export const ORACLE_INTERFACE_HASH = '9866cc52510acaef75a3d47a0ed501fd9ff92b9d53b2c8a88c8a3ffd04ced81f';
12
+ export const ORACLE_INTERFACE_HASH = '57e5b07c6d55fb167ef90f8d0f410f9bdb5b154a31159c624a061be40b02a2c2';
@@ -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';