@aztec/pxe 0.0.1-commit.23b0eb0 → 0.0.1-commit.2448fdb

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 (238) hide show
  1. package/dest/bin/check_oracle_version.js +4 -4
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +6 -2
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +17 -1
  5. package/dest/config/package_info.js +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts +63 -29
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.js +203 -70
  9. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  10. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  12. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  13. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  15. package/dest/contract_function_simulator/index.d.ts +2 -1
  16. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/index.js +1 -0
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  26. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
  29. package/dest/contract_function_simulator/oracle/interfaces.d.ts +61 -45
  30. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  32. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -44
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +300 -103
  37. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  38. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +53 -78
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +111 -88
  41. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +120 -66
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +317 -126
  44. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  45. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/pick_notes.js +20 -3
  47. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  48. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  50. package/dest/contract_logging.d.ts +27 -0
  51. package/dest/contract_logging.d.ts.map +1 -0
  52. package/dest/contract_logging.js +38 -0
  53. package/dest/contract_sync/contract_sync_service.d.ts +44 -0
  54. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  55. package/dest/contract_sync/contract_sync_service.js +116 -0
  56. package/dest/contract_sync/helpers.d.ts +28 -0
  57. package/dest/contract_sync/helpers.d.ts.map +1 -0
  58. package/dest/contract_sync/{index.js → helpers.js} +14 -15
  59. package/dest/debug/pxe_debug_utils.d.ts +14 -10
  60. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  61. package/dest/debug/pxe_debug_utils.js +16 -15
  62. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  63. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  64. package/dest/entrypoints/client/bundle/index.js +2 -0
  65. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  66. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  67. package/dest/entrypoints/client/bundle/utils.js +11 -3
  68. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  69. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  70. package/dest/entrypoints/client/lazy/index.js +2 -0
  71. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  72. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  73. package/dest/entrypoints/client/lazy/utils.js +11 -3
  74. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  75. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  76. package/dest/entrypoints/pxe_creation_options.js +3 -1
  77. package/dest/entrypoints/server/index.d.ts +4 -3
  78. package/dest/entrypoints/server/index.d.ts.map +1 -1
  79. package/dest/entrypoints/server/index.js +3 -2
  80. package/dest/entrypoints/server/utils.d.ts +2 -2
  81. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  82. package/dest/entrypoints/server/utils.js +11 -3
  83. package/dest/events/event_service.d.ts +3 -2
  84. package/dest/events/event_service.d.ts.map +1 -1
  85. package/dest/events/event_service.js +16 -4
  86. package/dest/events/private_event_filter_validator.d.ts +3 -2
  87. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  88. package/dest/events/private_event_filter_validator.js +15 -0
  89. package/dest/logs/log_service.d.ts +7 -7
  90. package/dest/logs/log_service.d.ts.map +1 -1
  91. package/dest/logs/log_service.js +33 -48
  92. package/dest/messages/message_context_service.d.ts +17 -0
  93. package/dest/messages/message_context_service.d.ts.map +1 -0
  94. package/dest/messages/message_context_service.js +36 -0
  95. package/dest/notes/note_service.d.ts +4 -4
  96. package/dest/notes/note_service.d.ts.map +1 -1
  97. package/dest/notes/note_service.js +17 -7
  98. package/dest/notes_filter.d.ts +24 -0
  99. package/dest/notes_filter.d.ts.map +1 -0
  100. package/dest/notes_filter.js +4 -0
  101. package/dest/oracle_version.d.ts +4 -3
  102. package/dest/oracle_version.d.ts.map +1 -1
  103. package/dest/oracle_version.js +20 -10
  104. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  105. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  106. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  107. package/dest/private_kernel/hints/index.d.ts +1 -1
  108. package/dest/private_kernel/hints/index.js +1 -1
  109. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  110. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  111. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  112. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  113. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  114. package/dest/private_kernel/hints/test_utils.js +203 -0
  115. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  116. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  117. package/dest/private_kernel/private_kernel_execution_prover.js +18 -13
  118. package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
  119. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  120. package/dest/private_kernel/private_kernel_oracle.js +19 -18
  121. package/dest/pxe.d.ts +72 -23
  122. package/dest/pxe.d.ts.map +1 -1
  123. package/dest/pxe.js +130 -75
  124. package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
  125. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  126. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  127. package/dest/storage/capsule_store/capsule_service.js +50 -0
  128. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  129. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  130. package/dest/storage/capsule_store/capsule_store.js +36 -28
  131. package/dest/storage/capsule_store/index.d.ts +2 -1
  132. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  133. package/dest/storage/capsule_store/index.js +1 -0
  134. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  135. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  136. package/dest/storage/contract_store/contract_store.js +148 -70
  137. package/dest/storage/metadata.d.ts +1 -1
  138. package/dest/storage/metadata.js +1 -1
  139. package/dest/storage/note_store/note_store.d.ts +3 -3
  140. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  141. package/dest/storage/note_store/note_store.js +6 -4
  142. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  143. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  144. package/dest/storage/private_event_store/private_event_store.js +3 -0
  145. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  146. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  147. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  148. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  149. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  150. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  151. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  152. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  153. package/dest/tagging/index.d.ts +3 -3
  154. package/dest/tagging/index.d.ts.map +1 -1
  155. package/dest/tagging/index.js +1 -1
  156. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  157. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  158. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -22
  159. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  160. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  161. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  162. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  163. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  164. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  165. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  166. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  167. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  168. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  169. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  170. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  171. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  172. package/package.json +25 -16
  173. package/src/bin/check_oracle_version.ts +4 -4
  174. package/src/block_synchronizer/block_synchronizer.ts +18 -0
  175. package/src/config/package_info.ts +1 -1
  176. package/src/contract_function_simulator/contract_function_simulator.ts +363 -131
  177. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  178. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  179. package/src/contract_function_simulator/index.ts +1 -0
  180. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
  181. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  182. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  183. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
  184. package/src/contract_function_simulator/oracle/interfaces.ts +82 -54
  185. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  186. package/src/contract_function_simulator/oracle/oracle.ts +373 -142
  187. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  188. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +140 -181
  189. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +532 -156
  190. package/src/contract_function_simulator/pick_notes.ts +22 -3
  191. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  192. package/src/contract_logging.ts +52 -0
  193. package/src/contract_sync/contract_sync_service.ts +176 -0
  194. package/src/contract_sync/{index.ts → helpers.ts} +14 -35
  195. package/src/debug/pxe_debug_utils.ts +48 -18
  196. package/src/entrypoints/client/bundle/index.ts +2 -0
  197. package/src/entrypoints/client/bundle/utils.ts +11 -4
  198. package/src/entrypoints/client/lazy/index.ts +2 -0
  199. package/src/entrypoints/client/lazy/utils.ts +11 -4
  200. package/src/entrypoints/pxe_creation_options.ts +7 -0
  201. package/src/entrypoints/server/index.ts +3 -2
  202. package/src/entrypoints/server/utils.ts +9 -10
  203. package/src/events/event_service.ts +17 -4
  204. package/src/events/private_event_filter_validator.ts +21 -1
  205. package/src/logs/log_service.ts +63 -91
  206. package/src/messages/message_context_service.ts +44 -0
  207. package/src/notes/note_service.ts +19 -8
  208. package/src/notes_filter.ts +24 -0
  209. package/src/oracle_version.ts +20 -10
  210. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  211. package/src/private_kernel/hints/index.ts +1 -1
  212. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  213. package/src/private_kernel/hints/test_utils.ts +325 -0
  214. package/src/private_kernel/private_kernel_execution_prover.ts +18 -16
  215. package/src/private_kernel/private_kernel_oracle.ts +21 -21
  216. package/src/pxe.ts +234 -128
  217. package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
  218. package/src/storage/capsule_store/capsule_service.ts +90 -0
  219. package/src/storage/capsule_store/capsule_store.ts +44 -26
  220. package/src/storage/capsule_store/index.ts +1 -0
  221. package/src/storage/contract_store/contract_store.ts +181 -80
  222. package/src/storage/metadata.ts +1 -1
  223. package/src/storage/note_store/note_store.ts +9 -5
  224. package/src/storage/private_event_store/private_event_store.ts +4 -0
  225. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  226. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  227. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  228. package/src/tagging/index.ts +2 -2
  229. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +12 -25
  230. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  231. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  232. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  233. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  234. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
  235. package/dest/contract_sync/index.d.ts +0 -24
  236. package/dest/contract_sync/index.d.ts.map +0 -1
  237. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  238. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
package/dest/pxe.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pxe.d.ts","sourceRoot":"","sources":["../src/pxe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAqC,MAAM,uBAAuB,CAAC;AAIvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MA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AC,CA8B/B;IAED;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAGjC;CACF"}
package/dest/pxe.js CHANGED
@@ -13,11 +13,14 @@ import { BlockSynchronizer } from './block_synchronizer/index.js';
13
13
  import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
14
14
  import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
15
15
  import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
16
- import { ensureContractSynced, readCurrentClassId } from './contract_sync/index.js';
16
+ import { displayDebugLogs } from './contract_logging.js';
17
+ import { ContractSyncService } from './contract_sync/contract_sync_service.js';
18
+ import { readCurrentClassId } from './contract_sync/helpers.js';
17
19
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
18
20
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
19
21
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
20
22
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
23
+ import { MessageContextService } from './messages/message_context_service.js';
21
24
  import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
22
25
  import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
23
26
  import { AddressStore } from './storage/address_store/address_store.js';
@@ -45,6 +48,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
45
48
  recipientTaggingStore;
46
49
  addressStore;
47
50
  privateEventStore;
51
+ contractSyncService;
52
+ messageContextService;
53
+ l2TipsStore;
48
54
  simulator;
49
55
  proverEnabled;
50
56
  proofCreator;
@@ -53,7 +59,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
53
59
  jobQueue;
54
60
  jobCoordinator;
55
61
  debug;
56
- constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
62
+ constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, l2TipsStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
57
63
  this.node = node;
58
64
  this.blockStateSynchronizer = blockStateSynchronizer;
59
65
  this.keyStore = keyStore;
@@ -66,6 +72,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
66
72
  this.recipientTaggingStore = recipientTaggingStore;
67
73
  this.addressStore = addressStore;
68
74
  this.privateEventStore = privateEventStore;
75
+ this.contractSyncService = contractSyncService;
76
+ this.messageContextService = messageContextService;
77
+ this.l2TipsStore = l2TipsStore;
69
78
  this.simulator = simulator;
70
79
  this.proverEnabled = proverEnabled;
71
80
  this.proofCreator = proofCreator;
@@ -81,11 +90,12 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
81
90
  * can be contacted.
82
91
  *
83
92
  * @returns A promise that resolves PXE is ready to be used.
84
- */ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
93
+ */ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
85
94
  // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
86
95
  const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
87
96
  const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
88
- const proverEnabled = !!config.proverEnabled;
97
+ const info = await node.getNodeInfo();
98
+ const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
89
99
  const addressStore = new AddressStore(store);
90
100
  const privateEventStore = new PrivateEventStore(store);
91
101
  const contractStore = new ContractStore(store);
@@ -97,29 +107,46 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
97
107
  const capsuleStore = new CapsuleStore(store);
98
108
  const keyStore = new KeyStore(store);
99
109
  const tipsStore = new L2TipsKVStore(store, 'pxe');
100
- const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, config, bindings);
110
+ const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
111
+ const messageContextService = new MessageContextService(node);
112
+ const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
101
113
  const jobCoordinator = new JobCoordinator(store, bindings);
102
114
  jobCoordinator.registerStores([
103
115
  capsuleStore,
104
116
  senderTaggingStore,
105
117
  recipientTaggingStore,
106
118
  privateEventStore,
107
- noteStore
119
+ noteStore,
120
+ contractSyncService
108
121
  ]);
109
- const debugUtils = new PXEDebugUtils(contractStore, noteStore, synchronizer, anchorBlockStore);
122
+ const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
110
123
  const jobQueue = new SerialQueue();
111
- const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
112
- debugUtils.setPXE(pxe, pxe.#putInJobQueue.bind(pxe));
124
+ const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, tipsStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
125
+ debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
113
126
  pxe.jobQueue.start();
114
127
  await pxe.#registerProtocolContracts();
115
- const info = await node.getNodeInfo();
116
128
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
117
129
  return pxe;
118
130
  }
119
131
  // Internal methods
120
132
  #getSimulatorForTx(overrides) {
121
133
  const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
122
- return new ContractFunctionSimulator(proxyContractStore, this.noteStore, this.keyStore, this.addressStore, BenchmarkedNodeFactory.create(this.node), this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.simulator);
134
+ return new ContractFunctionSimulator({
135
+ contractStore: proxyContractStore,
136
+ noteStore: this.noteStore,
137
+ keyStore: this.keyStore,
138
+ addressStore: this.addressStore,
139
+ aztecNode: BenchmarkedNodeFactory.create(this.node),
140
+ l2TipsStore: this.l2TipsStore,
141
+ senderTaggingStore: this.senderTaggingStore,
142
+ recipientTaggingStore: this.recipientTaggingStore,
143
+ senderAddressBookStore: this.senderAddressBookStore,
144
+ capsuleStore: this.capsuleStore,
145
+ privateEventStore: this.privateEventStore,
146
+ simulator: this.simulator,
147
+ contractSyncService: this.contractSyncService,
148
+ messageContextService: this.messageContextService
149
+ });
123
150
  }
124
151
  #contextualizeError(err, ...context) {
125
152
  let contextStr = '';
@@ -162,8 +189,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
162
189
  async #registerProtocolContracts() {
163
190
  const registered = {};
164
191
  for (const name of protocolContractNames){
165
- const { address, contractClass, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
166
- await this.contractStore.addContractArtifact(contractClass.id, artifact);
192
+ const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
193
+ await this.contractStore.addContractArtifact(artifact);
167
194
  await this.contractStore.addContractInstance(instance);
168
195
  registered[name] = address.toString();
169
196
  }
@@ -175,10 +202,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
175
202
  const { origin: contractAddress, functionSelector } = txRequest;
176
203
  try {
177
204
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
178
- await ensureContractSynced(contractAddress, functionSelector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), this.node, this.contractStore, this.noteStore, anchorBlockHeader, jobId);
179
- const result = await contractFunctionSimulator.run(txRequest, contractAddress, functionSelector, undefined, anchorBlockHeader, // The sender for tags is set by contracts, typically by an account
180
- // contract entrypoint
181
- undefined, scopes, jobId);
205
+ await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
206
+ const result = await contractFunctionSimulator.run(txRequest, {
207
+ contractAddress,
208
+ selector: functionSelector,
209
+ anchorBlockHeader,
210
+ scopes,
211
+ jobId
212
+ });
182
213
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
183
214
  return result;
184
215
  } catch (err) {
@@ -189,18 +220,22 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
189
220
  }
190
221
  }
191
222
  /**
192
- * Simulate a utility function call on the given contract.
223
+ * Execute a utility function call on the given contract.
193
224
  * @param contractFunctionSimulator - The simulator to use for the function call.
194
225
  * @param call - The function call to execute.
195
226
  * @param authWitnesses - Authentication witnesses required for the function call.
196
227
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
197
228
  * accounts if not specified.
198
229
  * @param jobId - The job ID for staged writes.
199
- * @returns The simulation result containing the outputs of the utility function.
200
- */ async #simulateUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
230
+ * @returns The execution result containing the outputs of the utility function.
231
+ */ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
201
232
  try {
202
233
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
203
- return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
234
+ const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
235
+ return {
236
+ result,
237
+ offchainEffects
238
+ };
204
239
  } catch (err) {
205
240
  if (err instanceof SimulationError) {
206
241
  await enrichSimulationError(err, this.contractStore, this.log);
@@ -245,14 +280,25 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
245
280
  * @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
246
281
  */ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
247
282
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
248
- const anchorBlockHash = await anchorBlockHeader.hash();
249
- const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
283
+ const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
250
284
  const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
251
285
  this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
252
286
  return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
253
287
  }
254
288
  // Public API
255
- getContractInstance(address) {
289
+ /**
290
+ * Returns the block header up to which the PXE has synced.
291
+ * @returns The synced block header
292
+ */ getSyncedBlockHeader() {
293
+ return this.#putInJobQueue(()=>{
294
+ return this.anchorBlockStore.getBlockHeader();
295
+ });
296
+ }
297
+ /**
298
+ * Returns the contract instance for a given address, if it's registered in the PXE.
299
+ * @param address - The contract address.
300
+ * @returns The contract instance if found, undefined otherwise.
301
+ */ getContractInstance(address) {
256
302
  return this.contractStore.getContractInstance(address);
257
303
  }
258
304
  /**
@@ -294,6 +340,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
294
340
  * @returns The address of the sender.
295
341
  * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
296
342
  */ async registerSender(sender) {
343
+ if (!await sender.isValid()) {
344
+ throw new Error(`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`);
345
+ }
297
346
  const accounts = await this.keyStore.getAccounts();
298
347
  if (accounts.includes(sender)) {
299
348
  this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
@@ -302,6 +351,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
302
351
  const wasAdded = await this.senderAddressBookStore.addSender(sender);
303
352
  if (wasAdded) {
304
353
  this.log.info(`Added sender:\n ${sender.toString()}`);
354
+ // Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
355
+ // all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
356
+ await this.#putInJobQueue(()=>Promise.resolve(this.contractSyncService.wipe()));
305
357
  } else {
306
358
  this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
307
359
  }
@@ -339,8 +391,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
339
391
  *
340
392
  * @param artifact - The build artifact for the contract class.
341
393
  */ async registerContractClass(artifact) {
342
- const { id: contractClassId } = await getContractClassFromArtifact(artifact);
343
- await this.contractStore.addContractArtifact(contractClassId, artifact);
394
+ const contractClassId = await this.contractStore.addContractArtifact(artifact);
344
395
  this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
345
396
  }
346
397
  /**
@@ -356,15 +407,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
356
407
  if (artifact) {
357
408
  // If the user provides an artifact, validate it against the expected class id and register it
358
409
  const contractClass = await getContractClassFromArtifact(artifact);
359
- const contractClassId = contractClass.id;
360
- if (!contractClassId.equals(instance.currentContractClassId)) {
361
- throw new Error(`Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`);
410
+ if (!contractClass.id.equals(instance.currentContractClassId)) {
411
+ throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
362
412
  }
363
413
  const computedAddress = await computeContractAddressFromInstance(instance);
364
414
  if (!computedAddress.equals(instance.address)) {
365
415
  throw new Error('Added a contract in which the address does not match the contract instance.');
366
416
  }
367
- await this.contractStore.addContractArtifact(contractClass.id, artifact);
417
+ await this.contractStore.addContractArtifact(artifact, contractClass);
368
418
  const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
369
419
  await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
370
420
  } else {
@@ -400,11 +450,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
400
450
  if (!contractClass.id.equals(currentClassId)) {
401
451
  throw new Error('Could not update contract to a class different from the current one.');
402
452
  }
403
- await this.contractStore.addContractArtifact(contractClass.id, artifact);
404
453
  const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
405
454
  await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
406
455
  currentInstance.currentContractClassId = contractClass.id;
407
- await this.contractStore.addContractInstance(currentInstance);
456
+ await Promise.all([
457
+ this.contractStore.addContractArtifact(artifact, contractClass),
458
+ this.contractStore.addContractInstance(currentInstance)
459
+ ]);
408
460
  this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
409
461
  });
410
462
  }
@@ -419,10 +471,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
419
471
  * (where validators prove the public portion).
420
472
  *
421
473
  * @param txRequest - An authenticated tx request ready for proving
474
+ * @param scopes - Addresses whose private state and keys are accessible during private execution.
422
475
  * @returns A result containing the proof and public inputs of the tail circuit.
423
476
  * @throws If contract code not found, or public simulation reverts.
424
477
  * Also throws if simulatePublic is true and public simulation reverts.
425
- */ proveTx(txRequest) {
478
+ */ proveTx(txRequest, scopes) {
426
479
  let privateExecutionResult;
427
480
  // We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
428
481
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
@@ -433,7 +486,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
433
486
  await this.blockStateSynchronizer.sync();
434
487
  const syncTime = syncTimer.ms();
435
488
  const contractFunctionSimulator = this.#getSimulatorForTx();
436
- privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
489
+ privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
437
490
  const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
438
491
  simulate: false,
439
492
  skipFeeEnforcement: false,
@@ -464,16 +517,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
464
517
  // transaction before this one is included in a block from this PXE, and that transaction contains a log with
465
518
  // a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
466
519
  // storing the tags here prevents linkage of txs sent from the same PXE.
467
- const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
468
- if (preTagsUsedInTheTx.length > 0) {
520
+ const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
521
+ if (taggingIndexRangesUsedInTheTx.length > 0) {
469
522
  // TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
470
523
  const txHash = (await txProvingResult.toTx()).txHash;
471
- await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash, jobId);
472
- this.log.debug(`Stored used pre-tags as sender for the tx`, {
473
- preTagsUsedInTheTx
524
+ await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
525
+ this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
526
+ taggingIndexRangesUsedInTheTx
474
527
  });
475
528
  } else {
476
- this.log.debug(`No pre-tags used in the tx`);
529
+ this.log.debug(`No tagging index ranges used in the tx`);
477
530
  }
478
531
  return txProvingResult;
479
532
  } catch (err) {
@@ -483,13 +536,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
483
536
  }
484
537
  /**
485
538
  * Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
486
- *
487
- * @param txRequest - An authenticated tx request ready for simulation
488
- * @param msgSender - (Optional) The message sender to use for the simulation.
489
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
539
+ * @param txRequest - An authenticated tx request ready for simulation.
490
540
  * @returns A trace of the program execution with gate counts.
491
541
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
492
- */ profileTx(txRequest, profileMode, skipProofGeneration = true) {
542
+ */ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes }) {
493
543
  // We disable concurrent profiles for consistency with simulateTx.
494
544
  return this.#putInJobQueue(async (jobId)=>{
495
545
  const totalTimer = new Timer();
@@ -507,7 +557,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
507
557
  await this.blockStateSynchronizer.sync();
508
558
  const syncTime = syncTimer.ms();
509
559
  const contractFunctionSimulator = this.#getSimulatorForTx();
510
- const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
560
+ const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
511
561
  const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
512
562
  simulate: skipProofGeneration,
513
563
  skipFeeEnforcement: false,
@@ -552,18 +602,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
552
602
  * In that case, the transaction returned is only potentially ready to be sent to the network for execution.
553
603
  *
554
604
  *
555
- * @param txRequest - An authenticated tx request ready for simulation
556
- * @param simulatePublic - Whether to simulate the public part of the transaction.
557
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
558
- * @param skipFeeEnforcement - (Optional) If false, fees are enforced.
559
- * @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
560
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
605
+ * @param txRequest - An authenticated tx request ready for simulation.
561
606
  * @returns A simulated transaction result object that includes public and private return values.
562
607
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
563
608
  * Also throws if simulatePublic is true and public simulation reverts.
564
609
  *
565
610
  * TODO(#7456) Prevent msgSender being defined here for the first call
566
- */ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
611
+ */ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes }) {
567
612
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
568
613
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
569
614
  // delete the same read value, or reading values that another simulation is currently modifying).
@@ -582,17 +627,23 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
582
627
  const syncTimer = new Timer();
583
628
  await this.blockStateSynchronizer.sync();
584
629
  const syncTime = syncTimer.ms();
630
+ const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
631
+ const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
632
+ if (hasOverriddenContracts && !skipKernels) {
633
+ throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
634
+ }
585
635
  const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
586
- // Temporary: in case there are overrides, we have to skip the kernels or validations
587
- // will fail. Consider handing control to the user/wallet on whether they want to run them
588
- // or not.
589
- const skipKernels = overrides?.contracts !== undefined && Object.keys(overrides.contracts ?? {}).length > 0;
636
+ if (hasOverriddenContracts) {
637
+ // Overridden contracts don't have a sync function, so calling sync on them would fail.
638
+ // We exclude them so the sync service skips them entirely.
639
+ this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
640
+ }
590
641
  // Execution of private functions only; no proving, and no kernel logic.
591
642
  const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
592
643
  let publicInputs;
593
644
  let executionSteps = [];
594
645
  if (skipKernels) {
595
- ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
646
+ ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
596
647
  } else {
597
648
  // Kernel logic, plus proving of all private functions and kernels.
598
649
  ({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
@@ -609,6 +660,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
609
660
  const publicSimulationTimer = new Timer();
610
661
  publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
611
662
  publicSimulationTime = publicSimulationTimer.ms();
663
+ if (publicOutput?.debugLogs?.length) {
664
+ await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
665
+ }
612
666
  }
613
667
  let validationTime;
614
668
  if (!skipTxValidation) {
@@ -619,7 +673,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
619
673
  });
620
674
  validationTime = validationTimer.ms();
621
675
  if (validationResult.result === 'invalid') {
622
- throw new Error('The simulated transaction is unable to be added to state and is invalid.');
676
+ const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
677
+ throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
623
678
  }
624
679
  }
625
680
  const txHash = simulatedTx.getTxHash();
@@ -652,22 +707,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
652
707
  nodeRPCCalls: simulatorStats.nodeRPCCalls
653
708
  });
654
709
  } catch (err) {
655
- throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
710
+ throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
656
711
  }
657
712
  });
658
713
  }
659
714
  /**
660
- * Simulate the execution of a contract utility function.
661
- *
715
+ * Executes a contract utility function.
662
716
  * @param call - The function call containing the function details, arguments, and target contract address.
663
- * @param authwits - (Optional) The authentication witnesses required for the function call.
664
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
665
- * default to all.
666
- * @returns The result of the utility function call, structured based on the function ABI.
667
- */ simulateUtility(call, authwits, scopes) {
668
- // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
717
+ */ executeUtility(call, { authwits, scopes } = {
718
+ scopes: []
719
+ }) {
720
+ // We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
669
721
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
670
- // delete the same read value, or reading values that another simulation is currently modifying).
722
+ // delete the same read value, or reading values that another execution is currently modifying).
671
723
  return this.#putInJobQueue(async (jobId)=>{
672
724
  try {
673
725
  const totalTimer = new Timer();
@@ -677,8 +729,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
677
729
  const functionTimer = new Timer();
678
730
  const contractFunctionSimulator = this.#getSimulatorForTx();
679
731
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
680
- await ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), this.node, this.contractStore, this.noteStore, anchorBlockHeader, jobId);
681
- const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
732
+ await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
733
+ const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
682
734
  const functionTime = functionTimer.ms();
683
735
  const totalTime = totalTimer.ms();
684
736
  const perFunction = [
@@ -696,6 +748,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
696
748
  const simulationStats = contractFunctionSimulator.getStats();
697
749
  return {
698
750
  result: executionResult,
751
+ offchainEffects,
752
+ anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
699
753
  stats: {
700
754
  timings,
701
755
  nodeRPCCalls: simulationStats.nodeRPCCalls
@@ -704,7 +758,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
704
758
  } catch (err) {
705
759
  const { to, name, args } = call;
706
760
  const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
707
- throw this.#contextualizeError(err, `simulateUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
761
+ throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
708
762
  }
709
763
  });
710
764
  }
@@ -727,7 +781,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
727
781
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
728
782
  anchorBlockNumber = anchorBlockHeader.getBlockNumber();
729
783
  const contractFunctionSimulator = this.#getSimulatorForTx();
730
- await ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), this.node, this.contractStore, this.noteStore, anchorBlockHeader, jobId);
784
+ await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
731
785
  });
732
786
  // anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
733
787
  const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
@@ -736,7 +790,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
736
790
  }
737
791
  /**
738
792
  * Stops the PXE's job queue.
739
- */ stop() {
740
- return this.jobQueue.end();
793
+ */ async stop() {
794
+ await this.jobQueue.end();
795
+ await this.blockStateSynchronizer.stop();
741
796
  }
742
797
  }
@@ -17,7 +17,7 @@ export class AnchorBlockStore {
17
17
  await this.#synchronizedHeader.set(header.toBuffer());
18
18
  }
19
19
  async getBlockHeader() {
20
- const headerBuffer = await this.#synchronizedHeader.getAsync();
20
+ const headerBuffer = await this.#store.transactionAsync(()=>this.#synchronizedHeader.getAsync());
21
21
  if (!headerBuffer) {
22
22
  throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
23
23
  }
@@ -0,0 +1,21 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { Capsule } from '@aztec/stdlib/tx';
4
+ import type { CapsuleStore } from './capsule_store.js';
5
+ /**
6
+ * Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
7
+ * allowed scopes list before delegating to the underlying store.
8
+ */
9
+ export declare class CapsuleService {
10
+ private readonly capsuleStore;
11
+ private readonly allowedScopes;
12
+ constructor(capsuleStore: CapsuleStore, allowedScopes: AztecAddress[]);
13
+ setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress): void;
14
+ getCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress, transientCapsules?: Capsule[]): Promise<Fr[] | null>;
15
+ deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): void;
16
+ copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string, scope: AztecAddress): Promise<void>;
17
+ appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
18
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]>;
19
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9jYXBzdWxlX3N0b3JlL2NhcHN1bGVfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQ7OztHQUdHO0FBQ0gscUJBQWEsY0FBYztJQUV2QixPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxhQUFhO0lBRmhDLFlBQ21CLFlBQVksRUFBRSxZQUFZLEVBQzFCLGFBQWEsRUFBRSxZQUFZLEVBQUUsRUFDNUM7SUFFSixVQUFVLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxZQUFZLFFB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,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,oBAAoB,CAClB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,EAAE,EAAE,EAAE,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAGjH;IAED,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,iBAG/G;CACF"}
@@ -0,0 +1,50 @@
1
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ /**
3
+ * Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
4
+ * allowed scopes list before delegating to the underlying store.
5
+ */ export class CapsuleService {
6
+ capsuleStore;
7
+ allowedScopes;
8
+ constructor(capsuleStore, allowedScopes){
9
+ this.capsuleStore = capsuleStore;
10
+ this.allowedScopes = allowedScopes;
11
+ }
12
+ setCapsule(contractAddress, slot, capsule, jobId, scope) {
13
+ assertAllowedScope(scope, this.allowedScopes);
14
+ this.capsuleStore.setCapsule(contractAddress, slot, capsule, jobId, scope);
15
+ }
16
+ async getCapsule(contractAddress, slot, jobId, scope, transientCapsules) {
17
+ assertAllowedScope(scope, this.allowedScopes);
18
+ // TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
19
+ const maybeTransientCapsule = transientCapsules?.find((c)=>c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot) && (c.scope ?? AztecAddress.ZERO).equals(scope))?.data;
20
+ return maybeTransientCapsule ?? await this.capsuleStore.getCapsule(contractAddress, slot, jobId, scope);
21
+ }
22
+ deleteCapsule(contractAddress, slot, jobId, scope) {
23
+ assertAllowedScope(scope, this.allowedScopes);
24
+ this.capsuleStore.deleteCapsule(contractAddress, slot, jobId, scope);
25
+ }
26
+ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope) {
27
+ assertAllowedScope(scope, this.allowedScopes);
28
+ return this.capsuleStore.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope);
29
+ }
30
+ appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
31
+ assertAllowedScope(scope, this.allowedScopes);
32
+ return this.capsuleStore.appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
33
+ }
34
+ readCapsuleArray(contractAddress, baseSlot, jobId, scope) {
35
+ assertAllowedScope(scope, this.allowedScopes);
36
+ return this.capsuleStore.readCapsuleArray(contractAddress, baseSlot, jobId, scope);
37
+ }
38
+ setCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
39
+ assertAllowedScope(scope, this.allowedScopes);
40
+ return this.capsuleStore.setCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
41
+ }
42
+ }
43
+ function assertAllowedScope(scope, allowedScopes) {
44
+ if (scope.equals(AztecAddress.ZERO)) {
45
+ return;
46
+ }
47
+ if (!allowedScopes.some((allowed)=>allowed.equals(scope))) {
48
+ throw new Error(`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s)=>s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`);
49
+ }
50
+ }