@aztec/txe 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +53 -0
- 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-32UHX7YY.js +3 -0
- package/dest/chunk-32UHX7YY.js.map +7 -0
- package/dest/chunk-GSUKUCKV.js +260 -0
- package/dest/chunk-GSUKUCKV.js.map +7 -0
- package/dest/chunk-UP4KKUVA.js +304 -0
- package/dest/chunk-UP4KKUVA.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 +286 -0
- package/dest/index.d.ts +51 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +75 -158
- package/dest/metafile.json +38759 -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 +71 -30
- 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 +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +32 -0
- package/dest/oracle/test-resolver/resolver.d.ts +48 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +181 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +40 -16
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +69 -23
- package/dest/oracle/txe_oracle_registry.d.ts +172 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +767 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +79 -30
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +653 -285
- 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 +115 -216
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +901 -560
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +23 -58
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +76 -112
- package/dest/state_machine/dummy_p2p_client.d.ts +31 -17
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +63 -25
- package/dest/state_machine/global_variable_builder.d.ts +10 -5
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +20 -5
- package/dest/state_machine/index.d.ts +14 -8
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +84 -27
- package/dest/state_machine/mock_epoch_cache.d.ts +24 -8
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +43 -9
- package/dest/state_machine/synchronizer.d.ts +14 -6
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +23 -10
- package/dest/txe_session.d.ts +102 -20
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +442 -75
- package/dest/utils/block_creation.d.ts +20 -6
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +40 -6
- package/dest/utils/encoding.d.ts +192 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +8 -3
- package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -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 +51 -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 +39 -22
- package/src/bin/check_txe_oracle_version.ts +67 -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 +317 -0
- package/src/index.ts +113 -201
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +77 -35
- 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 +44 -0
- package/src/oracle/test-resolver/resolver.ts +245 -0
- package/src/oracle/txe_oracle_public_context.ts +82 -27
- package/src/oracle/txe_oracle_registry.ts +556 -0
- package/src/oracle/txe_oracle_top_level_context.ts +555 -189
- 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 +1115 -923
- package/src/state_machine/archiver.ts +81 -132
- package/src/state_machine/dummy_p2p_client.ts +96 -38
- package/src/state_machine/global_variable_builder.ts +28 -10
- package/src/state_machine/index.ts +118 -44
- package/src/state_machine/mock_epoch_cache.ts +53 -14
- package/src/state_machine/synchronizer.ts +32 -12
- package/src/txe_session.ts +727 -123
- package/src/utils/block_creation.ts +50 -16
- package/src/{util → utils}/encoding.ts +9 -3
- package/src/utils/tx_effect_creation.ts +3 -13
- 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 +60 -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.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 -21
- 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 -86
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
package/src/txe_session.ts
CHANGED
|
@@ -1,52 +1,79 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
+
import { openEphemeralStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
AddressStore,
|
|
9
|
+
AnchorBlockStore,
|
|
10
|
+
AnchoredContractData,
|
|
11
|
+
CapsuleService,
|
|
12
|
+
CapsuleStore,
|
|
13
|
+
ContractStore,
|
|
14
|
+
FactService,
|
|
15
|
+
FactStore,
|
|
16
|
+
JobCoordinator,
|
|
17
|
+
NoteService,
|
|
18
|
+
NoteStore,
|
|
19
|
+
PrivateEventStore,
|
|
20
|
+
RecipientTaggingStore,
|
|
21
|
+
SenderTaggingStore,
|
|
22
|
+
TaggingSecretSourcesStore,
|
|
23
|
+
composeHooks,
|
|
14
24
|
} from '@aztec/pxe/server';
|
|
15
25
|
import {
|
|
16
26
|
ExecutionNoteCache,
|
|
17
27
|
ExecutionTaggingIndexCache,
|
|
18
28
|
HashedValuesCache,
|
|
29
|
+
type IMiscOracle,
|
|
19
30
|
type IPrivateExecutionOracle,
|
|
20
31
|
type IUtilityExecutionOracle,
|
|
21
|
-
|
|
32
|
+
LEGACY_ORACLE_REGISTRY,
|
|
33
|
+
Option,
|
|
34
|
+
TransientArrayService,
|
|
22
35
|
UtilityExecutionOracle,
|
|
36
|
+
buildACIRCallback,
|
|
23
37
|
} from '@aztec/pxe/simulator';
|
|
24
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
ExecutionError,
|
|
40
|
+
WASMSimulator,
|
|
41
|
+
createSimulationError,
|
|
42
|
+
extractCallStack,
|
|
43
|
+
resolveAssertionMessageFromError,
|
|
44
|
+
toACVMWitness,
|
|
45
|
+
} from '@aztec/simulator/client';
|
|
46
|
+
import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-registry/constants';
|
|
47
|
+
import { EventSelector, FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
25
48
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
26
49
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
27
|
-
import {
|
|
28
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
50
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
29
51
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
30
52
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
31
|
-
import {
|
|
32
|
-
import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
|
|
53
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
54
|
+
import { CallContext, GlobalVariables, OFFCHAIN_MESSAGE_IDENTIFIER, TxContext } from '@aztec/stdlib/tx';
|
|
33
55
|
|
|
34
56
|
import { z } from 'zod';
|
|
35
57
|
|
|
58
|
+
import { DEFAULT_ADDRESS, MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY, MAX_OFFCHAIN_EFFECT_LEN } from './constants.js';
|
|
36
59
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
60
|
+
import {
|
|
61
|
+
type TXETaggingSecretStrategies,
|
|
62
|
+
makeResolveTaggingSecretStrategyHook,
|
|
63
|
+
} from './oracle/tagging_secret_strategy.js';
|
|
37
64
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
65
|
+
import { callTxeLegacyHandler } from './oracle/txe_oracle_registry.js';
|
|
66
|
+
import { TXEOracleTopLevelContext, authorizeAllUtilityCallsHook } from './oracle/txe_oracle_top_level_context.js';
|
|
67
|
+
import { TXE_ORACLE_VERSION_MAJOR, TXE_ORACLE_VERSION_MINOR } from './oracle/txe_oracle_version.js';
|
|
68
|
+
import { TXEPrivateExecutionOracle } from './oracle/txe_private_execution_oracle.js';
|
|
69
|
+
import { RPCTranslator, UnavailableOracleError } from './rpc_translator.js';
|
|
70
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
40
71
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
41
|
-
import
|
|
42
|
-
import {
|
|
43
|
-
import { TXEContractDataProvider } from './util/txe_contract_data_provider.js';
|
|
44
|
-
import {
|
|
45
|
-
getSingleTxBlockRequestHash,
|
|
46
|
-
insertTxEffectIntoWorldTrees,
|
|
47
|
-
makeTXEBlockHeader,
|
|
48
|
-
} from './utils/block_creation.js';
|
|
72
|
+
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
73
|
+
import type { ForeignCallArgs, ForeignCallResult } from './utils/encoding.js';
|
|
49
74
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
75
|
+
import { TXEAccountStore } from './utils/txe_account_store.js';
|
|
76
|
+
import type { TXEArtifactResolver } from './utils/txe_artifact_resolver.js';
|
|
50
77
|
|
|
51
78
|
/**
|
|
52
79
|
* A TXE Session can be in one of four states, which change as the test progresses and different oracles are called.
|
|
@@ -67,7 +94,6 @@ type SessionState =
|
|
|
67
94
|
| {
|
|
68
95
|
name: 'PRIVATE';
|
|
69
96
|
nextBlockGlobalVariables: GlobalVariables;
|
|
70
|
-
protocolNullifier: Fr;
|
|
71
97
|
noteCache: ExecutionNoteCache;
|
|
72
98
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
73
99
|
}
|
|
@@ -100,13 +126,112 @@ export type TXEOracleFunctionName = Exclude<
|
|
|
100
126
|
>;
|
|
101
127
|
|
|
102
128
|
export interface TXESessionStateHandler {
|
|
129
|
+
/** Records the TXE oracle version reported by the Noir test code for diagnostics. */
|
|
130
|
+
setTxeOracleVersion(major: number, minor: number): void;
|
|
131
|
+
|
|
103
132
|
enterTopLevelState(): Promise<void>;
|
|
104
|
-
enterPublicState(contractAddress
|
|
105
|
-
enterPrivateState(
|
|
106
|
-
|
|
133
|
+
enterPublicState(contractAddress: Option<AztecAddress>): Promise<void>;
|
|
134
|
+
enterPrivateState(
|
|
135
|
+
contractAddress: Option<AztecAddress>,
|
|
136
|
+
anchorBlockNumber: Option<BlockNumber>,
|
|
137
|
+
gasSettings: GasSettings,
|
|
138
|
+
): Promise<PrivateContextInputs>;
|
|
139
|
+
enterUtilityState(contractAddress: Option<AztecAddress>): Promise<void>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Executes a top-level private call: runs the private function, drains its offchain effects into the session buffer,
|
|
143
|
+
* commits the job, and (for non-static calls) tags the result with the mined tx hash.
|
|
144
|
+
*/
|
|
145
|
+
executePrivateCall(
|
|
146
|
+
from: Option<AztecAddress>,
|
|
147
|
+
targetContractAddress: AztecAddress,
|
|
148
|
+
functionSelector: FunctionSelector,
|
|
149
|
+
args: Fr[],
|
|
150
|
+
argsHash: Fr,
|
|
151
|
+
isStaticCall: boolean,
|
|
152
|
+
additionalScopes: AztecAddress[],
|
|
153
|
+
authorizedUtilityCallTargets: AztecAddress[],
|
|
154
|
+
gasSettings: GasSettings,
|
|
155
|
+
): Promise<Fr[]>;
|
|
156
|
+
|
|
157
|
+
/** Executes a top-level utility function and commits the job. */
|
|
158
|
+
executeUtilityFunction(
|
|
159
|
+
from: Option<AztecAddress>,
|
|
160
|
+
targetContractAddress: AztecAddress,
|
|
161
|
+
functionSelector: FunctionSelector,
|
|
162
|
+
args: Fr[],
|
|
163
|
+
authorizedUtilityCallTargets: AztecAddress[],
|
|
164
|
+
): Promise<Fr[]>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Executes a top-level public call, commits the job, and (for non-static calls) tags the result with the mined tx
|
|
168
|
+
* hash.
|
|
169
|
+
*/
|
|
170
|
+
executePublicCall(
|
|
171
|
+
from: Option<AztecAddress>,
|
|
172
|
+
targetContractAddress: AztecAddress,
|
|
173
|
+
calldata: Fr[],
|
|
174
|
+
isStaticCall: boolean,
|
|
175
|
+
gasSettings: GasSettings,
|
|
176
|
+
): Promise<Fr[]>;
|
|
177
|
+
|
|
178
|
+
/** Syncs the target contract and returns the private events it emitted matching the given selector and scope. */
|
|
179
|
+
getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Captures a raw offchain effect payload for consumption from test environment. Called by the `emit_offchain_effect`
|
|
183
|
+
* oracle handler whenever a contract function emits an offchain message, at any call depth.
|
|
184
|
+
*/
|
|
185
|
+
recordOffchainEffect(data: Fr[]): void;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Returns the raw offchain effect payloads emitted by the last top-level call. Each payload follows the protocol
|
|
189
|
+
* convention documented on `OFFCHAIN_MESSAGE_IDENTIFIER`, i.e. `[identifier, recipient, ...ciphertext]`. Decoding into
|
|
190
|
+
* `OffchainMessage` structs happens on the Noir side of the test helper. Marks the buffer as queried so the
|
|
191
|
+
* unqueried-messages warning doesn't fire on the next reset.
|
|
192
|
+
*/
|
|
193
|
+
getLastCallOffchainEffects(): { effects: Fr[][] };
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Returns the context of the last top-level call: its tx hash (`Fr.ZERO` if the call was tx-less) and the anchor
|
|
197
|
+
* block timestamp captured at the start of the call. Does *not* mark the buffer as queried — context reads are
|
|
198
|
+
* metadata, not effect consumption.
|
|
199
|
+
*/
|
|
200
|
+
getLastCallContext(): { txHash: Fr; anchorBlockTimestamp: bigint };
|
|
107
201
|
}
|
|
108
202
|
|
|
109
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Session state tracking the most recently completed top-level call: the offchain effect buffer it produced, and the
|
|
205
|
+
* call's context (tx hash + anchor block timestamp). The context is refreshed on every top-level call, independently
|
|
206
|
+
* of whether the call produced offchain effects.
|
|
207
|
+
*/
|
|
208
|
+
interface LastCallState {
|
|
209
|
+
/**
|
|
210
|
+
* Raw offchain effect payloads emitted by the currently-executing (or most recently completed) top-level call. Wiped
|
|
211
|
+
* at the start of every top-level entry point, appended to on every `emit_offchain_effect` oracle invocation.
|
|
212
|
+
*/
|
|
213
|
+
offchainEffects: Fr[][];
|
|
214
|
+
/**
|
|
215
|
+
* Tracks whether the test has queried `effects` since the last reset. If a new top-level call clobbers the buffer
|
|
216
|
+
* without it being queried first, any accumulated messages are lost and we emit a warning so tests don't silently
|
|
217
|
+
* drop delivery.
|
|
218
|
+
*/
|
|
219
|
+
queried: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Tx hash of the most recently completed top-level call, or `Fr.ZERO` if the call was tx-less (context setters,
|
|
222
|
+
* utility execution). Populated by call executor handlers after execution completes.
|
|
223
|
+
*/
|
|
224
|
+
txHash: Fr;
|
|
225
|
+
/**
|
|
226
|
+
* Anchor block timestamp of the most recently completed top-level call, captured from the anchor block header that
|
|
227
|
+
* was active when the call started. Populated by call executor handlers after execution completes.
|
|
228
|
+
*/
|
|
229
|
+
anchorBlockTimestamp: bigint;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function emptyLastCallState(): LastCallState {
|
|
233
|
+
return { offchainEffects: [], queried: false, txHash: Fr.ZERO, anchorBlockTimestamp: 0n };
|
|
234
|
+
}
|
|
110
235
|
|
|
111
236
|
/**
|
|
112
237
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
@@ -115,87 +240,168 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
115
240
|
export class TXESession implements TXESessionStateHandler {
|
|
116
241
|
private state: SessionState = { name: 'TOP_LEVEL' };
|
|
117
242
|
private authwits: Map<string, AuthWitness> = new Map();
|
|
243
|
+
private taggingSecretStrategies: TXETaggingSecretStrategies = new Map();
|
|
244
|
+
private authorizeAllUtilityCallTargets = false;
|
|
245
|
+
private lastCallInfo: LastCallState = emptyLastCallState();
|
|
246
|
+
private txeOracleVersion: { major: number; minor: number } | undefined;
|
|
247
|
+
|
|
248
|
+
private disposed = false;
|
|
118
249
|
|
|
119
250
|
constructor(
|
|
120
251
|
private logger: Logger,
|
|
252
|
+
private sessionStore: AztecAsyncKVStore,
|
|
121
253
|
private stateMachine: TXEStateMachine,
|
|
122
254
|
private oracleHandler:
|
|
255
|
+
| IMiscOracle
|
|
123
256
|
| IUtilityExecutionOracle
|
|
124
257
|
| IPrivateExecutionOracle
|
|
125
258
|
| IAvmExecutionOracle
|
|
126
259
|
| ITxeExecutionOracle,
|
|
127
|
-
private
|
|
260
|
+
private contractStore: ContractStore,
|
|
261
|
+
private noteStore: NoteStore,
|
|
128
262
|
private keyStore: KeyStore,
|
|
129
|
-
private
|
|
130
|
-
private
|
|
263
|
+
private addressStore: AddressStore,
|
|
264
|
+
private accountStore: TXEAccountStore,
|
|
265
|
+
private senderTaggingStore: SenderTaggingStore,
|
|
266
|
+
private recipientTaggingStore: RecipientTaggingStore,
|
|
267
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
268
|
+
private capsuleStore: CapsuleStore,
|
|
269
|
+
private factStore: FactStore,
|
|
270
|
+
private privateEventStore: PrivateEventStore,
|
|
271
|
+
private jobCoordinator: JobCoordinator,
|
|
272
|
+
private currentJobId: string,
|
|
131
273
|
private chainId: Fr,
|
|
132
274
|
private version: Fr,
|
|
133
275
|
private nextBlockTimestamp: bigint,
|
|
134
|
-
private
|
|
276
|
+
private readonly artifactResolver: TXEArtifactResolver,
|
|
277
|
+
private readonly rootPath: string,
|
|
278
|
+
private readonly packageName: string,
|
|
135
279
|
) {}
|
|
136
280
|
|
|
137
|
-
|
|
138
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Tears down the per-session AVM simulator (process pool + CDB server), the `NativeWorldStateService`,
|
|
283
|
+
* and the `txe-session` LMDB. Called via IPC when the dispatcher detects the end of a test. Idempotent.
|
|
284
|
+
*/
|
|
285
|
+
async dispose(): Promise<void> {
|
|
286
|
+
if (this.disposed) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
this.disposed = true;
|
|
290
|
+
// Dispose the AVM pool before the world state: it kills the bb-avm-sim processes so they release their
|
|
291
|
+
// connection to the WSDB server, letting it shut down cleanly. Skipping this leaks a bb-avm-sim process
|
|
292
|
+
// (and keeps its WSDB alive) per session.
|
|
293
|
+
try {
|
|
294
|
+
await this.stateMachine.synchronizer.closeIpc();
|
|
295
|
+
} catch (err) {
|
|
296
|
+
this.logger.warn(`Error closing AVM simulator during session dispose`, err);
|
|
297
|
+
}
|
|
298
|
+
try {
|
|
299
|
+
await this.stateMachine.synchronizer.nativeWorldStateService.close();
|
|
300
|
+
} catch (err) {
|
|
301
|
+
this.logger.warn(`Error closing native world state during session dispose`, err);
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
await this.sessionStore.close();
|
|
305
|
+
} catch (err) {
|
|
306
|
+
this.logger.warn(`Error closing session LMDB during dispose`, err);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
static async init(
|
|
311
|
+
contractStore: ContractStore,
|
|
312
|
+
artifactResolver: TXEArtifactResolver,
|
|
313
|
+
rootPath: string,
|
|
314
|
+
packageName: string,
|
|
315
|
+
) {
|
|
316
|
+
// Size LMDB's reader slots to the libuv pool (capped to 2 in bin/index.ts via
|
|
317
|
+
// HARDWARE_CONCURRENCY): each native LMDB read needs a libuv worker thread to run, so any
|
|
318
|
+
// slot beyond the pool size would sit idle while still consuming a semaphore + reader-table
|
|
319
|
+
// entry per session.
|
|
320
|
+
const store = await openEphemeralStore('txe-session', undefined, 2);
|
|
139
321
|
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
322
|
+
const addressStore = new AddressStore(store);
|
|
323
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
324
|
+
const noteStore = new NoteStore(store);
|
|
325
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
326
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
327
|
+
const taggingSecretSourcesStore = new TaggingSecretSourcesStore(store);
|
|
328
|
+
const capsuleStore = new CapsuleStore(store);
|
|
329
|
+
const factStore = new FactStore(store);
|
|
146
330
|
const keyStore = new KeyStore(store);
|
|
147
|
-
const
|
|
331
|
+
const accountStore = new TXEAccountStore(store);
|
|
148
332
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
333
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
334
|
+
jobCoordinator.registerStores([
|
|
335
|
+
capsuleStore,
|
|
336
|
+
factStore,
|
|
337
|
+
senderTaggingStore,
|
|
338
|
+
recipientTaggingStore,
|
|
339
|
+
privateEventStore,
|
|
340
|
+
noteStore,
|
|
341
|
+
]);
|
|
154
342
|
|
|
155
|
-
const
|
|
343
|
+
const archiver = new TXEArchiver(store);
|
|
344
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
345
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
156
346
|
|
|
157
347
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
158
348
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
159
349
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
160
350
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
contractDataProvider,
|
|
165
|
-
noteDataProvider,
|
|
166
|
-
capsuleDataProvider,
|
|
167
|
-
stateMachine.syncDataProvider,
|
|
168
|
-
taggingDataProvider,
|
|
169
|
-
addressDataProvider,
|
|
170
|
-
privateEventDataProvider,
|
|
171
|
-
);
|
|
351
|
+
const initialJobId = jobCoordinator.beginJob();
|
|
352
|
+
|
|
353
|
+
const logger = createLogger('txe:session');
|
|
172
354
|
|
|
173
355
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
174
356
|
stateMachine,
|
|
175
|
-
|
|
357
|
+
contractStore,
|
|
358
|
+
noteStore,
|
|
176
359
|
keyStore,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
360
|
+
addressStore,
|
|
361
|
+
accountStore,
|
|
362
|
+
senderTaggingStore,
|
|
363
|
+
recipientTaggingStore,
|
|
364
|
+
taggingSecretSourcesStore,
|
|
365
|
+
capsuleStore,
|
|
366
|
+
factStore,
|
|
367
|
+
privateEventStore,
|
|
180
368
|
nextBlockTimestamp,
|
|
181
369
|
version,
|
|
182
370
|
chainId,
|
|
183
371
|
new Map(),
|
|
372
|
+
new Map(),
|
|
373
|
+
false, // authorizeAllUtilityCallTargets
|
|
374
|
+
artifactResolver,
|
|
375
|
+
rootPath,
|
|
376
|
+
packageName,
|
|
184
377
|
);
|
|
185
|
-
|
|
378
|
+
|
|
379
|
+
await topLevelOracleHandler.mineDeploymentNullifiers([STANDARD_AUTH_REGISTRY_ADDRESS]);
|
|
186
380
|
|
|
187
381
|
return new TXESession(
|
|
188
|
-
|
|
382
|
+
logger,
|
|
383
|
+
store,
|
|
189
384
|
stateMachine,
|
|
190
385
|
topLevelOracleHandler,
|
|
191
|
-
|
|
386
|
+
contractStore,
|
|
387
|
+
noteStore,
|
|
192
388
|
keyStore,
|
|
193
|
-
|
|
194
|
-
|
|
389
|
+
addressStore,
|
|
390
|
+
accountStore,
|
|
391
|
+
senderTaggingStore,
|
|
392
|
+
recipientTaggingStore,
|
|
393
|
+
taggingSecretSourcesStore,
|
|
394
|
+
capsuleStore,
|
|
395
|
+
factStore,
|
|
396
|
+
privateEventStore,
|
|
397
|
+
jobCoordinator,
|
|
398
|
+
initialJobId,
|
|
195
399
|
version,
|
|
196
400
|
chainId,
|
|
197
401
|
nextBlockTimestamp,
|
|
198
|
-
|
|
402
|
+
artifactResolver,
|
|
403
|
+
rootPath,
|
|
404
|
+
packageName,
|
|
199
405
|
);
|
|
200
406
|
}
|
|
201
407
|
|
|
@@ -207,6 +413,18 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
207
413
|
*/
|
|
208
414
|
processFunction(functionName: TXEOracleFunctionName, inputs: ForeignCallArgs): Promise<ForeignCallResult> {
|
|
209
415
|
try {
|
|
416
|
+
// Oracles retired into the PXE legacy registry have no translator method; dispatch them through the same
|
|
417
|
+
// buildACIRCallback legacy path that contract execution uses, keeping TXE's two oracle paths in sync.
|
|
418
|
+
// Use an own-property check: `in` would match inherited `Object.prototype` keys (e.g. `constructor`), routing
|
|
419
|
+
// them into the legacy path instead of letting them fall through to the unknown-oracle error.
|
|
420
|
+
if (Object.hasOwn(LEGACY_ORACLE_REGISTRY, functionName)) {
|
|
421
|
+
return callTxeLegacyHandler(
|
|
422
|
+
functionName,
|
|
423
|
+
inputs,
|
|
424
|
+
this.oracleHandler as Parameters<typeof buildACIRCallback>[0],
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
210
428
|
const translator = new RPCTranslator(this, this.oracleHandler) as any;
|
|
211
429
|
// We perform a runtime validation to check that the function name corresponds to a real oracle handler.
|
|
212
430
|
const validatedFunctionName = z
|
|
@@ -217,7 +435,28 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
217
435
|
return translator[validatedFunctionName](...inputs);
|
|
218
436
|
} catch (error) {
|
|
219
437
|
if (error instanceof z.ZodError) {
|
|
220
|
-
|
|
438
|
+
let versionHint: string;
|
|
439
|
+
if (!this.txeOracleVersion) {
|
|
440
|
+
versionHint =
|
|
441
|
+
' The test appears to use an older version of Aztec.nr that does not' +
|
|
442
|
+
' support test environment oracle versioning. Update Aztec.nr to a compatible version.' +
|
|
443
|
+
' See https://docs.aztec.network/errors/12';
|
|
444
|
+
} else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
|
|
445
|
+
versionHint =
|
|
446
|
+
` The test uses Aztec.nr test oracle version` +
|
|
447
|
+
` ${this.txeOracleVersion.major}.${this.txeOracleVersion.minor}, but this test environment` +
|
|
448
|
+
` only supports up to ${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}.` +
|
|
449
|
+
` Upgrade the Aztec CLI to a compatible version.` +
|
|
450
|
+
` See https://docs.aztec.network/errors/12`;
|
|
451
|
+
} else {
|
|
452
|
+
versionHint =
|
|
453
|
+
` The test's oracle version (${this.txeOracleVersion.major}.${this.txeOracleVersion.minor})` +
|
|
454
|
+
` is compatible with this test environment` +
|
|
455
|
+
` (${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}), so this oracle should be` +
|
|
456
|
+
` available. This is an unexpected error, please report it.` +
|
|
457
|
+
` See https://docs.aztec.network/errors/13`;
|
|
458
|
+
}
|
|
459
|
+
throw new Error(`Unknown oracle '${functionName}'.${versionHint}`);
|
|
221
460
|
} else if (error instanceof Error) {
|
|
222
461
|
throw new Error(
|
|
223
462
|
`Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`,
|
|
@@ -230,6 +469,195 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
230
469
|
}
|
|
231
470
|
}
|
|
232
471
|
|
|
472
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */
|
|
473
|
+
private async cycleJob(): Promise<string> {
|
|
474
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
475
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
476
|
+
return this.currentJobId;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
private resetLastCall(): void {
|
|
480
|
+
const notQueriedMessageCount = this.lastCallInfo.queried
|
|
481
|
+
? 0
|
|
482
|
+
: this.lastCallInfo.offchainEffects.filter(payload => payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
|
|
483
|
+
if (notQueriedMessageCount > 0) {
|
|
484
|
+
this.logger.warn(
|
|
485
|
+
`Dropping ${notQueriedMessageCount} unqueried offchain message(s) from the previous top-level call. ` +
|
|
486
|
+
`To deliver them, call \`env.offchain_messages()\` and forward the result to the recipient contract's ` +
|
|
487
|
+
`\`offchain_receive\` utility before issuing another top-level call. To intentionally discard, assign ` +
|
|
488
|
+
`to \`let _ = env.offchain_messages()\` to silence this warning.`,
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
this.lastCallInfo = emptyLastCallState();
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
recordOffchainEffect(data: Fr[]): void {
|
|
495
|
+
this.lastCallInfo.offchainEffects.push(data);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
private setLastCallContext(txHash: Fr, anchorBlockTimestamp: bigint): void {
|
|
499
|
+
this.lastCallInfo.txHash = txHash;
|
|
500
|
+
this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
private async withTopLevelCallTracking<T>(work: () => Promise<{ result: T; txHash?: Fr }>): Promise<T> {
|
|
504
|
+
this.resetLastCall();
|
|
505
|
+
// Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
|
|
506
|
+
// side effect, and that block's timestamp should not be attributed to this call's anchor.
|
|
507
|
+
const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables
|
|
508
|
+
.timestamp;
|
|
509
|
+
const { result, txHash } = await work();
|
|
510
|
+
this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
|
|
511
|
+
return result;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
getLastCallOffchainEffects(): { effects: Fr[][] } {
|
|
515
|
+
this.lastCallInfo.queried = true;
|
|
516
|
+
const effects = this.lastCallInfo.offchainEffects;
|
|
517
|
+
|
|
518
|
+
if (effects.length > MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY) {
|
|
519
|
+
throw new Error(`${effects.length} offchain effects exceed max ${MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY}`);
|
|
520
|
+
}
|
|
521
|
+
if (effects.some(e => e.length > MAX_OFFCHAIN_EFFECT_LEN)) {
|
|
522
|
+
throw new Error(`Some offchain effect has length larger than max ${MAX_OFFCHAIN_EFFECT_LEN}`);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return { effects };
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
getLastCallContext(): { txHash: Fr; anchorBlockTimestamp: bigint } {
|
|
529
|
+
const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
|
|
530
|
+
return { txHash, anchorBlockTimestamp };
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
async executePrivateCall(
|
|
534
|
+
from: Option<AztecAddress>,
|
|
535
|
+
targetContractAddress: AztecAddress,
|
|
536
|
+
functionSelector: FunctionSelector,
|
|
537
|
+
args: Fr[],
|
|
538
|
+
argsHash: Fr,
|
|
539
|
+
isStaticCall: boolean,
|
|
540
|
+
additionalScopes: AztecAddress[],
|
|
541
|
+
authorizedUtilityCallTargets: AztecAddress[],
|
|
542
|
+
gasSettings: GasSettings,
|
|
543
|
+
): Promise<Fr[]> {
|
|
544
|
+
const handler = this.handlerAsTxe();
|
|
545
|
+
return await this.withTopLevelCallTracking(async () => {
|
|
546
|
+
const { returnValues, offchainEffects } = await handler.privateCallNewFlow(
|
|
547
|
+
from?.value,
|
|
548
|
+
targetContractAddress,
|
|
549
|
+
functionSelector,
|
|
550
|
+
args,
|
|
551
|
+
argsHash,
|
|
552
|
+
isStaticCall,
|
|
553
|
+
additionalScopes,
|
|
554
|
+
this.currentJobId,
|
|
555
|
+
authorizedUtilityCallTargets,
|
|
556
|
+
gasSettings,
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
// Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than round-tripping
|
|
560
|
+
// them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty at this point. Drain the effects
|
|
561
|
+
// from the execution tree into the session buffer so the next `env.offchain_messages()` call in the test sees
|
|
562
|
+
// them.
|
|
563
|
+
for (const data of offchainEffects) {
|
|
564
|
+
this.recordOffchainEffect(data);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
await this.cycleJob();
|
|
568
|
+
|
|
569
|
+
if (isStaticCall) {
|
|
570
|
+
// Static calls revert their checkpoint and mine no block, so there is no tx hash to tag offchain effects
|
|
571
|
+
// with. Querying `getLastTxEffects()` here would return an unrelated predecessor tx.
|
|
572
|
+
return { result: returnValues };
|
|
573
|
+
}
|
|
574
|
+
const { txHash } = await handler.getLastTxEffects();
|
|
575
|
+
return { result: returnValues, txHash: txHash.hash };
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
async executeUtilityFunction(
|
|
580
|
+
from: Option<AztecAddress>,
|
|
581
|
+
targetContractAddress: AztecAddress,
|
|
582
|
+
functionSelector: FunctionSelector,
|
|
583
|
+
args: Fr[],
|
|
584
|
+
authorizedUtilityCallTargets: AztecAddress[],
|
|
585
|
+
): Promise<Fr[]> {
|
|
586
|
+
const handler = this.handlerAsTxe();
|
|
587
|
+
return await this.withTopLevelCallTracking(async () => {
|
|
588
|
+
const returnValues = await handler.executeUtilityFunction(
|
|
589
|
+
from?.value,
|
|
590
|
+
targetContractAddress,
|
|
591
|
+
functionSelector,
|
|
592
|
+
args,
|
|
593
|
+
this.currentJobId,
|
|
594
|
+
authorizedUtilityCallTargets,
|
|
595
|
+
);
|
|
596
|
+
|
|
597
|
+
await this.cycleJob();
|
|
598
|
+
|
|
599
|
+
return { result: returnValues };
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
async executePublicCall(
|
|
604
|
+
from: Option<AztecAddress>,
|
|
605
|
+
targetContractAddress: AztecAddress,
|
|
606
|
+
calldata: Fr[],
|
|
607
|
+
isStaticCall: boolean,
|
|
608
|
+
gasSettings: GasSettings,
|
|
609
|
+
): Promise<Fr[]> {
|
|
610
|
+
const handler = this.handlerAsTxe();
|
|
611
|
+
return await this.withTopLevelCallTracking(async () => {
|
|
612
|
+
const returnValues = await handler.publicCallNewFlow(
|
|
613
|
+
from?.value,
|
|
614
|
+
targetContractAddress,
|
|
615
|
+
calldata,
|
|
616
|
+
isStaticCall,
|
|
617
|
+
gasSettings,
|
|
618
|
+
);
|
|
619
|
+
|
|
620
|
+
await this.cycleJob();
|
|
621
|
+
|
|
622
|
+
if (isStaticCall) {
|
|
623
|
+
// See the equivalent branch in `executePrivateCall`.
|
|
624
|
+
return { result: returnValues };
|
|
625
|
+
}
|
|
626
|
+
const { txHash } = await handler.getLastTxEffects();
|
|
627
|
+
return { result: returnValues, txHash: txHash.hash };
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]> {
|
|
632
|
+
const handler = this.handlerAsTxe();
|
|
633
|
+
await handler.syncContractNonOracleMethod(contractAddress, scope, this.currentJobId);
|
|
634
|
+
// Cycle the job to commit the stores after the contract sync.
|
|
635
|
+
await this.cycleJob();
|
|
636
|
+
return handler.getPrivateEvents(selector, contractAddress, scope);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
private handlerAsTxe(): ITxeExecutionOracle {
|
|
640
|
+
if (!('isTxe' in this.oracleHandler)) {
|
|
641
|
+
throw new UnavailableOracleError('Txe');
|
|
642
|
+
}
|
|
643
|
+
return this.oracleHandler;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
setTxeOracleVersion(major: number, minor: number): void {
|
|
647
|
+
if (major !== TXE_ORACLE_VERSION_MAJOR) {
|
|
648
|
+
const hint =
|
|
649
|
+
major > TXE_ORACLE_VERSION_MAJOR
|
|
650
|
+
? 'The test was compiled with a newer version of Aztec.nr than your test environment supports. Upgrade your test environment to a compatible version.'
|
|
651
|
+
: 'The test was compiled with an older version of Aztec.nr than your test environment supports. Recompile the test with a compatible version of Aztec.nr.';
|
|
652
|
+
throw new Error(
|
|
653
|
+
`Incompatible test environment version: ${hint} See https://docs.aztec.network/errors/12 (expected test oracle major version ${TXE_ORACLE_VERSION_MAJOR}, got ${major})`,
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
this.txeOracleVersion = { major, minor };
|
|
658
|
+
this.logger.debug(`Test compiled with test oracle version ${major}.${minor}`);
|
|
659
|
+
}
|
|
660
|
+
|
|
233
661
|
async enterTopLevelState() {
|
|
234
662
|
switch (this.state.name) {
|
|
235
663
|
case 'PRIVATE': {
|
|
@@ -252,17 +680,31 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
252
680
|
}
|
|
253
681
|
}
|
|
254
682
|
|
|
683
|
+
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
684
|
+
await this.cycleJob();
|
|
685
|
+
|
|
255
686
|
this.oracleHandler = new TXEOracleTopLevelContext(
|
|
256
687
|
this.stateMachine,
|
|
257
|
-
this.
|
|
688
|
+
this.contractStore,
|
|
689
|
+
this.noteStore,
|
|
258
690
|
this.keyStore,
|
|
259
|
-
this.
|
|
260
|
-
this.
|
|
261
|
-
this.
|
|
691
|
+
this.addressStore,
|
|
692
|
+
this.accountStore,
|
|
693
|
+
this.senderTaggingStore,
|
|
694
|
+
this.recipientTaggingStore,
|
|
695
|
+
this.taggingSecretSourcesStore,
|
|
696
|
+
this.capsuleStore,
|
|
697
|
+
this.factStore,
|
|
698
|
+
this.privateEventStore,
|
|
262
699
|
this.nextBlockTimestamp,
|
|
263
700
|
this.version,
|
|
264
701
|
this.chainId,
|
|
265
702
|
this.authwits,
|
|
703
|
+
this.taggingSecretStrategies,
|
|
704
|
+
this.authorizeAllUtilityCallTargets,
|
|
705
|
+
this.artifactResolver,
|
|
706
|
+
this.rootPath,
|
|
707
|
+
this.packageName,
|
|
266
708
|
);
|
|
267
709
|
|
|
268
710
|
this.state = { name: 'TOP_LEVEL' };
|
|
@@ -270,23 +712,25 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
270
712
|
}
|
|
271
713
|
|
|
272
714
|
async enterPrivateState(
|
|
273
|
-
|
|
274
|
-
|
|
715
|
+
contractAddressOpt: Option<AztecAddress>,
|
|
716
|
+
anchorBlockNumberOpt: Option<BlockNumber>,
|
|
717
|
+
gasSettings: GasSettings,
|
|
275
718
|
): Promise<PrivateContextInputs> {
|
|
719
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
720
|
+
const anchorBlockNumber = anchorBlockNumberOpt?.value;
|
|
276
721
|
this.exitTopLevelState();
|
|
277
|
-
|
|
278
|
-
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
279
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
280
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
281
|
-
// be removed from the database.
|
|
282
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
283
|
-
await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
|
|
722
|
+
this.resetLastCall();
|
|
284
723
|
|
|
285
724
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
286
725
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
287
726
|
// a single transaction with the effects of what was done in the test.
|
|
288
|
-
const anchorBlock = await this.stateMachine.node.
|
|
289
|
-
|
|
727
|
+
const anchorBlock = await this.stateMachine.node.getBlock(anchorBlockNumber ?? 'latest').then(b => b?.header);
|
|
728
|
+
|
|
729
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
730
|
+
contractAddress,
|
|
731
|
+
await this.keyStore.getAccounts(),
|
|
732
|
+
);
|
|
733
|
+
const latestBlock = await this.stateMachine.node.getBlock('latest').then(b => b?.header);
|
|
290
734
|
|
|
291
735
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
292
736
|
blockNumber: BlockNumber(latestBlock!.globalVariables.blockNumber + 1),
|
|
@@ -300,68 +744,157 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
300
744
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
301
745
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
302
746
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
747
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
748
|
+
const transientArrayService = new TransientArrayService();
|
|
749
|
+
const anchoredContractData = new AnchoredContractData(
|
|
750
|
+
this.contractStore,
|
|
751
|
+
this.stateMachine.contractClassService,
|
|
307
752
|
anchorBlock!,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
753
|
+
);
|
|
754
|
+
this.oracleHandler = new TXEPrivateExecutionOracle({
|
|
755
|
+
argsHash: Fr.ZERO,
|
|
756
|
+
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
757
|
+
txRequestSalt: Fr.ZERO,
|
|
758
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
759
|
+
anchorBlockHeader: anchorBlock!,
|
|
760
|
+
utilityExecutor,
|
|
761
|
+
authWitnesses: [],
|
|
762
|
+
capsules: [],
|
|
763
|
+
executionCache: new HashedValuesCache(),
|
|
311
764
|
noteCache,
|
|
312
765
|
taggingIndexCache,
|
|
313
|
-
|
|
314
|
-
|
|
766
|
+
anchoredContractData,
|
|
767
|
+
noteStore: this.noteStore,
|
|
768
|
+
keyStore: this.keyStore,
|
|
769
|
+
addressStore: this.addressStore,
|
|
770
|
+
aztecNode: this.stateMachine.node,
|
|
771
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
772
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
773
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
774
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
775
|
+
factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
|
|
776
|
+
privateEventStore: this.privateEventStore,
|
|
777
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
778
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
779
|
+
jobId: this.currentJobId,
|
|
780
|
+
scopes: await this.keyStore.getAccounts(),
|
|
781
|
+
txResolver: this.stateMachine.txResolver,
|
|
782
|
+
simulator: new WASMSimulator(),
|
|
783
|
+
hooks: composeHooks({
|
|
784
|
+
resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
|
|
785
|
+
authorizeUtilityCall: this.authorizeAllUtilityCallTargets ? authorizeAllUtilityCallsHook : undefined,
|
|
786
|
+
}),
|
|
787
|
+
transientArrayService,
|
|
788
|
+
});
|
|
315
789
|
|
|
316
790
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
317
791
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
318
792
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
319
793
|
// will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
|
|
320
794
|
// execution finishes.
|
|
321
|
-
this.state = { name: 'PRIVATE', nextBlockGlobalVariables,
|
|
795
|
+
this.state = { name: 'PRIVATE', nextBlockGlobalVariables, noteCache, taggingIndexCache };
|
|
322
796
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
323
797
|
|
|
324
|
-
|
|
798
|
+
// Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
|
|
799
|
+
// via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
|
|
800
|
+
this.setLastCallContext(Fr.ZERO, anchorBlock!.globalVariables.timestamp);
|
|
801
|
+
|
|
802
|
+
return (this.oracleHandler as TXEPrivateExecutionOracle).getPrivateContextInputs();
|
|
325
803
|
}
|
|
326
804
|
|
|
327
|
-
async enterPublicState(
|
|
805
|
+
async enterPublicState(contractAddressOpt: Option<AztecAddress>) {
|
|
806
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
328
807
|
this.exitTopLevelState();
|
|
808
|
+
this.resetLastCall();
|
|
329
809
|
|
|
330
810
|
// The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
|
|
331
811
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
332
|
-
const
|
|
812
|
+
const latestHeader = (await this.stateMachine.node.getBlockData('latest'))!.header;
|
|
333
813
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
334
|
-
blockNumber: BlockNumber(
|
|
814
|
+
blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
|
|
335
815
|
timestamp: this.nextBlockTimestamp,
|
|
336
816
|
version: this.version,
|
|
337
817
|
chainId: this.chainId,
|
|
338
818
|
});
|
|
339
819
|
|
|
340
820
|
this.oracleHandler = new TXEOraclePublicContext(
|
|
341
|
-
contractAddress
|
|
821
|
+
contractAddress,
|
|
342
822
|
await this.stateMachine.synchronizer.nativeWorldStateService.fork(),
|
|
343
823
|
getSingleTxBlockRequestHash(globalVariables.blockNumber),
|
|
344
824
|
globalVariables,
|
|
825
|
+
this.contractStore,
|
|
345
826
|
);
|
|
346
827
|
|
|
347
828
|
this.state = { name: 'PUBLIC' };
|
|
348
829
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
830
|
+
|
|
831
|
+
// Public state is anchored at the latest block.
|
|
832
|
+
this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
|
|
349
833
|
}
|
|
350
834
|
|
|
351
|
-
async enterUtilityState(
|
|
835
|
+
async enterUtilityState(contractAddressOpt: Option<AztecAddress>) {
|
|
836
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
352
837
|
this.exitTopLevelState();
|
|
838
|
+
this.resetLastCall();
|
|
839
|
+
|
|
840
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
353
841
|
|
|
354
842
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
355
843
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
356
844
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
357
845
|
// be removed from the database.
|
|
358
846
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
359
|
-
await
|
|
847
|
+
await new NoteService(
|
|
848
|
+
this.noteStore,
|
|
849
|
+
this.stateMachine.node,
|
|
850
|
+
anchorBlockHeader,
|
|
851
|
+
this.currentJobId,
|
|
852
|
+
).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
360
853
|
|
|
361
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
854
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
855
|
+
callContext: CallContext.from({
|
|
856
|
+
msgSender: AztecAddress.NULL_MSG_SENDER,
|
|
857
|
+
contractAddress,
|
|
858
|
+
// No specific function is being executed in this inlined utility context, hence the empty selector.
|
|
859
|
+
functionSelector: FunctionSelector.empty(),
|
|
860
|
+
isStaticCall: true,
|
|
861
|
+
}),
|
|
862
|
+
authWitnesses: [],
|
|
863
|
+
capsules: [],
|
|
864
|
+
anchorBlockHeader,
|
|
865
|
+
anchoredContractData: new AnchoredContractData(
|
|
866
|
+
this.contractStore,
|
|
867
|
+
this.stateMachine.contractClassService,
|
|
868
|
+
anchorBlockHeader,
|
|
869
|
+
),
|
|
870
|
+
noteStore: this.noteStore,
|
|
871
|
+
keyStore: this.keyStore,
|
|
872
|
+
addressStore: this.addressStore,
|
|
873
|
+
aztecNode: this.stateMachine.node,
|
|
874
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
875
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
876
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
877
|
+
factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
|
|
878
|
+
privateEventStore: this.privateEventStore,
|
|
879
|
+
txResolver: this.stateMachine.txResolver,
|
|
880
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
881
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
882
|
+
jobId: this.currentJobId,
|
|
883
|
+
scopes: await this.keyStore.getAccounts(),
|
|
884
|
+
simulator: new WASMSimulator(),
|
|
885
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlockHeader),
|
|
886
|
+
hooks: composeHooks({
|
|
887
|
+
authorizeUtilityCall: this.authorizeAllUtilityCallTargets ? authorizeAllUtilityCallsHook : undefined,
|
|
888
|
+
}),
|
|
889
|
+
// Execution-tree root (top-level utility run): own store; nested frames inherit it.
|
|
890
|
+
transientArrayService: new TransientArrayService(),
|
|
891
|
+
});
|
|
362
892
|
|
|
363
893
|
this.state = { name: 'UTILITY' };
|
|
364
894
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
895
|
+
|
|
896
|
+
// Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
|
|
897
|
+
this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
|
|
365
898
|
}
|
|
366
899
|
|
|
367
900
|
private exitTopLevelState() {
|
|
@@ -370,15 +903,23 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
370
903
|
}
|
|
371
904
|
|
|
372
905
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
//
|
|
379
|
-
// the
|
|
380
|
-
|
|
381
|
-
|
|
906
|
+
// them, the top level context does most of its work as it goes: it creates empty blocks (via `advanceBlocksBy`
|
|
907
|
+
// and `deploy`), creates blocks with transactions (via `privateCallNewFlow` and `publicCallNewFlow`), adds
|
|
908
|
+
// accounts to PXE (via `addAccount`), etc. This is a slight inconsistency in the working model of this class, but
|
|
909
|
+
// is not too bad. The `close` call below therefore only hands back the session-scoped values that a test
|
|
910
|
+
// sets directly at the top level, outside any contract execution (e.g. via `advanceTimestampBy`,
|
|
911
|
+
// `addAuthWitness`, `setTaggingSecretStrategies`). The oracle handler is discarded on every state transition,
|
|
912
|
+
// so the session must seed these values into the contexts it creates later.
|
|
913
|
+
|
|
914
|
+
// TODO: persisting authwits this way is quite unfortunate: they create a temporary utility context that would
|
|
915
|
+
// otherwise reset them, so we'd not be able to pass more than one per execution. Ideally authwits would be passed
|
|
916
|
+
// alongside a contract call instead of pre-seeded.
|
|
917
|
+
({
|
|
918
|
+
nextBlockTimestamp: this.nextBlockTimestamp,
|
|
919
|
+
authwits: this.authwits,
|
|
920
|
+
taggingSecretStrategies: this.taggingSecretStrategies,
|
|
921
|
+
authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets,
|
|
922
|
+
} = (this.oracleHandler as TXEOracleTopLevelContext).close());
|
|
382
923
|
}
|
|
383
924
|
|
|
384
925
|
private async exitPrivateState() {
|
|
@@ -392,21 +933,14 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
392
933
|
|
|
393
934
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
394
935
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
this.state.protocolNullifier,
|
|
398
|
-
this.state.nextBlockGlobalVariables.blockNumber,
|
|
399
|
-
);
|
|
936
|
+
|
|
937
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
400
938
|
|
|
401
939
|
// We build a block holding just this transaction
|
|
402
940
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
403
941
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
404
942
|
|
|
405
|
-
const block =
|
|
406
|
-
makeAppendOnlyTreeSnapshot(),
|
|
407
|
-
await makeTXEBlockHeader(forkedWorldTrees, this.state.nextBlockGlobalVariables),
|
|
408
|
-
new Body([txEffect]),
|
|
409
|
-
);
|
|
943
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [txEffect]);
|
|
410
944
|
await this.stateMachine.handleL2Block(block);
|
|
411
945
|
|
|
412
946
|
await forkedWorldTrees.close();
|
|
@@ -431,4 +965,74 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
431
965
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
432
966
|
}
|
|
433
967
|
}
|
|
968
|
+
|
|
969
|
+
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
970
|
+
return async (call: FunctionCall, scopes: AztecAddress[]) => {
|
|
971
|
+
const anchoredContractData = new AnchoredContractData(
|
|
972
|
+
this.contractStore,
|
|
973
|
+
this.stateMachine.contractClassService,
|
|
974
|
+
anchorBlock!,
|
|
975
|
+
);
|
|
976
|
+
const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(
|
|
977
|
+
call.to,
|
|
978
|
+
call.selector,
|
|
979
|
+
);
|
|
980
|
+
if (!entryPointArtifact) {
|
|
981
|
+
throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
|
|
982
|
+
}
|
|
983
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
984
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
try {
|
|
988
|
+
const simulator = new WASMSimulator();
|
|
989
|
+
const oracle = new UtilityExecutionOracle({
|
|
990
|
+
callContext: CallContext.from({
|
|
991
|
+
msgSender: AztecAddress.NULL_MSG_SENDER,
|
|
992
|
+
contractAddress: call.to,
|
|
993
|
+
functionSelector: call.selector,
|
|
994
|
+
isStaticCall: true,
|
|
995
|
+
}),
|
|
996
|
+
authWitnesses: [],
|
|
997
|
+
capsules: [],
|
|
998
|
+
anchorBlockHeader: anchorBlock!,
|
|
999
|
+
anchoredContractData,
|
|
1000
|
+
noteStore: this.noteStore,
|
|
1001
|
+
keyStore: this.keyStore,
|
|
1002
|
+
addressStore: this.addressStore,
|
|
1003
|
+
aztecNode: this.stateMachine.node,
|
|
1004
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
1005
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
1006
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
1007
|
+
factService: new FactService(this.factStore, scopes),
|
|
1008
|
+
privateEventStore: this.privateEventStore,
|
|
1009
|
+
txResolver: this.stateMachine.txResolver,
|
|
1010
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
1011
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
1012
|
+
jobId: this.currentJobId,
|
|
1013
|
+
scopes,
|
|
1014
|
+
simulator,
|
|
1015
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlock),
|
|
1016
|
+
// Top-level utility entrypoint: gets a fresh store. Nested frames inherit it via UtilityExecutionOracle.
|
|
1017
|
+
transientArrayService: new TransientArrayService(),
|
|
1018
|
+
});
|
|
1019
|
+
await simulator
|
|
1020
|
+
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle))
|
|
1021
|
+
.catch((err: Error) => {
|
|
1022
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
1023
|
+
throw new ExecutionError(
|
|
1024
|
+
err.message,
|
|
1025
|
+
{
|
|
1026
|
+
contractAddress: call.to,
|
|
1027
|
+
functionSelector: call.selector,
|
|
1028
|
+
},
|
|
1029
|
+
extractCallStack(err, entryPointArtifact.debug),
|
|
1030
|
+
{ cause: err },
|
|
1031
|
+
);
|
|
1032
|
+
});
|
|
1033
|
+
} catch (err) {
|
|
1034
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
434
1038
|
}
|