@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97
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/ContractClassRegistry-PII7Q556.js +3 -0
- package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
- package/dest/FeeJuice-TQV5AQK7.js +3 -0
- package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
- package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
- package/dest/SchnorrAccount-MQXPIZ44.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +61 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/bin/oracle_test_server.d.ts +3 -0
- package/dest/bin/oracle_test_server.d.ts.map +1 -0
- package/dest/bin/oracle_test_server.js +41 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-CUSVOJA4.js +304 -0
- package/dest/chunk-CUSVOJA4.js.map +7 -0
- package/dest/chunk-OYLIPWI6.js +260 -0
- package/dest/chunk-OYLIPWI6.js.map +7 -0
- package/dest/constants.d.ts +7 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +10 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +185 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +73 -158
- package/dest/metafile.json +36863 -0
- package/dest/msgpackr_fr_extension.d.ts +2 -0
- package/dest/msgpackr_fr_extension.d.ts.map +1 -0
- package/dest/msgpackr_fr_extension.js +21 -0
- package/dest/oracle/interfaces.d.ts +60 -31
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
- package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/fixtures.js +39 -0
- package/dest/oracle/test-resolver/index.d.ts +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +33 -0
- package/dest/oracle/test-resolver/resolver.d.ts +34 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +114 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +41 -17
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +63 -23
- package/dest/oracle/txe_oracle_registry.d.ts +147 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +562 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +57 -28
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +341 -130
- package/dest/oracle/txe_oracle_version.d.ts +17 -0
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_version.js +14 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
- package/dest/oracle/txe_private_execution_oracle.js +15 -0
- package/dest/rpc_server.d.ts +14 -0
- package/dest/rpc_server.d.ts.map +1 -0
- package/dest/rpc_server.js +78 -0
- package/dest/rpc_translator.d.ts +96 -213
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +815 -550
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +23 -52
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +77 -99
- package/dest/state_machine/dummy_p2p_client.d.ts +28 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +54 -22
- package/dest/state_machine/global_variable_builder.d.ts +11 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +21 -3
- package/dest/state_machine/index.d.ts +11 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +60 -25
- package/dest/state_machine/mock_epoch_cache.d.ts +29 -12
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +50 -15
- package/dest/state_machine/synchronizer.d.ts +6 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +9 -8
- package/dest/txe_session.d.ts +94 -21
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +314 -68
- package/dest/utils/block_creation.d.ts +21 -6
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +38 -4
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +8 -3
- package/dest/utils/expected_failure_error.d.ts +4 -0
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.d.ts +3 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +4 -7
- package/dest/utils/txe_account_store.d.ts +10 -0
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
- package/dest/utils/txe_artifact_resolver.d.ts +37 -0
- package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.js +161 -0
- package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
- package/dest/utils/txe_public_contract_data_source.js +48 -0
- package/dest/worker.bundle.js +3 -0
- package/dest/worker.bundle.js.map +7 -0
- package/dest/worker.d.ts +2 -0
- package/dest/worker.d.ts.map +1 -0
- package/dest/worker.js +92 -0
- package/package.json +40 -22
- package/src/bin/check_txe_oracle_version.ts +70 -0
- package/src/bin/index.ts +11 -2
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +13 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +111 -201
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +62 -36
- package/src/oracle/test-resolver/fixtures.ts +84 -0
- package/src/oracle/test-resolver/index.ts +45 -0
- package/src/oracle/test-resolver/resolver.ts +165 -0
- package/src/oracle/txe_oracle_public_context.ts +81 -28
- package/src/oracle/txe_oracle_registry.ts +401 -0
- package/src/oracle/txe_oracle_top_level_context.ts +418 -178
- package/src/oracle/txe_oracle_version.ts +17 -0
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +999 -909
- package/src/state_machine/archiver.ts +83 -115
- package/src/state_machine/dummy_p2p_client.ts +83 -33
- package/src/state_machine/global_variable_builder.ts +39 -6
- package/src/state_machine/index.ts +82 -24
- package/src/state_machine/mock_epoch_cache.ts +63 -23
- package/src/state_machine/synchronizer.ts +10 -9
- package/src/txe_session.ts +486 -119
- package/src/utils/block_creation.ts +49 -14
- package/src/{util → utils}/encoding.ts +9 -3
- package/src/utils/tx_effect_creation.ts +5 -12
- package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/utils/txe_public_contract_data_source.ts +58 -0
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -121
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts +0 -4
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.js +0 -22
- package/dest/util/txe_public_contract_data_source.d.ts +0 -20
- package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
- package/dest/util/txe_public_contract_data_source.js +0 -67
- package/src/util/txe_contract_data_provider.ts +0 -36
- package/src/util/txe_public_contract_data_source.ts +0 -85
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
|
|
3
|
+
import { addExtension } from 'msgpackr';
|
|
4
|
+
|
|
5
|
+
// `@aztec/native/msgpack_channel` registers a msgpackr extension that packs `Fr` instances to
|
|
6
|
+
// their raw 32-byte buffer for the C++ world-state side to deserialize. Because `@aztec/native`
|
|
7
|
+
// is externalized in TXE's esbuild config (it loads a `.node` binary that can't be bundled),
|
|
8
|
+
// the `Fr` class the extension is keyed on belongs to the *external* `@aztec/foundation`
|
|
9
|
+
// module instance — a different class identity than the `Fr` bundled into the TXE worker /
|
|
10
|
+
// bin. msgpackr's extension match uses `instanceof`, so bundled `Fr` instances slip through
|
|
11
|
+
// and msgpackr falls back to `Fr.toJSON()` (returns `Fr.toString()` — a `0x...` hex string).
|
|
12
|
+
// The C++ side then sees a string where a 32-byte binary was expected and throws
|
|
13
|
+
// `msgpack::type_error` whose `what()` is literally `"std::bad_cast"`.
|
|
14
|
+
//
|
|
15
|
+
// Fix: register the same extension under the BUNDLED `Fr` class identity. msgpackr's extension
|
|
16
|
+
// table holds an entry per `Class`, so both Fr classes now resolve to the same `write` callback
|
|
17
|
+
// and produce the same wire format. Imported as a side-effect from `./index.js` so both the
|
|
18
|
+
// worker (via `./worker.ts`) and the main-thread RPC server (via `./rpc_server.ts`) get the
|
|
19
|
+
// registration before any `sendMessage` runs.
|
|
20
|
+
addExtension({
|
|
21
|
+
Class: Fr,
|
|
22
|
+
write: (fr: Fr) => fr.toBuffer(),
|
|
23
|
+
});
|
package/src/oracle/interfaces.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
1
|
import { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
4
2
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
3
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type {
|
|
7
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
8
|
+
import type { PrivateLog } from '@aztec/stdlib/logs';
|
|
9
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
9
10
|
|
|
10
11
|
// These interfaces complement the ones defined in PXE, and combined with those contain the full list of oracles used by
|
|
11
12
|
// aztec-nr. In particular, these include the ones needed to run Brillig code associated to #[external("public")] functions that has
|
|
@@ -23,18 +24,27 @@ import type { UInt32, UInt64 } from '@aztec/stdlib/types';
|
|
|
23
24
|
export interface IAvmExecutionOracle {
|
|
24
25
|
isAvm: true;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
address(): Promise<AztecAddress>;
|
|
28
|
+
sender(): Promise<AztecAddress>;
|
|
29
|
+
blockNumber(): Promise<BlockNumber>;
|
|
30
|
+
timestamp(): Promise<bigint>;
|
|
31
|
+
isStaticCall(): Promise<boolean>;
|
|
32
|
+
chainId(): Promise<Fr>;
|
|
33
|
+
version(): Promise<Fr>;
|
|
34
|
+
emitNullifier(nullifier: Fr): Promise<void>;
|
|
35
|
+
emitNoteHash(noteHash: Fr): Promise<void>;
|
|
36
|
+
nullifierExists(siloedNullifier: Fr): Promise<boolean>;
|
|
37
|
+
storageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
38
|
+
storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
39
|
+
getContractInstanceDeployer(address: AztecAddress): Promise<{ member: Fr; exists: boolean }>;
|
|
40
|
+
getContractInstanceClassId(address: AztecAddress): Promise<{ member: Fr; exists: boolean }>;
|
|
41
|
+
getContractInstanceInitializationHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }>;
|
|
42
|
+
getContractInstanceImmutablesHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }>;
|
|
43
|
+
returndataSize(): Promise<Fr>;
|
|
44
|
+
returndataCopy(rdOffset: number, copySize: number): Promise<Fr[]>;
|
|
45
|
+
call(l2Gas: number, daGas: number, address: AztecAddress, argsLength: number, args: Fr[]): Promise<Fr[]>;
|
|
46
|
+
staticCall(l2Gas: number, daGas: number, address: AztecAddress, argsLength: number, args: Fr[]): Promise<Fr[]>;
|
|
47
|
+
successCopy(): Promise<Fr>;
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/**
|
|
@@ -43,41 +53,57 @@ export interface IAvmExecutionOracle {
|
|
|
43
53
|
export interface ITxeExecutionOracle {
|
|
44
54
|
isTxe: true;
|
|
45
55
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
getDefaultAddress(): AztecAddress;
|
|
57
|
+
getNextBlockNumber(): Promise<BlockNumber>;
|
|
58
|
+
getNextBlockTimestamp(): Promise<UInt64>;
|
|
59
|
+
advanceBlocksBy(blocks: number): Promise<void>;
|
|
60
|
+
advanceTimestampBy(duration: UInt64): void;
|
|
61
|
+
deploy(
|
|
62
|
+
contractPath: string,
|
|
63
|
+
initializer: string,
|
|
64
|
+
args: Fr[],
|
|
55
65
|
secret: Fr,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
salt: Fr,
|
|
67
|
+
deployer: AztecAddress,
|
|
68
|
+
): Promise<Fr[]>;
|
|
69
|
+
createAccount(secret: Fr): Promise<CompleteAddress>;
|
|
70
|
+
addAccount(secret: Fr): Promise<CompleteAddress>;
|
|
71
|
+
addAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
72
|
+
getLastBlockTimestamp(): Promise<bigint>;
|
|
73
|
+
getLastTxEffects(): Promise<{
|
|
60
74
|
txHash: TxHash;
|
|
61
75
|
noteHashes: Fr[];
|
|
62
76
|
nullifiers: Fr[];
|
|
77
|
+
privateLogs: PrivateLog[];
|
|
63
78
|
}>;
|
|
64
|
-
|
|
65
|
-
|
|
79
|
+
getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
80
|
+
privateCallNewFlow(
|
|
81
|
+
from: AztecAddress | undefined,
|
|
66
82
|
targetContractAddress: AztecAddress,
|
|
67
83
|
functionSelector: FunctionSelector,
|
|
68
84
|
args: Fr[],
|
|
69
85
|
argsHash: Fr,
|
|
70
86
|
isStaticCall: boolean,
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
additionalScopes: AztecAddress[],
|
|
88
|
+
jobId: string,
|
|
89
|
+
authorizedUtilityCallTargets: AztecAddress[],
|
|
90
|
+
gasSettings: GasSettings,
|
|
91
|
+
): Promise<{ returnValues: Fr[]; offchainEffects: Fr[][] }>;
|
|
92
|
+
executeUtilityFunction(
|
|
73
93
|
targetContractAddress: AztecAddress,
|
|
74
94
|
functionSelector: FunctionSelector,
|
|
75
95
|
args: Fr[],
|
|
96
|
+
jobId: string,
|
|
97
|
+
authorizedUtilityCallTargets: AztecAddress[],
|
|
76
98
|
): Promise<Fr[]>;
|
|
77
|
-
|
|
78
|
-
from: AztecAddress,
|
|
99
|
+
publicCallNewFlow(
|
|
100
|
+
from: AztecAddress | undefined,
|
|
79
101
|
targetContractAddress: AztecAddress,
|
|
80
102
|
calldata: Fr[],
|
|
81
103
|
isStaticCall: boolean,
|
|
104
|
+
gasSettings: GasSettings,
|
|
82
105
|
): Promise<Fr[]>;
|
|
106
|
+
// TODO(F-335): Drop this from here as it's not a real oracle handler - it's only called from
|
|
107
|
+
// RPCTranslator::txeGetPrivateEvents and never from Noir.
|
|
108
|
+
syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string): Promise<void>;
|
|
83
109
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { type NamedValue, Option } from '@aztec/pxe/simulator';
|
|
5
|
+
|
|
6
|
+
import { TXE_ORACLE_REGISTRY } from '../txe_oracle_registry.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Fixture definitions for oracle roundtrip tests.
|
|
10
|
+
*
|
|
11
|
+
* Each key is an oracle name from TXE_ORACLE_REGISTRY, and the value is an array of scenarios. The resolver selects a
|
|
12
|
+
* scenario (by name for multi-scenario oracles, or automatically for single-scenario ones), verifies that the
|
|
13
|
+
* deserialized inputs match the fixture's expected values, and returns the fixture output.
|
|
14
|
+
*
|
|
15
|
+
* To add a new oracle test:
|
|
16
|
+
* 1. Add a fixture entry here with the expected inputs and output.
|
|
17
|
+
* 2. Add a Noir `#[oracle_test]` function that calls the oracle with the same input values and asserts the output.
|
|
18
|
+
*/
|
|
19
|
+
export const ORACLE_TEST_FIXTURES: OracleTestFixtures = {
|
|
20
|
+
aztec_avm_storageRead: [
|
|
21
|
+
makeScenario({
|
|
22
|
+
inputs: { slot: new Fr(10), contractAddress: AztecAddress.fromNumber(1) },
|
|
23
|
+
output: new Fr(42),
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
aztec_prv_getSenderForTags: [
|
|
28
|
+
makeScenario({
|
|
29
|
+
scenario: 'some',
|
|
30
|
+
inputs: {},
|
|
31
|
+
output: Option.some(AztecAddress.fromNumber(42)),
|
|
32
|
+
}),
|
|
33
|
+
makeScenario({
|
|
34
|
+
scenario: 'none',
|
|
35
|
+
inputs: {},
|
|
36
|
+
output: Option.none(AztecAddress.ZERO),
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Converts a `NamedValue` tuple (from `deserializeParams`) to a record.
|
|
43
|
+
* `[NamedValue<'slot', Fr>, NamedValue<'addr', AztecAddress>]` → `{ slot: Fr, addr: AztecAddress }`.
|
|
44
|
+
*/
|
|
45
|
+
type NamedValuesToRecord<T extends readonly NamedValue[]> = {
|
|
46
|
+
[K in T[number] as K extends NamedValue<infer N, any> ? N : never]: K extends NamedValue<string, infer V> ? V : never;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Extracts the deserialized inputs record type from an oracle registry entry. */
|
|
50
|
+
type OracleInputs<K extends keyof typeof TXE_ORACLE_REGISTRY> = (typeof TXE_ORACLE_REGISTRY)[K] extends {
|
|
51
|
+
deserializeParams(...args: any[]): infer P;
|
|
52
|
+
}
|
|
53
|
+
? P extends readonly NamedValue[]
|
|
54
|
+
? NamedValuesToRecord<P>
|
|
55
|
+
: Record<string, never>
|
|
56
|
+
: Record<string, never>;
|
|
57
|
+
|
|
58
|
+
/** Extracts the return type from an oracle registry entry's serializeReturn method. */
|
|
59
|
+
type OracleOutput<K extends keyof typeof TXE_ORACLE_REGISTRY> = (typeof TXE_ORACLE_REGISTRY)[K] extends {
|
|
60
|
+
serializeReturn(result: infer R): any;
|
|
61
|
+
}
|
|
62
|
+
? R
|
|
63
|
+
: void;
|
|
64
|
+
|
|
65
|
+
/** A single test scenario for an oracle, typed against the oracle registry. */
|
|
66
|
+
export interface OracleTestScenario<K extends keyof typeof TXE_ORACLE_REGISTRY = keyof typeof TXE_ORACLE_REGISTRY> {
|
|
67
|
+
/** Scenario name for selection via `#[oracle_test("name")]`. Required when an oracle has multiple scenarios. */
|
|
68
|
+
scenario?: string;
|
|
69
|
+
/** Expected deserialized inputs. */
|
|
70
|
+
inputs: OracleInputs<K>;
|
|
71
|
+
/** Return value to serialize back to Noir. */
|
|
72
|
+
output: OracleOutput<K>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type OracleTestFixtures = {
|
|
76
|
+
[K in keyof typeof TXE_ORACLE_REGISTRY]?: OracleTestScenario<K>[];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Creates a typed fixture scenario for a given oracle. */
|
|
80
|
+
function makeScenario<K extends keyof typeof TXE_ORACLE_REGISTRY>(
|
|
81
|
+
scenario: OracleTestScenario<K>,
|
|
82
|
+
): OracleTestScenario<K> {
|
|
83
|
+
return scenario;
|
|
84
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
5
|
+
import { zodFor } from '@aztec/stdlib/schemas';
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
import { ForeignCallArgsSchema, type ForeignCallResult, ForeignCallResultSchema } from '../../utils/encoding.js';
|
|
10
|
+
import { TXE_ORACLE_REGISTRY } from '../txe_oracle_registry.js';
|
|
11
|
+
import { ORACLE_TEST_FIXTURES } from './fixtures.js';
|
|
12
|
+
import { type OracleTestCallInput, OracleTestResolver } from './resolver.js';
|
|
13
|
+
|
|
14
|
+
const OracleTestCallInputSchema = zodFor<OracleTestCallInput>()(
|
|
15
|
+
z.object({
|
|
16
|
+
session_id: z.number().nonnegative(),
|
|
17
|
+
function: z.string(),
|
|
18
|
+
root_path: z.string(),
|
|
19
|
+
package_name: z.string(),
|
|
20
|
+
inputs: ForeignCallArgsSchema,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/** Narrowed interface exposing only the RPC method. */
|
|
25
|
+
interface OracleTestRpcHandler {
|
|
26
|
+
resolve_foreign_call(callData: OracleTestCallInput): Promise<ForeignCallResult>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const OracleTestRpcHandlerSchema: ApiSchemaFor<OracleTestRpcHandler> = {
|
|
30
|
+
resolve_foreign_call: z.function({
|
|
31
|
+
input: z.tuple([OracleTestCallInputSchema]),
|
|
32
|
+
output: ForeignCallResultSchema,
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Creates an RPC server backed by the oracle test resolver. */
|
|
37
|
+
export function createOracleTestRpcServer(logger: Logger) {
|
|
38
|
+
const resolver = new OracleTestResolver(TXE_ORACLE_REGISTRY, ORACLE_TEST_FIXTURES, logger);
|
|
39
|
+
const server = createSafeJsonRpcServer<OracleTestRpcHandler>(resolver, OracleTestRpcHandlerSchema, {
|
|
40
|
+
http200OnError: true,
|
|
41
|
+
});
|
|
42
|
+
return { server, resolver };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { OracleTestResolver } from './resolver.js';
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { withHexPrefix, withoutHexPrefix } from '@aztec/foundation/string';
|
|
5
|
+
import type { InputSlot, OracleRegistryEntry } from '@aztec/pxe/simulator';
|
|
6
|
+
|
|
7
|
+
import type { ForeignCallArgs, ForeignCallResult } from '../../utils/encoding.js';
|
|
8
|
+
import type { OracleTestScenario } from './fixtures.js';
|
|
9
|
+
|
|
10
|
+
/** Name of the meta-oracle that Noir tests call to select a fixture scenario by name. */
|
|
11
|
+
const SET_SCENARIO_ORACLE = 'aztec_oracle_test_set_scenario';
|
|
12
|
+
|
|
13
|
+
export type OracleTestCallInput = {
|
|
14
|
+
session_id: number;
|
|
15
|
+
function: string;
|
|
16
|
+
root_path: string;
|
|
17
|
+
package_name: string;
|
|
18
|
+
inputs: ForeignCallArgs;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Oracle resolver for roundtrip tests. Selects a fixture scenario, verifies that the received inputs match, and
|
|
23
|
+
* returns the corresponding fixture output.
|
|
24
|
+
*
|
|
25
|
+
* For oracles with a single fixture, it is selected automatically. For oracles with multiple fixtures, Noir tests
|
|
26
|
+
* must call the `oracle_test_set_scenario` meta-oracle to select a specific scenario by name before calling the
|
|
27
|
+
* real oracle.
|
|
28
|
+
*/
|
|
29
|
+
export class OracleTestResolver {
|
|
30
|
+
private readonly calledOracles = new Set<string>();
|
|
31
|
+
private readonly pendingScenario = new Map<number, string>();
|
|
32
|
+
private readonly logger: Logger;
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
private readonly registry: Record<string, OracleRegistryEntry>,
|
|
36
|
+
private readonly fixtures: Record<string, OracleTestScenario[]>,
|
|
37
|
+
logger?: Logger,
|
|
38
|
+
) {
|
|
39
|
+
this.logger = logger ?? createLogger('txe:test-resolver');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line require-await
|
|
43
|
+
async resolve_foreign_call(callData: OracleTestCallInput): Promise<ForeignCallResult> {
|
|
44
|
+
const oracleName = callData.function;
|
|
45
|
+
this.logger.debug('Resolving oracle', { oracleName });
|
|
46
|
+
|
|
47
|
+
if (oracleName === SET_SCENARIO_ORACLE) {
|
|
48
|
+
return this.#handleSetScenario(callData);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.calledOracles.add(oracleName);
|
|
52
|
+
|
|
53
|
+
if (!(oracleName in this.registry)) {
|
|
54
|
+
throw new Error(`Oracle '${oracleName}' not found in registry`);
|
|
55
|
+
}
|
|
56
|
+
const entry = this.registry[oracleName];
|
|
57
|
+
|
|
58
|
+
const scenarios = this.fixtures[oracleName];
|
|
59
|
+
if (!scenarios || scenarios.length === 0) {
|
|
60
|
+
throw new Error(`No fixture defined for oracle '${oracleName}'`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const match = this.#selectScenario(callData.session_id, oracleName, scenarios);
|
|
64
|
+
this.#verifyInputs(callData.inputs, entry, match, oracleName);
|
|
65
|
+
|
|
66
|
+
this.logger.debug('Verified scenario for oracle', { oracleName });
|
|
67
|
+
|
|
68
|
+
const outputSlots = entry.serializeReturn(match.output);
|
|
69
|
+
return {
|
|
70
|
+
values: outputSlots.map(slot => (Array.isArray(slot) ? slot.map(withoutHexPrefix) : withoutHexPrefix(slot))),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Returns oracles that have a fixture defined but were never called during testing. */
|
|
75
|
+
getUncalledFixtures(): string[] {
|
|
76
|
+
return Object.keys(this.fixtures).filter(name => !this.calledOracles.has(name));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Returns oracles in the registry that have no fixture defined at all. */
|
|
80
|
+
getMissingFixtures(): string[] {
|
|
81
|
+
return Object.keys(this.registry).filter(name => !(name in this.fixtures));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#handleSetScenario(callData: { session_id: number; inputs: ForeignCallArgs }): ForeignCallResult {
|
|
85
|
+
const charCodes = callData.inputs[0] as string[];
|
|
86
|
+
const scenarioName = charCodes
|
|
87
|
+
.map(hex => Number(BigInt(hex.startsWith('0x') ? hex : `0x${hex}`)))
|
|
88
|
+
.map(code => String.fromCharCode(code))
|
|
89
|
+
.join('');
|
|
90
|
+
|
|
91
|
+
this.logger.debug('Setting scenario for next oracle call', { sessionId: callData.session_id, scenarioName });
|
|
92
|
+
this.pendingScenario.set(callData.session_id, scenarioName);
|
|
93
|
+
|
|
94
|
+
return { values: [] };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Selects a scenario by pending name (for multi-fixture oracles) or returns the single fixture. */
|
|
98
|
+
#selectScenario(sessionId: number, oracleName: string, fixtures: OracleTestScenario[]): OracleTestScenario {
|
|
99
|
+
const selectedName = this.pendingScenario.get(sessionId);
|
|
100
|
+
|
|
101
|
+
if (selectedName !== undefined) {
|
|
102
|
+
this.pendingScenario.delete(sessionId);
|
|
103
|
+
const matches = fixtures.filter(s => s.scenario === selectedName);
|
|
104
|
+
if (matches.length === 0) {
|
|
105
|
+
const available = fixtures.map(s => s.scenario).join(', ');
|
|
106
|
+
throw new Error(`No scenario named '${selectedName}' for oracle '${oracleName}'. Available: ${available}`);
|
|
107
|
+
}
|
|
108
|
+
if (matches.length > 1) {
|
|
109
|
+
throw new Error(`Duplicate scenario name '${selectedName}' for oracle '${oracleName}'`);
|
|
110
|
+
}
|
|
111
|
+
return matches[0];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (fixtures.length === 1) {
|
|
115
|
+
return fixtures[0];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Oracle '${oracleName}' has ${fixtures.length} fixture scenarios. ` +
|
|
120
|
+
`Use #[oracle_test("scenario_name")] to select one.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Deserializes actual inputs and verifies they match the scenario's expected inputs. */
|
|
125
|
+
#verifyInputs(
|
|
126
|
+
rawInputs: ForeignCallArgs,
|
|
127
|
+
entry: OracleRegistryEntry,
|
|
128
|
+
scenario: OracleTestScenario,
|
|
129
|
+
oracleName: string,
|
|
130
|
+
): void {
|
|
131
|
+
const expectedInputs = scenario.inputs as Record<string, unknown>;
|
|
132
|
+
if (Object.keys(expectedInputs).length === 0) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const normalized: InputSlot[] = rawInputs.map(v =>
|
|
137
|
+
Array.isArray(v) ? (v as string[]).map(withHexPrefix) : [withHexPrefix(v as string)],
|
|
138
|
+
);
|
|
139
|
+
const named = entry.deserializeParams(normalized);
|
|
140
|
+
|
|
141
|
+
for (const param of named) {
|
|
142
|
+
if (!(param.name in expectedInputs)) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
`Unexpected param '${param.name}' for oracle '${oracleName}'. ` +
|
|
145
|
+
`Expected: ${Object.keys(expectedInputs).join(', ')}`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (!valuesEqual(param.value, expectedInputs[param.name])) {
|
|
149
|
+
const scenarioLabel = scenario.scenario ? ` (scenario '${scenario.scenario}')` : '';
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Input mismatch for oracle '${oracleName}'${scenarioLabel}: ` +
|
|
152
|
+
`param '${param.name}' expected ${String(expectedInputs[param.name])} ` +
|
|
153
|
+
`but got ${String(param.value)}`,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function valuesEqual(actual: unknown, expected: unknown): boolean {
|
|
161
|
+
if (Array.isArray(actual) && Array.isArray(expected)) {
|
|
162
|
+
return actual.length === expected.length && actual.every((v, i) => valuesEqual(v, expected[i]));
|
|
163
|
+
}
|
|
164
|
+
return String(actual) === String(expected);
|
|
165
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import type { ContractStore } from '@aztec/pxe/server';
|
|
3
5
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
4
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import {
|
|
7
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
8
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
9
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
7
|
-
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
8
10
|
import {
|
|
9
11
|
MerkleTreeId,
|
|
10
12
|
type MerkleTreeWriteOperations,
|
|
@@ -12,9 +14,8 @@ import {
|
|
|
12
14
|
PublicDataTreeLeafPreimage,
|
|
13
15
|
} from '@aztec/stdlib/trees';
|
|
14
16
|
import { GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
15
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
16
17
|
|
|
17
|
-
import { insertTxEffectIntoWorldTrees,
|
|
18
|
+
import { insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
18
19
|
import type { IAvmExecutionOracle } from './interfaces.js';
|
|
19
20
|
|
|
20
21
|
export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
@@ -30,6 +31,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
30
31
|
private forkedWorldTrees: MerkleTreeWriteOperations,
|
|
31
32
|
private txRequestHash: Fr,
|
|
32
33
|
private globalVariables: GlobalVariables,
|
|
34
|
+
private contractStore: ContractStore,
|
|
33
35
|
) {
|
|
34
36
|
this.logger = createLogger('txe:public_context');
|
|
35
37
|
|
|
@@ -40,57 +42,55 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
address(): Promise<AztecAddress> {
|
|
44
46
|
return Promise.resolve(this.contractAddress);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
sender(): Promise<AztecAddress> {
|
|
48
50
|
return Promise.resolve(AztecAddress.ZERO); // todo: change?
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
blockNumber(): Promise<BlockNumber> {
|
|
52
54
|
return Promise.resolve(this.globalVariables.blockNumber);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
timestamp(): Promise<bigint> {
|
|
56
58
|
return Promise.resolve(this.globalVariables.timestamp);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
isStaticCall(): Promise<boolean> {
|
|
60
62
|
return Promise.resolve(false);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
chainId(): Promise<Fr> {
|
|
64
66
|
return Promise.resolve(this.globalVariables.chainId);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
version(): Promise<Fr> {
|
|
68
70
|
return Promise.resolve(this.globalVariables.version);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
async
|
|
73
|
+
async emitNullifier(nullifier: Fr) {
|
|
72
74
|
const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
|
|
73
75
|
this.transientSiloedNullifiers.push(siloedNullifier);
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
async
|
|
78
|
+
async emitNoteHash(noteHash: Fr) {
|
|
77
79
|
const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
|
|
78
80
|
// TODO: make the note hash unique - they are only siloed right now
|
|
79
81
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
async
|
|
83
|
-
const nullifier = await siloNullifier(targetAddress, innerNullifier!);
|
|
84
|
-
|
|
84
|
+
async nullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
85
85
|
const treeIndex = (
|
|
86
|
-
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
86
|
+
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
87
87
|
)[0];
|
|
88
|
-
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(
|
|
88
|
+
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
|
|
89
89
|
|
|
90
90
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
async
|
|
93
|
+
async storageWrite(slot: Fr, value: Fr) {
|
|
94
94
|
this.logger.debug('AVM storage write', { slot, value });
|
|
95
95
|
|
|
96
96
|
const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
|
|
@@ -102,8 +102,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
102
102
|
]);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
async
|
|
106
|
-
const leafSlot = await computePublicDataTreeLeafSlot(
|
|
105
|
+
async storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
106
|
+
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
107
107
|
|
|
108
108
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
109
109
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
@@ -120,11 +120,68 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
120
120
|
)) as PublicDataTreeLeafPreimage
|
|
121
121
|
).leaf.value;
|
|
122
122
|
|
|
123
|
-
this.logger.debug('AVM storage read', { slot, value });
|
|
123
|
+
this.logger.debug('AVM storage read', { slot, contractAddress, value });
|
|
124
124
|
|
|
125
125
|
return value;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
getContractInstanceDeployer(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
129
|
+
return this.getContractInstanceMember(address, i => i.deployer.toField());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getContractInstanceClassId(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
133
|
+
return this.getContractInstanceMember(address, i => i.currentContractClassId);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getContractInstanceInitializationHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
137
|
+
return this.getContractInstanceMember(address, i => i.initializationHash);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
getContractInstanceImmutablesHash(address: AztecAddress): Promise<{ member: Fr; exists: boolean }> {
|
|
141
|
+
return this.getContractInstanceMember(address, i => i.immutablesHash);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private async getContractInstanceMember(
|
|
145
|
+
address: AztecAddress,
|
|
146
|
+
accessor: (instance: ContractInstanceWithAddress) => Fr,
|
|
147
|
+
): Promise<{ member: Fr; exists: boolean }> {
|
|
148
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
149
|
+
if (!instance) {
|
|
150
|
+
return { member: Fr.ZERO, exists: false };
|
|
151
|
+
}
|
|
152
|
+
return { member: accessor(instance), exists: true };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
returndataSize(): Promise<Fr> {
|
|
156
|
+
throw new Error(
|
|
157
|
+
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
returndataCopy(_rdOffset: number, _copySize: number): Promise<Fr[]> {
|
|
162
|
+
throw new Error(
|
|
163
|
+
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
call(_l2Gas: number, _daGas: number, _address: AztecAddress, _argsLength: number, _args: Fr[]): Promise<Fr[]> {
|
|
168
|
+
throw new Error(
|
|
169
|
+
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
staticCall(_l2Gas: number, _daGas: number, _address: AztecAddress, _argsLength: number, _args: Fr[]): Promise<Fr[]> {
|
|
174
|
+
throw new Error(
|
|
175
|
+
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
successCopy(): Promise<Fr> {
|
|
180
|
+
throw new Error(
|
|
181
|
+
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
128
185
|
async close(): Promise<L2Block> {
|
|
129
186
|
this.logger.debug('Exiting Public Context, building block with collected side effects', {
|
|
130
187
|
blockNumber: this.globalVariables.blockNumber,
|
|
@@ -133,11 +190,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
133
190
|
const txEffect = this.makeTxEffect();
|
|
134
191
|
await insertTxEffectIntoWorldTrees(txEffect, this.forkedWorldTrees);
|
|
135
192
|
|
|
136
|
-
const block =
|
|
137
|
-
makeAppendOnlyTreeSnapshot(),
|
|
138
|
-
await makeTXEBlockHeader(this.forkedWorldTrees, this.globalVariables),
|
|
139
|
-
new Body([txEffect]),
|
|
140
|
-
);
|
|
193
|
+
const block = await makeTXEBlock(this.forkedWorldTrees, this.globalVariables, [txEffect]);
|
|
141
194
|
|
|
142
195
|
await this.forkedWorldTrees.close();
|
|
143
196
|
|