@aztec/txe 0.0.1-commit.3100065 → 0.0.1-commit.330febf

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 (87) hide show
  1. package/dest/AuthRegistry-QVGDDH5X.js +3 -0
  2. package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
  3. package/dest/ContractClassRegistry-PVNCKGG7.js +3 -0
  4. package/dest/ContractClassRegistry-PVNCKGG7.js.map +7 -0
  5. package/dest/{ContractInstanceRegistry-NADDSLGL.js → ContractInstanceRegistry-WLOZKTR6.js} +1 -1
  6. package/dest/{ContractInstanceRegistry-NADDSLGL.js.map → ContractInstanceRegistry-WLOZKTR6.js.map} +2 -2
  7. package/dest/FeeJuice-MAQJU53K.js +3 -0
  8. package/dest/FeeJuice-MAQJU53K.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-TGICA67H.js.map → MultiCallEntrypoint-QG5H33ZZ.js.map} +2 -2
  13. package/dest/SchnorrAccount-ADD65DYA.js +3 -0
  14. package/dest/SchnorrAccount-ADD65DYA.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.js +8 -47
  18. package/dest/bin/index.js +1 -1
  19. package/dest/chunk-32UHX7YY.js +3 -0
  20. package/dest/{chunk-PDOEF22H.js → chunk-RVEPNDEP.js} +2 -2
  21. package/dest/{chunk-PDOEF22H.js.map → chunk-RVEPNDEP.js.map} +2 -2
  22. package/dest/chunk-XWIMXLKD.js +258 -0
  23. package/dest/chunk-XWIMXLKD.js.map +7 -0
  24. package/dest/constants.js +1 -1
  25. package/dest/metafile.json +2369 -3419
  26. package/dest/oracle/interfaces.d.ts +6 -2
  27. package/dest/oracle/interfaces.d.ts.map +1 -1
  28. package/dest/oracle/test-resolver/default_fixtures.d.ts +9 -2
  29. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -1
  30. package/dest/oracle/test-resolver/default_fixtures.js +32 -39
  31. package/dest/oracle/test-resolver/resolver.d.ts +1 -1
  32. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
  33. package/dest/oracle/test-resolver/resolver.js +2 -2
  34. package/dest/oracle/txe_oracle_registry.d.ts +5 -3
  35. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
  36. package/dest/oracle/txe_oracle_registry.js +45 -27
  37. package/dest/oracle/txe_oracle_top_level_context.d.ts +18 -5
  38. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  39. package/dest/oracle/txe_oracle_top_level_context.js +375 -272
  40. package/dest/oracle/txe_oracle_version.d.ts +5 -5
  41. package/dest/oracle/txe_oracle_version.js +5 -5
  42. package/dest/rpc_translator.d.ts +4 -1
  43. package/dest/rpc_translator.d.ts.map +1 -1
  44. package/dest/rpc_translator.js +25 -1
  45. package/dest/server.bundle.js +1 -1
  46. package/dest/state_machine/mock_epoch_cache.d.ts +2 -1
  47. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  48. package/dest/state_machine/mock_epoch_cache.js +3 -0
  49. package/dest/state_machine/synchronizer.d.ts +6 -1
  50. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  51. package/dest/state_machine/synchronizer.js +12 -3
  52. package/dest/txe_session.d.ts +6 -3
  53. package/dest/txe_session.d.ts.map +1 -1
  54. package/dest/txe_session.js +25 -9
  55. package/dest/utils/encoding.d.ts +5 -3
  56. package/dest/utils/encoding.d.ts.map +1 -1
  57. package/dest/worker.bundle.js +1 -1
  58. package/package.json +17 -17
  59. package/src/bin/check_txe_oracle_version.ts +10 -49
  60. package/src/constants.ts +1 -1
  61. package/src/oracle/interfaces.ts +5 -1
  62. package/src/oracle/test-resolver/default_fixtures.ts +58 -69
  63. package/src/oracle/test-resolver/resolver.ts +2 -2
  64. package/src/oracle/txe_oracle_registry.ts +42 -25
  65. package/src/oracle/txe_oracle_top_level_context.ts +55 -23
  66. package/src/oracle/txe_oracle_version.ts +5 -5
  67. package/src/rpc_translator.ts +29 -1
  68. package/src/state_machine/mock_epoch_cache.ts +4 -0
  69. package/src/state_machine/synchronizer.ts +18 -3
  70. package/src/txe_session.ts +31 -9
  71. package/dest/AuthRegistry-FSRZIMX6.js +0 -3
  72. package/dest/AuthRegistry-FSRZIMX6.js.map +0 -7
  73. package/dest/ContractClassRegistry-N6NA3SFA.js +0 -3
  74. package/dest/ContractClassRegistry-N6NA3SFA.js.map +0 -7
  75. package/dest/FeeJuice-QBH5JWJV.js +0 -3
  76. package/dest/FeeJuice-QBH5JWJV.js.map +0 -7
  77. package/dest/HandshakeRegistry-KKUEU7XW.js +0 -3
  78. package/dest/HandshakeRegistry-KKUEU7XW.js.map +0 -7
  79. package/dest/MultiCallEntrypoint-TGICA67H.js +0 -3
  80. package/dest/SchnorrAccount-J5T6OKR3.js +0 -3
  81. package/dest/SchnorrAccount-J5T6OKR3.js.map +0 -7
  82. package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js +0 -3
  83. package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js.map +0 -7
  84. package/dest/chunk-BJVAAXNA.js +0 -3
  85. package/dest/chunk-YP4ODNMQ.js +0 -268
  86. package/dest/chunk-YP4ODNMQ.js.map +0 -7
  87. /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/txe",
3
- "version": "0.0.1-commit.3100065",
3
+ "version": "0.0.1-commit.330febf",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": {
@@ -69,22 +69,22 @@
69
69
  ]
70
70
  },
71
71
  "dependencies": {
72
- "@aztec/accounts": "0.0.1-commit.3100065",
73
- "@aztec/archiver": "0.0.1-commit.3100065",
74
- "@aztec/aztec-node": "0.0.1-commit.3100065",
75
- "@aztec/aztec.js": "0.0.1-commit.3100065",
76
- "@aztec/bb-prover": "0.0.1-commit.3100065",
77
- "@aztec/bb.js": "0.0.1-commit.3100065",
78
- "@aztec/constants": "0.0.1-commit.3100065",
79
- "@aztec/foundation": "0.0.1-commit.3100065",
80
- "@aztec/key-store": "0.0.1-commit.3100065",
81
- "@aztec/kv-store": "0.0.1-commit.3100065",
82
- "@aztec/protocol-contracts": "0.0.1-commit.3100065",
83
- "@aztec/pxe": "0.0.1-commit.3100065",
84
- "@aztec/simulator": "0.0.1-commit.3100065",
85
- "@aztec/standard-contracts": "0.0.1-commit.3100065",
86
- "@aztec/stdlib": "0.0.1-commit.3100065",
87
- "@aztec/world-state": "0.0.1-commit.3100065",
72
+ "@aztec/accounts": "0.0.1-commit.330febf",
73
+ "@aztec/archiver": "0.0.1-commit.330febf",
74
+ "@aztec/aztec-node": "0.0.1-commit.330febf",
75
+ "@aztec/aztec.js": "0.0.1-commit.330febf",
76
+ "@aztec/bb-prover": "0.0.1-commit.330febf",
77
+ "@aztec/bb.js": "6.0.0-nightly.20260807",
78
+ "@aztec/constants": "0.0.1-commit.330febf",
79
+ "@aztec/foundation": "0.0.1-commit.330febf",
80
+ "@aztec/key-store": "0.0.1-commit.330febf",
81
+ "@aztec/kv-store": "0.0.1-commit.330febf",
82
+ "@aztec/protocol-contracts": "0.0.1-commit.330febf",
83
+ "@aztec/pxe": "0.0.1-commit.330febf",
84
+ "@aztec/simulator": "0.0.1-commit.330febf",
85
+ "@aztec/standard-contracts": "0.0.1-commit.330febf",
86
+ "@aztec/stdlib": "0.0.1-commit.330febf",
87
+ "@aztec/world-state": "0.0.1-commit.330febf",
88
88
  "msgpackr": "^1.11.2",
89
89
  "zod": "^4"
90
90
  },
@@ -1,32 +1,26 @@
1
1
  import { keccak256String } from '@aztec/foundation/crypto/keccak';
2
- import { getOracleInterfaceSignature, readNumericGlobal } from '@aztec/pxe/bin';
2
+ import { getOracleRegistrySignature } from '@aztec/pxe/bin';
3
+ import { ORACLE_REGISTRY, type OracleRegistryEntry } from '@aztec/pxe/simulator';
3
4
 
4
- import { dirname, join } from 'path';
5
- import { fileURLToPath } from 'url';
6
-
7
- import { TXE_ORACLE_INTERFACE_HASH, TXE_ORACLE_VERSION_MAJOR } from '../oracle/txe_oracle_version.js';
5
+ import { TXE_ORACLE_REGISTRY } from '../oracle/txe_oracle_registry.js';
6
+ import { TXE_ORACLE_INTERFACE_HASH } from '../oracle/txe_oracle_version.js';
8
7
 
9
8
  /**
10
9
  * Verifies that the TXE oracle interfaces match the expected interface hash.
11
10
  *
12
11
  * The TXE oracle interfaces need to be versioned to ensure compatibility between Aztec.nr tests and TXE. This function
13
- * computes a hash of the TXE oracle interfaces and compares it against a known hash. If they don't match, it means an
12
+ * computes a hash of the TXE-specific entries in `TXE_ORACLE_REGISTRY` (the shared PXE entries are covered by the PXE
13
+ * oracle version check) and compares it against a known hash. If they don't match, it means an
14
14
  * interface has changed and the TXE oracle version needs to be bumped:
15
15
  * - If the change is backward-breaking (e.g. removing/renaming an oracle), bump TXE_ORACLE_VERSION_MAJOR.
16
16
  * - If the change is an oracle addition (non-breaking), bump TXE_ORACLE_VERSION_MINOR.
17
17
  */
18
18
  function assertTxeOracleInterfaceMatches(): void {
19
- const currentDir = dirname(fileURLToPath(import.meta.url));
20
- const packageRoot = dirname(dirname(currentDir));
21
- const interfacesSourcePath = join(packageRoot, 'src/oracle/interfaces.ts');
22
-
23
- const targets = ['IAvmExecutionOracle', 'ITxeExecutionOracle'];
24
- // Not an oracle foreign call handler (see TODO(F-335) in interfaces.ts).
25
- const excludedMembers = ['syncContractNonOracleMethod'];
26
-
27
- const txeOracleInterfaceSignature = getOracleInterfaceSignature(interfacesSourcePath, targets, excludedMembers);
19
+ const txeOnlyEntries: Record<string, OracleRegistryEntry> = Object.fromEntries(
20
+ Object.entries(TXE_ORACLE_REGISTRY).filter(([name]) => !(name in ORACLE_REGISTRY)),
21
+ );
28
22
 
29
- const txeOracleInterfaceHash = keccak256String(txeOracleInterfaceSignature);
23
+ const txeOracleInterfaceHash = keccak256String(getOracleRegistrySignature(txeOnlyEntries));
30
24
  if (txeOracleInterfaceHash !== TXE_ORACLE_INTERFACE_HASH) {
31
25
  throw new Error(
32
26
  `The TXE oracle interface has changed. Update TXE_ORACLE_INTERFACE_HASH to ${txeOracleInterfaceHash} in txe/src/oracle/txe_oracle_version.ts and bump the TXE oracle version (TXE_ORACLE_VERSION_MAJOR for breaking changes, TXE_ORACLE_VERSION_MINOR for oracle additions).`,
@@ -34,37 +28,4 @@ function assertTxeOracleInterfaceMatches(): void {
34
28
  }
35
29
  }
36
30
 
37
- /**
38
- * Verifies that `TXE_ORACLE_VERSION_MAJOR` is identical across its two hand-maintained copies: the TXE TypeScript
39
- * constant and the Aztec.nr Noir test helper constant. These layers can't import each other, so the major version is
40
- * duplicated by hand and a mismatch otherwise only surfaces at runtime. This is the TXE counterpart of the contract
41
- * oracle version check in `pxe/src/bin/check_oracle_version.ts`; the two version families are tracked separately.
42
- *
43
- * Only the major version is checked: the minor version legitimately diverges under the "environment minor >= contract
44
- * minor" tolerance, so asserting minor equality would false-positive.
45
- */
46
- function assertTxeOracleVersionMajorInSync(): void {
47
- const currentDir = dirname(fileURLToPath(import.meta.url));
48
- // Go up from dest/bin/ or src/bin/ to the package root (txe/), then up two more to the git root.
49
- const packageRoot = dirname(dirname(currentDir));
50
- const gitRoot = join(packageRoot, '..', '..');
51
-
52
- const copies = [
53
- { label: 'txe/src/txe_oracle_version.ts', value: TXE_ORACLE_VERSION_MAJOR },
54
- {
55
- label: 'aztec-nr/aztec/src/test/helpers/txe_oracles.nr',
56
- value: readNumericGlobal(
57
- join(gitRoot, 'noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr'),
58
- 'TXE_ORACLE_VERSION_MAJOR',
59
- ),
60
- },
61
- ];
62
-
63
- if (new Set(copies.map(copy => copy.value)).size > 1) {
64
- const details = copies.map(copy => `${copy.label}=${copy.value}`).join(', ');
65
- throw new Error(`TXE_ORACLE_VERSION_MAJOR is out of sync: ${details}. Bump all copies together.`);
66
- }
67
- }
68
-
69
31
  assertTxeOracleInterfaceMatches();
70
- assertTxeOracleVersionMajorInSync();
package/src/constants.ts CHANGED
@@ -9,5 +9,5 @@ export const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
9
9
 
10
10
  // Arbitrarily set at 64 because we need a bound. Nothing inherent about it.
11
11
  export const MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY = 64;
12
- // Must match MAX_OFFCHAIN_EFFECT_LEN in noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr.
12
+ // Must match MAX_OFFCHAIN_EFFECT_LEN in noir-projects/labs/aztec-nr/aztec/src/test/helpers/txe_oracles.nr.
13
13
  export const MAX_OFFCHAIN_EFFECT_LEN = 2 + PRIVATE_LOG_CIPHERTEXT_LEN;
@@ -69,7 +69,7 @@ export interface ITxeExecutionOracle {
69
69
  salt: Fr,
70
70
  deployer: AztecAddress,
71
71
  ): Promise<Fr[]>;
72
- createAccount(secret: Fr): Promise<CompleteAddress>;
72
+ createAccount(secret: Fr, partialAddress: Fr): Promise<CompleteAddress>;
73
73
  addAccount(secret: Fr): Promise<CompleteAddress>;
74
74
  addAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
75
75
  sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr>;
@@ -81,6 +81,10 @@ export interface ITxeExecutionOracle {
81
81
  unconstrainedStrategy: Option<TaggingSecretStrategy>,
82
82
  constrainedStrategy: Option<TaggingSecretStrategy>,
83
83
  ): void;
84
+ /**
85
+ * Configures whether the test's simulated wallet authorizes every cross-contract utility call target.
86
+ */
87
+ setAuthorizeAllUtilityCallTargets(authorizeAll: boolean): void;
84
88
  getLastBlockTimestamp(): Promise<bigint>;
85
89
  getLastTxEffects(): Promise<{
86
90
  txHash: TxHash;
@@ -8,19 +8,29 @@ import {
8
8
  BLOCK_HASH,
9
9
  BLOCK_NUMBER,
10
10
  BOOL,
11
- BYTE,
12
11
  BoundedVec,
12
+ type CompositeMapping,
13
13
  DELIVERY_MODE,
14
14
  ETH_ADDRESS,
15
15
  FIELD,
16
16
  FUNCTION_SELECTOR,
17
+ LEAF_INDEX,
17
18
  NOTE_SELECTOR,
18
19
  Option,
19
20
  type OracleRegistryEntry,
20
21
  SLOT_NUMBER,
21
- type StructField,
22
+ type StructMapping,
22
23
  type TypeMapping,
24
+ U8,
23
25
  U32,
26
+ U64,
27
+ U128,
28
+ isArrayMapping,
29
+ isBoundedVecMapping,
30
+ isFixedArrayMapping,
31
+ isFixedBoundedVecMapping,
32
+ isOptionMapping,
33
+ isStructMapping,
24
34
  tryFieldWidth,
25
35
  } from '@aztec/pxe/simulator';
26
36
  import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
@@ -50,15 +60,18 @@ export function synthesizeDefaultFixtures(
50
60
  }
51
61
 
52
62
  /**
53
- * The test-value implementations, one per oracle type, mirroring the Noir synthesizer tables (`scalars` and
54
- * `synthesizers` in `noir-projects/aztec-nr/.../macros/oracle_testing.nr`) exactly.
63
+ * The scalar test-value implementations, mirroring the Noir synthesizer's `scalars` table in
64
+ * `noir-projects/labs/aztec-nr/.../macros/oracle_testing.nr` exactly.
55
65
  */
56
- const TEST_VALUE_IMPLS: TestValueImpl[] = [
66
+ const SCALAR_IMPLS: ScalarImpl[] = [
57
67
  scalar(FIELD, seed => new Fr(seed)),
58
68
  scalar(U32, seed => seed),
59
69
  scalar(BLOCK_NUMBER, seed => BlockNumber(seed)),
60
70
  scalar(BIGINT, seed => BigInt(seed)),
61
- scalar(BYTE, seed => seed),
71
+ scalar(U64, seed => BigInt(seed)),
72
+ scalar(U128, seed => BigInt(seed)),
73
+ scalar(LEAF_INDEX, seed => seed),
74
+ scalar(U8, seed => seed),
62
75
  scalar(BOOL, seed => seed % 2 !== 0),
63
76
  scalar(AZTEC_ADDRESS, seed => AztecAddress.fromNumberUnsafe(seed)),
64
77
  scalar(ETH_ADDRESS, seed => EthAddress.fromField(new Fr(seed))),
@@ -70,12 +83,18 @@ const TEST_VALUE_IMPLS: TestValueImpl[] = [
70
83
  scalar(DELIVERY_MODE, seed =>
71
84
  seed % 2 === 0 ? AppTaggingSecretKind.UNCONSTRAINED : AppTaggingSecretKind.CONSTRAINED,
72
85
  ),
73
- composite(isOption, (type, seed) => [
74
- named(Option.some(firstValue(type.inner, seed)), 'some'),
75
- named(Option.none(firstValue(type.inner, seed)), 'none'),
86
+ ];
87
+
88
+ /**
89
+ * The composite test-value implementations, one per combinator, mirroring the Noir synthesizer's `synthesizers` table.
90
+ */
91
+ const COMPOSITE_IMPLS: CompositeImpl[] = [
92
+ composite(isOptionMapping, (type, seed) => [
93
+ named(Option.some(testValueFor(type.inner, seed)), 'some'),
94
+ named(Option.none(testValueFor(type.inner, seed)), 'none'),
76
95
  ]),
77
- composite(isArray, (type, seed) => [unnamed(collectionData(type.inner, seed, DEFAULT_ARRAY_LENGTH))]),
78
- composite(isBoundedVec, (type, seed) => [
96
+ composite(isArrayMapping, (type, seed) => [unnamed(collectionData(type.inner, seed, DEFAULT_ARRAY_LENGTH))]),
97
+ composite(isBoundedVecMapping, (type, seed) => [
79
98
  unnamed(
80
99
  BoundedVec.from({
81
100
  data: collectionData(type.inner, seed, DEFAULT_ARRAY_LENGTH),
@@ -83,17 +102,20 @@ const TEST_VALUE_IMPLS: TestValueImpl[] = [
83
102
  }),
84
103
  ),
85
104
  ]),
86
- composite(isStruct, (type, seed) => [unnamed(structValue(type, seed))]),
105
+ composite(isStructMapping, (type, seed) => [unnamed(structValue(type, seed))]),
87
106
  // A fixed-length array uses its real (signature) length, unlike the generic-length ARRAY which is pinned to
88
107
  // DEFAULT_ARRAY_LENGTH.
89
- composite(isFixedArray, (type, seed) => [unnamed(collectionData(type.inner, seed, type.length))]),
108
+ composite(isFixedArrayMapping, (type, seed) => [unnamed(collectionData(type.inner, seed, type.length))]),
90
109
  // Same for a fixed-capacity bounded vec: real capacity, DEFAULT_ARRAY_LENGTH elements (its value type is a plain
91
110
  // element array, unlike the two-slot BOUNDED_VEC), clamped to the capacity so small vecs stay valid.
92
- composite(isFixedBoundedVec, (type, seed) => [
111
+ composite(isFixedBoundedVecMapping, (type, seed) => [
93
112
  unnamed(collectionData(type.inner, seed, Math.min(DEFAULT_ARRAY_LENGTH, type.maxLength))),
94
113
  ]),
95
114
  ];
96
115
 
116
+ /** The scalar mappings with a registered test-value impl. */
117
+ export const SCALAR_MAPPINGS: TypeMapping<any>[] = SCALAR_IMPLS.map(impl => impl.mapping);
118
+
97
119
  /**
98
120
  * The base every seed is offset by, applied once where a parameter's position becomes its seed, so generated values
99
121
  * stay clear of 0. Must match `SEED_BASE` in the Noir `oracle_testing.nr`.
@@ -125,32 +147,34 @@ function named(value: unknown, name: string): Scenario {
125
147
  return { value, name };
126
148
  }
127
149
 
128
- /**
129
- * One type's test-value implementation, mirroring a Noir `TestValueSynthesizer` entry: `match` selects the type and
130
- * `scenarios` yields its [`Scenario`]s for `seed`, one per serialization shape, like the Noir entry's `scenarios`
131
- * function.
132
- */
133
- interface TestValueImpl {
150
+ /** An impl for the single scalar `mapping` it synthesizes for. */
151
+ type ScalarImpl = {
152
+ mapping: TypeMapping<any>;
153
+ scenarios: (type: TypeMapping<any>, seed: number) => Scenario[];
154
+ };
155
+
156
+ /** An impl for a whole family of composite mappings, selected by its `kind` type guard. */
157
+ type CompositeImpl = {
134
158
  match: (type: TypeMapping<any>) => boolean;
135
159
  scenarios: (type: TypeMapping<any>, seed: number) => Scenario[];
136
- }
160
+ };
137
161
 
138
- /** A scalar impl: matches the singleton `type` by identity and yields a single unnamed scenario. */
139
- function scalar(type: TypeMapping<any>, value: (seed: number) => unknown): TestValueImpl {
140
- return { match: t => t === type, scenarios: (_type, seed) => [unnamed(value(seed))] };
162
+ /** A scalar impl yielding a single unnamed scenario. */
163
+ function scalar(mapping: TypeMapping<any>, value: (seed: number) => unknown): ScalarImpl {
164
+ return { mapping, scenarios: (_type, seed) => [unnamed(value(seed))] };
141
165
  }
142
166
 
143
- /** A composite impl: selected by the `kind` type guard, recursing through its element/inner mapping. */
167
+ /** A composite impl, recursing through the matched mapping's element/inner mapping. */
144
168
  function composite<K extends CompositeMapping>(
145
169
  guard: (type: TypeMapping<any>) => type is K,
146
170
  scenarios: (type: K, seed: number) => Scenario[],
147
- ): TestValueImpl {
171
+ ): CompositeImpl {
148
172
  return { match: guard, scenarios: (type, seed) => scenarios(type as K, seed) };
149
173
  }
150
174
 
151
175
  /** Synthesized element values for a collection. */
152
176
  function collectionData(element: TypeMapping<any>, seed: number, length: number): unknown[] {
153
- return Array.from({ length }, (_, i) => firstValue(element, seed + i));
177
+ return Array.from({ length }, (_, i) => testValueFor(element, seed + i));
154
178
  }
155
179
 
156
180
  /**
@@ -161,7 +185,7 @@ function structValue(type: StructMapping, seed: number): Record<string, unknown>
161
185
  const value: Record<string, unknown> = {};
162
186
  let offset = 0;
163
187
  for (const field of type.fields) {
164
- value[field.name] = firstValue(field.type, seed + offset);
188
+ value[field.name] = testValueFor(field.type, seed + offset);
165
189
  const width = tryFieldWidth(field.type.shape);
166
190
  if (width === undefined) {
167
191
  // A variable-width field has no flat offset to seed the next field at, so only this oracle is unsynthesizable.
@@ -177,15 +201,18 @@ function structValue(type: StructMapping, seed: number): Record<string, unknown>
177
201
  * dispatcher. Throws if the type has no matching impl.
178
202
  */
179
203
  function scenariosForType(type: TypeMapping<any>, seed: number): Scenario[] {
180
- const impl = TEST_VALUE_IMPLS.find(i => i.match(type));
204
+ const impl = SCALAR_IMPLS.find(i => i.mapping === type) ?? COMPOSITE_IMPLS.find(i => i.match(type));
181
205
  if (!impl) {
182
206
  throw new UnsynthesizableTypeError(type);
183
207
  }
184
208
  return impl.scenarios(type, seed);
185
209
  }
186
210
 
187
- /** The first (representative) test value of `type`, used for collection elements and `Option` inners. */
188
- function firstValue(type: TypeMapping<any>, seed: number): unknown {
211
+ /**
212
+ * The test value of `type` at `seed`, matching what the Noir synthesizer produces for the same type and seed. Throws
213
+ * for types without a test-value impl.
214
+ */
215
+ export function testValueFor(type: TypeMapping<any>, seed: number): unknown {
189
216
  return scenariosForType(type, seed)[0].value;
190
217
  }
191
218
 
@@ -242,41 +269,3 @@ function synthesizeScenariosOrThrow(entry: OracleRegistryEntry): OracleTestScena
242
269
  }
243
270
  return scenarios;
244
271
  }
245
-
246
- /**
247
- * The composite `TypeMapping`s (`ARRAY`/`BOUNDED_VEC`/`OPTION`/`STRUCT`/`FIXED_ARRAY`/`FIXED_BOUNDED_VEC`),
248
- * discriminated by `kind`. The combinators attach `kind` plus the inner mapping(s) at construction; the registry
249
- * erases params to the base `TypeMapping`, so the guards below recover the structure for recursion.
250
- */
251
- type ArrayMapping = TypeMapping & { kind: 'array'; inner: TypeMapping };
252
- type BoundedVecMapping = TypeMapping & { kind: 'bounded-vec'; inner: TypeMapping };
253
- type OptionMapping = TypeMapping & { kind: 'option'; inner: TypeMapping };
254
- type StructMapping = TypeMapping & { kind: 'struct'; fields: readonly StructField[] };
255
- type FixedArrayMapping = TypeMapping & { kind: 'fixed-array'; inner: TypeMapping; length: number };
256
- type FixedBoundedVecMapping = TypeMapping & { kind: 'fixed-bounded-vec'; inner: TypeMapping; maxLength: number };
257
- type CompositeMapping =
258
- | ArrayMapping
259
- | BoundedVecMapping
260
- | OptionMapping
261
- | StructMapping
262
- | FixedArrayMapping
263
- | FixedBoundedVecMapping;
264
-
265
- function isArray(type: TypeMapping<any>): type is ArrayMapping {
266
- return 'kind' in type && type.kind === 'array';
267
- }
268
- function isBoundedVec(type: TypeMapping<any>): type is BoundedVecMapping {
269
- return 'kind' in type && type.kind === 'bounded-vec';
270
- }
271
- function isOption(type: TypeMapping<any>): type is OptionMapping {
272
- return 'kind' in type && type.kind === 'option';
273
- }
274
- function isStruct(type: TypeMapping<any>): type is StructMapping {
275
- return 'kind' in type && type.kind === 'struct';
276
- }
277
- function isFixedArray(type: TypeMapping<any>): type is FixedArrayMapping {
278
- return 'kind' in type && type.kind === 'fixed-array';
279
- }
280
- function isFixedBoundedVec(type: TypeMapping<any>): type is FixedBoundedVecMapping {
281
- return 'kind' in type && type.kind === 'fixed-bounded-vec';
282
- }
@@ -2,7 +2,7 @@
2
2
  import type { Logger } from '@aztec/foundation/log';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { withoutHexPrefix } from '@aztec/foundation/string';
5
- import { BOUNDED_VEC, BYTE, BoundedVec, Option, type OracleRegistryEntry, makeEntry } from '@aztec/pxe/simulator';
5
+ import { BOUNDED_VEC, BoundedVec, Option, type OracleRegistryEntry, U8, makeEntry } from '@aztec/pxe/simulator';
6
6
 
7
7
  import type { ForeignCallArgs, ForeignCallResult } from '../../utils/encoding.js';
8
8
  import { toInputSlots } from '../txe_oracle_registry.js';
@@ -10,7 +10,7 @@ import { synthesizeDefaultFixtures } from './default_fixtures.js';
10
10
 
11
11
  /** Name of the meta-oracle that Noir tests call to announce the next call's scenario by name. */
12
12
  const SET_SCENARIO_ORACLE = 'aztec_oracle_test_set_scenario';
13
- export const SET_SCENARIO_ENTRY = makeEntry({ params: [{ name: 'name', type: BOUNDED_VEC(BYTE) }] });
13
+ export const SET_SCENARIO_ENTRY = makeEntry({ params: [{ name: 'name', type: BOUNDED_VEC(U8) }] });
14
14
 
15
15
  export type OracleTestCallInput = {
16
16
  session_id: number;
@@ -14,7 +14,6 @@ import type { TaggingSecretStrategy } from '@aztec/pxe/server';
14
14
  import {
15
15
  ARRAY,
16
16
  AZTEC_ADDRESS,
17
- BIGINT,
18
17
  BLOCK_NUMBER,
19
18
  BOOL,
20
19
  ETH_ADDRESS,
@@ -22,17 +21,20 @@ import {
22
21
  FIXED_ARRAY,
23
22
  FUNCTION_SELECTOR,
24
23
  type InputSlot,
24
+ LEAF,
25
25
  type MaybePromise,
26
26
  OPTION,
27
27
  ORACLE_REGISTRY,
28
28
  type OracleRegistryEntry,
29
29
  type OutputSlot,
30
30
  type ParamTypes,
31
+ SCALAR,
31
32
  STR,
32
33
  STRUCT,
33
34
  type SlotShape,
34
35
  type TypeMapping,
35
36
  U32,
37
+ U64,
36
38
  buildACIRCallback,
37
39
  makeEntry,
38
40
  } from '@aztec/pxe/simulator';
@@ -59,12 +61,13 @@ export type { BlockHash } from '@aztec/stdlib/block';
59
61
  export type { MembershipWitness } from '@aztec/foundation/trees';
60
62
  export type { NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
61
63
 
62
- const GAS_SETTINGS: TypeMapping<GasSettings> = {
64
+ const GAS_SETTINGS: TypeMapping<GasSettings> = LEAF({
65
+ kind: 'gas-settings',
63
66
  deserialization: {
64
67
  fn: ([reader]) => GasSettings.fromFields(reader.readFieldArray(GAS_SETTINGS_LENGTH)),
65
68
  },
66
69
  shape: [{ len: GAS_SETTINGS_LENGTH }],
67
- };
70
+ });
68
71
 
69
72
  // Tagging secret strategy discriminants. Must match the Noir test helper `TaggingSecretStrategy` in
70
73
  // aztec-nr `test/helpers/tagging_secret_strategy.nr`. This is a test-only oracle (only `set_tagging_secret_strategies`
@@ -74,7 +77,8 @@ const STRATEGY_ARBITRARY_SECRET = 2;
74
77
  const STRATEGY_ADDRESS_DERIVED = 3;
75
78
  const STRATEGY_INTERACTIVE_HANDSHAKE = 4;
76
79
 
77
- const TAGGING_SECRET_STRATEGY: TypeMapping<TaggingSecretStrategy> = {
80
+ const TAGGING_SECRET_STRATEGY: TypeMapping<TaggingSecretStrategy> = LEAF({
81
+ kind: 'tagging-secret-strategy',
78
82
  serialization: {
79
83
  fn: strategy => {
80
84
  switch (strategy.type) {
@@ -108,24 +112,27 @@ const TAGGING_SECRET_STRATEGY: TypeMapping<TaggingSecretStrategy> = {
108
112
  },
109
113
  },
110
114
  shape: ['scalar', 'scalar', 'scalar'],
111
- };
115
+ });
112
116
 
113
- const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = {
117
+ const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = LEAF({
118
+ kind: 'private-context-inputs',
114
119
  serialization: { fn: v => v.toFields() },
115
120
  shape: Array<SlotShape>(PRIVATE_CONTEXT_INPUTS_LENGTH).fill('scalar'),
116
- };
121
+ });
117
122
 
118
- const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = {
123
+ const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = LEAF({
124
+ kind: 'complete-address',
119
125
  serialization: { fn: v => [v.address.toField(), ...v.publicKeys.toFields()] },
120
126
  shape: Array<SlotShape>(8).fill('scalar'), // address + 7 public-key fields
121
- };
127
+ });
122
128
 
123
129
  const TXE_TX_EFFECTS: TypeMapping<{
124
130
  txHash: TxHash;
125
131
  noteHashes: Fr[];
126
132
  nullifiers: Fr[];
127
133
  privateLogs: PrivateLog[];
128
- }> = {
134
+ }> = LEAF({
135
+ kind: 'txe-tx-effects',
129
136
  serialization: {
130
137
  fn: ({ txHash, noteHashes, nullifiers, privateLogs }) => {
131
138
  const emittedLogs = privateLogs.map(log => log.getEmittedFields());
@@ -164,9 +171,10 @@ const TXE_TX_EFFECTS: TypeMapping<{
164
171
  { len: MAX_PRIVATE_LOGS_PER_TX },
165
172
  'scalar',
166
173
  ],
167
- };
174
+ });
168
175
 
169
- const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = {
176
+ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = LEAF({
177
+ kind: 'txe-offchain-effects',
170
178
  serialization: {
171
179
  fn: ({ effects }) => {
172
180
  const rawArrayStorage = effects
@@ -188,9 +196,10 @@ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = {
188
196
  { len: MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY },
189
197
  'scalar',
190
198
  ],
191
- };
199
+ });
192
200
 
193
- const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = {
201
+ const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = LEAF({
202
+ kind: 'txe-call-context',
194
203
  serialization: {
195
204
  fn: ({ txHash, anchorBlockTimestamp }) => {
196
205
  const isSome = txHash.isZero() ? 0 : 1;
@@ -198,7 +207,7 @@ const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }
198
207
  },
199
208
  },
200
209
  shape: ['scalar', 'scalar', 'scalar'], // discriminant, txHash, anchor block timestamp
201
- };
210
+ });
202
211
 
203
212
  const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ exists: boolean; member: Fr }[]> = FIXED_ARRAY(
204
213
  STRUCT([
@@ -208,13 +217,14 @@ const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ exists: boolean; member: Fr }[]> =
208
217
  1,
209
218
  );
210
219
 
211
- const EVENT_SELECTOR: TypeMapping<EventSelector> = {
220
+ const EVENT_SELECTOR: TypeMapping<EventSelector> = SCALAR({
221
+ kind: 'event-selector',
212
222
  serialization: { fn: v => [v.toField()] },
213
223
  deserialization: { fn: ([reader]) => EventSelector.fromField(reader.readField()) },
214
- shape: ['scalar'],
215
- };
224
+ });
216
225
 
217
- const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = {
226
+ const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = LEAF({
227
+ kind: 'txe-private-events',
218
228
  serialization: {
219
229
  fn: events => {
220
230
  const rawArrayStorage = events
@@ -235,7 +245,7 @@ const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = {
235
245
  { len: MAX_PRIVATE_EVENTS_PER_TXE_QUERY },
236
246
  'scalar',
237
247
  ],
238
- };
248
+ });
239
249
 
240
250
  export const TXE_ORACLE_REGISTRY = {
241
251
  ...ORACLE_REGISTRY,
@@ -270,14 +280,14 @@ export const TXE_ORACLE_REGISTRY = {
270
280
 
271
281
  aztec_txe_getNextBlockNumber: makeEntry({ returnType: BLOCK_NUMBER }),
272
282
 
273
- aztec_txe_getNextBlockTimestamp: makeEntry({ returnType: BIGINT }),
283
+ aztec_txe_getNextBlockTimestamp: makeEntry({ returnType: U64 }),
274
284
 
275
285
  aztec_txe_advanceBlocksBy: makeEntry({
276
286
  params: [{ name: 'blocks', type: U32 }],
277
287
  }),
278
288
 
279
289
  aztec_txe_advanceTimestampBy: makeEntry({
280
- params: [{ name: 'duration', type: BIGINT }],
290
+ params: [{ name: 'duration', type: U64 }],
281
291
  }),
282
292
 
283
293
  aztec_txe_deploy: makeEntry({
@@ -294,7 +304,10 @@ export const TXE_ORACLE_REGISTRY = {
294
304
  }),
295
305
 
296
306
  aztec_txe_createAccount: makeEntry({
297
- params: [{ name: 'secret', type: FIELD }],
307
+ params: [
308
+ { name: 'secret', type: FIELD },
309
+ { name: 'partialAddress', type: FIELD },
310
+ ],
298
311
  returnType: COMPLETE_ADDRESS,
299
312
  }),
300
313
 
@@ -327,8 +340,12 @@ export const TXE_ORACLE_REGISTRY = {
327
340
  ],
328
341
  }),
329
342
 
343
+ aztec_txe_setAuthorizeAllUtilityCallTargets: makeEntry({
344
+ params: [{ name: 'authorizeAll', type: BOOL }],
345
+ }),
346
+
330
347
  aztec_txe_getLastBlockTimestamp: makeEntry({
331
- returnType: BIGINT,
348
+ returnType: U64,
332
349
  }),
333
350
 
334
351
  aztec_txe_getLastTxEffects: makeEntry({ returnType: TXE_TX_EFFECTS }),
@@ -387,7 +404,7 @@ export const TXE_ORACLE_REGISTRY = {
387
404
 
388
405
  aztec_avm_blockNumber: makeEntry({ returnType: BLOCK_NUMBER }),
389
406
 
390
- aztec_avm_timestamp: makeEntry({ returnType: BIGINT }),
407
+ aztec_avm_timestamp: makeEntry({ returnType: U64 }),
391
408
 
392
409
  aztec_avm_isStaticCall: makeEntry({ returnType: BOOL }),
393
410