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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/dest/block_synchronizer/block_stream_source.d.ts +5 -5
  2. package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_stream_source.js +4 -29
  4. package/dest/block_synchronizer/block_synchronizer.d.ts +13 -11
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  6. package/dest/block_synchronizer/block_synchronizer.js +43 -15
  7. package/dest/config/index.d.ts +2 -1
  8. package/dest/config/index.d.ts.map +1 -1
  9. package/dest/config/index.js +1 -0
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts +11 -16
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/contract_function_simulator.js +22 -18
  13. package/dest/contract_function_simulator/index.d.ts +15 -9
  14. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/index.js +3 -7
  16. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
  17. package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
  19. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
  20. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
  22. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
  23. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
  25. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  26. package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
  27. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
  28. package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
  29. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
  30. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
  31. package/dest/contract_function_simulator/noir-structs/fact_collection.js +29 -0
  32. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
  33. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +4 -8
  36. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -60
  38. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  39. package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
  40. package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/noir-structs/option.js +18 -13
  42. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
  43. package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
  44. package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
  45. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +5 -8
  46. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -14
  48. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +21 -0
  49. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +33 -0
  51. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
  52. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
  53. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
  54. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
  55. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
  56. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
  57. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
  58. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
  60. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
  61. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
  63. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +81 -6
  64. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  65. package/dest/contract_function_simulator/oracle/oracle_registry.js +128 -9
  66. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +80 -36
  67. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  68. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +926 -264
  69. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +13 -8
  70. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +80 -11
  72. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +46 -20
  73. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  74. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +119 -55
  75. package/dest/contract_sync/helpers.d.ts +7 -6
  76. package/dest/contract_sync/helpers.d.ts.map +1 -1
  77. package/dest/contract_sync/helpers.js +11 -16
  78. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  79. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  80. package/dest/entrypoints/client/bundle/utils.js +1 -0
  81. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  82. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/lazy/utils.js +1 -0
  84. package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
  85. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  86. package/dest/entrypoints/server/index.d.ts +1 -2
  87. package/dest/entrypoints/server/index.d.ts.map +1 -1
  88. package/dest/entrypoints/server/index.js +0 -1
  89. package/dest/entrypoints/server/utils.d.ts +1 -1
  90. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  91. package/dest/entrypoints/server/utils.js +3 -1
  92. package/dest/error_enriching.js +1 -1
  93. package/dest/hooks/execution_hooks.d.ts +16 -7
  94. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  95. package/dest/hooks/execution_hooks.js +3 -3
  96. package/dest/hooks/index.d.ts +3 -3
  97. package/dest/hooks/index.d.ts.map +1 -1
  98. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +41 -0
  99. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
  100. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
  101. package/dest/logs/log_service.d.ts +6 -6
  102. package/dest/logs/log_service.d.ts.map +1 -1
  103. package/dest/logs/log_service.js +62 -28
  104. package/dest/messages/tx_resolver_service.d.ts +17 -0
  105. package/dest/messages/tx_resolver_service.d.ts.map +1 -0
  106. package/dest/messages/{message_context_service.js → tx_resolver_service.js} +8 -8
  107. package/dest/oracle_version.d.ts +2 -2
  108. package/dest/oracle_version.js +2 -2
  109. package/dest/private_kernel/hints/test_utils.js +1 -1
  110. package/dest/pxe.d.ts +46 -19
  111. package/dest/pxe.d.ts.map +1 -1
  112. package/dest/pxe.js +104 -52
  113. package/dest/storage/allowed_scopes.d.ts +6 -0
  114. package/dest/storage/allowed_scopes.d.ts.map +1 -0
  115. package/dest/storage/allowed_scopes.js +7 -0
  116. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  117. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  118. package/dest/storage/backwards_compatibility_tests/schema_tests.js +86 -33
  119. package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
  120. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
  121. package/dest/storage/capsule_store/capsule_service.js +6 -9
  122. package/dest/storage/contract_store/contract_store.js +2 -2
  123. package/dest/storage/fact_store/fact_service.d.ts +20 -0
  124. package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
  125. package/dest/storage/fact_store/fact_service.js +30 -0
  126. package/dest/storage/fact_store/fact_store.d.ts +95 -0
  127. package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
  128. package/dest/storage/fact_store/fact_store.js +408 -0
  129. package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
  130. package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
  131. package/dest/storage/fact_store/fact_store_keys.js +50 -0
  132. package/dest/storage/fact_store/index.d.ts +5 -0
  133. package/dest/storage/fact_store/index.d.ts.map +1 -0
  134. package/dest/storage/fact_store/index.js +3 -0
  135. package/dest/storage/fact_store/stored_fact.d.ts +32 -0
  136. package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
  137. package/dest/storage/fact_store/stored_fact.js +64 -0
  138. package/dest/storage/index.d.ts +2 -1
  139. package/dest/storage/index.d.ts.map +1 -1
  140. package/dest/storage/index.js +1 -0
  141. package/dest/storage/metadata.d.ts +1 -1
  142. package/dest/storage/metadata.js +1 -1
  143. package/dest/storage/open_pxe_stores.d.ts +5 -3
  144. package/dest/storage/open_pxe_stores.d.ts.map +1 -1
  145. package/dest/storage/open_pxe_stores.js +5 -3
  146. package/dest/storage/tagging_store/index.d.ts +2 -2
  147. package/dest/storage/tagging_store/index.d.ts.map +1 -1
  148. package/dest/storage/tagging_store/index.js +1 -1
  149. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +40 -0
  150. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
  151. package/dest/storage/tagging_store/tagging_secret_sources_store.js +92 -0
  152. package/package.json +17 -17
  153. package/src/block_synchronizer/block_stream_source.ts +6 -45
  154. package/src/block_synchronizer/block_synchronizer.ts +56 -23
  155. package/src/config/index.ts +1 -0
  156. package/src/contract_function_simulator/contract_function_simulator.ts +32 -31
  157. package/src/contract_function_simulator/index.ts +17 -8
  158. package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
  159. package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
  160. package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
  161. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  162. package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
  163. package/src/contract_function_simulator/noir-structs/fact_collection.ts +59 -0
  164. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
  165. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +7 -60
  166. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  167. package/src/contract_function_simulator/noir-structs/option.ts +17 -11
  168. package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
  169. package/src/contract_function_simulator/noir-structs/provided_secret.ts +3 -14
  170. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +45 -0
  171. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
  172. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
  173. package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
  174. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
  175. package/src/contract_function_simulator/oracle/oracle_registry.ts +87 -79
  176. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +641 -247
  177. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +94 -14
  178. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +206 -66
  179. package/src/contract_sync/helpers.ts +11 -18
  180. package/src/entrypoints/client/bundle/utils.ts +1 -0
  181. package/src/entrypoints/client/lazy/utils.ts +1 -0
  182. package/src/entrypoints/pxe_creation_options.ts +7 -1
  183. package/src/entrypoints/server/index.ts +0 -1
  184. package/src/entrypoints/server/utils.ts +3 -1
  185. package/src/error_enriching.ts +1 -1
  186. package/src/hooks/execution_hooks.ts +17 -8
  187. package/src/hooks/index.ts +6 -2
  188. package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
  189. package/src/logs/log_service.ts +71 -37
  190. package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
  191. package/src/oracle_version.ts +2 -2
  192. package/src/private_kernel/hints/test_utils.ts +1 -1
  193. package/src/pxe.ts +150 -54
  194. package/src/storage/allowed_scopes.ts +14 -0
  195. package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
  196. package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +1 -1
  197. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
  198. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +21 -5
  199. package/src/storage/backwards_compatibility_tests/schema_tests.ts +88 -33
  200. package/src/storage/capsule_store/capsule_service.ts +8 -13
  201. package/src/storage/contract_store/contract_store.ts +2 -2
  202. package/src/storage/fact_store/fact_service.ts +45 -0
  203. package/src/storage/fact_store/fact_store.ts +487 -0
  204. package/src/storage/fact_store/fact_store_keys.ts +75 -0
  205. package/src/storage/fact_store/index.ts +4 -0
  206. package/src/storage/fact_store/stored_fact.ts +80 -0
  207. package/src/storage/index.ts +1 -0
  208. package/src/storage/metadata.ts +1 -1
  209. package/src/storage/open_pxe_stores.ts +6 -3
  210. package/src/storage/tagging_store/index.ts +1 -1
  211. package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
  212. package/dest/messages/message_context_service.d.ts +0 -17
  213. package/dest/messages/message_context_service.d.ts.map +0 -1
  214. package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
  215. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
  216. package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
  217. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
  218. package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
@@ -3,7 +3,7 @@ import type { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { uniqueBy } from '@aztec/foundation/collection';
4
4
  import { Aes128 } from '@aztec/foundation/crypto/aes128';
5
5
  import { Fr } from '@aztec/foundation/curves/bn254';
6
- import type { Point } from '@aztec/foundation/curves/grumpkin';
6
+ import { Point } from '@aztec/foundation/curves/grumpkin';
7
7
  import { LogLevels, type Logger, createLogger } from '@aztec/foundation/log';
8
8
  import { MembershipWitness } from '@aztec/foundation/trees';
9
9
  import type { KeyStore } from '@aztec/key-store';
@@ -27,7 +27,7 @@ import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
27
27
  import { PublicKeys, computeAddressSecret, hashPublicKey } from '@aztec/stdlib/keys';
28
28
  import {
29
29
  AppTaggingSecret,
30
- MessageContext,
30
+ FlatPublicLogs,
31
31
  type PendingTaggedLog,
32
32
  deriveAppSiloedSharedSecret,
33
33
  } from '@aztec/stdlib/logs';
@@ -36,10 +36,10 @@ import type { NoteStatus } from '@aztec/stdlib/note';
36
36
  import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
37
37
  import {
38
38
  type BlockHeader,
39
+ CallContext,
39
40
  type Capsule,
40
41
  type IndexedTxEffect,
41
42
  type OffchainEffect,
42
- TxEffect,
43
43
  type TxHash,
44
44
  } from '@aztec/stdlib/tx';
45
45
 
@@ -49,36 +49,41 @@ import { EventService } from '../../events/event_service.js';
49
49
  import type { UtilityCallAuthorizationRequest } from '../../hooks/authorize_utility_call.js';
50
50
  import type { ExecutionHooks } from '../../hooks/index.js';
51
51
  import { LogService } from '../../logs/log_service.js';
52
- import { MessageContextService } from '../../messages/message_context_service.js';
52
+ import { TxResolverService } from '../../messages/tx_resolver_service.js';
53
53
  import { NoteService } from '../../notes/note_service.js';
54
54
  import { ORACLE_VERSION_MAJOR } from '../../oracle_version.js';
55
55
  import type { AddressStore } from '../../storage/address_store/address_store.js';
56
56
  import type { CapsuleService } from '../../storage/capsule_store/capsule_service.js';
57
57
  import type { ContractStore } from '../../storage/contract_store/contract_store.js';
58
+ import { FactCollectionKey, FactCollectionTypeKey } from '../../storage/fact_store/index.js';
59
+ import type { FactService, OriginBlock } from '../../storage/fact_store/index.js';
58
60
  import type { NoteStore } from '../../storage/note_store/note_store.js';
59
61
  import type { PrivateEventStore } from '../../storage/private_event_store/private_event_store.js';
60
62
  import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
61
- import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_address_book_store.js';
63
+ import type { TaggingSecretSourcesStore } from '../../storage/tagging_store/tagging_secret_sources_store.js';
62
64
  import { EphemeralArrayService } from '../ephemeral_array_service.js';
63
65
  import { BoundedVec } from '../noir-structs/bounded_vec.js';
66
+ import type { EmbeddedCurvePoint } from '../noir-structs/embedded_curve_point.js';
64
67
  import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
65
68
  import type { EventValidationRequest } from '../noir-structs/event_validation_request.js';
69
+ import { type FactCollection, emptyFactCollection, toNoirFactCollection } from '../noir-structs/fact_collection.js';
66
70
  import type { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
67
71
  import type { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
68
72
  import type { NoteData } from '../noir-structs/note_data.js';
69
73
  import type { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
70
74
  import { Option } from '../noir-structs/option.js';
71
75
  import type { ProvidedSecret } from '../noir-structs/provided_secret.js';
72
- import { UtilityContext } from '../noir-structs/utility_context.js';
76
+ import type { ResolvedTx } from '../noir-structs/resolved_tx.js';
77
+ import type { TxEffectData } from '../noir-structs/tx_effect_data.js';
78
+ import type { UtilityContext } from '../noir-structs/utility_context.js';
73
79
  import { pickNotes } from '../pick_notes.js';
74
80
  import type { TransientArrayService } from '../transient_array_service.js';
75
81
  import { buildACIRCallback } from './acir_callback.js';
76
82
  import type { IMiscOracle, IUtilityExecutionOracle } from './interfaces.js';
77
- import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
78
83
 
79
84
  /** Args for UtilityExecutionOracle constructor. */
80
85
  export type UtilityExecutionOracleArgs = {
81
- contractAddress: AztecAddress;
86
+ callContext: CallContext;
82
87
  /** List of transient auth witnesses to be used during this simulation */
83
88
  authWitnesses: AuthWitness[];
84
89
  capsules: Capsule[]; // TODO(#12425): Rename to transientCapsules
@@ -89,10 +94,11 @@ export type UtilityExecutionOracleArgs = {
89
94
  addressStore: AddressStore;
90
95
  aztecNode: AztecNode;
91
96
  recipientTaggingStore: RecipientTaggingStore;
92
- senderAddressBookStore: SenderAddressBookStore;
97
+ taggingSecretSourcesStore: TaggingSecretSourcesStore;
93
98
  capsuleService: CapsuleService;
99
+ factService: FactService;
94
100
  privateEventStore: PrivateEventStore;
95
- messageContextService: MessageContextService;
101
+ txResolver: TxResolverService;
96
102
  contractSyncService: ContractSyncService;
97
103
  l2TipsStore: L2TipsProvider;
98
104
  jobId: string;
@@ -121,7 +127,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
121
127
  // We store oracle version to be able to show a nice error message when an oracle handler is missing.
122
128
  private contractOracleVersion: { major: number; minor: number } | undefined;
123
129
 
124
- protected readonly contractAddress: AztecAddress;
130
+ protected readonly callContext: CallContext;
125
131
  protected readonly authWitnesses: AuthWitness[];
126
132
  protected readonly capsules: Capsule[];
127
133
  protected readonly anchorBlockHeader: BlockHeader;
@@ -131,10 +137,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
131
137
  protected readonly addressStore: AddressStore;
132
138
  protected readonly aztecNode: AztecNode;
133
139
  protected readonly recipientTaggingStore: RecipientTaggingStore;
134
- protected readonly senderAddressBookStore: SenderAddressBookStore;
140
+ protected readonly taggingSecretSourcesStore: TaggingSecretSourcesStore;
135
141
  protected readonly capsuleService: CapsuleService;
142
+ protected readonly factService: FactService;
136
143
  protected readonly privateEventStore: PrivateEventStore;
137
- protected readonly messageContextService: MessageContextService;
144
+ protected readonly txResolver: TxResolverService;
138
145
  protected readonly contractSyncService: ContractSyncService;
139
146
  protected readonly l2TipsStore: L2TipsProvider;
140
147
  protected readonly jobId: string;
@@ -145,7 +152,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
145
152
  protected readonly utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
146
153
 
147
154
  constructor(args: UtilityExecutionOracleArgs) {
148
- this.contractAddress = args.contractAddress;
155
+ this.callContext = args.callContext;
149
156
  this.authWitnesses = args.authWitnesses;
150
157
  this.capsules = args.capsules;
151
158
  this.anchorBlockHeader = args.anchorBlockHeader;
@@ -155,10 +162,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
155
162
  this.addressStore = args.addressStore;
156
163
  this.aztecNode = args.aztecNode;
157
164
  this.recipientTaggingStore = args.recipientTaggingStore;
158
- this.senderAddressBookStore = args.senderAddressBookStore;
165
+ this.taggingSecretSourcesStore = args.taggingSecretSourcesStore;
159
166
  this.capsuleService = args.capsuleService;
167
+ this.factService = args.factService;
160
168
  this.privateEventStore = args.privateEventStore;
161
- this.messageContextService = args.messageContextService;
169
+ this.txResolver = args.txResolver;
162
170
  this.contractSyncService = args.contractSyncService;
163
171
  this.l2TipsStore = args.l2TipsStore;
164
172
  this.jobId = args.jobId;
@@ -194,17 +202,22 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
194
202
  }
195
203
 
196
204
  public getUtilityContext(): UtilityContext {
197
- return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
205
+ return {
206
+ blockHeader: this.anchorBlockHeader,
207
+ contractAddress: this.callContext.contractAddress,
208
+ msgSender: this.callContext.msgSender,
209
+ };
198
210
  }
199
211
 
200
212
  /**
201
213
  * Retrieve keys associated with a specific master public key and app address.
202
214
  * @param pkMHash - The master public key hash.
215
+ * @param _keyIndex - Sent by the Noir oracle caller but unused here; kept to match the oracle signature.
203
216
  * @returns A Promise that resolves to nullifier keys.
204
217
  * @throws If the keys are not registered in the key store.
205
218
  * @throws If scopes are defined and the account is not in the scopes.
206
219
  */
207
- public async getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
220
+ public async getKeyValidationRequest(pkMHash: Fr, _keyIndex: Fr): Promise<KeyValidationRequest> {
208
221
  let hasAccess = false;
209
222
  for (let i = 0; i < this.scopes.length && !hasAccess; i++) {
210
223
  if (await this.keyStore.accountHasKey(this.scopes[i], pkMHash)) {
@@ -258,7 +271,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
258
271
  const witness = await this.#queryWithBlockHashNotAfterAnchor(referenceBlockHash, () =>
259
272
  this.aztecNode.getBlockHashMembershipWitness(referenceBlockHash, blockHash),
260
273
  );
261
- return witness ? Option.some(witness) : Option.none(MembershipWitness.empty(ARCHIVE_HEIGHT));
274
+ return witness ? Option.some(witness) : Option.none();
262
275
  }
263
276
 
264
277
  /**
@@ -350,7 +363,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
350
363
  ): Promise<Option<{ publicKeys: PublicKeys; partialAddress: PartialAddress }>> {
351
364
  const completeAddress = await this.addressStore.getCompleteAddress(account);
352
365
  if (!completeAddress) {
353
- return Option.none({ publicKeys: PublicKeys.default(), partialAddress: Fr.ZERO });
366
+ return Option.none();
354
367
  }
355
368
  return Option.some({ publicKeys: completeAddress.publicKeys, partialAddress: completeAddress.partialAddress });
356
369
  }
@@ -360,7 +373,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
360
373
  if (!completeAddress) {
361
374
  throw new Error(
362
375
  `No public key registered for address ${account}.
363
- Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
376
+ Register it by calling wallet.registerSender(...).\nSee docs for context: https://docs.aztec.network/errors/14`,
364
377
  );
365
378
  }
366
379
  return completeAddress;
@@ -485,7 +498,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
485
498
  await this.anchorBlockHeader.hash(),
486
499
  );
487
500
 
488
- return new MessageLoadOracleInputs(messageIndex, siblingPath);
501
+ return { index: messageIndex, siblingPath };
489
502
  }
490
503
 
491
504
  /**
@@ -584,7 +597,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
584
597
  this.l2TipsStore,
585
598
  this.keyStore,
586
599
  this.recipientTaggingStore,
587
- this.senderAddressBookStore,
600
+ this.taggingSecretSourcesStore,
588
601
  this.addressStore,
589
602
  this.jobId,
590
603
  this.logger.getBindings(),
@@ -638,20 +651,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
638
651
  return EphemeralArray.fromValues(this.ephemeralArrayService, innerArrays);
639
652
  }
640
653
 
641
- /** Reads tx hash requests from an ephemeral array, resolves their contexts, and returns the response array. */
642
- public async getMessageContextsByTxHash(
643
- requests: EphemeralArray<Fr>,
644
- ): Promise<EphemeralArray<Option<MessageContext>>> {
654
+ /** Given an array of tx hashes, returns an aligned array of tx info if the tx is available. */
655
+ public async getResolvedTxs(requests: EphemeralArray<Fr>): Promise<EphemeralArray<Option<ResolvedTx>>> {
645
656
  const txHashes = requests.readAll(this.ephemeralArrayService);
646
657
 
647
- const maybeMessageContexts = await this.messageContextService.getMessageContextsByTxHash(
648
- txHashes,
649
- this.anchorBlockHeader.getBlockNumber(),
650
- );
658
+ const resolved = await this.txResolver.resolveTxs(txHashes, this.anchorBlockHeader.getBlockNumber());
651
659
 
652
- const options = maybeMessageContexts.map(mc =>
653
- mc ? Option.some(mc) : Option.none<MessageContext>(MessageContext.empty()),
654
- );
660
+ const options = resolved.map(r => (r ? Option.some(r) : Option.none<ResolvedTx>()));
655
661
  return EphemeralArray.fromValues(this.ephemeralArrayService, options);
656
662
  }
657
663
 
@@ -659,24 +665,30 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
659
665
  * Fetches the effects of a transaction by its hash. Returns null if the tx is not found or is beyond the anchor
660
666
  * block.
661
667
  */
662
- public async getTxEffect(txHash: TxHash): Promise<Option<TxEffect>> {
668
+ public async getTxEffect(txHash: TxHash): Promise<Option<TxEffectData>> {
663
669
  if (txHash.hash.isZero()) {
664
670
  throw new Error('Invalid tx hash passed into aztec_utl_getTxEffect oracle handler');
665
671
  }
666
672
 
667
673
  const receipt = await this.aztecNode.getTxReceipt(txHash, { includeTxEffect: true });
668
674
  if (!receipt.isMined() || !receipt.txEffect || receipt.blockNumber > this.anchorBlockHeader.getBlockNumber()) {
669
- return Option.none(TxEffect.empty());
675
+ return Option.none();
670
676
  }
671
677
 
672
- return Option.some(receipt.txEffect);
678
+ const txEffect = receipt.txEffect;
679
+ return Option.some({
680
+ ...txEffect,
681
+ publicLogs: FlatPublicLogs.fromLogs(txEffect.publicLogs),
682
+ contractClassLogs: txEffect.contractClassLogs.map(log => ({
683
+ contractAddress: log.contractAddress,
684
+ fields: log.fields.toFields(),
685
+ emittedLength: log.emittedLength,
686
+ })),
687
+ });
673
688
  }
674
689
 
675
690
  public setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], scope: AztecAddress): void {
676
- if (!contractAddress.equals(this.contractAddress)) {
677
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
678
- throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
679
- }
691
+ this.#assertOwnContract(contractAddress);
680
692
  this.capsuleService.setCapsule(contractAddress, slot, capsule, this.jobId, scope);
681
693
  }
682
694
 
@@ -686,19 +698,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
686
698
  tSize: number,
687
699
  scope: AztecAddress,
688
700
  ): Promise<Option<Fr[]>> {
689
- if (!contractAddress.equals(this.contractAddress)) {
690
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
691
- throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
692
- }
701
+ this.#assertOwnContract(contractAddress);
693
702
  const values = await this.capsuleService.getCapsule(contractAddress, slot, this.jobId, scope, this.capsules);
694
- return values ? Option.some(values) : Option.none(new Array(tSize).fill(Fr.ZERO));
703
+ return values ? Option.some(values) : Option.none({ length: tSize });
695
704
  }
696
705
 
697
706
  public deleteCapsule(contractAddress: AztecAddress, slot: Fr, scope: AztecAddress): void {
698
- if (!contractAddress.equals(this.contractAddress)) {
699
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
700
- throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
701
- }
707
+ this.#assertOwnContract(contractAddress);
702
708
  this.capsuleService.deleteCapsule(contractAddress, slot, this.jobId, scope);
703
709
  }
704
710
 
@@ -709,11 +715,110 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
709
715
  numEntries: number,
710
716
  scope: AztecAddress,
711
717
  ): Promise<void> {
718
+ this.#assertOwnContract(contractAddress);
719
+ return this.capsuleService.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, this.jobId, scope);
720
+ }
721
+
722
+ /**
723
+ * Asserts the executing contract may only access its own slice of PXE DB.
724
+ */
725
+ #assertOwnContract(contractAddress: AztecAddress): void {
712
726
  if (!contractAddress.equals(this.contractAddress)) {
713
- // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
714
727
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
715
728
  }
716
- return this.capsuleService.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, this.jobId, scope);
729
+ }
730
+
731
+ /**
732
+ * Records a fact into a collection. A `Some` origin block makes the fact retractable (pruned on reorg of that
733
+ * block), a `None` origin block makes it non-retractable, surviving reorgs.
734
+ */
735
+ public recordFact(
736
+ contractAddress: AztecAddress,
737
+ scope: AztecAddress,
738
+ factCollectionTypeId: Fr,
739
+ factCollectionId: Fr,
740
+ factTypeId: Fr,
741
+ payload: EphemeralArray<Fr>,
742
+ originBlock: Option<OriginBlock>,
743
+ ): Promise<void> {
744
+ this.#assertOwnContract(contractAddress);
745
+ return this.factService.recordFact(
746
+ new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId),
747
+ factTypeId,
748
+ payload.readAll(this.ephemeralArrayService),
749
+ originBlock.isSome() ? originBlock.value : undefined,
750
+ this.jobId,
751
+ );
752
+ }
753
+
754
+ /**
755
+ * Deletes a fact collection, removing all its facts. A no-op if no such collection exists.
756
+ */
757
+ public deleteFactCollection(
758
+ contractAddress: AztecAddress,
759
+ scope: AztecAddress,
760
+ factCollectionTypeId: Fr,
761
+ factCollectionId: Fr,
762
+ ): Promise<void> {
763
+ this.#assertOwnContract(contractAddress);
764
+ return this.factService.deleteFactCollection(
765
+ new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId),
766
+ this.jobId,
767
+ );
768
+ }
769
+
770
+ /**
771
+ * Returns a fact collection.
772
+ */
773
+ public async getFactCollection(
774
+ contractAddress: AztecAddress,
775
+ scope: AztecAddress,
776
+ factCollectionTypeId: Fr,
777
+ factCollectionId: Fr,
778
+ ): Promise<Option<FactCollection>> {
779
+ this.#assertOwnContract(contractAddress);
780
+ const collection = await this.factService.getFactCollection(
781
+ new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId),
782
+ this.jobId,
783
+ );
784
+ return collection
785
+ ? Option.some(
786
+ toNoirFactCollection(
787
+ this.ephemeralArrayService,
788
+ contractAddress,
789
+ scope,
790
+ factCollectionTypeId,
791
+ factCollectionId,
792
+ collection.facts,
793
+ ),
794
+ )
795
+ : Option.none(emptyFactCollection(this.ephemeralArrayService));
796
+ }
797
+
798
+ /** Returns every fact collection of `factCollectionTypeId`. */
799
+ public async getFactCollectionsByType(
800
+ contractAddress: AztecAddress,
801
+ scope: AztecAddress,
802
+ factCollectionTypeId: Fr,
803
+ ): Promise<EphemeralArray<FactCollection>> {
804
+ this.#assertOwnContract(contractAddress);
805
+ const collections = await this.factService.getFactCollectionsByType(
806
+ new FactCollectionTypeKey(contractAddress, scope, factCollectionTypeId),
807
+ this.jobId,
808
+ );
809
+ return EphemeralArray.fromValues(
810
+ this.ephemeralArrayService,
811
+ collections.map(collection =>
812
+ toNoirFactCollection(
813
+ this.ephemeralArrayService,
814
+ collection.key.contractAddress,
815
+ collection.key.scope,
816
+ collection.key.factCollectionTypeId,
817
+ collection.key.factCollectionId,
818
+ collection.facts,
819
+ ),
820
+ ),
821
+ );
717
822
  }
718
823
 
719
824
  /**
@@ -739,7 +844,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
739
844
  const plaintext = await aes128.decryptBufferCBC(Buffer.from(ciphertext.data), iv, symKey);
740
845
  return Option.some(BoundedVec.from<number>({ data: [...plaintext], maxLength: capacity }));
741
846
  } catch {
742
- return Option.none(BoundedVec.empty<number>({ maxLength: capacity }));
847
+ return Option.none({ maxLength: capacity });
743
848
  }
744
849
  }
745
850
 
@@ -752,7 +857,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
752
857
  */
753
858
  public async getSharedSecrets(
754
859
  address: AztecAddress,
755
- ephPks: EphemeralArray<Point>,
860
+ ephPks: EphemeralArray<EmbeddedCurvePoint>,
756
861
  contractAddress: AztecAddress,
757
862
  ): Promise<EphemeralArray<Fr>> {
758
863
  if (!contractAddress.equals(this.contractAddress)) {
@@ -767,7 +872,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
767
872
 
768
873
  const ephPkPoints = ephPks.readAll(this.ephemeralArrayService);
769
874
  const secrets = await Promise.all(
770
- ephPkPoints.map(ephPk => deriveAppSiloedSharedSecret(addressSecret, ephPk, this.contractAddress)),
875
+ ephPkPoints.map(({ x, y }) => deriveAppSiloedSharedSecret(addressSecret, new Point(x, y), this.contractAddress)),
771
876
  );
772
877
 
773
878
  return EphemeralArray.fromValues(this.ephemeralArrayService, secrets);
@@ -846,12 +951,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
846
951
  );
847
952
 
848
953
  if (!targetContractAddress.equals(this.contractAddress)) {
849
- // The HandshakeRegistry is called during every contract's sync to discover handshake secrets.
850
- // It is a standard contract that only reads its own state, so it is always authorized.
851
- const isHandshakeRegistryRead =
852
- targetContractAddress.equals(STANDARD_HANDSHAKE_REGISTRY_ADDRESS) &&
853
- functionSelector.equals(await FunctionSelector.fromSignature('get_handshakes((Field),u32)'));
854
- if (!isHandshakeRegistryRead) {
954
+ // Standard handshake registry reads are authorized by default; every other cross-contract call needs the hook.
955
+ if (!(await isStandardHandshakeRegistryUtilityRead(targetContractAddress, functionSelector))) {
855
956
  const [callerInstance, targetInstance] = await Promise.all([
856
957
  this.getContractInstance(this.contractAddress),
857
958
  this.getContractInstance(targetContractAddress),
@@ -867,9 +968,9 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
867
968
  callerContext: this.callerContext,
868
969
  };
869
970
 
870
- const response = this.hooks
971
+ const response = this.hooks?.authorizeUtilityCall
871
972
  ? await this.hooks.authorizeUtilityCall(request)
872
- : { authorized: false, reason: 'No execution hooks configured' };
973
+ : { authorized: false, reason: 'No authorizeUtilityCall hook configured' };
873
974
 
874
975
  if (!response.authorized) {
875
976
  const reason = response.reason ? `: ${response.reason}` : '';
@@ -896,7 +997,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
896
997
  );
897
998
 
898
999
  const nestedOracle = new UtilityExecutionOracle({
899
- contractAddress: targetContractAddress,
1000
+ callContext: CallContext.from({
1001
+ msgSender: this.contractAddress,
1002
+ contractAddress: targetContractAddress,
1003
+ functionSelector,
1004
+ isStaticCall: true,
1005
+ }),
900
1006
  authWitnesses: this.authWitnesses,
901
1007
  capsules: this.capsules,
902
1008
  anchorBlockHeader: this.anchorBlockHeader,
@@ -906,10 +1012,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
906
1012
  addressStore: this.addressStore,
907
1013
  aztecNode: this.aztecNode,
908
1014
  recipientTaggingStore: this.recipientTaggingStore,
909
- senderAddressBookStore: this.senderAddressBookStore,
1015
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
910
1016
  capsuleService: this.capsuleService,
1017
+ factService: this.factService,
911
1018
  privateEventStore: this.privateEventStore,
912
- messageContextService: this.messageContextService,
1019
+ txResolver: this.txResolver,
913
1020
  contractSyncService: this.contractSyncService,
914
1021
  l2TipsStore: this.l2TipsStore,
915
1022
  jobId: this.jobId,
@@ -1005,4 +1112,37 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
1005
1112
  protected get callerContext(): 'private' | 'private view' | 'utility' {
1006
1113
  return 'utility';
1007
1114
  }
1115
+
1116
+ /** The address of the contract whose function is being executed, from the call context. */
1117
+ protected get contractAddress(): AztecAddress {
1118
+ return this.callContext.contractAddress;
1119
+ }
1120
+ }
1121
+
1122
+ const STANDARD_HANDSHAKE_REGISTRY_GET_HANDSHAKES_SIGNATURE = 'get_handshakes((Field),u32)';
1123
+ const STANDARD_HANDSHAKE_REGISTRY_GET_APP_SILOED_SECRET_SIGNATURE = 'get_app_siloed_secret((Field),(Field))';
1124
+
1125
+ async function doesSelectorHaveSignature(functionSelector: FunctionSelector, signature: string): Promise<boolean> {
1126
+ return functionSelector.equals(await FunctionSelector.fromSignature(signature));
1127
+ }
1128
+
1129
+ /**
1130
+ * Whether a cross-contract utility call targets one of the standard handshake registry's read functions.
1131
+ *
1132
+ * These reads are authorized by PXE for every wallet, without consulting the `authorizeUtilityCall` hook, so that
1133
+ * wallets don't need to know the handshake registry exists in order to deliver and discover messages through it.
1134
+ */
1135
+ async function isStandardHandshakeRegistryUtilityRead(
1136
+ targetContractAddress: AztecAddress,
1137
+ functionSelector: FunctionSelector,
1138
+ ): Promise<boolean> {
1139
+ if (!targetContractAddress.equals(STANDARD_HANDSHAKE_REGISTRY_ADDRESS)) {
1140
+ return false;
1141
+ }
1142
+
1143
+ const [isGetHandshakes, isGetAppSiloedSecret] = await Promise.all([
1144
+ doesSelectorHaveSignature(functionSelector, STANDARD_HANDSHAKE_REGISTRY_GET_HANDSHAKES_SIGNATURE),
1145
+ doesSelectorHaveSignature(functionSelector, STANDARD_HANDSHAKE_REGISTRY_GET_APP_SILOED_SECRET_SIGNATURE),
1146
+ ]);
1147
+ return isGetHandshakes || isGetAppSiloedSecret;
1008
1148
  }
@@ -1,20 +1,20 @@
1
- import { ProtocolContractAddress, isProtocolContract } from '@aztec/protocol-contracts';
1
+ import { isProtocolContract } from '@aztec/protocol-contracts';
2
2
  import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { ContractInstance } from '@aztec/stdlib/contract';
5
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
6
5
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
6
  import type { BlockHeader } from '@aztec/stdlib/tx';
8
7
 
9
8
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
10
9
 
11
10
  /**
12
- * Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
13
- * from the instance is used.
11
+ * Read the current class id of a contract as of the given block, as seen by the AztecNode. The node resolves it from
12
+ * the same scheduled value change the AVM enforces against the public data tree. If the node has no record of the
13
+ * instance (e.g. it was never publicly deployed), the original class id from the local instance is used.
14
14
  * @param contractAddress - The address of the contract to read the class id for.
15
- * @param instance - The instance of the contract.
16
- * @param aztecNode - The Aztec node to query for storage.
17
- * @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
15
+ * @param instance - The local instance of the contract, used as a fallback when the node doesn't know it.
16
+ * @param aztecNode - The Aztec node to query.
17
+ * @param header - The header of the block at which to resolve the current class id.
18
18
  * @returns The current class id.
19
19
  */
20
20
  export async function readCurrentClassId(
@@ -23,17 +23,10 @@ export async function readCurrentClassId(
23
23
  aztecNode: AztecNode,
24
24
  header: BlockHeader,
25
25
  ) {
26
- const blockHash = await header.hash();
27
- const timestamp = header.globalVariables.timestamp;
28
- const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
29
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
30
- aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
31
- );
32
- let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
33
- if (currentClassId.isZero()) {
34
- currentClassId = instance.originalContractClassId;
35
- }
36
- return currentClassId;
26
+ const nodeInstance = await aztecNode.getContract(contractAddress, await header.hash());
27
+ // If the contract was upgraded then the node WILL know of that and return a non-undefined instance. An undefined
28
+ // result therefore means that no upgrade has happened, and therefore that the original class is the current one.
29
+ return nodeInstance?.currentContractClassId ?? instance.originalContractClassId;
37
30
  }
38
31
 
39
32
  export async function syncScope(
@@ -63,6 +63,7 @@ export async function createPXE(
63
63
  const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
64
64
  const pxe = await PXE.create({
65
65
  node: aztecNode,
66
+ nodeDebug: options.nodeDebug,
66
67
  store,
67
68
  proofCreator: prover,
68
69
  simulator,
@@ -63,6 +63,7 @@ export async function createPXE(
63
63
  const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
64
64
  const pxe = await PXE.create({
65
65
  node: aztecNode,
66
+ nodeDebug: options.nodeDebug,
66
67
  store,
67
68
  proofCreator: prover,
68
69
  simulator,
@@ -2,7 +2,7 @@ import type { BBPrivateKernelProverOptions } from '@aztec/bb-prover/client';
2
2
  import type { Logger } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
4
  import type { CircuitSimulator } from '@aztec/simulator/client';
5
- import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
5
+ import type { AztecNodeDebug, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
6
6
 
7
7
  import type { ExecutionHooks } from '../hooks/index.js';
8
8
  import type { PreloadedContractsProvider } from '../pxe.js';
@@ -18,6 +18,12 @@ export type PXECreationOptions = {
18
18
  hooks?: ExecutionHooks;
19
19
  /** Contracts to preload on startup. Replaces the default when set. */
20
20
  preloadedContractsProvider?: PreloadedContractsProvider;
21
+ /**
22
+ * Optional debug API client for the same node. When provided, public function signatures are registered so the
23
+ * node can produce named public-execution stack traces. Only available on nodes started with debug endpoints
24
+ * enabled; omitted in prod-like setups.
25
+ */
26
+ nodeDebug?: AztecNodeDebug;
21
27
  };
22
28
 
23
29
  /** Checks if the given value implements the PrivateKernelProver interface via duck-typing. */
@@ -1,6 +1,5 @@
1
1
  export * from '../../notes_filter.js';
2
2
  export * from '../../pxe.js';
3
- export * from '../../hooks/index.js';
4
3
  export * from '../../config/index.js';
5
4
  export * from '../../error_enriching.js';
6
5
  export * from '../../storage/index.js';
@@ -3,7 +3,8 @@ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses'
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { createStore } from '@aztec/kv-store/lmdb-v2';
5
5
  import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
6
- import { MemoryCircuitRecorder, SimulatorRecorderWrapper, WASMSimulator } from '@aztec/simulator/client';
6
+ import { WASMSimulator } from '@aztec/simulator/client';
7
+ import { MemoryCircuitRecorder, SimulatorRecorderWrapper } from '@aztec/simulator/server';
7
8
  import { FileCircuitRecorder } from '@aztec/simulator/testing';
8
9
  import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
9
10
  import { getStandardHandshakeRegistry } from '@aztec/standard-contracts/handshake-registry';
@@ -73,6 +74,7 @@ export async function createPXE(
73
74
  const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
74
75
  const pxe = await PXE.create({
75
76
  node: aztecNode,
77
+ nodeDebug: options.nodeDebug,
76
78
  store: options.store,
77
79
  proofCreator: prover,
78
80
  simulator,
@@ -29,7 +29,7 @@ export async function enrichSimulationError(err: SimulationError, contractStore:
29
29
 
30
30
  await Promise.all(
31
31
  [...mentionedFunctions.entries()].map(async ([contractAddress, fnSelectors]) => {
32
- const parsedContractAddress = AztecAddress.fromString(contractAddress);
32
+ const parsedContractAddress = AztecAddress.fromStringUnsafe(contractAddress);
33
33
  const contract = await contractStore.getContract(parsedContractAddress);
34
34
  if (contract) {
35
35
  err.enrichWithContractName(parsedContractAddress, contract.name);