@aztec/pxe 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec5f612

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 (205) 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 +5 -3
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  6. package/dest/block_synchronizer/block_synchronizer.js +11 -5
  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 +10 -10
  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 +38 -26
  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 -31
  26. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +53 -29
  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} +14 -15
  38. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  39. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  40. package/dest/debug/pxe_debug_utils.js +28 -18
  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 +21 -7
  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 +2 -2
  51. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  52. package/dest/entrypoints/client/lazy/utils.js +22 -8
  53. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  54. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  55. package/dest/entrypoints/server/index.d.ts +4 -2
  56. package/dest/entrypoints/server/index.d.ts.map +1 -1
  57. package/dest/entrypoints/server/index.js +3 -1
  58. package/dest/entrypoints/server/utils.d.ts +1 -1
  59. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  60. package/dest/entrypoints/server/utils.js +28 -9
  61. package/dest/events/event_service.d.ts +4 -5
  62. package/dest/events/event_service.d.ts.map +1 -1
  63. package/dest/events/event_service.js +5 -6
  64. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  65. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  66. package/dest/job_coordinator/job_coordinator.js +3 -2
  67. package/dest/logs/log_service.d.ts +7 -5
  68. package/dest/logs/log_service.d.ts.map +1 -1
  69. package/dest/logs/log_service.js +19 -30
  70. package/dest/notes/note_service.d.ts +7 -7
  71. package/dest/notes/note_service.d.ts.map +1 -1
  72. package/dest/notes/note_service.js +9 -10
  73. package/dest/notes_filter.d.ts +25 -0
  74. package/dest/notes_filter.d.ts.map +1 -0
  75. package/dest/notes_filter.js +4 -0
  76. package/dest/oracle_version.d.ts +3 -3
  77. package/dest/oracle_version.d.ts.map +1 -1
  78. package/dest/oracle_version.js +2 -2
  79. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  80. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  81. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  82. package/dest/private_kernel/hints/index.d.ts +1 -1
  83. package/dest/private_kernel/hints/index.js +1 -1
  84. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  85. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  86. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  87. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  88. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  89. package/dest/private_kernel/hints/test_utils.js +203 -0
  90. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  91. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  92. package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
  93. package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
  94. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  95. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  96. package/dest/pxe.d.ts +69 -23
  97. package/dest/pxe.d.ts.map +1 -1
  98. package/dest/pxe.js +99 -65
  99. package/dest/storage/address_store/address_store.d.ts +1 -1
  100. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  101. package/dest/storage/address_store/address_store.js +12 -11
  102. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  103. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  104. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  105. package/dest/storage/capsule_store/capsule_store.js +6 -8
  106. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  107. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  108. package/dest/storage/contract_store/contract_store.js +157 -72
  109. package/dest/storage/metadata.d.ts +1 -1
  110. package/dest/storage/metadata.js +1 -1
  111. package/dest/storage/note_store/note_store.d.ts +13 -3
  112. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  113. package/dest/storage/note_store/note_store.js +147 -107
  114. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  115. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  116. package/dest/storage/private_event_store/private_event_store.js +84 -61
  117. package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
  118. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
  119. package/dest/storage/private_event_store/stored_private_event.js +2 -2
  120. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  121. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  122. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  123. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  124. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  125. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  126. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  127. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  128. package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
  129. package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
  130. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  131. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  132. package/dest/tagging/index.d.ts +2 -2
  133. package/dest/tagging/index.d.ts.map +1 -1
  134. package/dest/tagging/index.js +1 -1
  135. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -6
  136. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  137. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  138. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  139. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -8
  140. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  141. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  142. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -9
  143. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  144. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  145. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -8
  146. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  147. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  148. package/package.json +25 -16
  149. package/src/access_scopes.ts +9 -0
  150. package/src/block_synchronizer/block_synchronizer.ts +23 -19
  151. package/src/config/package_info.ts +1 -1
  152. package/src/contract_function_simulator/contract_function_simulator.ts +323 -128
  153. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  154. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  155. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  156. package/src/contract_function_simulator/oracle/interfaces.ts +12 -12
  157. package/src/contract_function_simulator/oracle/oracle.ts +41 -24
  158. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +101 -113
  159. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +139 -70
  160. package/src/contract_logging.ts +39 -0
  161. package/src/contract_sync/contract_sync_service.ts +152 -0
  162. package/src/contract_sync/{index.ts → helpers.ts} +22 -24
  163. package/src/debug/pxe_debug_utils.ts +63 -19
  164. package/src/entrypoints/client/bundle/index.ts +3 -0
  165. package/src/entrypoints/client/bundle/utils.ts +16 -15
  166. package/src/entrypoints/client/lazy/index.ts +3 -0
  167. package/src/entrypoints/client/lazy/utils.ts +17 -15
  168. package/src/entrypoints/pxe_creation_options.ts +2 -1
  169. package/src/entrypoints/server/index.ts +3 -1
  170. package/src/entrypoints/server/utils.ts +22 -26
  171. package/src/events/event_service.ts +4 -6
  172. package/src/job_coordinator/job_coordinator.ts +4 -3
  173. package/src/logs/log_service.ts +31 -39
  174. package/src/notes/note_service.ts +9 -11
  175. package/src/notes_filter.ts +26 -0
  176. package/src/oracle_version.ts +2 -2
  177. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  178. package/src/private_kernel/hints/index.ts +1 -1
  179. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  180. package/src/private_kernel/hints/test_utils.ts +325 -0
  181. package/src/private_kernel/private_kernel_execution_prover.ts +25 -15
  182. package/src/private_kernel/private_kernel_oracle.ts +9 -9
  183. package/src/pxe.ts +192 -117
  184. package/src/storage/address_store/address_store.ts +15 -15
  185. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  186. package/src/storage/capsule_store/capsule_store.ts +8 -8
  187. package/src/storage/contract_store/contract_store.ts +186 -76
  188. package/src/storage/metadata.ts +1 -1
  189. package/src/storage/note_store/note_store.ts +169 -132
  190. package/src/storage/private_event_store/private_event_store.ts +102 -81
  191. package/src/storage/private_event_store/stored_private_event.ts +3 -3
  192. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  193. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  194. package/src/storage/tagging_store/sender_tagging_store.ts +214 -130
  195. package/src/tagging/get_all_logs_by_tags.ts +31 -7
  196. package/src/tagging/index.ts +1 -1
  197. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +9 -12
  198. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  199. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +12 -17
  200. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +6 -11
  201. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +14 -23
  202. package/dest/contract_sync/index.d.ts +0 -23
  203. package/dest/contract_sync/index.d.ts.map +0 -1
  204. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  205. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
package/src/pxe.ts CHANGED
@@ -1,7 +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 { type Logger, createLogger } from '@aztec/foundation/log';
4
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
5
5
  import { SerialQueue } from '@aztec/foundation/queue';
6
6
  import { Timer } from '@aztec/foundation/timer';
7
7
  import { KeyStore } from '@aztec/key-store';
@@ -18,7 +18,6 @@ import {
18
18
  } from '@aztec/stdlib/abi';
19
19
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
20
20
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
21
- import { L2BlockHash } from '@aztec/stdlib/block';
22
21
  import {
23
22
  CompleteAddress,
24
23
  type ContractInstanceWithAddress,
@@ -34,6 +33,7 @@ import type {
34
33
  PrivateKernelTailCircuitPublicInputs,
35
34
  } from '@aztec/stdlib/kernel';
36
35
  import {
36
+ BlockHeader,
37
37
  type ContractOverrides,
38
38
  type InTx,
39
39
  PrivateExecutionResult,
@@ -47,11 +47,12 @@ import {
47
47
  TxProfileResult,
48
48
  TxProvingResult,
49
49
  TxSimulationResult,
50
- UtilitySimulationResult,
50
+ UtilityExecutionResult,
51
51
  } from '@aztec/stdlib/tx';
52
52
 
53
53
  import { inspect } from 'util';
54
54
 
55
+ import type { AccessScopes } from './access_scopes.js';
55
56
  import { BlockSynchronizer } from './block_synchronizer/index.js';
56
57
  import type { PXEConfig } from './config/index.js';
57
58
  import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
@@ -60,7 +61,9 @@ import {
60
61
  generateSimulatedProvingResult,
61
62
  } from './contract_function_simulator/contract_function_simulator.js';
62
63
  import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
63
- import { ensureContractSynced, readCurrentClassId } from './contract_sync/index.js';
64
+ import { displayDebugLogs } from './contract_logging.js';
65
+ import { ContractSyncService } from './contract_sync/contract_sync_service.js';
66
+ import { readCurrentClassId } from './contract_sync/helpers.js';
64
67
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
65
68
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
66
69
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
@@ -85,6 +88,56 @@ export type PackedPrivateEvent = InTx & {
85
88
  eventSelector: EventSelector;
86
89
  };
87
90
 
91
+ /** Options for PXE.profileTx. */
92
+ export type ProfileTxOpts = {
93
+ /** The profiling mode to use. */
94
+ profileMode: 'full' | 'execution-steps' | 'gates';
95
+ /** If true, proof generation is skipped during profiling. Defaults to true. */
96
+ skipProofGeneration?: boolean;
97
+ /** Addresses whose private state and keys are accessible during private execution. */
98
+ scopes: AccessScopes;
99
+ };
100
+
101
+ /** Options for PXE.simulateTx. */
102
+ export type SimulateTxOpts = {
103
+ /** Whether to simulate the public part of the transaction. */
104
+ simulatePublic: boolean;
105
+ /** If false, this function throws if the transaction is unable to be included in a block at the current state. */
106
+ skipTxValidation?: boolean;
107
+ /** If false, fees are enforced. */
108
+ skipFeeEnforcement?: boolean;
109
+ /** State overrides for the simulation, such as contract instances and artifacts. */
110
+ overrides?: SimulationOverrides;
111
+ /** Addresses whose private state and keys are accessible during private execution */
112
+ scopes: AccessScopes;
113
+ };
114
+
115
+ /** Options for PXE.executeUtility. */
116
+ export type ExecuteUtilityOpts = {
117
+ /** The authentication witnesses required for the function call. */
118
+ authwits?: AuthWitness[];
119
+ /** The accounts whose notes we can access in this call */
120
+ scopes: AccessScopes;
121
+ };
122
+
123
+ /** Args for PXE.create. */
124
+ export type PXECreateArgs = {
125
+ /** The Aztec node to connect to. */
126
+ node: AztecNode;
127
+ /** The key-value store for persisting PXE state. */
128
+ store: AztecAsyncKVStore;
129
+ /** The prover for generating private kernel proofs. */
130
+ proofCreator: PrivateKernelProver;
131
+ /** The circuit simulator for executing ACIR circuits. */
132
+ simulator: CircuitSimulator;
133
+ /** Provider for protocol contract artifacts and instances. */
134
+ protocolContractsProvider: ProtocolContractsProvider;
135
+ /** PXE configuration options. */
136
+ config: PXEConfig;
137
+ /** Optional logger instance or string suffix for the logger name. */
138
+ loggerOrSuffix?: string | Logger;
139
+ };
140
+
88
141
  /**
89
142
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
90
143
  * manage private state of users.
@@ -103,6 +156,7 @@ export class PXE {
103
156
  private recipientTaggingStore: RecipientTaggingStore,
104
157
  private addressStore: AddressStore,
105
158
  private privateEventStore: PrivateEventStore,
159
+ private contractSyncService: ContractSyncService,
106
160
  private simulator: CircuitSimulator,
107
161
  private proverEnabled: boolean,
108
162
  private proofCreator: PrivateKernelProver,
@@ -120,21 +174,27 @@ export class PXE {
120
174
  *
121
175
  * @returns A promise that resolves PXE is ready to be used.
122
176
  */
123
- public static async create(
124
- node: AztecNode,
125
- store: AztecAsyncKVStore,
126
- proofCreator: PrivateKernelProver,
127
- simulator: CircuitSimulator,
128
- protocolContractsProvider: ProtocolContractsProvider,
129
- config: PXEConfig,
130
- loggerOrSuffix?: string | Logger,
131
- ) {
177
+ public static async create({
178
+ node,
179
+ store,
180
+ proofCreator,
181
+ simulator,
182
+ protocolContractsProvider,
183
+ config,
184
+ loggerOrSuffix,
185
+ }: PXECreateArgs) {
186
+ // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
187
+ const bindings: LoggerBindings | undefined =
188
+ loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
189
+
132
190
  const log =
133
191
  !loggerOrSuffix || typeof loggerOrSuffix === 'string'
134
192
  ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
135
193
  : loggerOrSuffix;
136
194
 
137
- const proverEnabled = !!config.proverEnabled;
195
+ const info = await node.getNodeInfo();
196
+
197
+ const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
138
198
  const addressStore = new AddressStore(store);
139
199
  const privateEventStore = new PrivateEventStore(store);
140
200
  const contractStore = new ContractStore(store);
@@ -146,6 +206,12 @@ export class PXE {
146
206
  const capsuleStore = new CapsuleStore(store);
147
207
  const keyStore = new KeyStore(store);
148
208
  const tipsStore = new L2TipsKVStore(store, 'pxe');
209
+ const contractSyncService = new ContractSyncService(
210
+ node,
211
+ contractStore,
212
+ noteStore,
213
+ createLogger('pxe:contract_sync', bindings),
214
+ );
149
215
  const synchronizer = new BlockSynchronizer(
150
216
  node,
151
217
  store,
@@ -153,20 +219,22 @@ export class PXE {
153
219
  noteStore,
154
220
  privateEventStore,
155
221
  tipsStore,
222
+ contractSyncService,
156
223
  config,
157
- loggerOrSuffix,
224
+ bindings,
158
225
  );
159
226
 
160
- const jobCoordinator = new JobCoordinator(store);
227
+ const jobCoordinator = new JobCoordinator(store, bindings);
161
228
  jobCoordinator.registerStores([
162
229
  capsuleStore,
163
230
  senderTaggingStore,
164
231
  recipientTaggingStore,
165
232
  privateEventStore,
166
233
  noteStore,
234
+ contractSyncService,
167
235
  ]);
168
236
 
169
- const debugUtils = new PXEDebugUtils(contractStore, noteStore);
237
+ const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
170
238
 
171
239
  const jobQueue = new SerialQueue();
172
240
 
@@ -183,6 +251,7 @@ export class PXE {
183
251
  recipientTaggingStore,
184
252
  addressStore,
185
253
  privateEventStore,
254
+ contractSyncService,
186
255
  simulator,
187
256
  proverEnabled,
188
257
  proofCreator,
@@ -193,12 +262,15 @@ export class PXE {
193
262
  debugUtils,
194
263
  );
195
264
 
196
- debugUtils.setPXE(pxe);
265
+ debugUtils.setPXEHelpers(
266
+ pxe.#putInJobQueue.bind(pxe),
267
+ pxe.#getSimulatorForTx.bind(pxe),
268
+ pxe.#executeUtility.bind(pxe),
269
+ );
197
270
 
198
271
  pxe.jobQueue.start();
199
272
 
200
273
  await pxe.#registerProtocolContracts();
201
- const info = await node.getNodeInfo();
202
274
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
203
275
  return pxe;
204
276
  }
@@ -208,20 +280,20 @@ export class PXE {
208
280
  #getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
209
281
  const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
210
282
 
211
- return new ContractFunctionSimulator(
212
- proxyContractStore,
213
- this.noteStore,
214
- this.keyStore,
215
- this.addressStore,
216
- BenchmarkedNodeFactory.create(this.node),
217
- this.anchorBlockStore,
218
- this.senderTaggingStore,
219
- this.recipientTaggingStore,
220
- this.senderAddressBookStore,
221
- this.capsuleStore,
222
- this.privateEventStore,
223
- this.simulator,
224
- );
283
+ return new ContractFunctionSimulator({
284
+ contractStore: proxyContractStore,
285
+ noteStore: this.noteStore,
286
+ keyStore: this.keyStore,
287
+ addressStore: this.addressStore,
288
+ aztecNode: BenchmarkedNodeFactory.create(this.node),
289
+ senderTaggingStore: this.senderTaggingStore,
290
+ recipientTaggingStore: this.recipientTaggingStore,
291
+ senderAddressBookStore: this.senderAddressBookStore,
292
+ capsuleStore: this.capsuleStore,
293
+ privateEventStore: this.privateEventStore,
294
+ simulator: this.simulator,
295
+ contractSyncService: this.contractSyncService,
296
+ });
225
297
  }
226
298
 
227
299
  #contextualizeError(err: Error, ...context: string[]): Error {
@@ -273,9 +345,8 @@ export class PXE {
273
345
  async #registerProtocolContracts() {
274
346
  const registered: Record<string, string> = {};
275
347
  for (const name of protocolContractNames) {
276
- const { address, contractClass, instance, artifact } =
277
- await this.protocolContractsProvider.getProtocolContractArtifact(name);
278
- await this.contractStore.addContractArtifact(contractClass.id, artifact);
348
+ const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
349
+ await this.contractStore.addContractArtifact(artifact);
279
350
  await this.contractStore.addContractInstance(instance);
280
351
  registered[name] = address.toString();
281
352
  }
@@ -287,7 +358,7 @@ export class PXE {
287
358
  async #executePrivate(
288
359
  contractFunctionSimulator: ContractFunctionSimulator,
289
360
  txRequest: TxExecutionRequest,
290
- scopes: AztecAddress[] | undefined,
361
+ scopes: AccessScopes,
291
362
  jobId: string,
292
363
  ): Promise<PrivateExecutionResult> {
293
364
  const { origin: contractAddress, functionSelector } = txRequest;
@@ -295,27 +366,23 @@ export class PXE {
295
366
  try {
296
367
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
297
368
 
298
- await ensureContractSynced(
369
+ await this.contractSyncService.ensureContractSynced(
299
370
  contractAddress,
300
371
  functionSelector,
301
- privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
302
- this.node,
303
- this.contractStore,
372
+ (privateSyncCall, execScopes) =>
373
+ this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
304
374
  anchorBlockHeader,
375
+ jobId,
376
+ scopes,
305
377
  );
306
378
 
307
- const result = await contractFunctionSimulator.run(
308
- txRequest,
379
+ const result = await contractFunctionSimulator.run(txRequest, {
309
380
  contractAddress,
310
- functionSelector,
311
- undefined,
381
+ selector: functionSelector,
312
382
  anchorBlockHeader,
313
- // The sender for tags is set by contracts, typically by an account
314
- // contract entrypoint
315
- undefined, // senderForTags
316
383
  scopes,
317
384
  jobId,
318
- );
385
+ });
319
386
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
320
387
  return result;
321
388
  } catch (err) {
@@ -327,20 +394,20 @@ export class PXE {
327
394
  }
328
395
 
329
396
  /**
330
- * Simulate a utility function call on the given contract.
397
+ * Execute a utility function call on the given contract.
331
398
  * @param contractFunctionSimulator - The simulator to use for the function call.
332
399
  * @param call - The function call to execute.
333
400
  * @param authWitnesses - Authentication witnesses required for the function call.
334
401
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
335
402
  * accounts if not specified.
336
403
  * @param jobId - The job ID for staged writes.
337
- * @returns The simulation result containing the outputs of the utility function.
404
+ * @returns The execution result containing the outputs of the utility function.
338
405
  */
339
- async #simulateUtility(
406
+ async #executeUtility(
340
407
  contractFunctionSimulator: ContractFunctionSimulator,
341
408
  call: FunctionCall,
342
409
  authWitnesses: AuthWitness[] | undefined,
343
- scopes: AztecAddress[] | undefined,
410
+ scopes: AccessScopes,
344
411
  jobId: string,
345
412
  ) {
346
413
  try {
@@ -399,15 +466,33 @@ export class PXE {
399
466
  config: PrivateKernelExecutionProverConfig,
400
467
  ): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
401
468
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
402
- const anchorBlockHash = L2BlockHash.fromField(await anchorBlockHeader.hash());
469
+ const anchorBlockHash = await anchorBlockHeader.hash();
403
470
  const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
404
- const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
471
+ const kernelTraceProver = new PrivateKernelExecutionProver(
472
+ kernelOracle,
473
+ proofCreator,
474
+ !this.proverEnabled,
475
+ this.log.getBindings(),
476
+ );
405
477
  this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
406
478
  return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
407
479
  }
408
480
 
409
481
  // Public API
410
482
 
483
+ /**
484
+ * Returns the block header up to which the PXE has synced.
485
+ * @returns The synced block header
486
+ */
487
+ public getSyncedBlockHeader(): Promise<BlockHeader> {
488
+ return this.anchorBlockStore.getBlockHeader();
489
+ }
490
+
491
+ /**
492
+ * Returns the contract instance for a given address, if it's registered in the PXE.
493
+ * @param address - The contract address.
494
+ * @returns The contract instance if found, undefined otherwise.
495
+ */
411
496
  public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
412
497
  return this.contractStore.getContractInstance(address);
413
498
  }
@@ -516,8 +601,7 @@ export class PXE {
516
601
  * @param artifact - The build artifact for the contract class.
517
602
  */
518
603
  public async registerContractClass(artifact: ContractArtifact): Promise<void> {
519
- const { id: contractClassId } = await getContractClassFromArtifact(artifact);
520
- await this.contractStore.addContractArtifact(contractClassId, artifact);
604
+ const contractClassId = await this.contractStore.addContractArtifact(artifact);
521
605
  this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
522
606
  }
523
607
 
@@ -536,17 +620,17 @@ export class PXE {
536
620
  if (artifact) {
537
621
  // If the user provides an artifact, validate it against the expected class id and register it
538
622
  const contractClass = await getContractClassFromArtifact(artifact);
539
- const contractClassId = contractClass.id;
540
- if (!contractClassId.equals(instance.currentContractClassId)) {
623
+ if (!contractClass.id.equals(instance.currentContractClassId)) {
541
624
  throw new Error(
542
- `Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`,
625
+ `Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
543
626
  );
544
627
  }
545
628
  const computedAddress = await computeContractAddressFromInstance(instance);
546
629
  if (!computedAddress.equals(instance.address)) {
547
630
  throw new Error('Added a contract in which the address does not match the contract instance.');
548
631
  }
549
- await this.contractStore.addContractArtifact(contractClass.id, artifact);
632
+
633
+ await this.contractStore.addContractArtifact(artifact, contractClass);
550
634
 
551
635
  const publicFunctionSignatures = artifact.functions
552
636
  .filter(fn => fn.functionType === FunctionType.PUBLIC)
@@ -595,15 +679,16 @@ export class PXE {
595
679
  throw new Error('Could not update contract to a class different from the current one.');
596
680
  }
597
681
 
598
- await this.contractStore.addContractArtifact(contractClass.id, artifact);
599
-
600
682
  const publicFunctionSignatures = artifact.functions
601
683
  .filter(fn => fn.functionType === FunctionType.PUBLIC)
602
684
  .map(fn => decodeFunctionSignature(fn.name, fn.parameters));
603
685
  await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
604
686
 
605
687
  currentInstance.currentContractClassId = contractClass.id;
606
- await this.contractStore.addContractInstance(currentInstance);
688
+ await Promise.all([
689
+ this.contractStore.addContractArtifact(artifact, contractClass),
690
+ this.contractStore.addContractInstance(currentInstance),
691
+ ]);
607
692
  this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
608
693
  });
609
694
  }
@@ -621,11 +706,12 @@ export class PXE {
621
706
  * (where validators prove the public portion).
622
707
  *
623
708
  * @param txRequest - An authenticated tx request ready for proving
709
+ * @param scopes - Addresses whose private state and keys are accessible during private execution.
624
710
  * @returns A result containing the proof and public inputs of the tail circuit.
625
711
  * @throws If contract code not found, or public simulation reverts.
626
712
  * Also throws if simulatePublic is true and public simulation reverts.
627
713
  */
628
- public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
714
+ public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
629
715
  let privateExecutionResult: PrivateExecutionResult;
630
716
  // We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
631
717
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
@@ -636,7 +722,7 @@ export class PXE {
636
722
  await this.blockStateSynchronizer.sync();
637
723
  const syncTime = syncTimer.ms();
638
724
  const contractFunctionSimulator = this.#getSimulatorForTx();
639
- privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
725
+ privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
640
726
 
641
727
  const {
642
728
  publicInputs,
@@ -700,17 +786,13 @@ export class PXE {
700
786
 
701
787
  /**
702
788
  * Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
703
- *
704
- * @param txRequest - An authenticated tx request ready for simulation
705
- * @param msgSender - (Optional) The message sender to use for the simulation.
706
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
789
+ * @param txRequest - An authenticated tx request ready for simulation.
707
790
  * @returns A trace of the program execution with gate counts.
708
791
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
709
792
  */
710
793
  public profileTx(
711
794
  txRequest: TxExecutionRequest,
712
- profileMode: 'full' | 'execution-steps' | 'gates',
713
- skipProofGeneration: boolean = true,
795
+ { profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
714
796
  ): Promise<TxProfileResult> {
715
797
  // We disable concurrent profiles for consistency with simulateTx.
716
798
  return this.#putInJobQueue(async jobId => {
@@ -733,12 +815,7 @@ export class PXE {
733
815
  const syncTime = syncTimer.ms();
734
816
 
735
817
  const contractFunctionSimulator = this.#getSimulatorForTx();
736
- const privateExecutionResult = await this.#executePrivate(
737
- contractFunctionSimulator,
738
- txRequest,
739
- undefined,
740
- jobId,
741
- );
818
+ const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
742
819
 
743
820
  const { executionSteps, timings: { proving } = {} } = await this.#prove(
744
821
  txRequest,
@@ -795,12 +872,7 @@ export class PXE {
795
872
  * In that case, the transaction returned is only potentially ready to be sent to the network for execution.
796
873
  *
797
874
  *
798
- * @param txRequest - An authenticated tx request ready for simulation
799
- * @param simulatePublic - Whether to simulate the public part of the transaction.
800
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
801
- * @param skipFeeEnforcement - (Optional) If false, fees are enforced.
802
- * @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
803
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
875
+ * @param txRequest - An authenticated tx request ready for simulation.
804
876
  * @returns A simulated transaction result object that includes public and private return values.
805
877
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
806
878
  * Also throws if simulatePublic is true and public simulation reverts.
@@ -809,11 +881,7 @@ export class PXE {
809
881
  */
810
882
  public simulateTx(
811
883
  txRequest: TxExecutionRequest,
812
- simulatePublic: boolean,
813
- skipTxValidation: boolean = false,
814
- skipFeeEnforcement: boolean = false,
815
- overrides?: SimulationOverrides,
816
- scopes?: AztecAddress[],
884
+ { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }: SimulateTxOpts,
817
885
  ): Promise<TxSimulationResult> {
818
886
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
819
887
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
@@ -841,7 +909,14 @@ export class PXE {
841
909
  // Temporary: in case there are overrides, we have to skip the kernels or validations
842
910
  // will fail. Consider handing control to the user/wallet on whether they want to run them
843
911
  // or not.
844
- const skipKernels = overrides?.contracts !== undefined && Object.keys(overrides.contracts ?? {}).length > 0;
912
+ const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
913
+ const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
914
+ const skipKernels = hasOverriddenContracts;
915
+
916
+ // Set overridden contracts on the sync service so it knows to skip syncing them
917
+ if (hasOverriddenContracts) {
918
+ this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
919
+ }
845
920
 
846
921
  // Execution of private functions only; no proving, and no kernel logic.
847
922
  const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
@@ -852,7 +927,8 @@ export class PXE {
852
927
  if (skipKernels) {
853
928
  ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
854
929
  privateExecutionResult,
855
- this.contractStore,
930
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
931
+ this.node,
856
932
  ));
857
933
  } else {
858
934
  // Kernel logic, plus proving of all private functions and kernels.
@@ -871,6 +947,9 @@ export class PXE {
871
947
  const publicSimulationTimer = new Timer();
872
948
  publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
873
949
  publicSimulationTime = publicSimulationTimer.ms();
950
+ if (publicOutput?.debugLogs?.length) {
951
+ await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
952
+ }
874
953
  }
875
954
 
876
955
  let validationTime: number | undefined;
@@ -879,7 +958,8 @@ export class PXE {
879
958
  const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
880
959
  validationTime = validationTimer.ms();
881
960
  if (validationResult.result === 'invalid') {
882
- throw new Error('The simulated transaction is unable to be added to state and is invalid.');
961
+ const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
962
+ throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
883
963
  }
884
964
  }
885
965
 
@@ -930,29 +1010,23 @@ export class PXE {
930
1010
  inspect(txRequest),
931
1011
  `simulatePublic=${simulatePublic}`,
932
1012
  `skipTxValidation=${skipTxValidation}`,
933
- `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
1013
+ `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
934
1014
  );
935
1015
  }
936
1016
  });
937
1017
  }
938
1018
 
939
1019
  /**
940
- * Simulate the execution of a contract utility function.
941
- *
1020
+ * Executes a contract utility function.
942
1021
  * @param call - The function call containing the function details, arguments, and target contract address.
943
- * @param authwits - (Optional) The authentication witnesses required for the function call.
944
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
945
- * default to all.
946
- * @returns The result of the utility function call, structured based on the function ABI.
947
1022
  */
948
- public simulateUtility(
1023
+ public executeUtility(
949
1024
  call: FunctionCall,
950
- authwits?: AuthWitness[],
951
- scopes?: AztecAddress[],
952
- ): Promise<UtilitySimulationResult> {
953
- // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
1025
+ { authwits, scopes }: ExecuteUtilityOpts = { scopes: 'ALL_SCOPES' },
1026
+ ): Promise<UtilityExecutionResult> {
1027
+ // We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
954
1028
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
955
- // delete the same read value, or reading values that another simulation is currently modifying).
1029
+ // delete the same read value, or reading values that another execution is currently modifying).
956
1030
  return this.#putInJobQueue(async jobId => {
957
1031
  try {
958
1032
  const totalTimer = new Timer();
@@ -963,16 +1037,17 @@ export class PXE {
963
1037
  const contractFunctionSimulator = this.#getSimulatorForTx();
964
1038
 
965
1039
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
966
- await ensureContractSynced(
1040
+ await this.contractSyncService.ensureContractSynced(
967
1041
  call.to,
968
1042
  call.selector,
969
- privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
970
- this.node,
971
- this.contractStore,
1043
+ (privateSyncCall, execScopes) =>
1044
+ this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
972
1045
  anchorBlockHeader,
1046
+ jobId,
1047
+ scopes,
973
1048
  );
974
1049
 
975
- const executionResult = await this.#simulateUtility(
1050
+ const executionResult = await this.#executeUtility(
976
1051
  contractFunctionSimulator,
977
1052
  call,
978
1053
  authwits ?? [],
@@ -999,8 +1074,8 @@ export class PXE {
999
1074
  const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
1000
1075
  throw this.#contextualizeError(
1001
1076
  err,
1002
- `simulateUtility ${to}:${name}(${stringifiedArgs})`,
1003
- `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
1077
+ `executeUtility ${to}:${name}(${stringifiedArgs})`,
1078
+ `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
1004
1079
  );
1005
1080
  }
1006
1081
  });
@@ -1033,14 +1108,14 @@ export class PXE {
1033
1108
 
1034
1109
  const contractFunctionSimulator = this.#getSimulatorForTx();
1035
1110
 
1036
- await ensureContractSynced(
1111
+ await this.contractSyncService.ensureContractSynced(
1037
1112
  filter.contractAddress,
1038
1113
  null,
1039
- async privateSyncCall =>
1040
- await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
1041
- this.node,
1042
- this.contractStore,
1114
+ async (privateSyncCall, execScopes) =>
1115
+ await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
1043
1116
  anchorBlockHeader,
1117
+ jobId,
1118
+ filter.scopes,
1044
1119
  );
1045
1120
  });
1046
1121
 
@@ -43,23 +43,23 @@ export class AddressStore {
43
43
  });
44
44
  }
45
45
 
46
- async #getCompleteAddress(address: AztecAddress): Promise<CompleteAddress | undefined> {
47
- const index = await this.#completeAddressIndex.getAsync(address.toString());
48
- if (index === undefined) {
49
- return undefined;
50
- }
51
-
52
- const value = await this.#completeAddresses.atAsync(index);
53
- return value ? await CompleteAddress.fromBuffer(value) : undefined;
54
- }
55
-
56
46
  getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
57
- return this.#getCompleteAddress(account);
47
+ return this.#store.transactionAsync(async () => {
48
+ const index = await this.#completeAddressIndex.getAsync(account.toString());
49
+ if (index === undefined) {
50
+ return undefined;
51
+ }
52
+
53
+ const value = await this.#completeAddresses.atAsync(index);
54
+ return value ? await CompleteAddress.fromBuffer(value) : undefined;
55
+ });
58
56
  }
59
57
 
60
- async getCompleteAddresses(): Promise<CompleteAddress[]> {
61
- return await Promise.all(
62
- (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
63
- );
58
+ getCompleteAddresses(): Promise<CompleteAddress[]> {
59
+ return this.#store.transactionAsync(async () => {
60
+ return await Promise.all(
61
+ (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
62
+ );
63
+ });
64
64
  }
65
65
  }