@aztec/pxe 5.0.0-rc.2 → 5.0.0

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 (188) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +5 -3
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.js +7 -1
  4. package/dest/contract/contract_class_service.d.ts +31 -0
  5. package/dest/contract/contract_class_service.d.ts.map +1 -0
  6. package/dest/contract/contract_class_service.js +68 -0
  7. package/dest/{contract_sync → contract}/contract_sync_service.d.ts +7 -6
  8. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  9. package/dest/{contract_sync → contract}/contract_sync_service.js +10 -30
  10. package/dest/contract/helpers.d.ts +7 -0
  11. package/dest/contract/helpers.d.ts.map +1 -0
  12. package/dest/contract/helpers.js +20 -0
  13. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  14. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  15. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  16. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  17. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  19. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  20. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/contract_function_simulator.js +31 -14
  22. package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
  23. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  25. package/dest/contract_function_simulator/index.d.ts +4 -2
  26. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/index.js +2 -1
  28. package/dest/contract_function_simulator/noir-structs/fact.d.ts +5 -5
  29. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/fact.js +2 -2
  31. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +3 -3
  32. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/noir-structs/fact_collection.js +3 -1
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +7 -1
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  37. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  39. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +2 -2
  40. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -1
  42. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +8 -1
  43. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +17 -0
  45. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +7 -2
  46. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/oracle/acir_callback.js +55 -11
  48. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  49. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  51. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +10 -7
  52. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  53. package/dest/contract_function_simulator/oracle/oracle_registry.js +41 -10
  54. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +48 -9
  55. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  56. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +51 -30
  57. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -2
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -32
  60. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -16
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +68 -47
  63. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  64. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  65. package/dest/entrypoints/client/bundle/utils.js +2 -2
  66. package/dest/entrypoints/client/lazy/utils.js +2 -2
  67. package/dest/entrypoints/server/index.d.ts +5 -2
  68. package/dest/entrypoints/server/index.d.ts.map +1 -1
  69. package/dest/entrypoints/server/index.js +3 -1
  70. package/dest/error_enriching.d.ts +5 -3
  71. package/dest/error_enriching.d.ts.map +1 -1
  72. package/dest/error_enriching.js +12 -10
  73. package/dest/hooks/execution_hooks.d.ts +15 -4
  74. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  75. package/dest/hooks/index.d.ts +3 -2
  76. package/dest/hooks/index.d.ts.map +1 -1
  77. package/dest/hooks/index.js +1 -0
  78. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  79. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  80. package/dest/hooks/resolve_custom_request.js +3 -0
  81. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +10 -1
  82. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
  83. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
  84. package/dest/logs/log_service.d.ts +3 -2
  85. package/dest/logs/log_service.d.ts.map +1 -1
  86. package/dest/logs/log_service.js +33 -16
  87. package/dest/oracle_version.d.ts +2 -2
  88. package/dest/oracle_version.js +2 -2
  89. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  90. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  91. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  92. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  93. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  94. package/dest/private_kernel/private_kernel_execution_prover.js +17 -36
  95. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  96. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  97. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  98. package/dest/pxe.d.ts +81 -46
  99. package/dest/pxe.d.ts.map +1 -1
  100. package/dest/pxe.js +135 -104
  101. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  102. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  103. package/dest/storage/backwards_compatibility_tests/schema_tests.js +31 -7
  104. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  105. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  106. package/dest/storage/contract_store/contract_store.js +63 -74
  107. package/dest/storage/fact_store/fact_service.d.ts +6 -4
  108. package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
  109. package/dest/storage/fact_store/fact_service.js +19 -4
  110. package/dest/storage/fact_store/fact_store.d.ts +1 -1
  111. package/dest/storage/fact_store/fact_store.js +1 -1
  112. package/dest/storage/fact_store/index.d.ts +2 -1
  113. package/dest/storage/fact_store/index.d.ts.map +1 -1
  114. package/dest/storage/fact_store/index.js +1 -0
  115. package/dest/storage/fact_store/origin_state.d.ts +57 -0
  116. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  117. package/dest/storage/fact_store/origin_state.js +53 -0
  118. package/dest/storage/metadata.d.ts +2 -2
  119. package/dest/storage/metadata.d.ts.map +1 -1
  120. package/dest/storage/metadata.js +1 -1
  121. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +17 -6
  122. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -1
  123. package/dest/storage/tagging_store/tagging_secret_sources_store.js +24 -11
  124. package/dest/tagging/constants.d.ts +2 -2
  125. package/dest/tagging/constants.d.ts.map +1 -1
  126. package/dest/tagging/constants.js +18 -9
  127. package/package.json +17 -17
  128. package/src/block_synchronizer/block_synchronizer.ts +9 -1
  129. package/src/contract/contract_class_service.ts +83 -0
  130. package/src/{contract_sync → contract}/contract_sync_service.ts +18 -37
  131. package/src/contract/helpers.ts +35 -0
  132. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  133. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  134. package/src/contract_function_simulator/contract_function_simulator.ts +56 -14
  135. package/src/contract_function_simulator/execution_note_cache.ts +7 -28
  136. package/src/contract_function_simulator/index.ts +7 -1
  137. package/src/contract_function_simulator/noir-structs/fact.ts +4 -4
  138. package/src/contract_function_simulator/noir-structs/fact_collection.ts +9 -4
  139. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +6 -0
  140. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  141. package/src/contract_function_simulator/noir-structs/provided_secret.ts +1 -1
  142. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +21 -0
  143. package/src/contract_function_simulator/oracle/acir_callback.ts +58 -12
  144. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  145. package/src/contract_function_simulator/oracle/oracle_registry.ts +32 -7
  146. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +49 -32
  147. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -41
  148. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +104 -59
  149. package/src/debug/pxe_debug_utils.ts +1 -1
  150. package/src/entrypoints/client/bundle/utils.ts +2 -2
  151. package/src/entrypoints/client/lazy/utils.ts +2 -2
  152. package/src/entrypoints/server/index.ts +5 -1
  153. package/src/error_enriching.ts +26 -10
  154. package/src/hooks/execution_hooks.ts +14 -3
  155. package/src/hooks/index.ts +2 -0
  156. package/src/hooks/resolve_custom_request.ts +24 -0
  157. package/src/hooks/resolve_tagging_secret_strategy.ts +14 -0
  158. package/src/logs/log_service.ts +31 -11
  159. package/src/oracle_version.ts +2 -2
  160. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  161. package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
  162. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  163. package/src/pxe.ts +209 -143
  164. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  165. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  166. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  167. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  168. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  169. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +3 -3
  170. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
  171. package/src/storage/backwards_compatibility_tests/schema_tests.ts +38 -4
  172. package/src/storage/contract_store/contract_store.ts +85 -92
  173. package/src/storage/fact_store/fact_service.ts +29 -5
  174. package/src/storage/fact_store/fact_store.ts +1 -1
  175. package/src/storage/fact_store/index.ts +10 -0
  176. package/src/storage/fact_store/origin_state.ts +75 -0
  177. package/src/storage/metadata.ts +1 -1
  178. package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
  179. package/src/tagging/constants.ts +19 -9
  180. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  181. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  182. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  183. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  184. package/dest/contract_sync/helpers.d.ts +0 -28
  185. package/dest/contract_sync/helpers.d.ts.map +0 -1
  186. package/dest/contract_sync/helpers.js +0 -48
  187. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  188. package/src/contract_sync/helpers.ts +0 -79
@@ -0,0 +1,147 @@
1
+ /* eslint-disable camelcase */
2
+ import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_CIPHERTEXT_LEN, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
3
+ import { computeFeeJuiceMessageNullifier } from '@aztec/stdlib/messaging';
4
+
5
+ import type { EphemeralArray } from '../noir-structs/ephemeral_array.js';
6
+ import type { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
7
+ import { Option } from '../noir-structs/option.js';
8
+ import type { PendingTaggedLog } from '../noir-structs/pending_tagged_log.js';
9
+ import type { ResolvedTx } from '../noir-structs/resolved_tx.js';
10
+ import {
11
+ type InferDeserializedParams,
12
+ ORACLE_REGISTRY,
13
+ type OracleRegistryEntry,
14
+ type ParamTypes,
15
+ type RegistryParam,
16
+ } from './oracle_registry.js';
17
+ import {
18
+ AZTEC_ADDRESS,
19
+ EPHEMERAL_ARRAY,
20
+ FIELD,
21
+ FIXED_BOUNDED_VEC,
22
+ STRUCT,
23
+ TX_HASH,
24
+ type TypeMapping,
25
+ } from './oracle_type_mappings.js';
26
+
27
+ const LEGACY_LOG_RETRIEVAL_RESPONSE: TypeMapping<LegacyLogRetrievalResponse> = STRUCT([
28
+ { name: 'logPayload', type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_CIPHERTEXT_LEN) },
29
+ { name: 'txHash', type: TX_HASH },
30
+ { name: 'uniqueNoteHashesInTx', type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX) },
31
+ { name: 'firstNullifierInTx', type: FIELD },
32
+ ]);
33
+
34
+ // Block-less transaction context: the prefix of `ResolvedTx`'s wire carried by the original `getPendingTaggedLogs`
35
+ // oracle. Known as `MessageContext` in the Aztec.nr versions that call that oracle.
36
+ const LEGACY_MESSAGE_CONTEXT: TypeMapping<LegacyMessageContext> = STRUCT<LegacyMessageContext>([
37
+ { name: 'txHash', type: TX_HASH },
38
+ { name: 'uniqueNoteHashesInTx', type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX) },
39
+ { name: 'firstNullifierInTx', type: FIELD },
40
+ ]);
41
+
42
+ const LEGACY_PENDING_TAGGED_LOG: TypeMapping<LegacyPendingTaggedLog> = STRUCT<LegacyPendingTaggedLog>([
43
+ { name: 'log', type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS) },
44
+ { name: 'context', type: LEGACY_MESSAGE_CONTEXT },
45
+ ]);
46
+
47
+ /**
48
+ * Wire shapes that already-deployed contracts still call by their original oracle name, keyed by that retired name.
49
+ * New Aztec.nr calls the current name in `ORACLE_REGISTRY`; old bytecode keeps calling the name compiled into it and
50
+ * is served from here, so versioning an oracle's wire (e.g. adding return fields) stops being a breaking change.
51
+ *
52
+ * Append-only. Drop an entry only once the `ORACLE_VERSION_MAJOR` that introduced its successor is retired, since
53
+ * older contracts can no longer run against this environment.
54
+ */
55
+ export const LEGACY_ORACLE_REGISTRY: Record<string, LegacyOracleEntry> = {
56
+ aztec_utl_getL1ToL2MembershipWitness: legacyOracle({
57
+ modernOracle: 'aztec_utl_getL1ToL2MembershipWitnessV2',
58
+ // The old wire passed the contract address and secret, the modern oracle takes the unsiloed nullifier (plus the
59
+ // address to silo it with) instead. We derive it here so already-deployed contracts that still emit the old call
60
+ // keep working.
61
+ //
62
+ // This is the fee juice message nullifier derivation: only contracts using that scheme call this retired oracle.
63
+ params: {
64
+ legacyType: [
65
+ { name: 'contractAddress', type: AZTEC_ADDRESS },
66
+ { name: 'messageHash', type: FIELD },
67
+ { name: 'secret', type: FIELD },
68
+ ],
69
+ mapping: async ([contractAddress, messageHash, secret]) => [
70
+ messageHash,
71
+ Option.some({ contractAddress, nullifier: await computeFeeJuiceMessageNullifier(messageHash, secret) }),
72
+ ],
73
+ },
74
+ }),
75
+ aztec_utl_getLogsByTag: legacyOracle({
76
+ modernOracle: 'aztec_utl_getLogsByTagV2',
77
+ returnType: {
78
+ legacyType: EPHEMERAL_ARRAY(EPHEMERAL_ARRAY(LEGACY_LOG_RETRIEVAL_RESPONSE)),
79
+ // We can map this directly, since the new type is a superset of the old type
80
+ mapping: result => result as unknown as EphemeralArray<EphemeralArray<LegacyLogRetrievalResponse>>,
81
+ },
82
+ }),
83
+ aztec_utl_getPendingTaggedLogs: legacyOracle({
84
+ modernOracle: 'aztec_utl_getPendingTaggedLogsV2',
85
+ returnType: {
86
+ legacyType: EPHEMERAL_ARRAY(LEGACY_PENDING_TAGGED_LOG),
87
+ // We can map this directly, since `ResolvedTx` carries the legacy context's fields under the same names
88
+ mapping: result => result as unknown as EphemeralArray<LegacyPendingTaggedLog>,
89
+ },
90
+ }),
91
+ };
92
+
93
+ type LegacyLogRetrievalResponse = Pick<
94
+ LogRetrievalResponse,
95
+ 'logPayload' | 'txHash' | 'uniqueNoteHashesInTx' | 'firstNullifierInTx'
96
+ >;
97
+
98
+ type LegacyMessageContext = Pick<ResolvedTx, 'txHash' | 'uniqueNoteHashesInTx' | 'firstNullifierInTx'>;
99
+
100
+ type LegacyPendingTaggedLog = {
101
+ log: PendingTaggedLog['log'];
102
+ context: LegacyMessageContext;
103
+ };
104
+
105
+ type Registry = typeof ORACLE_REGISTRY;
106
+
107
+ /** The handler return value type of a modern oracle entry. */
108
+ type ReturnValueOf<K extends keyof Registry> = Registry[K] extends OracleRegistryEntry<any, infer R> ? R : never;
109
+
110
+ /** The modern handler's positional argument tuple, derived from the oracle's declared params. */
111
+ type HandlerArgsOf<K extends keyof Registry> = ParamTypes<ReturnType<Registry[K]['deserializeParams']>>;
112
+
113
+ /**
114
+ * A legacy oracle adapter, stored under the retired oracle name that already-deployed contracts still call. It reuses
115
+ * the handler of `modernOracle` and overrides only the wire side(s) that changed; an omitted side falls back to that
116
+ * modern entry.
117
+ */
118
+ export interface LegacyOracleEntry {
119
+ /** The current oracle whose handler this reuses and whose param/return wire it inherits by default. */
120
+ modernOracle: keyof Registry;
121
+ /**
122
+ * Old param wire. `legacyType` deserializes the old wire; `mapping` bridges the deserialized legacy args to the
123
+ * modern handler's args. The mapping may be async. Omit when the param wire is unchanged.
124
+ */
125
+ params?: {
126
+ legacyType: readonly RegistryParam[];
127
+ mapping: (legacyArgs: any) => readonly unknown[] | Promise<readonly unknown[]>;
128
+ };
129
+ /**
130
+ * Old return wire. `legacyType` serializes the subset the old contract reads; `mapping` bridges the handler's
131
+ * current result to that subset's value type. Omit when the return wire is unchanged.
132
+ */
133
+ returnType?: { legacyType: TypeMapping; mapping: (result: any) => unknown };
134
+ }
135
+
136
+ function legacyOracle<K extends keyof Registry, W = never, const TLegacyParams extends RegistryParam[] = []>(entry: {
137
+ modernOracle: K;
138
+ params?: {
139
+ legacyType: [...TLegacyParams];
140
+ mapping: (
141
+ legacyArgs: ParamTypes<InferDeserializedParams<TLegacyParams>>,
142
+ ) => HandlerArgsOf<K> | Promise<HandlerArgsOf<K>>;
143
+ };
144
+ returnType?: { legacyType: TypeMapping<W>; mapping: (result: ReturnValueOf<K>) => W };
145
+ }): LegacyOracleEntry {
146
+ return entry;
147
+ }
@@ -3,6 +3,7 @@ import { ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { FieldReader } from '@aztec/foundation/serialize';
5
5
  import { toACVMField } from '@aztec/simulator/client';
6
+ import type { UnsiloedMessageNullifier } from '@aztec/stdlib/messaging';
6
7
 
7
8
  import {
8
9
  ARRAY,
@@ -45,6 +46,7 @@ import {
45
46
  RESOLVED_TAGGING_STRATEGY,
46
47
  RESOLVED_TX,
47
48
  STR,
49
+ STRUCT,
48
50
  TX_EFFECT,
49
51
  TX_HASH,
50
52
  type TypeMapping,
@@ -139,6 +141,14 @@ export const ORACLE_REGISTRY = {
139
141
  returnType: OPTION(MEMBERSHIP_WITNESS(ARCHIVE_HEIGHT)),
140
142
  }),
141
143
 
144
+ aztec_utl_areBlockHashesInArchive: makeEntry({
145
+ params: [
146
+ { name: 'anchorBlockHash', type: BLOCK_HASH },
147
+ { name: 'blockHashes', type: EPHEMERAL_ARRAY(BLOCK_HASH) },
148
+ ],
149
+ returnType: EPHEMERAL_ARRAY(BOOL),
150
+ }),
151
+
142
152
  aztec_utl_getNullifierMembershipWitness: makeEntry({
143
153
  params: [
144
154
  { name: 'blockHash', type: BLOCK_HASH },
@@ -183,11 +193,18 @@ export const ORACLE_REGISTRY = {
183
193
  returnType: BOOL,
184
194
  }),
185
195
 
186
- aztec_utl_getL1ToL2MembershipWitness: makeEntry({
196
+ aztec_utl_getL1ToL2MembershipWitnessV2: makeEntry({
187
197
  params: [
188
- { name: 'contractAddress', type: AZTEC_ADDRESS },
189
198
  { name: 'messageHash', type: FIELD },
190
- { name: 'secret', type: FIELD },
199
+ {
200
+ name: 'nullifier',
201
+ type: OPTION(
202
+ STRUCT<UnsiloedMessageNullifier>([
203
+ { name: 'contractAddress', type: AZTEC_ADDRESS },
204
+ { name: 'nullifier', type: FIELD },
205
+ ]),
206
+ ),
207
+ },
191
208
  ],
192
209
  returnType: MESSAGE_LOAD_ORACLE_INPUTS,
193
210
  }),
@@ -225,7 +242,7 @@ export const ORACLE_REGISTRY = {
225
242
  returnType: BOUNDED_VEC(NOTE),
226
243
  }),
227
244
 
228
- aztec_utl_getPendingTaggedLogs: makeEntry({
245
+ aztec_utl_getPendingTaggedLogsV2: makeEntry({
229
246
  params: [
230
247
  { name: 'scope', type: AZTEC_ADDRESS },
231
248
  { name: 'providedSecrets', type: EPHEMERAL_ARRAY(PROVIDED_SECRET) },
@@ -241,7 +258,7 @@ export const ORACLE_REGISTRY = {
241
258
  ],
242
259
  }),
243
260
 
244
- aztec_utl_getLogsByTag: makeEntry({
261
+ aztec_utl_getLogsByTagV2: makeEntry({
245
262
  params: [{ name: 'requests', type: EPHEMERAL_ARRAY(LOG_RETRIEVAL_REQUEST) }],
246
263
  returnType: EPHEMERAL_ARRAY(EPHEMERAL_ARRAY(LOG_RETRIEVAL_RESPONSE)),
247
264
  }),
@@ -562,6 +579,14 @@ export const ORACLE_REGISTRY = {
562
579
  ],
563
580
  returnType: RESOLVED_TAGGING_STRATEGY,
564
581
  }),
582
+
583
+ aztec_prv_resolveCustomRequest: makeEntry({
584
+ params: [
585
+ { name: 'kind', type: FIELD },
586
+ { name: 'payload', type: ARRAY(FIELD) },
587
+ ],
588
+ returnType: ARRAY(FIELD),
589
+ }),
565
590
  } satisfies Record<string, OracleRegistryEntry>;
566
591
 
567
592
  // ─── Registry Infrastructure ─────────────────────────────────────────────────
@@ -635,7 +660,7 @@ export function makeEntry<const TParams extends RegistryParam[] = [], TReturnVal
635
660
  }
636
661
 
637
662
  /** A named oracle parameter with its TypeMapping. */
638
- interface RegistryParam<TName extends string = string, T = any> {
663
+ export interface RegistryParam<TName extends string = string, T = any> {
639
664
  name: TName;
640
665
  type: TypeMapping<T>;
641
666
  }
@@ -661,7 +686,7 @@ export type ParamTypes<T extends readonly NamedValue[]> = {
661
686
  * @example `InferDeserializedParams<[RegistryParam<'addr', AztecAddress>, RegistryParam<'slot', Fr>]>`
662
687
  * → `[NamedValue<'addr', AztecAddress>, NamedValue<'slot', Fr>]`
663
688
  */
664
- type InferDeserializedParams<T extends RegistryParam[]> = {
689
+ export type InferDeserializedParams<T extends RegistryParam[]> = {
665
690
  [K in keyof T]: T[K] extends RegistryParam<infer N, infer V> ? NamedValue<N, V> : never;
666
691
  };
667
692
 
@@ -24,15 +24,13 @@ import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
24
24
  import { PublicDataWrite, RevertCode } from '@aztec/stdlib/avm';
25
25
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
26
26
  import { BlockHash } from '@aztec/stdlib/block';
27
- import type { ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
27
+ import type { ContractInstancePreimage, PartialAddress } from '@aztec/stdlib/contract';
28
28
  import type { GasFees } from '@aztec/stdlib/gas';
29
29
  import { KeyValidationRequest } from '@aztec/stdlib/kernel';
30
30
  import type { PublicKeys } from '@aztec/stdlib/keys';
31
31
  import {
32
32
  type AppTaggingSecretKind,
33
33
  type FlatPublicLogs,
34
- type MessageContext,
35
- type PendingTaggedLog,
36
34
  PrivateLog,
37
35
  Tag,
38
36
  appTaggingSecretKindFromDeliveryMode,
@@ -54,7 +52,7 @@ import {
54
52
  TxHash,
55
53
  } from '@aztec/stdlib/tx';
56
54
 
57
- import type { OriginBlock } from '../../storage/fact_store/index.js';
55
+ import type { OriginBlock, RetractableFactOrigin } from '../../storage/fact_store/index.js';
58
56
  import { BoundedVec } from '../noir-structs/bounded_vec.js';
59
57
  import type { ContractClassLogData } from '../noir-structs/contract_class_log_data.js';
60
58
  import type { EmbeddedCurvePoint } from '../noir-structs/embedded_curve_point.js';
@@ -67,6 +65,7 @@ import type { LogRetrievalResponse } from '../noir-structs/log_retrieval_respons
67
65
  import type { NoteData } from '../noir-structs/note_data.js';
68
66
  import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
69
67
  import { Option } from '../noir-structs/option.js';
68
+ import type { PendingTaggedLog } from '../noir-structs/pending_tagged_log.js';
70
69
  import type { ProvidedSecret } from '../noir-structs/provided_secret.js';
71
70
  import {
72
71
  type ResolvedTaggingStrategy,
@@ -86,9 +85,8 @@ export type {
86
85
  AppTaggingSecretKind,
87
86
  BlockHash,
88
87
  BlockHeader,
89
- ContractInstance,
88
+ ContractInstancePreimage,
90
89
  MembershipWitness,
91
- MessageContext,
92
90
  NullifierMembershipWitness,
93
91
  PendingTaggedLog,
94
92
  PublicDataWitness,
@@ -294,7 +292,7 @@ export const ETH_ADDRESS: TypeMapping<EthAddress> = {
294
292
  shape: ['scalar'],
295
293
  };
296
294
 
297
- const SLOT_NUMBER: TypeMapping<SlotNumber> = {
295
+ export const SLOT_NUMBER: TypeMapping<SlotNumber> = {
298
296
  serialization: { fn: v => [new Fr(v)] },
299
297
  shape: ['scalar'],
300
298
  };
@@ -354,7 +352,7 @@ const PUBLIC_KEYS: TypeMapping<PublicKeys> = STRUCT<PublicKeys>([
354
352
  { name: 'fbpkMHash', type: FIELD },
355
353
  ]);
356
354
 
357
- export const CONTRACT_INSTANCE: TypeMapping<ContractInstance> = STRUCT<ContractInstance>([
355
+ export const CONTRACT_INSTANCE: TypeMapping<ContractInstancePreimage> = STRUCT<ContractInstancePreimage>([
358
356
  { name: 'salt', type: FIELD },
359
357
  { name: 'deployer', type: AZTEC_ADDRESS },
360
358
  // Note that the nr side of this struct does not contain the current class, only original
@@ -518,17 +516,9 @@ export const LOG_RETRIEVAL_RESPONSE: TypeMapping<LogRetrievalResponse> = STRUCT<
518
516
  { name: 'txHash', type: TX_HASH },
519
517
  { name: 'uniqueNoteHashesInTx', type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX) },
520
518
  { name: 'firstNullifierInTx', type: FIELD },
521
- ]);
522
-
523
- export const MESSAGE_CONTEXT: TypeMapping<MessageContext> = STRUCT<MessageContext>([
524
- { name: 'txHash', type: TX_HASH },
525
- { name: 'uniqueNoteHashesInTx', type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX) },
526
- { name: 'firstNullifierInTx', type: FIELD },
527
- ]);
528
-
529
- export const PENDING_TAGGED_LOG: TypeMapping<PendingTaggedLog> = STRUCT<PendingTaggedLog>([
530
- { name: 'log', type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS) },
531
- { name: 'context', type: MESSAGE_CONTEXT },
519
+ { name: 'blockNumber', type: BLOCK_NUMBER },
520
+ { name: 'blockTimestamp', type: BIGINT },
521
+ { name: 'blockHash', type: BLOCK_HASH },
532
522
  ]);
533
523
 
534
524
  // `ResolvedTx.toFields()` packs the whole struct into a single slot: txHash, the uniqueNoteHashesInTx BoundedVec
@@ -538,6 +528,11 @@ export const RESOLVED_TX: TypeMapping<ResolvedTx> = {
538
528
  shape: [{ len: MAX_NOTE_HASHES_PER_TX + 5 }],
539
529
  };
540
530
 
531
+ export const PENDING_TAGGED_LOG: TypeMapping<PendingTaggedLog> = STRUCT([
532
+ { name: 'log', type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS) },
533
+ { name: 'context', type: RESOLVED_TX },
534
+ ]);
535
+
541
536
  export const ORIGIN_BLOCK: TypeMapping<OriginBlock> = {
542
537
  serialization: { fn: ob => [new Fr(ob.blockNumber), ob.blockHash] },
543
538
  deserialization: {
@@ -549,17 +544,23 @@ export const ORIGIN_BLOCK: TypeMapping<OriginBlock> = {
549
544
  shape: ['scalar', 'scalar'],
550
545
  };
551
546
 
547
+ /** Read-side origin of a retractable fact, carrying the chain state of its origin block. */
548
+ export const RETRACTABLE_FACT_ORIGIN: TypeMapping<RetractableFactOrigin> = {
549
+ serialization: { fn: o => [new Fr(o.blockNumber), o.blockHash, new Fr(o.blockState)] },
550
+ shape: ['scalar', 'scalar', 'scalar'],
551
+ };
552
+
552
553
  // `facts` and `payload` each materialize to a single service-slot id, so a Fact occupies: factTypeId, the payload
553
- // array slot, and `OPTION(ORIGIN_BLOCK)` (its discriminant plus ORIGIN_BLOCK's two slots).
554
+ // array slot, and `OPTION(RETRACTABLE_FACT_ORIGIN)` (its discriminant plus RETRACTABLE_FACT_ORIGIN's three slots).
554
555
  export const FACT: TypeMapping<Fact> = {
555
556
  serialization: {
556
557
  fn: f => [
557
558
  f.factTypeId,
558
559
  f.payload.materializeSlot(v => FIELD.serialization!.fn(v).flat() as Fr[]),
559
- ...OPTION(ORIGIN_BLOCK).serialization!.fn(f.originBlock),
560
+ ...OPTION(RETRACTABLE_FACT_ORIGIN).serialization!.fn(f.originBlock),
560
561
  ],
561
562
  },
562
- shape: ['scalar', 'scalar', 'scalar', 'scalar', 'scalar'],
563
+ shape: ['scalar', 'scalar', 'scalar', 'scalar', 'scalar', 'scalar'],
563
564
  };
564
565
 
565
566
  export const FACT_COLLECTION: TypeMapping<FactCollection> = {
@@ -618,20 +619,26 @@ export function ARRAY<T>(inner: TypeMapping<T>): TypeMapping<T[]> & { kind: 'arr
618
619
  }
619
620
 
620
621
  /**
621
- * Noir's fixed-length array `[T; maxLength]` in one slot: serializes `values` (each flattened via `element`)
622
- * zero-padded to exactly `maxLength * elementWidth` fields, and deserializes all `maxLength` elements back. An absent
622
+ * Noir's fixed-length array `[T; length]` in one slot: serializes `values` (each flattened via `element`)
623
+ * zero-padded to exactly `length * elementWidth` fields, and deserializes all `length` elements back. An absent
623
624
  * element is the zero encoding, so the padding is derived from the shape.
624
625
  */
625
- function FIXED_ARRAY<T>(element: TypeMapping<T>, maxLength: number): TypeMapping<T[]> {
626
+ export function FIXED_ARRAY<T>(
627
+ element: TypeMapping<T>,
628
+ length: number,
629
+ ): TypeMapping<T[]> & { kind: 'fixed-array'; inner: TypeMapping<T>; length: number } {
626
630
  const elementWidth = fieldWidth(element.shape);
627
631
  return {
632
+ kind: 'fixed-array',
633
+ inner: element,
634
+ length,
628
635
  serialization: element.serialization
629
- ? { fn: values => [padArrayEnd(packElements(element, values), Fr.ZERO, maxLength * elementWidth)] }
636
+ ? { fn: values => [padArrayEnd(packElements(element, values), Fr.ZERO, length * elementWidth)] }
630
637
  : undefined,
631
638
  deserialization: element.deserialization
632
- ? { fn: ([reader]) => unpackElements(element, reader, maxLength) }
639
+ ? { fn: ([reader]) => unpackElements(element, reader, length) }
633
640
  : undefined,
634
- shape: [{ len: maxLength * elementWidth }],
641
+ shape: [{ len: length * elementWidth }],
635
642
  };
636
643
  }
637
644
 
@@ -691,9 +698,15 @@ export function BOUNDED_VEC<T>(
691
698
  * (zero-padded) followed by the actual length, with no length prefix, so the width is statically known. Serialize-only.
692
699
  * Throws if the input exceeds `maxLength`.
693
700
  */
694
- function FIXED_BOUNDED_VEC<T>(element: TypeMapping<T>, maxLength: number): TypeMapping<T[]> {
701
+ export function FIXED_BOUNDED_VEC<T>(
702
+ element: TypeMapping<T>,
703
+ maxLength: number,
704
+ ): TypeMapping<T[]> & { kind: 'fixed-bounded-vec'; inner: TypeMapping<T>; maxLength: number } {
695
705
  const width = fieldWidth(element.shape);
696
706
  return {
707
+ kind: 'fixed-bounded-vec',
708
+ inner: element,
709
+ maxLength,
697
710
  serialization: element.serialization
698
711
  ? {
699
712
  fn: values => {
@@ -804,15 +817,19 @@ export function EPHEMERAL_ARRAY<T>(element: TypeMapping<T>): TypeMapping<Ephemer
804
817
  }
805
818
 
806
819
  /** A named field within a {@link STRUCT}: it owns however many wire slots its {@link TypeMapping} declares. */
807
- type StructField<TName extends string = string, T = any> = { name: TName; type: TypeMapping<T> };
820
+ export type StructField<TName extends string = string, T = any> = { name: TName; type: TypeMapping<T> };
808
821
 
809
822
  /**
810
823
  * A Noir struct: its `shape` and (de)serialization are the concatenation of its fields', so callers never hand-write a
811
824
  * `shape`. `T` is the struct's TS value type and must match the field layout — serialization reads each field by name
812
825
  * off the value, deserialization returns the decoded bag as `T`; convert in the handler, not here, when `T` differs.
813
826
  */
814
- function STRUCT<T>(fields: readonly StructField[]): TypeMapping<T> {
827
+ export function STRUCT<T>(
828
+ fields: readonly StructField[],
829
+ ): TypeMapping<T> & { kind: 'struct'; fields: readonly StructField[] } {
815
830
  return {
831
+ kind: 'struct',
832
+ fields,
816
833
  serialization: fields.every(f => f.type.serialization)
817
834
  ? {
818
835
  fn: (value: T) => {
@@ -845,7 +862,7 @@ export function slotsOf(mapping: TypeMapping): number {
845
862
  }
846
863
 
847
864
  /** Number of fields a fully-static shape occupies, or `undefined` if any slot is variable-width. */
848
- function tryFieldWidth(shape: SlotShape[]): number | undefined {
865
+ export function tryFieldWidth(shape: SlotShape[]): number | undefined {
849
866
  let total = 0;
850
867
  for (const slot of shape) {
851
868
  if (slot === 'scalar') {