@aztec/txe 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316

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 (136) hide show
  1. package/dest/AuthRegistry-QVGDDH5X.js +3 -0
  2. package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
  3. package/dest/ContractClassRegistry-VWR3F42P.js +3 -0
  4. package/dest/ContractClassRegistry-VWR3F42P.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-FHIWE33X.js +3 -0
  6. package/dest/ContractInstanceRegistry-FHIWE33X.js.map +7 -0
  7. package/dest/FeeJuice-SAOWVGG7.js +3 -0
  8. package/dest/FeeJuice-SAOWVGG7.js.map +7 -0
  9. package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
  10. package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
  12. package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
  13. package/dest/SchnorrAccount-NME3E45O.js +3 -0
  14. package/dest/SchnorrAccount-NME3E45O.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.js +7 -15
  18. package/dest/bin/index.js +1 -1
  19. package/dest/bin/oracle_test_server.js +2 -2
  20. package/dest/chunk-32UHX7YY.js +3 -0
  21. package/dest/{chunk-CUSVOJA4.js → chunk-DXIAVNMJ.js} +2 -2
  22. package/dest/{chunk-CUSVOJA4.js.map → chunk-DXIAVNMJ.js.map} +3 -3
  23. package/dest/chunk-JHAAHRCL.js +260 -0
  24. package/dest/chunk-JHAAHRCL.js.map +7 -0
  25. package/dest/constants.d.ts +1 -1
  26. package/dest/constants.d.ts.map +1 -1
  27. package/dest/constants.js +1 -1
  28. package/dest/dispatcher_pool.d.ts +2 -2
  29. package/dest/dispatcher_pool.d.ts.map +1 -1
  30. package/dest/dispatcher_pool.js +5 -3
  31. package/dest/index.d.ts +2 -136
  32. package/dest/index.d.ts.map +1 -1
  33. package/dest/index.js +5 -3
  34. package/dest/metafile.json +9387 -7491
  35. package/dest/oracle/interfaces.d.ts +24 -11
  36. package/dest/oracle/interfaces.d.ts.map +1 -1
  37. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  38. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  39. package/dest/oracle/tagging_secret_strategy.js +12 -0
  40. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  41. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  42. package/dest/oracle/test-resolver/default_fixtures.js +200 -0
  43. package/dest/oracle/test-resolver/index.d.ts +1 -1
  44. package/dest/oracle/test-resolver/index.d.ts.map +1 -1
  45. package/dest/oracle/test-resolver/index.js +1 -2
  46. package/dest/oracle/test-resolver/resolver.d.ts +21 -7
  47. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
  48. package/dest/oracle/test-resolver/resolver.js +100 -33
  49. package/dest/oracle/txe_oracle_public_context.d.ts +9 -9
  50. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  51. package/dest/oracle/txe_oracle_public_context.js +15 -9
  52. package/dest/oracle/txe_oracle_registry.d.ts +51 -26
  53. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
  54. package/dest/oracle/txe_oracle_registry.js +258 -53
  55. package/dest/oracle/txe_oracle_top_level_context.d.ts +30 -9
  56. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  57. package/dest/oracle/txe_oracle_top_level_context.js +454 -288
  58. package/dest/oracle/txe_oracle_version.d.ts +4 -4
  59. package/dest/oracle/txe_oracle_version.js +4 -4
  60. package/dest/rpc_translator.d.ts +23 -4
  61. package/dest/rpc_translator.d.ts.map +1 -1
  62. package/dest/rpc_translator.js +167 -81
  63. package/dest/server.bundle.js +1 -1
  64. package/dest/state_machine/archiver.d.ts +1 -1
  65. package/dest/state_machine/archiver.d.ts.map +1 -1
  66. package/dest/state_machine/archiver.js +1 -2
  67. package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
  68. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  69. package/dest/state_machine/dummy_p2p_client.js +9 -0
  70. package/dest/state_machine/global_variable_builder.d.ts +3 -4
  71. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  72. package/dest/state_machine/global_variable_builder.js +0 -3
  73. package/dest/state_machine/index.d.ts +8 -6
  74. package/dest/state_machine/index.d.ts.map +1 -1
  75. package/dest/state_machine/index.js +41 -19
  76. package/dest/state_machine/synchronizer.d.ts +10 -2
  77. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  78. package/dest/state_machine/synchronizer.js +18 -5
  79. package/dest/txe_session.d.ts +29 -20
  80. package/dest/txe_session.d.ts.map +1 -1
  81. package/dest/txe_session.js +165 -41
  82. package/dest/utils/block_creation.d.ts +2 -2
  83. package/dest/utils/block_creation.d.ts.map +1 -1
  84. package/dest/utils/block_creation.js +2 -2
  85. package/dest/utils/encoding.d.ts +4 -3
  86. package/dest/utils/encoding.d.ts.map +1 -1
  87. package/dest/utils/tx_effect_creation.d.ts +1 -1
  88. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  89. package/dest/utils/tx_effect_creation.js +0 -1
  90. package/dest/utils/txe_public_contract_data_source.d.ts +1 -1
  91. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
  92. package/dest/utils/txe_public_contract_data_source.js +7 -4
  93. package/dest/worker.bundle.js +1 -1
  94. package/package.json +17 -17
  95. package/src/bin/check_txe_oracle_version.ts +9 -12
  96. package/src/bin/oracle_test_server.ts +2 -2
  97. package/src/constants.ts +1 -1
  98. package/src/dispatcher_pool.ts +4 -3
  99. package/src/index.ts +6 -4
  100. package/src/oracle/interfaces.ts +26 -9
  101. package/src/oracle/tagging_secret_strategy.ts +25 -0
  102. package/src/oracle/test-resolver/default_fixtures.ts +271 -0
  103. package/src/oracle/test-resolver/index.ts +1 -2
  104. package/src/oracle/test-resolver/resolver.ts +121 -41
  105. package/src/oracle/txe_oracle_public_context.ts +16 -14
  106. package/src/oracle/txe_oracle_registry.ts +197 -42
  107. package/src/oracle/txe_oracle_top_level_context.ts +201 -66
  108. package/src/oracle/txe_oracle_version.ts +4 -4
  109. package/src/rpc_translator.ts +224 -108
  110. package/src/state_machine/archiver.ts +0 -1
  111. package/src/state_machine/dummy_p2p_client.ts +13 -0
  112. package/src/state_machine/global_variable_builder.ts +2 -16
  113. package/src/state_machine/index.ts +50 -34
  114. package/src/state_machine/synchronizer.ts +26 -5
  115. package/src/txe_session.ts +284 -45
  116. package/src/utils/block_creation.ts +2 -1
  117. package/src/utils/tx_effect_creation.ts +0 -2
  118. package/src/utils/txe_public_contract_data_source.ts +6 -4
  119. package/dest/ContractClassRegistry-PII7Q556.js +0 -3
  120. package/dest/ContractClassRegistry-PII7Q556.js.map +0 -7
  121. package/dest/ContractInstanceRegistry-3MHLGFNZ.js +0 -3
  122. package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +0 -7
  123. package/dest/FeeJuice-TQV5AQK7.js +0 -3
  124. package/dest/FeeJuice-TQV5AQK7.js.map +0 -7
  125. package/dest/MultiCallEntrypoint-SBJUIJY7.js +0 -3
  126. package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +0 -7
  127. package/dest/SchnorrAccount-MQXPIZ44.js +0 -3
  128. package/dest/SchnorrAccount-MQXPIZ44.js.map +0 -7
  129. package/dest/chunk-BJVAAXNA.js +0 -3
  130. package/dest/chunk-OYLIPWI6.js +0 -260
  131. package/dest/chunk-OYLIPWI6.js.map +0 -7
  132. package/dest/oracle/test-resolver/fixtures.d.ts +0 -43
  133. package/dest/oracle/test-resolver/fixtures.d.ts.map +0 -1
  134. package/dest/oracle/test-resolver/fixtures.js +0 -39
  135. package/src/oracle/test-resolver/fixtures.ts +0 -84
  136. /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
@@ -4,27 +4,38 @@ import {
4
4
  MAX_NOTE_HASHES_PER_TX,
5
5
  MAX_NULLIFIERS_PER_TX,
6
6
  MAX_PRIVATE_LOGS_PER_TX,
7
+ PRIVATE_CONTEXT_INPUTS_LENGTH,
7
8
  PRIVATE_LOG_SIZE_IN_FIELDS,
8
9
  } from '@aztec/constants';
9
10
  import { Fr } from '@aztec/foundation/curves/bn254';
11
+ import { Point } from '@aztec/foundation/curves/grumpkin';
10
12
  import { withHexPrefix, withoutHexPrefix } from '@aztec/foundation/string';
13
+ import type { TaggingSecretStrategy } from '@aztec/pxe/server';
11
14
  import {
12
15
  ARRAY,
13
16
  AZTEC_ADDRESS,
14
- BIGINT,
15
17
  BLOCK_NUMBER,
16
18
  BOOL,
19
+ ETH_ADDRESS,
17
20
  FIELD,
21
+ FIXED_ARRAY,
18
22
  FUNCTION_SELECTOR,
19
23
  type InputSlot,
24
+ LEAF,
20
25
  type MaybePromise,
21
26
  OPTION,
22
27
  ORACLE_REGISTRY,
23
28
  type OracleRegistryEntry,
29
+ type OutputSlot,
24
30
  type ParamTypes,
31
+ SCALAR,
25
32
  STR,
33
+ STRUCT,
34
+ type SlotShape,
26
35
  type TypeMapping,
27
36
  U32,
37
+ U64,
38
+ buildACIRCallback,
28
39
  makeEntry,
29
40
  } from '@aztec/pxe/simulator';
30
41
  import { EventSelector } from '@aztec/stdlib/abi';
@@ -42,28 +53,86 @@ import {
42
53
  } from '../constants.js';
43
54
  import type { ForeignCallArgs, ForeignCallResult } from '../utils/encoding.js';
44
55
 
45
- const GAS_SETTINGS: TypeMapping<GasSettings> = {
46
- serialization: { fn: v => v.toFields() },
56
+ // Spreading `ORACLE_REGISTRY` re-materializes its entries into `TXE_ORACLE_REGISTRY`'s inferred type, which names the
57
+ // protocol types below. Re-exporting them gives tsc a portable path to each instead of falling back to a deep
58
+ // node_modules path that breaks .d.ts portability (TS2742).
59
+ export type { ContractClassLogData, EmbeddedCurvePoint, TxEffectData } from '@aztec/pxe/simulator';
60
+ export type { BlockHash } from '@aztec/stdlib/block';
61
+ export type { MembershipWitness } from '@aztec/foundation/trees';
62
+ export type { NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
63
+
64
+ const GAS_SETTINGS: TypeMapping<GasSettings> = LEAF({
65
+ kind: 'gas-settings',
47
66
  deserialization: {
48
67
  fn: ([reader]) => GasSettings.fromFields(reader.readFieldArray(GAS_SETTINGS_LENGTH)),
49
- slots: 1,
50
68
  },
51
- };
69
+ shape: [{ len: GAS_SETTINGS_LENGTH }],
70
+ });
71
+
72
+ // Tagging secret strategy discriminants. Must match the Noir test helper `TaggingSecretStrategy` in
73
+ // aztec-nr `test/helpers/tagging_secret_strategy.nr`. This is a test-only oracle (only `set_tagging_secret_strategies`
74
+ // reads it), so the mapping lives here on the TXE side rather than in the production oracle type mappings.
75
+ const STRATEGY_NON_INTERACTIVE_HANDSHAKE = 1;
76
+ const STRATEGY_ARBITRARY_SECRET = 2;
77
+ const STRATEGY_ADDRESS_DERIVED = 3;
78
+ const STRATEGY_INTERACTIVE_HANDSHAKE = 4;
79
+
80
+ const TAGGING_SECRET_STRATEGY: TypeMapping<TaggingSecretStrategy> = LEAF({
81
+ kind: 'tagging-secret-strategy',
82
+ serialization: {
83
+ fn: strategy => {
84
+ switch (strategy.type) {
85
+ case 'non-interactive-handshake':
86
+ return [new Fr(STRATEGY_NON_INTERACTIVE_HANDSHAKE), Fr.ZERO, Fr.ZERO];
87
+ case 'interactive-handshake':
88
+ return [new Fr(STRATEGY_INTERACTIVE_HANDSHAKE), Fr.ZERO, Fr.ZERO];
89
+ case 'address-derived':
90
+ return [new Fr(STRATEGY_ADDRESS_DERIVED), Fr.ZERO, Fr.ZERO];
91
+ case 'arbitrary-secret':
92
+ return [new Fr(STRATEGY_ARBITRARY_SECRET), strategy.secret.x, strategy.secret.y];
93
+ }
94
+ },
95
+ },
96
+ deserialization: {
97
+ fn: ([kindReader, xReader, yReader]) => {
98
+ const kind = kindReader.readField().toNumber();
99
+ const [x, y] = [xReader.readField(), yReader.readField()];
100
+ switch (kind) {
101
+ case STRATEGY_NON_INTERACTIVE_HANDSHAKE:
102
+ return { type: 'non-interactive-handshake' };
103
+ case STRATEGY_INTERACTIVE_HANDSHAKE:
104
+ return { type: 'interactive-handshake' };
105
+ case STRATEGY_ADDRESS_DERIVED:
106
+ return { type: 'address-derived' };
107
+ case STRATEGY_ARBITRARY_SECRET:
108
+ return { type: 'arbitrary-secret', secret: Point.fromFields([x, y]) };
109
+ default:
110
+ throw new Error(`Unrecognized tagging secret strategy kind: ${kind}`);
111
+ }
112
+ },
113
+ },
114
+ shape: ['scalar', 'scalar', 'scalar'],
115
+ });
52
116
 
53
- const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = {
117
+ const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = LEAF({
118
+ kind: 'private-context-inputs',
54
119
  serialization: { fn: v => v.toFields() },
55
- };
120
+ shape: Array<SlotShape>(PRIVATE_CONTEXT_INPUTS_LENGTH).fill('scalar'),
121
+ });
56
122
 
57
- const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = {
123
+ const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = LEAF({
124
+ kind: 'complete-address',
58
125
  serialization: { fn: v => [v.address.toField(), ...v.publicKeys.toFields()] },
59
- };
126
+ shape: Array<SlotShape>(8).fill('scalar'), // address + 7 public-key fields
127
+ });
60
128
 
61
129
  const TXE_TX_EFFECTS: TypeMapping<{
62
130
  txHash: TxHash;
63
131
  noteHashes: Fr[];
64
132
  nullifiers: Fr[];
65
133
  privateLogs: PrivateLog[];
66
- }> = {
134
+ }> = LEAF({
135
+ kind: 'txe-tx-effects',
67
136
  serialization: {
68
137
  fn: ({ txHash, noteHashes, nullifiers, privateLogs }) => {
69
138
  const emittedLogs = privateLogs.map(log => log.getEmittedFields());
@@ -91,9 +160,21 @@ const TXE_TX_EFFECTS: TypeMapping<{
91
160
  ] as (Fr | Fr[])[];
92
161
  },
93
162
  },
94
- };
95
-
96
- const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = {
163
+ // txHash, padded note hashes + count, padded nullifiers + count, flattened private-log storage + lengths + count.
164
+ shape: [
165
+ 'scalar',
166
+ { len: MAX_NOTE_HASHES_PER_TX },
167
+ 'scalar',
168
+ { len: MAX_NULLIFIERS_PER_TX },
169
+ 'scalar',
170
+ { len: MAX_PRIVATE_LOGS_PER_TX * PRIVATE_LOG_SIZE_IN_FIELDS },
171
+ { len: MAX_PRIVATE_LOGS_PER_TX },
172
+ 'scalar',
173
+ ],
174
+ });
175
+
176
+ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = LEAF({
177
+ kind: 'txe-offchain-effects',
97
178
  serialization: {
98
179
  fn: ({ effects }) => {
99
180
  const rawArrayStorage = effects
@@ -109,27 +190,41 @@ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = {
109
190
  return [rawArrayStorage, effectLengths, new Fr(effects.length)] as (Fr | Fr[])[];
110
191
  },
111
192
  },
112
- };
113
-
114
- const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = {
193
+ // Flattened effect storage, per-effect lengths, then the effect count.
194
+ shape: [
195
+ { len: MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY * MAX_OFFCHAIN_EFFECT_LEN },
196
+ { len: MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY },
197
+ 'scalar',
198
+ ],
199
+ });
200
+
201
+ const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = LEAF({
202
+ kind: 'txe-call-context',
115
203
  serialization: {
116
204
  fn: ({ txHash, anchorBlockTimestamp }) => {
117
205
  const isSome = txHash.isZero() ? 0 : 1;
118
206
  return [new Fr(isSome), txHash, new Fr(anchorBlockTimestamp)];
119
207
  },
120
208
  },
121
- };
122
-
123
- const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ member: Fr; exists: boolean }> = {
124
- serialization: { fn: ({ member, exists }) => [member, new Fr(exists)] },
125
- };
126
-
127
- const EVENT_SELECTOR: TypeMapping<EventSelector> = {
209
+ shape: ['scalar', 'scalar', 'scalar'], // discriminant, txHash, anchor block timestamp
210
+ });
211
+
212
+ const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ exists: boolean; member: Fr }[]> = FIXED_ARRAY(
213
+ STRUCT([
214
+ { name: 'exists', type: BOOL },
215
+ { name: 'member', type: FIELD },
216
+ ]),
217
+ 1,
218
+ );
219
+
220
+ const EVENT_SELECTOR: TypeMapping<EventSelector> = SCALAR({
221
+ kind: 'event-selector',
128
222
  serialization: { fn: v => [v.toField()] },
129
- deserialization: { fn: ([reader]) => EventSelector.fromField(reader.readField()), slots: 1 },
130
- };
223
+ deserialization: { fn: ([reader]) => EventSelector.fromField(reader.readField()) },
224
+ });
131
225
 
132
- const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = {
226
+ const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = LEAF({
227
+ kind: 'txe-private-events',
133
228
  serialization: {
134
229
  fn: events => {
135
230
  const rawArrayStorage = events
@@ -144,7 +239,13 @@ const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = {
144
239
  return [rawArrayStorage, eventLengths, new Fr(events.length)] as (Fr | Fr[])[];
145
240
  },
146
241
  },
147
- };
242
+ // Flattened event storage, per-event lengths, then the event count.
243
+ shape: [
244
+ { len: MAX_PRIVATE_EVENTS_PER_TXE_QUERY * MAX_PRIVATE_EVENT_LEN },
245
+ { len: MAX_PRIVATE_EVENTS_PER_TXE_QUERY },
246
+ 'scalar',
247
+ ],
248
+ });
148
249
 
149
250
  export const TXE_ORACLE_REGISTRY = {
150
251
  ...ORACLE_REGISTRY,
@@ -179,14 +280,14 @@ export const TXE_ORACLE_REGISTRY = {
179
280
 
180
281
  aztec_txe_getNextBlockNumber: makeEntry({ returnType: BLOCK_NUMBER }),
181
282
 
182
- aztec_txe_getNextBlockTimestamp: makeEntry({ returnType: BIGINT }),
283
+ aztec_txe_getNextBlockTimestamp: makeEntry({ returnType: U64 }),
183
284
 
184
285
  aztec_txe_advanceBlocksBy: makeEntry({
185
286
  params: [{ name: 'blocks', type: U32 }],
186
287
  }),
187
288
 
188
289
  aztec_txe_advanceTimestampBy: makeEntry({
189
- params: [{ name: 'duration', type: BIGINT }],
290
+ params: [{ name: 'duration', type: U64 }],
190
291
  }),
191
292
 
192
293
  aztec_txe_deploy: makeEntry({
@@ -203,7 +304,10 @@ export const TXE_ORACLE_REGISTRY = {
203
304
  }),
204
305
 
205
306
  aztec_txe_createAccount: makeEntry({
206
- params: [{ name: 'secret', type: FIELD }],
307
+ params: [
308
+ { name: 'secret', type: FIELD },
309
+ { name: 'partialAddress', type: FIELD },
310
+ ],
207
311
  returnType: COMPLETE_ADDRESS,
208
312
  }),
209
313
 
@@ -219,8 +323,29 @@ export const TXE_ORACLE_REGISTRY = {
219
323
  ],
220
324
  }),
221
325
 
326
+ aztec_txe_sendL1ToL2Message: makeEntry({
327
+ params: [
328
+ { name: 'content', type: FIELD },
329
+ { name: 'secretHash', type: FIELD },
330
+ { name: 'sender', type: ETH_ADDRESS },
331
+ { name: 'recipient', type: AZTEC_ADDRESS },
332
+ ],
333
+ returnType: FIELD,
334
+ }),
335
+
336
+ aztec_txe_setTaggingSecretStrategies: makeEntry({
337
+ params: [
338
+ { name: 'unconstrainedStrategy', type: OPTION(TAGGING_SECRET_STRATEGY) },
339
+ { name: 'constrainedStrategy', type: OPTION(TAGGING_SECRET_STRATEGY) },
340
+ ],
341
+ }),
342
+
343
+ aztec_txe_setAuthorizeAllUtilityCallTargets: makeEntry({
344
+ params: [{ name: 'authorizeAll', type: BOOL }],
345
+ }),
346
+
222
347
  aztec_txe_getLastBlockTimestamp: makeEntry({
223
- returnType: BIGINT,
348
+ returnType: U64,
224
349
  }),
225
350
 
226
351
  aztec_txe_getLastTxEffects: makeEntry({ returnType: TXE_TX_EFFECTS }),
@@ -253,6 +378,7 @@ export const TXE_ORACLE_REGISTRY = {
253
378
 
254
379
  aztec_txe_executeUtilityFunction: makeEntry({
255
380
  params: [
381
+ { name: 'from', type: OPTION(AZTEC_ADDRESS) },
256
382
  { name: 'targetContractAddress', type: AZTEC_ADDRESS },
257
383
  { name: 'functionSelector', type: FUNCTION_SELECTOR },
258
384
  { name: 'args', type: ARRAY(FIELD) },
@@ -278,7 +404,7 @@ export const TXE_ORACLE_REGISTRY = {
278
404
 
279
405
  aztec_avm_blockNumber: makeEntry({ returnType: BLOCK_NUMBER }),
280
406
 
281
- aztec_avm_timestamp: makeEntry({ returnType: BIGINT }),
407
+ aztec_avm_timestamp: makeEntry({ returnType: U64 }),
282
408
 
283
409
  aztec_avm_isStaticCall: makeEntry({ returnType: BOOL }),
284
410
 
@@ -318,7 +444,7 @@ export const TXE_ORACLE_REGISTRY = {
318
444
  params: [{ name: 'message', type: ARRAY(FIELD) }],
319
445
  }),
320
446
 
321
- aztec_avm_returndataSize: makeEntry({ returnType: FIELD }),
447
+ aztec_avm_returndataSize: makeEntry({ returnType: U32 }),
322
448
 
323
449
  aztec_avm_returndataCopy: makeEntry({
324
450
  params: [
@@ -336,7 +462,6 @@ export const TXE_ORACLE_REGISTRY = {
336
462
  { name: 'argsLength', type: U32 },
337
463
  { name: 'args', type: ARRAY(FIELD) },
338
464
  ],
339
- returnType: ARRAY(FIELD),
340
465
  }),
341
466
 
342
467
  aztec_avm_staticCall: makeEntry({
@@ -347,10 +472,9 @@ export const TXE_ORACLE_REGISTRY = {
347
472
  { name: 'argsLength', type: U32 },
348
473
  { name: 'args', type: ARRAY(FIELD) },
349
474
  ],
350
- returnType: ARRAY(FIELD),
351
475
  }),
352
476
 
353
- aztec_avm_successCopy: makeEntry({ returnType: FIELD }),
477
+ aztec_avm_successCopy: makeEntry({ returnType: BOOL }),
354
478
 
355
479
  aztec_avm_getContractInstanceDeployer: makeEntry({
356
480
  params: [{ name: 'address', type: AZTEC_ADDRESS }],
@@ -370,6 +494,11 @@ export const TXE_ORACLE_REGISTRY = {
370
494
  }),
371
495
  } satisfies Record<string, OracleRegistryEntry>;
372
496
 
497
+ export function toInputSlots(inputs: ForeignCallArgs): InputSlot[] {
498
+ // TXE foreign calls use bare hex strings, but Fr.fromString requires a 0x prefix to parse as hex.
499
+ return inputs.map(v => (Array.isArray(v) ? (v as string[]).map(withHexPrefix) : [withHexPrefix(v as string)]));
500
+ }
501
+
373
502
  /**
374
503
  * Deserializes oracle inputs, calls the handler with typed params, serializes the result, and wraps
375
504
  * it in a `ForeignCallResult`. Normalizes `ForeignCallArgs` (which may contain bare strings) into
@@ -387,14 +516,40 @@ export async function callTxeHandler<K extends keyof typeof TXE_ORACLE_REGISTRY>
387
516
  ) => MaybePromise<Parameters<(typeof TXE_ORACLE_REGISTRY)[K]['serializeReturn']>[0]>;
388
517
  }): Promise<ForeignCallResult> {
389
518
  const entry = TXE_ORACLE_REGISTRY[oracle] as OracleRegistryEntry;
390
- // TXE foreign calls use bare hex strings, but Fr.fromString requires a 0x prefix to parse as hex.
391
- const normalized: InputSlot[] = inputs.map(v =>
392
- Array.isArray(v) ? (v as string[]).map(withHexPrefix) : [withHexPrefix(v as string)],
393
- );
394
- const named = entry.deserializeParams(normalized);
519
+ const named = entry.deserializeParams(toInputSlots(inputs));
395
520
  const positional = named.map((p: { value: unknown }) => p.value);
396
521
  const result = await handler(positional as any);
397
- const outputSlots = entry.serializeReturn(result);
522
+ return outputSlotsToForeignCallResult(entry.serializeReturn(result));
523
+ }
524
+
525
+ /**
526
+ * Dispatches an oracle that has been retired into the PXE legacy registry. TXE has no explicit handler method for such
527
+ * names; this runs them through the same `buildACIRCallback` legacy path that contract execution already uses, so
528
+ * TXE's top-level oracle path and its in-contract path treat the legacy registry identically.
529
+ */
530
+ const legacyCallbacksByHandler = new WeakMap<object, ReturnType<typeof buildACIRCallback>>();
531
+
532
+ export async function callTxeLegacyHandler(
533
+ oracle: string,
534
+ inputs: ForeignCallArgs,
535
+ oracleHandler: Parameters<typeof buildACIRCallback>[0],
536
+ ): Promise<ForeignCallResult> {
537
+ // `buildACIRCallback` materializes the whole real+legacy closure set, so memoize it per handler rather than
538
+ // rebuilding on every call (TXE routes one legacy oracle through here on each top-level discovery).
539
+ let callback = legacyCallbacksByHandler.get(oracleHandler);
540
+ if (!callback) {
541
+ callback = buildACIRCallback(oracleHandler);
542
+ legacyCallbacksByHandler.set(oracleHandler, callback);
543
+ }
544
+ const outputSlots = await callback[oracle](...toInputSlots(inputs));
545
+ return outputSlotsToForeignCallResult(outputSlots);
546
+ }
547
+
548
+ /**
549
+ * Strips the `0x` prefix from each serialized output slot (TXE foreign calls use bare hex strings) and wraps them in a
550
+ * `ForeignCallResult`.
551
+ */
552
+ function outputSlotsToForeignCallResult(outputSlots: OutputSlot[]): ForeignCallResult {
398
553
  return {
399
554
  values: outputSlots.map(slot => (Array.isArray(slot) ? slot.map(withoutHexPrefix) : withoutHexPrefix(slot))),
400
555
  };