@aztec/pxe 0.0.1-commit.c80b6263 → 0.0.1-commit.c949de6bc

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 (194) 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/package_info.js +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +174 -70
  11. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  12. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  14. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  15. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
  16. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  18. package/dest/contract_function_simulator/oracle/interfaces.d.ts +9 -9
  19. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -5
  21. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/oracle.js +32 -20
  23. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +36 -36
  24. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +74 -29
  26. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +48 -24
  27. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +84 -63
  29. package/dest/contract_logging.d.ts +22 -0
  30. package/dest/contract_logging.d.ts.map +1 -0
  31. package/dest/contract_logging.js +23 -0
  32. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  33. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  34. package/dest/contract_sync/contract_sync_service.js +97 -0
  35. package/dest/contract_sync/helpers.d.ts +29 -0
  36. package/dest/contract_sync/helpers.d.ts.map +1 -0
  37. package/dest/contract_sync/{index.js → helpers.js} +13 -12
  38. package/dest/debug/pxe_debug_utils.d.ts +14 -10
  39. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  40. package/dest/debug/pxe_debug_utils.js +16 -15
  41. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  42. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  43. package/dest/entrypoints/client/bundle/index.js +3 -0
  44. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  45. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  46. package/dest/entrypoints/client/bundle/utils.js +11 -2
  47. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  48. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  49. package/dest/entrypoints/client/lazy/index.js +3 -0
  50. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  51. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  52. package/dest/entrypoints/client/lazy/utils.js +11 -2
  53. package/dest/entrypoints/server/index.d.ts +4 -2
  54. package/dest/entrypoints/server/index.d.ts.map +1 -1
  55. package/dest/entrypoints/server/index.js +3 -1
  56. package/dest/entrypoints/server/utils.js +9 -1
  57. package/dest/events/event_service.d.ts +4 -5
  58. package/dest/events/event_service.d.ts.map +1 -1
  59. package/dest/events/event_service.js +5 -6
  60. package/dest/logs/log_service.d.ts +6 -5
  61. package/dest/logs/log_service.d.ts.map +1 -1
  62. package/dest/logs/log_service.js +18 -28
  63. package/dest/notes/note_service.d.ts +7 -7
  64. package/dest/notes/note_service.d.ts.map +1 -1
  65. package/dest/notes/note_service.js +9 -9
  66. package/dest/notes_filter.d.ts +25 -0
  67. package/dest/notes_filter.d.ts.map +1 -0
  68. package/dest/notes_filter.js +4 -0
  69. package/dest/oracle_version.d.ts +3 -3
  70. package/dest/oracle_version.d.ts.map +1 -1
  71. package/dest/oracle_version.js +2 -2
  72. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  73. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  74. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  75. package/dest/private_kernel/hints/index.d.ts +1 -1
  76. package/dest/private_kernel/hints/index.js +1 -1
  77. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  78. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  79. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  80. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  81. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  82. package/dest/private_kernel/hints/test_utils.js +203 -0
  83. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  84. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  85. package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
  86. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  87. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  88. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  89. package/dest/pxe.d.ts +69 -23
  90. package/dest/pxe.d.ts.map +1 -1
  91. package/dest/pxe.js +94 -61
  92. package/dest/storage/address_store/address_store.d.ts +1 -1
  93. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  94. package/dest/storage/address_store/address_store.js +12 -11
  95. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  96. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  97. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  98. package/dest/storage/capsule_store/capsule_store.js +6 -8
  99. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  100. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  101. package/dest/storage/contract_store/contract_store.js +157 -72
  102. package/dest/storage/metadata.d.ts +1 -1
  103. package/dest/storage/metadata.js +1 -1
  104. package/dest/storage/note_store/note_store.d.ts +13 -3
  105. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  106. package/dest/storage/note_store/note_store.js +147 -107
  107. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  108. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  109. package/dest/storage/private_event_store/private_event_store.js +84 -61
  110. package/dest/storage/private_event_store/stored_private_event.js +1 -1
  111. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  112. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  113. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  114. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  115. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  116. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  117. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  118. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  119. package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
  120. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  121. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  122. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  123. package/dest/tagging/index.d.ts +2 -2
  124. package/dest/tagging/index.d.ts.map +1 -1
  125. package/dest/tagging/index.js +1 -1
  126. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  127. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  128. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  129. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  130. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  131. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  132. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  133. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  134. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  135. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  136. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
  137. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  138. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  139. package/package.json +25 -16
  140. package/src/access_scopes.ts +9 -0
  141. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  142. package/src/config/package_info.ts +1 -1
  143. package/src/contract_function_simulator/contract_function_simulator.ts +323 -128
  144. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  145. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  146. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  147. package/src/contract_function_simulator/oracle/interfaces.ts +10 -10
  148. package/src/contract_function_simulator/oracle/oracle.ts +35 -18
  149. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +100 -110
  150. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +131 -64
  151. package/src/contract_logging.ts +39 -0
  152. package/src/contract_sync/contract_sync_service.ts +152 -0
  153. package/src/contract_sync/{index.ts → helpers.ts} +21 -21
  154. package/src/debug/pxe_debug_utils.ts +48 -18
  155. package/src/entrypoints/client/bundle/index.ts +3 -0
  156. package/src/entrypoints/client/bundle/utils.ts +12 -2
  157. package/src/entrypoints/client/lazy/index.ts +3 -0
  158. package/src/entrypoints/client/lazy/utils.ts +12 -2
  159. package/src/entrypoints/server/index.ts +3 -1
  160. package/src/entrypoints/server/utils.ts +7 -7
  161. package/src/events/event_service.ts +4 -6
  162. package/src/logs/log_service.ts +25 -35
  163. package/src/notes/note_service.ts +9 -10
  164. package/src/notes_filter.ts +26 -0
  165. package/src/oracle_version.ts +2 -2
  166. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  167. package/src/private_kernel/hints/index.ts +1 -1
  168. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  169. package/src/private_kernel/hints/test_utils.ts +325 -0
  170. package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
  171. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  172. package/src/pxe.ts +178 -111
  173. package/src/storage/address_store/address_store.ts +15 -15
  174. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  175. package/src/storage/capsule_store/capsule_store.ts +8 -8
  176. package/src/storage/contract_store/contract_store.ts +186 -76
  177. package/src/storage/metadata.ts +1 -1
  178. package/src/storage/note_store/note_store.ts +169 -132
  179. package/src/storage/private_event_store/private_event_store.ts +102 -81
  180. package/src/storage/private_event_store/stored_private_event.ts +1 -1
  181. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  182. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  183. package/src/storage/tagging_store/sender_tagging_store.ts +214 -130
  184. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  185. package/src/tagging/index.ts +1 -1
  186. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
  187. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  188. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  189. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
  190. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
  191. package/dest/contract_sync/index.d.ts +0 -23
  192. package/dest/contract_sync/index.d.ts.map +0 -1
  193. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  194. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
@@ -1,10 +1,13 @@
1
- import { randomBytes } from '@aztec/foundation/crypto/random';
2
- import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
3
- import type { BlockHeader } from '@aztec/stdlib/tx';
1
+ import type { FunctionCall } from '@aztec/stdlib/abi';
2
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
3
+ import type { NoteDao } from '@aztec/stdlib/note';
4
+ import type { ContractOverrides } from '@aztec/stdlib/tx';
4
5
 
6
+ import type { AccessScopes } from '../access_scopes.js';
5
7
  import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
6
- import type { PXE } from '../pxe.js';
7
- import type { ContractStore } from '../storage/contract_store/contract_store.js';
8
+ import type { ContractFunctionSimulator } from '../contract_function_simulator/contract_function_simulator.js';
9
+ import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
10
+ import type { NotesFilter } from '../notes_filter.js';
8
11
  import type { AnchorBlockStore } from '../storage/index.js';
9
12
  import type { NoteStore } from '../storage/note_store/note_store.js';
10
13
 
@@ -13,20 +16,38 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
13
16
  * No backwards compatibility or API stability should be expected. Use at your own risk.
14
17
  */
15
18
  export class PXEDebugUtils {
16
- #pxe!: PXE;
17
19
  #putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
20
+ #getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
21
+ #executeUtility!: (
22
+ contractFunctionSimulator: ContractFunctionSimulator,
23
+ call: FunctionCall,
24
+ authWitnesses: AuthWitness[] | undefined,
25
+ scopes: AccessScopes,
26
+ jobId: string,
27
+ ) => Promise<any>;
18
28
 
19
29
  constructor(
20
- private contractStore: ContractStore,
30
+ private contractSyncService: ContractSyncService,
21
31
  private noteStore: NoteStore,
22
32
  private blockStateSynchronizer: BlockSynchronizer,
23
33
  private anchorBlockStore: AnchorBlockStore,
24
34
  ) {}
25
35
 
26
36
  /** Not injected through constructor since they're are co-dependant */
27
- public setPXE(pxe: PXE, putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>) {
28
- this.#pxe = pxe;
37
+ public setPXEHelpers(
38
+ putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
39
+ getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
40
+ executeUtility: (
41
+ contractFunctionSimulator: ContractFunctionSimulator,
42
+ call: FunctionCall,
43
+ authWitnesses: AuthWitness[] | undefined,
44
+ scopes: AccessScopes,
45
+ jobId: string,
46
+ ) => Promise<any>,
47
+ ) {
29
48
  this.#putJobInQueue = putJobInQueue;
49
+ this.#getSimulatorForTx = getSimulatorForTx;
50
+ this.#executeUtility = executeUtility;
30
51
  }
31
52
 
32
53
  /**
@@ -40,17 +61,26 @@ export class PXEDebugUtils {
40
61
  * @param filter - The filter to apply to the notes.
41
62
  * @returns The requested notes.
42
63
  */
43
- public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
44
- // We need to manually trigger private state sync to have a guarantee that all the notes are available.
45
- const call = await this.contractStore.getFunctionCall('sync_state', [], filter.contractAddress);
46
- await this.#pxe.simulateUtility(call);
64
+ public getNotes(filter: NotesFilter): Promise<NoteDao[]> {
65
+ return this.#putJobInQueue(async (jobId: string) => {
66
+ await this.blockStateSynchronizer.sync();
47
67
 
48
- return this.noteStore.getNotes(filter, randomBytes(8).toString('hex'));
49
- }
68
+ const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
69
+
70
+ const contractFunctionSimulator = this.#getSimulatorForTx();
71
+
72
+ await this.contractSyncService.ensureContractSynced(
73
+ filter.contractAddress,
74
+ null,
75
+ async (privateSyncCall, execScopes) =>
76
+ await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
77
+ anchorBlockHeader,
78
+ jobId,
79
+ filter.scopes,
80
+ );
50
81
 
51
- /** Returns the block header up to which the PXE has synced. */
52
- public getSyncedBlockHeader(): Promise<BlockHeader> {
53
- return this.anchorBlockStore.getBlockHeader();
82
+ return this.noteStore.getNotes(filter, jobId);
83
+ });
54
84
  }
55
85
 
56
86
  /**
@@ -1,6 +1,9 @@
1
+ export * from '../../../access_scopes.js';
2
+ export * from '../../../notes_filter.js';
1
3
  export * from '../../../pxe.js';
2
4
  export * from '../../../config/index.js';
3
5
  export * from '../../../error_enriching.js';
6
+ export * from '../../../contract_logging.js';
4
7
  export * from '../../../storage/index.js';
5
8
  export * from './utils.js';
6
9
  export type { PXECreationOptions } from '../../pxe_creation_options.js';
@@ -8,6 +8,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
8
 
9
9
  import type { PXEConfig } from '../../../config/index.js';
10
10
  import { PXE } from '../../../pxe.js';
11
+ import { PXE_DATA_SCHEMA_VERSION } from '../../../storage/metadata.js';
11
12
  import type { PXECreationOptions } from '../../pxe_creation_options.js';
12
13
 
13
14
  /**
@@ -36,7 +37,8 @@ export async function createPXE(
36
37
 
37
38
  const storeLogger = loggers.store ?? createLogger('pxe:data:idb', { actor });
38
39
 
39
- const store = options.store ?? (await createStore('pxe_data', configWithContracts, storeLogger));
40
+ const store =
41
+ options.store ?? (await createStore('pxe_data', configWithContracts, PXE_DATA_SCHEMA_VERSION, storeLogger));
40
42
 
41
43
  const simulator = options.simulator ?? new WASMSimulator();
42
44
  const proverLogger = loggers.prover ?? createLogger('pxe:bb:wasm:bundle', { actor });
@@ -50,6 +52,14 @@ export async function createPXE(
50
52
  const protocolContractsProvider = new BundledProtocolContractsProvider();
51
53
 
52
54
  const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
53
- const pxe = await PXE.create(aztecNode, store, prover, simulator, protocolContractsProvider, config, pxeLogger);
55
+ const pxe = await PXE.create({
56
+ node: aztecNode,
57
+ store,
58
+ proofCreator: prover,
59
+ simulator,
60
+ protocolContractsProvider,
61
+ config,
62
+ loggerOrSuffix: pxeLogger,
63
+ });
54
64
  return pxe;
55
65
  }
@@ -1,6 +1,9 @@
1
+ export * from '../../../access_scopes.js';
2
+ export * from '../../../notes_filter.js';
1
3
  export * from '../../../pxe.js';
2
4
  export * from '../../../config/index.js';
3
5
  export * from '../../../storage/index.js';
4
6
  export * from '../../../error_enriching.js';
7
+ export * from '../../../contract_logging.js';
5
8
  export * from './utils.js';
6
9
  export { type PXECreationOptions } from '../../pxe_creation_options.js';
@@ -8,6 +8,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
8
 
9
9
  import type { PXEConfig } from '../../../config/index.js';
10
10
  import { PXE } from '../../../pxe.js';
11
+ import { PXE_DATA_SCHEMA_VERSION } from '../../../storage/metadata.js';
11
12
  import type { PXECreationOptions } from '../../pxe_creation_options.js';
12
13
 
13
14
  /**
@@ -36,7 +37,8 @@ export async function createPXE(
36
37
 
37
38
  const storeLogger = loggers.store ?? createLogger('pxe:data:idb', { actor });
38
39
 
39
- const store = options.store ?? (await createStore('pxe_data', configWithContracts, storeLogger));
40
+ const store =
41
+ options.store ?? (await createStore('pxe_data', configWithContracts, PXE_DATA_SCHEMA_VERSION, storeLogger));
40
42
 
41
43
  const simulator = options.simulator ?? new WASMSimulator();
42
44
  const proverLogger = loggers.prover ?? createLogger('pxe:bb:wasm:bundle', { actor });
@@ -50,6 +52,14 @@ export async function createPXE(
50
52
  const protocolContractsProvider = new LazyProtocolContractsProvider();
51
53
 
52
54
  const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
53
- const pxe = await PXE.create(aztecNode, store, prover, simulator, protocolContractsProvider, config, pxeLogger);
55
+ const pxe = await PXE.create({
56
+ node: aztecNode,
57
+ store,
58
+ proofCreator: prover,
59
+ simulator,
60
+ protocolContractsProvider,
61
+ config,
62
+ loggerOrSuffix: pxeLogger,
63
+ });
54
64
  return pxe;
55
65
  }
@@ -1,3 +1,5 @@
1
+ export * from '../../access_scopes.js';
2
+ export * from '../../notes_filter.js';
1
3
  export * from '../../pxe.js';
2
4
  export * from '../../config/index.js';
3
5
  export * from '../../error_enriching.js';
@@ -7,4 +9,4 @@ export { NoteService } from '../../notes/note_service.js';
7
9
  export { ORACLE_VERSION } from '../../oracle_version.js';
8
10
  export { type PXECreationOptions } from '../pxe_creation_options.js';
9
11
  export { JobCoordinator } from '../../job_coordinator/job_coordinator.js';
10
- export { syncState } from '../../contract_sync/index.js';
12
+ export { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
@@ -58,14 +58,14 @@ export async function createPXE(
58
58
  const protocolContractsProvider = new BundledProtocolContractsProvider();
59
59
 
60
60
  const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
61
- const pxe = await PXE.create(
62
- aztecNode,
63
- options.store,
64
- prover,
61
+ const pxe = await PXE.create({
62
+ node: aztecNode,
63
+ store: options.store,
64
+ proofCreator: prover,
65
65
  simulator,
66
66
  protocolContractsProvider,
67
- configWithContracts,
68
- pxeLogger,
69
- );
67
+ config: configWithContracts,
68
+ loggerOrSuffix: pxeLogger,
69
+ });
70
70
  return pxe;
71
71
  }
@@ -3,14 +3,13 @@ import type { EventSelector } from '@aztec/stdlib/abi';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { siloNullifier } from '@aztec/stdlib/hash';
5
5
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
6
- import type { TxHash } from '@aztec/stdlib/tx';
6
+ import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
7
7
 
8
- import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
9
8
  import { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
10
9
 
11
10
  export class EventService {
12
11
  constructor(
13
- private readonly anchorBlockStore: AnchorBlockStore,
12
+ private readonly anchorBlockHeader: BlockHeader,
14
13
  private readonly aztecNode: AztecNode,
15
14
  private readonly privateEventStore: PrivateEventStore,
16
15
  private readonly jobId: string,
@@ -29,13 +28,12 @@ export class EventService {
29
28
  // (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
30
29
  // maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
31
30
  // since `fetchTaggedLogs` only processes logs up to the synced block.
32
- const [anchorBlockHeader, siloedEventCommitment, txEffect] = await Promise.all([
33
- this.anchorBlockStore.getBlockHeader(),
31
+ const [siloedEventCommitment, txEffect] = await Promise.all([
34
32
  siloNullifier(contractAddress, eventCommitment),
35
33
  this.aztecNode.getTxEffect(txHash),
36
34
  ]);
37
35
 
38
- const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
36
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
39
37
 
40
38
  if (!txEffect) {
41
39
  throw new Error(`Could not find tx effect for tx hash ${txHash}`);
@@ -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
  }
@@ -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
+ };
@@ -4,9 +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 = 9;
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
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 = '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';