@aztec/txe 0.0.1-commit.3100065 → 0.0.1-commit.321f6a9

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 (79) 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-NADDSLGL.js → ContractInstanceRegistry-FHIWE33X.js} +1 -1
  6. package/dest/{ContractInstanceRegistry-NADDSLGL.js.map → ContractInstanceRegistry-FHIWE33X.js.map} +2 -2
  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-TGICA67H.js.map → MultiCallEntrypoint-QG5H33ZZ.js.map} +2 -2
  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/chunk-32UHX7YY.js +3 -0
  20. package/dest/chunk-SZPMCTJK.js +260 -0
  21. package/dest/chunk-SZPMCTJK.js.map +7 -0
  22. package/dest/{chunk-PDOEF22H.js → chunk-YS3UIBVR.js} +2 -2
  23. package/dest/metafile.json +1732 -2856
  24. package/dest/oracle/interfaces.d.ts +6 -2
  25. package/dest/oracle/interfaces.d.ts.map +1 -1
  26. package/dest/oracle/test-resolver/default_fixtures.d.ts +9 -2
  27. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -1
  28. package/dest/oracle/test-resolver/default_fixtures.js +32 -39
  29. package/dest/oracle/test-resolver/resolver.d.ts +1 -1
  30. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
  31. package/dest/oracle/test-resolver/resolver.js +2 -2
  32. package/dest/oracle/txe_oracle_registry.d.ts +5 -3
  33. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
  34. package/dest/oracle/txe_oracle_registry.js +45 -27
  35. package/dest/oracle/txe_oracle_top_level_context.d.ts +18 -5
  36. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  37. package/dest/oracle/txe_oracle_top_level_context.js +374 -270
  38. package/dest/oracle/txe_oracle_version.d.ts +4 -4
  39. package/dest/oracle/txe_oracle_version.js +4 -4
  40. package/dest/rpc_translator.d.ts +3 -1
  41. package/dest/rpc_translator.d.ts.map +1 -1
  42. package/dest/rpc_translator.js +17 -1
  43. package/dest/server.bundle.js +1 -1
  44. package/dest/state_machine/synchronizer.d.ts +6 -1
  45. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  46. package/dest/state_machine/synchronizer.js +12 -3
  47. package/dest/txe_session.d.ts +4 -3
  48. package/dest/txe_session.d.ts.map +1 -1
  49. package/dest/txe_session.js +21 -7
  50. package/dest/worker.bundle.js +1 -1
  51. package/package.json +17 -17
  52. package/src/bin/check_txe_oracle_version.ts +9 -12
  53. package/src/oracle/interfaces.ts +5 -1
  54. package/src/oracle/test-resolver/default_fixtures.ts +58 -69
  55. package/src/oracle/test-resolver/resolver.ts +2 -2
  56. package/src/oracle/txe_oracle_registry.ts +42 -25
  57. package/src/oracle/txe_oracle_top_level_context.ts +55 -22
  58. package/src/oracle/txe_oracle_version.ts +4 -4
  59. package/src/rpc_translator.ts +19 -1
  60. package/src/state_machine/synchronizer.ts +18 -3
  61. package/src/txe_session.ts +24 -6
  62. package/dest/AuthRegistry-FSRZIMX6.js +0 -3
  63. package/dest/AuthRegistry-FSRZIMX6.js.map +0 -7
  64. package/dest/ContractClassRegistry-N6NA3SFA.js +0 -3
  65. package/dest/ContractClassRegistry-N6NA3SFA.js.map +0 -7
  66. package/dest/FeeJuice-QBH5JWJV.js +0 -3
  67. package/dest/FeeJuice-QBH5JWJV.js.map +0 -7
  68. package/dest/HandshakeRegistry-KKUEU7XW.js +0 -3
  69. package/dest/HandshakeRegistry-KKUEU7XW.js.map +0 -7
  70. package/dest/MultiCallEntrypoint-TGICA67H.js +0 -3
  71. package/dest/SchnorrAccount-J5T6OKR3.js +0 -3
  72. package/dest/SchnorrAccount-J5T6OKR3.js.map +0 -7
  73. package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js +0 -3
  74. package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js.map +0 -7
  75. package/dest/chunk-BJVAAXNA.js +0 -3
  76. package/dest/chunk-YP4ODNMQ.js +0 -268
  77. package/dest/chunk-YP4ODNMQ.js.map +0 -7
  78. /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
  79. /package/dest/{chunk-PDOEF22H.js.map → chunk-YS3UIBVR.js.map} +0 -0
@@ -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/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
 
@@ -53,10 +53,10 @@ import {
53
53
  witnessMapToFields,
54
54
  } from '@aztec/simulator/client';
55
55
  import {
56
- CppPublicTxSimulator,
57
56
  GuardedMerkleTreeOperations,
58
57
  PublicContractsDB,
59
58
  PublicProcessor,
59
+ PublicTxSimulator,
60
60
  } from '@aztec/simulator/server';
61
61
  import { type ContractArtifact, EventSelector, FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
62
62
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
@@ -126,6 +126,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
126
126
  private chainId: Fr,
127
127
  private authwits: Map<string, AuthWitness>,
128
128
  private taggingSecretStrategies: TXETaggingSecretStrategies,
129
+ private authorizeAllUtilityCallTargets: boolean,
129
130
  private readonly artifactResolver: TXEArtifactResolver,
130
131
  private readonly rootPath: string,
131
132
  private readonly packageName: string,
@@ -335,9 +336,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
335
336
  return completeAddress;
336
337
  }
337
338
 
338
- async createAccount(secret: Fr) {
339
- // This is a foot gun !
340
- const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), secret);
339
+ async createAccount(secret: Fr, partialAddress: Fr) {
340
+ const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
341
341
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
342
342
  await this.addressStore.addCompleteAddress(completeAddress);
343
343
  this.logger.debug(`Created account ${completeAddress.address}`);
@@ -373,6 +373,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
373
373
  apply(AppTaggingSecretKind.CONSTRAINED, constrainedStrategy);
374
374
  }
375
375
 
376
+ setAuthorizeAllUtilityCallTargets(authorizeAll: boolean): void {
377
+ this.authorizeAllUtilityCallTargets = authorizeAll;
378
+ }
379
+
376
380
  async sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr> {
377
381
  // Messages are appended to the tree, so the next free slot is simply the current tree size.
378
382
  const { size } = await this.stateMachine.synchronizer
@@ -487,7 +491,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
487
491
  const privateExecutionOracle = new PrivateExecutionOracle({
488
492
  argsHash,
489
493
  txContext,
490
- // The TXE does not run the init kernel's salt binding, so no tx-request salt is in scope.
491
494
  txRequestSalt: Fr.ZERO,
492
495
  callContext,
493
496
  anchorBlockHeader: blockHeader,
@@ -577,7 +580,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
577
580
  globals.version = this.version;
578
581
  globals.gasFees = GasFees.empty();
579
582
 
580
- const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
583
+ await using forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
581
584
 
582
585
  const bindings = this.logger.getBindings();
583
586
  const contractsDB = new PublicContractsDB(
@@ -592,11 +595,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
592
595
  collectStatistics: false,
593
596
  collectCallMetadata: true,
594
597
  });
598
+ // The AVM simulator reads this fork's contracts DB, scoped by fork id, for each simulation.
599
+ const forkId = forkedWorldTrees.getRevision().forkId;
595
600
  const processor = new PublicProcessor(
596
601
  globals,
597
602
  guardedMerkleTrees,
598
603
  contractsDB,
599
- new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
604
+ new PublicTxSimulator(
605
+ this.stateMachine.synchronizer.avmSimulator,
606
+ globals,
607
+ contractsDB,
608
+ forkId,
609
+ config,
610
+ bindings,
611
+ ),
600
612
  new TestDateProvider(),
601
613
  undefined,
602
614
  createLogger('simulator:public-processor', bindings),
@@ -647,8 +659,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
647
659
 
648
660
  if (isStaticCall) {
649
661
  await checkpoint!.revert();
650
-
651
- await forkedWorldTrees.close();
652
662
  return { returnValues: executionResult.returnValues ?? [], offchainEffects };
653
663
  }
654
664
 
@@ -669,8 +679,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
669
679
 
670
680
  await this.stateMachine.handleL2Block(l2Block);
671
681
 
672
- await forkedWorldTrees.close();
673
-
674
682
  return { returnValues: executionResult.returnValues ?? [], offchainEffects };
675
683
  }
676
684
 
@@ -706,7 +714,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
706
714
  globals.version = this.version;
707
715
  globals.gasFees = GasFees.empty();
708
716
 
709
- const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
717
+ await using forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
710
718
 
711
719
  const bindings2 = this.logger.getBindings();
712
720
  const contractsDB = new PublicContractsDB(
@@ -721,7 +729,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
721
729
  collectStatistics: false,
722
730
  collectCallMetadata: true,
723
731
  });
724
- const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
732
+ // The AVM simulator reads this fork's contracts DB, scoped by fork id, for each simulation.
733
+ const forkId2 = forkedWorldTrees.getRevision().forkId;
734
+ const simulator = new PublicTxSimulator(
735
+ this.stateMachine.synchronizer.avmSimulator,
736
+ globals,
737
+ contractsDB,
738
+ forkId2,
739
+ config,
740
+ bindings2,
741
+ );
725
742
  const processor = new PublicProcessor(
726
743
  globals,
727
744
  guardedMerkleTrees,
@@ -807,9 +824,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
807
824
 
808
825
  if (isStaticCall) {
809
826
  await checkpoint!.revert();
810
-
811
- await forkedWorldTrees.close();
812
-
813
827
  return returnValues ?? [];
814
828
  }
815
829
 
@@ -830,8 +844,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
830
844
 
831
845
  await this.stateMachine.handleL2Block(l2Block);
832
846
 
833
- await forkedWorldTrees.close();
834
-
835
847
  return returnValues ?? [];
836
848
  }
837
849
 
@@ -918,7 +930,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
918
930
  try {
919
931
  const simulator = new WASMSimulator();
920
932
  const utilityExecutor = async (syncCall: FunctionCall, execScopes: AztecAddress[]) => {
921
- await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId, authorizedUtilityCallTargets });
933
+ await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId });
922
934
  };
923
935
  const oracle = new UtilityExecutionOracle({
924
936
  callContext: CallContext.from({
@@ -946,10 +958,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
946
958
  jobId,
947
959
  scopes,
948
960
  simulator,
949
- utilityExecutor,
950
961
  hooks: composeHooks({
951
962
  authorizeUtilityCall: this.buildAuthorizeUtilityCallHook('utility', authorizedUtilityCallTargets),
952
963
  }),
964
+ utilityExecutor,
953
965
  // Execution-tree root (top-level utility run or contract sync): own store; nested frames inherit it.
954
966
  transientArrayService: new TransientArrayService(),
955
967
  });
@@ -975,9 +987,19 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
975
987
  }
976
988
  }
977
989
 
978
- close(): [bigint, Map<string, AuthWitness>, TXETaggingSecretStrategies] {
990
+ close(): {
991
+ nextBlockTimestamp: bigint;
992
+ authwits: Map<string, AuthWitness>;
993
+ taggingSecretStrategies: TXETaggingSecretStrategies;
994
+ authorizeAllUtilityCallTargets: boolean;
995
+ } {
979
996
  this.logger.debug('Exiting Top Level Context');
980
- return [this.nextBlockTimestamp, this.authwits, this.taggingSecretStrategies];
997
+ return {
998
+ nextBlockTimestamp: this.nextBlockTimestamp,
999
+ authwits: this.authwits,
1000
+ taggingSecretStrategies: this.taggingSecretStrategies,
1001
+ authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets,
1002
+ };
981
1003
  }
982
1004
 
983
1005
  private async getLastBlockNumber(): Promise<BlockNumber> {
@@ -989,6 +1011,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
989
1011
  callerContext: 'private' | 'private view' | 'utility',
990
1012
  authorizedTargets: AztecAddress[],
991
1013
  ): ExecutionHooks['authorizeUtilityCall'] | undefined {
1014
+ if (this.authorizeAllUtilityCallTargets) {
1015
+ return authorizeAllUtilityCallsHook;
1016
+ }
992
1017
  if (authorizedTargets.length === 0) {
993
1018
  return undefined;
994
1019
  }
@@ -998,3 +1023,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
998
1023
  });
999
1024
  }
1000
1025
  }
1026
+
1027
+ /**
1028
+ * An `authorizeUtilityCall` hook that authorizes every cross-contract utility call.
1029
+ *
1030
+ * Backs the `aztec_txe_setAuthorizeAllUtilityCallTargets` oracle.
1031
+ */
1032
+ export const authorizeAllUtilityCallsHook: NonNullable<ExecutionHooks['authorizeUtilityCall']> = () =>
1033
+ Promise.resolve({ authorized: true });
@@ -5,13 +5,13 @@
5
5
  *
6
6
  * The Noir counterparts are in `noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr`.
7
7
  */
8
- export const TXE_ORACLE_VERSION_MAJOR = 3;
9
- export const TXE_ORACLE_VERSION_MINOR = 0;
8
+ export const TXE_ORACLE_VERSION_MAJOR = 4;
9
+ export const TXE_ORACLE_VERSION_MINOR = 1;
10
10
 
11
11
  /**
12
- * This hash is computed from the TXE oracle interfaces (IAvmExecutionOracle and ITxeExecutionOracle) and is used to
12
+ * This hash is computed from the TXE-specific entries in `TXE_ORACLE_REGISTRY` and is used to
13
13
  * detect when those interfaces change. When it does, bump:
14
14
  * - TXE_ORACLE_VERSION_MAJOR (and reset MINOR to 0) for breaking changes, or
15
15
  * - TXE_ORACLE_VERSION_MINOR for additive changes (new oracle method added).
16
16
  */
17
- export const TXE_ORACLE_INTERFACE_HASH = 'bea75bd85baebd7aa1438efb1defab496d27540bc805a8d854bb74b8d45fd859';
17
+ export const TXE_ORACLE_INTERFACE_HASH = '1a6c578d0a47cd8dd7dae07fd00abe781225a73920c596d873afcc061c0e4284';