@aztec/pxe 5.0.0-rc.1 → 5.0.0-rc.2

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 (218) hide show
  1. package/dest/block_synchronizer/block_stream_source.d.ts +5 -5
  2. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_stream_source.js +4 -29
  4. package/dest/block_synchronizer/block_synchronizer.d.ts +13 -11
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  6. package/dest/block_synchronizer/block_synchronizer.js +43 -15
  7. package/dest/config/index.d.ts +2 -1
  8. package/dest/config/index.d.ts.map +1 -1
  9. package/dest/config/index.js +1 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts +11 -16
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/contract_function_simulator.js +22 -18
  13. package/dest/contract_function_simulator/index.d.ts +15 -9
  14. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/index.js +3 -7
  16. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
  17. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
  19. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  20. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  22. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  23. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  25. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  26. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  27. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  28. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  29. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  30. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  31. package/dest/contract_function_simulator/noir-structs/fact_collection.js +29 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +4 -8
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  39. package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
  40. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/noir-structs/option.js +18 -13
  42. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  43. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  45. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +5 -8
  46. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -14
  48. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +21 -0
  49. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +33 -0
  51. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
  52. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
  54. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
  55. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  57. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  58. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  60. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  61. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  63. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +81 -6
  64. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/oracle/oracle_registry.js +128 -9
  66. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +80 -36
  67. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  68. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +926 -264
  69. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +13 -8
  70. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +80 -11
  72. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +46 -20
  73. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  74. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +119 -55
  75. package/dest/contract_sync/helpers.d.ts +7 -6
  76. package/dest/contract_sync/helpers.d.ts.map +1 -1
  77. package/dest/contract_sync/helpers.js +11 -16
  78. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  79. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/utils.js +1 -0
  81. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  82. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/lazy/utils.js +1 -0
  84. package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
  85. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  86. package/dest/entrypoints/server/index.d.ts +1 -2
  87. package/dest/entrypoints/server/index.d.ts.map +1 -1
  88. package/dest/entrypoints/server/index.js +0 -1
  89. package/dest/entrypoints/server/utils.d.ts +1 -1
  90. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  91. package/dest/entrypoints/server/utils.js +3 -1
  92. package/dest/error_enriching.js +1 -1
  93. package/dest/hooks/execution_hooks.d.ts +16 -7
  94. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  95. package/dest/hooks/execution_hooks.js +3 -3
  96. package/dest/hooks/index.d.ts +3 -3
  97. package/dest/hooks/index.d.ts.map +1 -1
  98. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +41 -0
  99. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  100. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  101. package/dest/logs/log_service.d.ts +6 -6
  102. package/dest/logs/log_service.d.ts.map +1 -1
  103. package/dest/logs/log_service.js +62 -28
  104. package/dest/messages/tx_resolver_service.d.ts +17 -0
  105. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  106. package/dest/messages/{message_context_service.js → tx_resolver_service.js} +8 -8
  107. package/dest/oracle_version.d.ts +2 -2
  108. package/dest/oracle_version.js +2 -2
  109. package/dest/private_kernel/hints/test_utils.js +1 -1
  110. package/dest/pxe.d.ts +46 -19
  111. package/dest/pxe.d.ts.map +1 -1
  112. package/dest/pxe.js +104 -52
  113. package/dest/storage/allowed_scopes.d.ts +6 -0
  114. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  115. package/dest/storage/allowed_scopes.js +7 -0
  116. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  117. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  118. package/dest/storage/backwards_compatibility_tests/schema_tests.js +86 -33
  119. package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
  120. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  121. package/dest/storage/capsule_store/capsule_service.js +6 -9
  122. package/dest/storage/contract_store/contract_store.js +2 -2
  123. package/dest/storage/fact_store/fact_service.d.ts +20 -0
  124. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  125. package/dest/storage/fact_store/fact_service.js +30 -0
  126. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  127. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  128. package/dest/storage/fact_store/fact_store.js +408 -0
  129. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  130. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  131. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  132. package/dest/storage/fact_store/index.d.ts +5 -0
  133. package/dest/storage/fact_store/index.d.ts.map +1 -0
  134. package/dest/storage/fact_store/index.js +3 -0
  135. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  136. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  137. package/dest/storage/fact_store/stored_fact.js +64 -0
  138. package/dest/storage/index.d.ts +2 -1
  139. package/dest/storage/index.d.ts.map +1 -1
  140. package/dest/storage/index.js +1 -0
  141. package/dest/storage/metadata.d.ts +1 -1
  142. package/dest/storage/metadata.js +1 -1
  143. package/dest/storage/open_pxe_stores.d.ts +5 -3
  144. package/dest/storage/open_pxe_stores.d.ts.map +1 -1
  145. package/dest/storage/open_pxe_stores.js +5 -3
  146. package/dest/storage/tagging_store/index.d.ts +2 -2
  147. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  148. package/dest/storage/tagging_store/index.js +1 -1
  149. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +40 -0
  150. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  151. package/dest/storage/tagging_store/tagging_secret_sources_store.js +92 -0
  152. package/package.json +17 -17
  153. package/src/block_synchronizer/block_stream_source.ts +6 -45
  154. package/src/block_synchronizer/block_synchronizer.ts +56 -23
  155. package/src/config/index.ts +1 -0
  156. package/src/contract_function_simulator/contract_function_simulator.ts +32 -31
  157. package/src/contract_function_simulator/index.ts +17 -8
  158. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
  159. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  160. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  161. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  162. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  163. package/src/contract_function_simulator/noir-structs/fact_collection.ts +59 -0
  164. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
  165. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +7 -60
  166. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  167. package/src/contract_function_simulator/noir-structs/option.ts +17 -11
  168. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  169. package/src/contract_function_simulator/noir-structs/provided_secret.ts +3 -14
  170. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +45 -0
  171. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
  172. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
  173. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  174. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  175. package/src/contract_function_simulator/oracle/oracle_registry.ts +87 -79
  176. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +641 -247
  177. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +94 -14
  178. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +206 -66
  179. package/src/contract_sync/helpers.ts +11 -18
  180. package/src/entrypoints/client/bundle/utils.ts +1 -0
  181. package/src/entrypoints/client/lazy/utils.ts +1 -0
  182. package/src/entrypoints/pxe_creation_options.ts +7 -1
  183. package/src/entrypoints/server/index.ts +0 -1
  184. package/src/entrypoints/server/utils.ts +3 -1
  185. package/src/error_enriching.ts +1 -1
  186. package/src/hooks/execution_hooks.ts +17 -8
  187. package/src/hooks/index.ts +6 -2
  188. package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
  189. package/src/logs/log_service.ts +71 -37
  190. package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
  191. package/src/oracle_version.ts +2 -2
  192. package/src/private_kernel/hints/test_utils.ts +1 -1
  193. package/src/pxe.ts +150 -54
  194. package/src/storage/allowed_scopes.ts +14 -0
  195. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  196. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +1 -1
  197. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  198. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +21 -5
  199. package/src/storage/backwards_compatibility_tests/schema_tests.ts +88 -33
  200. package/src/storage/capsule_store/capsule_service.ts +8 -13
  201. package/src/storage/contract_store/contract_store.ts +2 -2
  202. package/src/storage/fact_store/fact_service.ts +45 -0
  203. package/src/storage/fact_store/fact_store.ts +487 -0
  204. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  205. package/src/storage/fact_store/index.ts +4 -0
  206. package/src/storage/fact_store/stored_fact.ts +80 -0
  207. package/src/storage/index.ts +1 -0
  208. package/src/storage/metadata.ts +1 -1
  209. package/src/storage/open_pxe_stores.ts +6 -3
  210. package/src/storage/tagging_store/index.ts +1 -1
  211. package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
  212. package/dest/messages/message_context_service.d.ts +0 -17
  213. package/dest/messages/message_context_service.d.ts.map +0 -1
  214. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  215. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  216. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  217. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
  218. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
package/src/pxe.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { Point } from '@aztec/foundation/curves/grumpkin';
4
5
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
5
6
  import { SerialQueue } from '@aztec/foundation/queue';
6
7
  import { Timer } from '@aztec/foundation/timer';
@@ -26,7 +27,7 @@ import {
26
27
  getContractClassFromArtifact,
27
28
  } from '@aztec/stdlib/contract';
28
29
  import { SimulationError } from '@aztec/stdlib/errors';
29
- import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
30
+ import type { AztecNode, AztecNodeDebug, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
30
31
  import type {
31
32
  PrivateExecutionStep,
32
33
  PrivateKernelExecutionProofOutput,
@@ -68,7 +69,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
68
69
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
69
70
  import type { ExecutionHooks } from './hooks/index.js';
70
71
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
71
- import { MessageContextService } from './messages/message_context_service.js';
72
+ import { TxResolverService } from './messages/tx_resolver_service.js';
72
73
  import {
73
74
  PrivateKernelExecutionProver,
74
75
  type PrivateKernelExecutionProverConfig,
@@ -78,12 +79,13 @@ import { AddressStore } from './storage/address_store/address_store.js';
78
79
  import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
79
80
  import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
80
81
  import { ContractStore } from './storage/contract_store/contract_store.js';
82
+ import { FactStore } from './storage/fact_store/index.js';
81
83
  import { NoteStore } from './storage/note_store/note_store.js';
82
84
  import { openPxeStores } from './storage/open_pxe_stores.js';
83
85
  import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
84
86
  import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
85
- import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
86
87
  import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
88
+ import { TaggingSecretSourcesStore } from './storage/tagging_store/tagging_secret_sources_store.js';
87
89
  import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
88
90
 
89
91
  export type PackedPrivateEvent = InTx & {
@@ -160,6 +162,11 @@ export type PreloadedContractsProvider = {
160
162
  export type PXECreateArgs = {
161
163
  /** The Aztec node to connect to. */
162
164
  node: AztecNode;
165
+ /**
166
+ * Optional debug API client. When provided, public function signatures are registered with the node so that
167
+ * node-side public-execution stack traces can be named. Skipped when the node does not expose the debug API.
168
+ */
169
+ nodeDebug?: AztecNodeDebug;
163
170
  /** The key-value store for persisting PXE state. */
164
171
  store: AztecAsyncKVStore;
165
172
  /** The prover for generating private kernel proofs. */
@@ -182,6 +189,19 @@ export type PXECreateArgs = {
182
189
  hooks?: ExecutionHooks;
183
190
  };
184
191
 
192
+ /**
193
+ * A source from which PXE derives the tagging secrets it scans for to discover incoming private logs.
194
+ *
195
+ * - `address-derived`: derives a shared secret via ECDH from an external `sender` address against every account
196
+ * registered in this PXE (present and future), so registering one sender applies it to all of them. The address is
197
+ * not secret, so unlike `arbitrary-secret` it can be reused freely across recipients.
198
+ * - `arbitrary-secret`: a shared secret point provided directly, scoped to a single recipient. It bypasses ECDH, so it
199
+ * must not be reused across recipients (each would then be able to find the others' tags).
200
+ */
201
+ export type TaggingSecretSource =
202
+ | { kind: 'address-derived'; sender: AztecAddress }
203
+ | { kind: 'arbitrary-secret'; recipient: AztecAddress; secret: Point };
204
+
185
205
  /**
186
206
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
187
207
  * manage private state of users.
@@ -189,20 +209,22 @@ export type PXECreateArgs = {
189
209
  export class PXE {
190
210
  private constructor(
191
211
  private node: AztecNode,
212
+ private nodeDebug: AztecNodeDebug | undefined,
192
213
  private db: AztecAsyncKVStore,
193
214
  private blockStateSynchronizer: BlockSynchronizer,
194
215
  private keyStore: KeyStore,
195
216
  private contractStore: ContractStore,
196
217
  private noteStore: NoteStore,
197
218
  private capsuleStore: CapsuleStore,
219
+ private factStore: FactStore,
198
220
  private anchorBlockStore: AnchorBlockStore,
199
221
  private senderTaggingStore: SenderTaggingStore,
200
- private senderAddressBookStore: SenderAddressBookStore,
222
+ private taggingSecretSourcesStore: TaggingSecretSourcesStore,
201
223
  private recipientTaggingStore: RecipientTaggingStore,
202
224
  private addressStore: AddressStore,
203
225
  private privateEventStore: PrivateEventStore,
204
226
  private contractSyncService: ContractSyncService,
205
- private messageContextService: MessageContextService,
227
+ private txResolver: TxResolverService,
206
228
  private l2TipsStore: L2TipsProvider,
207
229
  private simulator: CircuitSimulator,
208
230
  private proverEnabled: boolean,
@@ -226,6 +248,7 @@ export class PXE {
226
248
  */
227
249
  public static async create({
228
250
  node,
251
+ nodeDebug,
229
252
  store,
230
253
  proofCreator,
231
254
  simulator,
@@ -262,11 +285,12 @@ export class PXE {
262
285
  noteStore,
263
286
  anchorBlockStore,
264
287
  senderTaggingStore,
265
- senderAddressBookStore,
288
+ taggingSecretSourcesStore,
266
289
  recipientTaggingStore,
267
290
  capsuleStore,
268
291
  keyStore,
269
292
  l2TipsStore,
293
+ factStore,
270
294
  } = openPxeStores(store, initialBlockHash);
271
295
  const contractSyncService = new ContractSyncService(
272
296
  node,
@@ -274,7 +298,7 @@ export class PXE {
274
298
  noteStore,
275
299
  createLogger('pxe:contract_sync', bindings),
276
300
  );
277
- const messageContextService = new MessageContextService(node);
301
+ const txResolver = new TxResolverService(node);
278
302
 
279
303
  const synchronizer = new BlockSynchronizer(
280
304
  node,
@@ -282,6 +306,7 @@ export class PXE {
282
306
  anchorBlockStore,
283
307
  noteStore,
284
308
  privateEventStore,
309
+ factStore,
285
310
  l2TipsStore,
286
311
  contractSyncService,
287
312
  config,
@@ -295,6 +320,7 @@ export class PXE {
295
320
  recipientTaggingStore,
296
321
  privateEventStore,
297
322
  noteStore,
323
+ factStore,
298
324
  contractSyncService,
299
325
  ]);
300
326
 
@@ -304,20 +330,22 @@ export class PXE {
304
330
 
305
331
  const pxe = new PXE(
306
332
  node,
333
+ nodeDebug,
307
334
  store,
308
335
  synchronizer,
309
336
  keyStore,
310
337
  contractStore,
311
338
  noteStore,
312
339
  capsuleStore,
340
+ factStore,
313
341
  anchorBlockStore,
314
342
  senderTaggingStore,
315
- senderAddressBookStore,
343
+ taggingSecretSourcesStore,
316
344
  recipientTaggingStore,
317
345
  addressStore,
318
346
  privateEventStore,
319
347
  contractSyncService,
320
- messageContextService,
348
+ txResolver,
321
349
  l2TipsStore,
322
350
  simulator,
323
351
  proverEnabled,
@@ -359,12 +387,13 @@ export class PXE {
359
387
  l2TipsStore: this.l2TipsStore,
360
388
  senderTaggingStore: this.senderTaggingStore,
361
389
  recipientTaggingStore: this.recipientTaggingStore,
362
- senderAddressBookStore: this.senderAddressBookStore,
390
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
363
391
  capsuleStore: this.capsuleStore,
392
+ factStore: this.factStore,
364
393
  privateEventStore: this.privateEventStore,
365
394
  simulator: this.simulator,
366
395
  contractSyncService: this.contractSyncService,
367
- messageContextService: this.messageContextService,
396
+ txResolver: this.txResolver,
368
397
  hooks: this.hooks,
369
398
  });
370
399
  }
@@ -469,8 +498,6 @@ export class PXE {
469
498
  );
470
499
 
471
500
  const result = await contractFunctionSimulator.run(txRequest, {
472
- contractAddress,
473
- selector: functionSelector,
474
501
  anchorBlockHeader,
475
502
  scopes,
476
503
  jobId,
@@ -653,62 +680,131 @@ export class PXE {
653
680
  }
654
681
 
655
682
  /**
656
- * Registers a sender in this PXE.
657
- *
658
- * After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
659
- * Will do nothing if the address is already registered.
683
+ * Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
684
+ * See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
660
685
  *
661
- * @param sender - Address of the sender to register.
662
- * @returns The address of the sender.
663
- * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
686
+ * After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
687
+ * re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
688
+ * notes/events are not discarded.
664
689
  */
665
- public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
666
- if (!(await sender.isValid())) {
667
- throw new Error(
668
- `Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
669
- );
670
- }
671
-
672
- const accounts = await this.keyStore.getAccounts();
673
- if (accounts.some(a => a.equals(sender))) {
674
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
675
- return sender;
690
+ public async registerTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
691
+ let wasAdded: boolean;
692
+
693
+ switch (source.kind) {
694
+ case 'address-derived':
695
+ wasAdded = await this.#registerSender(source.sender);
696
+ break;
697
+ case 'arbitrary-secret':
698
+ wasAdded = await this.#registerArbitrarySecret(source.recipient, source.secret);
699
+ break;
700
+ default: {
701
+ const _: never = source;
702
+ throw new Error('Unhandled tagging secret source kind');
703
+ }
676
704
  }
677
705
 
678
- const wasAdded = await this.senderAddressBookStore.addSender(sender);
679
-
680
706
  if (wasAdded) {
681
- this.log.info(`Added sender:\n ${sender.toString()}`);
682
- // Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
683
- // all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
707
+ // Queued to avoid wiping while a job is in flight.
684
708
  await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
685
- } else {
686
- this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
687
709
  }
688
-
689
- return sender;
690
710
  }
691
711
 
692
712
  /**
693
- * Retrieves senders registered in this PXE.
694
- * @returns Senders registered in this PXE.
713
+ * Removes a previously registered tagging secret source. Does nothing if it was not registered.
695
714
  */
696
- public getSenders(): Promise<AztecAddress[]> {
697
- return this.senderAddressBookStore.getSenders();
715
+ public async removeTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
716
+ switch (source.kind) {
717
+ case 'address-derived': {
718
+ const { sender } = source;
719
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
720
+ this.log.info(
721
+ wasRemoved
722
+ ? `Removed sender:\n ${sender.toString()}`
723
+ : `Sender:\n "${sender.toString()}"\n not registered in PXE.`,
724
+ );
725
+ break;
726
+ }
727
+ case 'arbitrary-secret': {
728
+ const { recipient, secret } = source;
729
+ const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, secret);
730
+ this.log.info(
731
+ wasRemoved
732
+ ? `Removed shared secret for recipient:\n ${recipient.toString()}`
733
+ : `Shared secret not registered for recipient:\n ${recipient.toString()}`,
734
+ );
735
+ break;
736
+ }
737
+ default: {
738
+ const _: never = source;
739
+ throw new Error('Unhandled tagging secret source kind');
740
+ }
741
+ }
698
742
  }
699
743
 
700
744
  /**
701
- * Removes a sender registered in this PXE.
702
- * @param sender - The address of the sender to remove.
745
+ * Retrieves the tagging secret sources registered in this PXE. Without a filter it returns every source; pass
746
+ * `{ kind }` to narrow to a single variant. See {@link TaggingSecretSource}.
703
747
  */
704
- public async removeSender(sender: AztecAddress): Promise<void> {
705
- const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
748
+ public getTaggingSecretSources<K extends TaggingSecretSource['kind']>(filter: {
749
+ kind: K;
750
+ }): Promise<Extract<TaggingSecretSource, { kind: K }>[]>;
751
+ public getTaggingSecretSources(): Promise<TaggingSecretSource[]>;
752
+ public async getTaggingSecretSources(filter?: {
753
+ kind?: TaggingSecretSource['kind'];
754
+ }): Promise<TaggingSecretSource[]> {
755
+ const [senders, secrets] = await Promise.all([
756
+ this.taggingSecretSourcesStore.getSenders(),
757
+ this.taggingSecretSourcesStore.getAllSharedSecrets(),
758
+ ]);
706
759
 
707
- if (wasRemoved) {
708
- this.log.info(`Removed sender:\n ${sender.toString()}`);
709
- } else {
710
- this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
760
+ const sources: TaggingSecretSource[] = [
761
+ ...senders.map((sender): TaggingSecretSource => ({ kind: 'address-derived', sender })),
762
+ ...secrets.map(({ recipient, secret }): TaggingSecretSource => ({ kind: 'arbitrary-secret', recipient, secret })),
763
+ ];
764
+
765
+ return filter?.kind ? sources.filter(source => source.kind === filter.kind) : sources;
766
+ }
767
+
768
+ /** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */
769
+ async #registerSender(address: AztecAddress): Promise<boolean> {
770
+ if (!(await address.isValid())) {
771
+ throw new Error(
772
+ `Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
773
+ );
774
+ }
775
+
776
+ const accounts = await this.keyStore.getAccounts();
777
+ if (accounts.some(a => a.equals(address))) {
778
+ this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
779
+ return false;
780
+ }
781
+
782
+ const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
783
+ this.log.info(
784
+ wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`,
785
+ );
786
+ return wasAdded;
787
+ }
788
+
789
+ /** Registers a directly-provided shared secret scoped to a recipient. Returns whether it was newly added. */
790
+ async #registerArbitrarySecret(recipient: AztecAddress, secret: Point): Promise<boolean> {
791
+ if (!(await recipient.isValid())) {
792
+ throw new Error(
793
+ `Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`,
794
+ );
795
+ }
796
+
797
+ if (secret.isZero() || !secret.isOnCurve()) {
798
+ throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
711
799
  }
800
+
801
+ const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, secret);
802
+ this.log.info(
803
+ wasAdded
804
+ ? `Added shared secret for recipient:\n ${recipient.toString()}`
805
+ : `Shared secret already registered for recipient:\n ${recipient.toString()}`,
806
+ );
807
+ return wasAdded;
712
808
  }
713
809
 
714
810
  /**
@@ -766,7 +862,7 @@ export class PXE {
766
862
  .filter(fn => fn.functionType === FunctionType.PUBLIC)
767
863
  .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
768
864
  if (publicFunctionSignatures.length > 0) {
769
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
865
+ await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
770
866
  }
771
867
  } else {
772
868
  // Otherwise, make sure there is an artifact already registered for that class id
@@ -815,7 +911,7 @@ export class PXE {
815
911
  .filter(fn => fn.functionType === FunctionType.PUBLIC)
816
912
  .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
817
913
  if (publicFunctionSignatures.length > 0) {
818
- await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
914
+ await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
819
915
  }
820
916
 
821
917
  currentInstance.currentContractClassId = contractClass.id;
@@ -0,0 +1,14 @@
1
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+
3
+ /**
4
+ * Asserts that `scope` is one of `allowedScopes`, throwing otherwise.
5
+ */
6
+ export function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[]): void {
7
+ if (!allowedScopes.some((allowed: AztecAddress) => allowed.equals(scope))) {
8
+ throw new Error(
9
+ `Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes
10
+ .map((s: AztecAddress) => s.toString())
11
+ .join(', ')}]. See https://docs.aztec.network/errors/10`,
12
+ );
13
+ }
14
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "facts": [
3
+ {
4
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000aa:0x0000000000000000000000000000000000000000000000000000000000000003:0x00eebee6df09ad503384e049aea9fbf0c0db2f5af46673e550694c6564d973f7:6:0x0000000000000000000000000000000000000000000000000000000000000002",
5
+ "value": "00000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000aa000000000000000000000000000000000000000000000000000000000000000300000001000000000000000000000000000000000000000000000000000000000000000501000000060000000000000000000000000000000000000000000000000000000000000002"
6
+ },
7
+ {
8
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb:0x0000000000000000000000000000000000000000000000000000000000000001:0x00a802572c436574f713d43f1852859f4496d694de0e5b17b89cf983439e6143:none",
9
+ "value": "00000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000bb000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000"
10
+ },
11
+ {
12
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb:0x0000000000000000000000000000000000000000000000000000000000000002:0x00df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b811:5:0x0000000000000000000000000000000000000000000000000000000000000001",
13
+ "value": "00000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000bb00000000000000000000000000000000000000000000000000000000000000020000000001000000050000000000000000000000000000000000000000000000000000000000000001"
14
+ }
15
+ ],
16
+ "facts_by_collection": [
17
+ {
18
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000aa",
19
+ "value": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000aa:0x0000000000000000000000000000000000000000000000000000000000000003:0x00eebee6df09ad503384e049aea9fbf0c0db2f5af46673e550694c6564d973f7:6:0x0000000000000000000000000000000000000000000000000000000000000002"
20
+ },
21
+ {
22
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb",
23
+ "value": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb:0x0000000000000000000000000000000000000000000000000000000000000001:0x00a802572c436574f713d43f1852859f4496d694de0e5b17b89cf983439e6143:none"
24
+ },
25
+ {
26
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb",
27
+ "value": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb:0x0000000000000000000000000000000000000000000000000000000000000002:0x00df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b811:5:0x0000000000000000000000000000000000000000000000000000000000000001"
28
+ }
29
+ ],
30
+ "facts_by_block": [
31
+ {
32
+ "key": "num:5",
33
+ "value": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000bb:0x0000000000000000000000000000000000000000000000000000000000000002:0x00df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b811:5:0x0000000000000000000000000000000000000000000000000000000000000001"
34
+ },
35
+ {
36
+ "key": "num:6",
37
+ "value": "utf8:0x0000000000000000000000000000000000000000000000000000000000000064:0x0000000000000000000000000000000000000000000000000000000000000001:0x0000000000000000000000000000000000000000000000000000000000000007:0x00000000000000000000000000000000000000000000000000000000000000aa:0x0000000000000000000000000000000000000000000000000000000000000003:0x00eebee6df09ad503384e049aea9fbf0c0db2f5af46673e550694c6564d973f7:6:0x0000000000000000000000000000000000000000000000000000000000000002"
38
+ }
39
+ ]
40
+ }
@@ -16,7 +16,7 @@
16
16
  "pxe_l2_tip_checkpoints": [
17
17
  {
18
18
  "key": "utf8:checkpointed",
19
- "value": "{\"number\":47,\"hash\":\"0x00a21eaf943186f15f609a8a76fb0bee7ce3e78c86ef95f5466614e59546eb19\"}"
19
+ "value": "{\"number\":47,\"hash\":\"0x00e66a45cc6583f772f44bdb5ae6535cf821a59a3d832702a125f0c57f6228ef\"}"
20
20
  },
21
21
  {
22
22
  "key": "utf8:proven",
@@ -0,0 +1,30 @@
1
+ {
2
+ "senders": [
3
+ {
4
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000002",
5
+ "value": "true"
6
+ },
7
+ {
8
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000003",
9
+ "value": "true"
10
+ },
11
+ {
12
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000005",
13
+ "value": "true"
14
+ }
15
+ ],
16
+ "recipient_shared_secrets": [
17
+ {
18
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000007",
19
+ "value": "utf8:0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003"
20
+ },
21
+ {
22
+ "key": "utf8:0x0000000000000000000000000000000000000000000000000000000000000007",
23
+ "value": "utf8:0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000007"
24
+ },
25
+ {
26
+ "key": "utf8:0x000000000000000000000000000000000000000000000000000000000000000b",
27
+ "value": "utf8:0x000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011"
28
+ }
29
+ ]
30
+ }
@@ -1,10 +1,6 @@
1
1
  {
2
- "schemaVersion": 8,
2
+ "schemaVersion": 9,
3
3
  "stores": [
4
- {
5
- "name": "address_book",
6
- "kind": "map"
7
- },
8
4
  {
9
5
  "name": "capsules",
10
6
  "kind": "map"
@@ -37,6 +33,18 @@
37
33
  "name": "events_by_contract_selector",
38
34
  "kind": "multimap"
39
35
  },
36
+ {
37
+ "name": "facts",
38
+ "kind": "map"
39
+ },
40
+ {
41
+ "name": "facts_by_block",
42
+ "kind": "multimap"
43
+ },
44
+ {
45
+ "name": "facts_by_collection",
46
+ "kind": "multimap"
47
+ },
40
48
  {
41
49
  "name": "header",
42
50
  "kind": "singleton"
@@ -96,6 +104,14 @@
96
104
  {
97
105
  "name": "pxe_l2_tips",
98
106
  "kind": "map"
107
+ },
108
+ {
109
+ "name": "recipient_shared_secrets",
110
+ "kind": "multimap"
111
+ },
112
+ {
113
+ "name": "senders",
114
+ "kind": "map"
99
115
  }
100
116
  ]
101
117
  }