@aztec/txe 0.0.1-commit.2f68f620 → 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.
- package/dest/AuthRegistry-QVGDDH5X.js +3 -0
- package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
- package/dest/ContractClassRegistry-VWR3F42P.js +3 -0
- package/dest/ContractClassRegistry-VWR3F42P.js.map +7 -0
- package/dest/ContractInstanceRegistry-FHIWE33X.js +3 -0
- package/dest/ContractInstanceRegistry-FHIWE33X.js.map +7 -0
- package/dest/FeeJuice-SAOWVGG7.js +3 -0
- package/dest/FeeJuice-SAOWVGG7.js.map +7 -0
- package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
- package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
- package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
- package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
- package/dest/SchnorrAccount-NME3E45O.js +3 -0
- package/dest/SchnorrAccount-NME3E45O.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js +3 -0
- package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.js +7 -15
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_test_server.js +2 -2
- package/dest/chunk-32UHX7YY.js +3 -0
- package/dest/chunk-SZPMCTJK.js +260 -0
- package/dest/chunk-SZPMCTJK.js.map +7 -0
- package/dest/{chunk-W2NSX64C.js → chunk-YS3UIBVR.js} +2 -2
- package/dest/{chunk-W2NSX64C.js.map → chunk-YS3UIBVR.js.map} +3 -3
- package/dest/constants.d.ts +1 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +1 -1
- package/dest/dispatcher_pool.d.ts +2 -2
- package/dest/dispatcher_pool.d.ts.map +1 -1
- package/dest/dispatcher_pool.js +5 -3
- package/dest/index.d.ts +2 -136
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -3
- package/dest/metafile.json +9632 -7418
- package/dest/oracle/interfaces.d.ts +24 -11
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
- package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
- package/dest/oracle/tagging_secret_strategy.js +12 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/default_fixtures.js +200 -0
- package/dest/oracle/test-resolver/index.d.ts +1 -1
- package/dest/oracle/test-resolver/index.d.ts.map +1 -1
- package/dest/oracle/test-resolver/index.js +1 -2
- package/dest/oracle/test-resolver/resolver.d.ts +21 -7
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
- package/dest/oracle/test-resolver/resolver.js +100 -33
- package/dest/oracle/txe_oracle_public_context.d.ts +9 -9
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +15 -9
- package/dest/oracle/txe_oracle_registry.d.ts +51 -26
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_registry.js +258 -53
- package/dest/oracle/txe_oracle_top_level_context.d.ts +30 -9
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +454 -288
- package/dest/oracle/txe_oracle_version.d.ts +4 -4
- package/dest/oracle/txe_oracle_version.js +4 -4
- package/dest/rpc_translator.d.ts +23 -4
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +167 -81
- package/dest/server.bundle.js +1 -1
- package/dest/state_machine/archiver.d.ts +1 -1
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +1 -2
- package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +9 -0
- package/dest/state_machine/global_variable_builder.d.ts +3 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +0 -3
- package/dest/state_machine/index.d.ts +8 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +41 -19
- package/dest/state_machine/synchronizer.d.ts +10 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +18 -5
- package/dest/txe_session.d.ts +29 -20
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +165 -41
- package/dest/utils/block_creation.d.ts +2 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +2 -2
- package/dest/utils/encoding.d.ts +4 -3
- package/dest/utils/encoding.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.d.ts +1 -1
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +0 -1
- package/dest/utils/txe_public_contract_data_source.d.ts +1 -1
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/utils/txe_public_contract_data_source.js +7 -4
- package/dest/worker.bundle.js +1 -1
- package/package.json +17 -17
- package/src/bin/check_txe_oracle_version.ts +9 -12
- package/src/bin/oracle_test_server.ts +2 -2
- package/src/constants.ts +1 -1
- package/src/dispatcher_pool.ts +4 -3
- package/src/index.ts +6 -4
- package/src/oracle/interfaces.ts +26 -9
- package/src/oracle/tagging_secret_strategy.ts +25 -0
- package/src/oracle/test-resolver/default_fixtures.ts +271 -0
- package/src/oracle/test-resolver/index.ts +1 -2
- package/src/oracle/test-resolver/resolver.ts +121 -41
- package/src/oracle/txe_oracle_public_context.ts +16 -14
- package/src/oracle/txe_oracle_registry.ts +197 -42
- package/src/oracle/txe_oracle_top_level_context.ts +201 -66
- package/src/oracle/txe_oracle_version.ts +4 -4
- package/src/rpc_translator.ts +224 -108
- package/src/state_machine/archiver.ts +0 -1
- package/src/state_machine/dummy_p2p_client.ts +13 -0
- package/src/state_machine/global_variable_builder.ts +2 -16
- package/src/state_machine/index.ts +50 -34
- package/src/state_machine/synchronizer.ts +26 -5
- package/src/txe_session.ts +284 -45
- package/src/utils/block_creation.ts +2 -1
- package/src/utils/tx_effect_creation.ts +0 -2
- package/src/utils/txe_public_contract_data_source.ts +6 -4
- package/dest/ContractClassRegistry-PII7Q556.js +0 -3
- package/dest/ContractClassRegistry-PII7Q556.js.map +0 -7
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +0 -3
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +0 -7
- package/dest/FeeJuice-TQV5AQK7.js +0 -3
- package/dest/FeeJuice-TQV5AQK7.js.map +0 -7
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +0 -3
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +0 -7
- package/dest/SchnorrAccount-MQXPIZ44.js +0 -3
- package/dest/SchnorrAccount-MQXPIZ44.js.map +0 -7
- package/dest/chunk-BJVAAXNA.js +0 -3
- package/dest/chunk-CDITIZHX.js +0 -257
- package/dest/chunk-CDITIZHX.js.map +0 -7
- package/dest/oracle/test-resolver/fixtures.d.ts +0 -43
- package/dest/oracle/test-resolver/fixtures.d.ts.map +0 -1
- package/dest/oracle/test-resolver/fixtures.js +0 -39
- package/src/oracle/test-resolver/fixtures.ts +0 -84
- /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { withoutHexPrefix } from '@aztec/foundation/string';
|
|
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
|
-
import
|
|
8
|
+
import { toInputSlots } from '../txe_oracle_registry.js';
|
|
9
|
+
import { synthesizeDefaultFixtures } from './default_fixtures.js';
|
|
9
10
|
|
|
10
|
-
/** Name of the meta-oracle that Noir tests call to
|
|
11
|
+
/** Name of the meta-oracle that Noir tests call to announce the next call's scenario by name. */
|
|
11
12
|
const SET_SCENARIO_ORACLE = 'aztec_oracle_test_set_scenario';
|
|
13
|
+
export const SET_SCENARIO_ENTRY = makeEntry({ params: [{ name: 'name', type: BOUNDED_VEC(U8) }] });
|
|
12
14
|
|
|
13
15
|
export type OracleTestCallInput = {
|
|
14
16
|
session_id: number;
|
|
@@ -19,12 +21,22 @@ export type OracleTestCallInput = {
|
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* One test case for an oracle: the expected deserialized `inputs`, the `output` to serialize back to Noir, and the
|
|
25
|
+
* `scenario` name (`some`/`none`) the matching Noir test announces. Single-scenario oracles leave `scenario` undefined
|
|
26
|
+
* and are selected automatically.
|
|
27
|
+
*/
|
|
28
|
+
export interface OracleTestScenario {
|
|
29
|
+
scenario?: string;
|
|
30
|
+
inputs: Record<string, unknown>;
|
|
31
|
+
output: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Oracle resolver for serialization tests. Selects a fixture scenario, verifies that the received inputs match, and
|
|
23
36
|
* returns the corresponding fixture output.
|
|
24
37
|
*
|
|
25
|
-
* For oracles with a single
|
|
26
|
-
*
|
|
27
|
-
* real oracle.
|
|
38
|
+
* For oracles with a single scenario, it is selected automatically. For oracles with multiple scenarios, the Noir test
|
|
39
|
+
* announces the scenario by name via the `aztec_oracle_test_set_scenario` meta-oracle before calling the real oracle.
|
|
28
40
|
*/
|
|
29
41
|
export class OracleTestResolver {
|
|
30
42
|
private readonly calledOracles = new Set<string>();
|
|
@@ -39,6 +51,14 @@ export class OracleTestResolver {
|
|
|
39
51
|
this.logger = logger ?? createLogger('txe:test-resolver');
|
|
40
52
|
}
|
|
41
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Builds a resolver whose fixtures are the default scenarios synthesized from the registry's type mappings. The
|
|
56
|
+
* matching Noir serialization tests are auto-generated by `#[generate_oracle_tests]` from the same convention.
|
|
57
|
+
*/
|
|
58
|
+
static fromRegistry(registry: Record<string, OracleRegistryEntry>, logger?: Logger): OracleTestResolver {
|
|
59
|
+
return new OracleTestResolver(registry, synthesizeDefaultFixtures(registry), logger);
|
|
60
|
+
}
|
|
61
|
+
|
|
42
62
|
// eslint-disable-next-line require-await
|
|
43
63
|
async resolve_foreign_call(callData: OracleTestCallInput): Promise<ForeignCallResult> {
|
|
44
64
|
const oracleName = callData.function;
|
|
@@ -48,8 +68,6 @@ export class OracleTestResolver {
|
|
|
48
68
|
return this.#handleSetScenario(callData);
|
|
49
69
|
}
|
|
50
70
|
|
|
51
|
-
this.calledOracles.add(oracleName);
|
|
52
|
-
|
|
53
71
|
if (!(oracleName in this.registry)) {
|
|
54
72
|
throw new Error(`Oracle '${oracleName}' not found in registry`);
|
|
55
73
|
}
|
|
@@ -62,6 +80,7 @@ export class OracleTestResolver {
|
|
|
62
80
|
|
|
63
81
|
const match = this.#selectScenario(callData.session_id, oracleName, scenarios);
|
|
64
82
|
this.#verifyInputs(callData.inputs, entry, match, oracleName);
|
|
83
|
+
this.calledOracles.add(oracleName);
|
|
65
84
|
|
|
66
85
|
this.logger.debug('Verified scenario for oracle', { oracleName });
|
|
67
86
|
|
|
@@ -81,62 +100,57 @@ export class OracleTestResolver {
|
|
|
81
100
|
return Object.keys(this.registry).filter(name => !(name in this.fixtures));
|
|
82
101
|
}
|
|
83
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Records the scenario name for the session's next oracle call. A test announces once per multi-scenario position
|
|
105
|
+
* (param or return), so successive announcements accumulate joined with `+`, matching the names the fixture
|
|
106
|
+
* synthesizer builds (e.g. `some+some`).
|
|
107
|
+
*/
|
|
84
108
|
#handleSetScenario(callData: { session_id: number; inputs: ForeignCallArgs }): ForeignCallResult {
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
.map(code => String.fromCharCode(code))
|
|
89
|
-
.join('');
|
|
109
|
+
const name = decodeScenarioName(callData.inputs);
|
|
110
|
+
const existing = this.pendingScenario.get(callData.session_id);
|
|
111
|
+
const scenario = existing !== undefined ? `${existing}+${name}` : name;
|
|
90
112
|
|
|
91
|
-
this.logger.debug('Setting scenario for next oracle call', { sessionId: callData.session_id,
|
|
92
|
-
this.pendingScenario.set(callData.session_id,
|
|
113
|
+
this.logger.debug('Setting scenario for next oracle call', { sessionId: callData.session_id, scenario });
|
|
114
|
+
this.pendingScenario.set(callData.session_id, scenario);
|
|
93
115
|
|
|
94
116
|
return { values: [] };
|
|
95
117
|
}
|
|
96
118
|
|
|
97
|
-
/** Selects
|
|
119
|
+
/** Selects the fixture by the announced scenario name (for multi-scenario oracles) or returns the single fixture. */
|
|
98
120
|
#selectScenario(sessionId: number, oracleName: string, fixtures: OracleTestScenario[]): OracleTestScenario {
|
|
99
|
-
const
|
|
121
|
+
const announced = this.pendingScenario.get(sessionId);
|
|
100
122
|
|
|
101
|
-
if (
|
|
123
|
+
if (announced !== undefined) {
|
|
102
124
|
this.pendingScenario.delete(sessionId);
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
const available = fixtures.map(s => s.scenario).join(', ');
|
|
106
|
-
throw new Error(`No scenario
|
|
125
|
+
const match = fixtures.find(s => s.scenario === announced);
|
|
126
|
+
if (!match) {
|
|
127
|
+
const available = fixtures.map(s => s.scenario ?? '<default>').join(', ');
|
|
128
|
+
throw new Error(`No scenario '${announced}' for oracle '${oracleName}'. Available: ${available}`);
|
|
107
129
|
}
|
|
108
|
-
|
|
109
|
-
throw new Error(`Duplicate scenario name '${selectedName}' for oracle '${oracleName}'`);
|
|
110
|
-
}
|
|
111
|
-
return matches[0];
|
|
130
|
+
return match;
|
|
112
131
|
}
|
|
113
132
|
|
|
114
133
|
if (fixtures.length === 1) {
|
|
115
134
|
return fixtures[0];
|
|
116
135
|
}
|
|
117
136
|
|
|
118
|
-
throw new Error(
|
|
119
|
-
`Oracle '${oracleName}' has ${fixtures.length} fixture scenarios. ` +
|
|
120
|
-
`Use #[oracle_test("scenario_name")] to select one.`,
|
|
121
|
-
);
|
|
137
|
+
throw new Error(`Oracle '${oracleName}' has ${fixtures.length} scenarios but none was announced before the call.`);
|
|
122
138
|
}
|
|
123
139
|
|
|
124
140
|
/** Deserializes actual inputs and verifies they match the scenario's expected inputs. */
|
|
125
141
|
#verifyInputs(
|
|
126
142
|
rawInputs: ForeignCallArgs,
|
|
127
143
|
entry: OracleRegistryEntry,
|
|
128
|
-
|
|
144
|
+
fixture: OracleTestScenario,
|
|
129
145
|
oracleName: string,
|
|
130
146
|
): void {
|
|
131
|
-
const expectedInputs =
|
|
147
|
+
const expectedInputs = fixture.inputs;
|
|
132
148
|
if (Object.keys(expectedInputs).length === 0) {
|
|
133
149
|
return;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
);
|
|
139
|
-
const named = entry.deserializeParams(normalized);
|
|
152
|
+
const scenarioLabel = fixture.scenario ? ` (scenario '${fixture.scenario}')` : '';
|
|
153
|
+
const named = entry.deserializeParams(toInputSlots(rawInputs));
|
|
140
154
|
|
|
141
155
|
for (const param of named) {
|
|
142
156
|
if (!(param.name in expectedInputs)) {
|
|
@@ -146,20 +160,86 @@ export class OracleTestResolver {
|
|
|
146
160
|
);
|
|
147
161
|
}
|
|
148
162
|
if (!valuesEqual(param.value, expectedInputs[param.name])) {
|
|
149
|
-
const scenarioLabel = scenario.scenario ? ` (scenario '${scenario.scenario}')` : '';
|
|
150
163
|
throw new Error(
|
|
151
164
|
`Input mismatch for oracle '${oracleName}'${scenarioLabel}: ` +
|
|
152
165
|
`param '${param.name}' expected ${String(expectedInputs[param.name])} ` +
|
|
153
|
-
`but got ${String(param.value)}`,
|
|
166
|
+
`but got ${String(param.value)}. ${versionBumpHint(oracleName)}`,
|
|
154
167
|
);
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
}
|
|
158
171
|
}
|
|
159
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Decodes the scenario name announced by `set_oracle_test_scenario`, whose argument is a `BoundedVec<u8, N>`
|
|
175
|
+
*/
|
|
176
|
+
function decodeScenarioName(inputs: ForeignCallArgs): string {
|
|
177
|
+
const [{ value }] = SET_SCENARIO_ENTRY.deserializeParams(toInputSlots(inputs));
|
|
178
|
+
return String.fromCharCode(...value.data);
|
|
179
|
+
}
|
|
180
|
+
|
|
160
181
|
function valuesEqual(actual: unknown, expected: unknown): boolean {
|
|
182
|
+
if (!isNonNullObject(actual) || !isNonNullObject(expected)) {
|
|
183
|
+
// Primitive scalars; String() bridges bigint vs number representations of the same seed. A primitive compared
|
|
184
|
+
// against an object is never equal.
|
|
185
|
+
return isNonNullObject(actual) === isNonNullObject(expected) && String(actual) === String(expected);
|
|
186
|
+
}
|
|
187
|
+
if (actual instanceof Option && expected instanceof Option) {
|
|
188
|
+
return actual.equals(expected, valuesEqual);
|
|
189
|
+
}
|
|
190
|
+
if (actual instanceof BoundedVec && expected instanceof BoundedVec) {
|
|
191
|
+
return actual.equals(expected, valuesEqual);
|
|
192
|
+
}
|
|
161
193
|
if (Array.isArray(actual) && Array.isArray(expected)) {
|
|
162
194
|
return actual.length === expected.length && actual.every((v, i) => valuesEqual(v, expected[i]));
|
|
163
195
|
}
|
|
164
|
-
|
|
196
|
+
if (isPlainObject(actual) && isPlainObject(expected)) {
|
|
197
|
+
const expectedKeys = Object.keys(expected);
|
|
198
|
+
return (
|
|
199
|
+
Object.keys(actual).length === expectedKeys.length &&
|
|
200
|
+
expectedKeys.every(key => valuesEqual(actual[key], expected[key]))
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
if (actual.constructor !== expected.constructor) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if (hasEquals(actual)) {
|
|
207
|
+
return actual.equals(expected);
|
|
208
|
+
}
|
|
209
|
+
const actualStr = customStringForm(actual);
|
|
210
|
+
const expectedStr = customStringForm(expected);
|
|
211
|
+
if (actualStr !== undefined && expectedStr !== undefined) {
|
|
212
|
+
return actualStr === expectedStr;
|
|
213
|
+
}
|
|
214
|
+
// Comparing blindly here could pass vacuously (e.g. two '[object Object]' strings), so refuse instead.
|
|
215
|
+
throw new Error(
|
|
216
|
+
`valuesEqual cannot compare a '${actual.constructor?.name}' against a '${expected.constructor?.name}'. Add a branch for the type.`,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function isNonNullObject(value: unknown): value is object {
|
|
221
|
+
return typeof value === 'object' && value !== null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
225
|
+
return isNonNullObject(value) && value.constructor === Object;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function hasEquals(value: object): value is { equals(other: unknown): boolean } {
|
|
229
|
+
return typeof (value as { equals?: unknown }).equals === 'function';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** The value's string form when its class overrides `toString` (a meaningful representation), undefined otherwise. */
|
|
233
|
+
function customStringForm(value: object): string | undefined {
|
|
234
|
+
const { toString } = value;
|
|
235
|
+
if (typeof toString !== 'function' || toString === Object.prototype.toString) {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
return toString.call(value);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function versionBumpHint(oracle: string): string {
|
|
242
|
+
return oracle.startsWith('aztec_txe_') || oracle.startsWith('aztec_avm_')
|
|
243
|
+
? 'If you changed this oracle, consider bumping the TXE oracle version in yarn-project/txe/src/oracle/txe_oracle_version.ts.'
|
|
244
|
+
: 'If you changed this oracle, consider bumping the PXE oracle version in yarn-project/pxe/src/oracle_version.ts.';
|
|
165
245
|
}
|
|
@@ -5,7 +5,7 @@ import type { ContractStore } from '@aztec/pxe/server';
|
|
|
5
5
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ContractInstancePreimageWithAddress } from '@aztec/stdlib/contract';
|
|
9
9
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
10
10
|
import {
|
|
11
11
|
MerkleTreeId,
|
|
@@ -125,34 +125,36 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
125
125
|
return value;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
getContractInstanceDeployer(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
128
|
+
getContractInstanceDeployer(address: AztecAddress): Promise<{ member: Fr; exists: boolean }[]> {
|
|
129
129
|
return this.getContractInstanceMember(address, i => i.deployer.toField());
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
getContractInstanceClassId(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
133
|
-
|
|
132
|
+
getContractInstanceClassId(address: AztecAddress): Promise<{ member: Fr; exists: boolean }[]> {
|
|
133
|
+
// TXE has no contract updates, so the current class always equals the original.
|
|
134
|
+
return this.getContractInstanceMember(address, i => i.originalContractClassId);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
getContractInstanceInitializationHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
137
|
+
getContractInstanceInitializationHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }[]> {
|
|
137
138
|
return this.getContractInstanceMember(address, i => i.initializationHash);
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
getContractInstanceImmutablesHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
141
|
+
getContractInstanceImmutablesHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }[]> {
|
|
141
142
|
return this.getContractInstanceMember(address, i => i.immutablesHash);
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
// The one-element array mirrors the oracles' Noir return type, `[GetContractInstanceResult; 1]`.
|
|
144
146
|
private async getContractInstanceMember(
|
|
145
147
|
address: AztecAddress,
|
|
146
|
-
accessor: (instance:
|
|
147
|
-
): Promise<{ member: Fr; exists: boolean }> {
|
|
148
|
+
accessor: (instance: ContractInstancePreimageWithAddress) => Fr,
|
|
149
|
+
): Promise<{ member: Fr; exists: boolean }[]> {
|
|
148
150
|
const instance = await this.contractStore.getContractInstance(address);
|
|
149
151
|
if (!instance) {
|
|
150
|
-
return { member: Fr.ZERO, exists: false };
|
|
152
|
+
return [{ member: Fr.ZERO, exists: false }];
|
|
151
153
|
}
|
|
152
|
-
return { member: accessor(instance), exists: true };
|
|
154
|
+
return [{ member: accessor(instance), exists: true }];
|
|
153
155
|
}
|
|
154
156
|
|
|
155
|
-
returndataSize(): Promise<
|
|
157
|
+
returndataSize(): Promise<number> {
|
|
156
158
|
throw new Error(
|
|
157
159
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
158
160
|
);
|
|
@@ -164,19 +166,19 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
164
166
|
);
|
|
165
167
|
}
|
|
166
168
|
|
|
167
|
-
call(_l2Gas: number, _daGas: number, _address: AztecAddress, _argsLength: number, _args: Fr[]): Promise<
|
|
169
|
+
call(_l2Gas: number, _daGas: number, _address: AztecAddress, _argsLength: number, _args: Fr[]): Promise<void> {
|
|
168
170
|
throw new Error(
|
|
169
171
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
170
172
|
);
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
staticCall(_l2Gas: number, _daGas: number, _address: AztecAddress, _argsLength: number, _args: Fr[]): Promise<
|
|
175
|
+
staticCall(_l2Gas: number, _daGas: number, _address: AztecAddress, _argsLength: number, _args: Fr[]): Promise<void> {
|
|
174
176
|
throw new Error(
|
|
175
177
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
176
178
|
);
|
|
177
179
|
}
|
|
178
180
|
|
|
179
|
-
successCopy(): Promise<
|
|
181
|
+
successCopy(): Promise<boolean> {
|
|
180
182
|
throw new Error(
|
|
181
183
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
182
184
|
);
|