@aztec/txe 0.0.1-commit.9372f48 → 0.0.1-commit.949a33fd8
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +88 -54
- package/dest/oracle/interfaces.d.ts +32 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +12 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +30 -23
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +160 -61
- package/dest/rpc_translator.d.ts +129 -83
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +482 -170
- package/dest/state_machine/archiver.d.ts +3 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +9 -8
- package/dest/state_machine/dummy_p2p_client.d.ts +18 -13
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +33 -18
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- package/dest/state_machine/index.d.ts +7 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +20 -11
- package/dest/state_machine/mock_epoch_cache.d.ts +20 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +39 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +54 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +156 -28
- package/dest/util/encoding.d.ts +71 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +6 -25
- package/dest/utils/block_creation.d.ts +1 -1
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +3 -1
- package/package.json +15 -15
- package/src/index.ts +89 -52
- package/src/oracle/interfaces.ts +33 -32
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +176 -111
- package/src/rpc_translator.ts +551 -197
- package/src/state_machine/archiver.ts +8 -5
- package/src/state_machine/dummy_p2p_client.ts +46 -24
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +33 -10
- package/src/state_machine/mock_epoch_cache.ts +51 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +221 -76
- package/src/util/encoding.ts +5 -0
- package/src/util/txe_public_contract_data_source.ts +10 -38
- package/src/utils/block_creation.ts +3 -1
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
2
|
+
import type { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
3
3
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations, SnapshotDataKeys, WorldStateSynchronizer, WorldStateSynchronizerStatus } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
5
5
|
export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
@@ -9,12 +9,12 @@ export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
9
9
|
static create(): Promise<TXESynchronizer>;
|
|
10
10
|
handleL2Block(block: L2Block): Promise<void>;
|
|
11
11
|
/**
|
|
12
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
12
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
13
13
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
14
|
-
* @param
|
|
14
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
|
|
15
15
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
16
16
|
*/
|
|
17
|
-
syncImmediate(_minBlockNumber?: BlockNumber,
|
|
17
|
+
syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber>;
|
|
18
18
|
/** Returns an instance of MerkleTreeAdminOperations that will not include uncommitted data. */
|
|
19
19
|
getCommitted(): MerkleTreeReadOperations;
|
|
20
20
|
/** Forks the world state at the given block number, defaulting to the latest one. */
|
|
@@ -30,4 +30,4 @@ export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
30
30
|
resumeSync(): void;
|
|
31
31
|
clear(): Promise<void>;
|
|
32
32
|
}
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RhdGVfbWFjaGluZS9zeW5jaHJvbml6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxPQUFPLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM5RCxPQUFPLEtBQUssRUFDVix3QkFBd0IsRUFDeEIseUJBQXl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UFJLE9BQU8sQ0FBQyw0QkFBNEIsQ0FBQyxDQUVyRDtJQUVNLElBQUksSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBRTNCO0lBRU0sUUFBUSxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFL0I7SUFFTSxVQUFVLElBQUksSUFBSSxDQUV4QjtJQUVNLEtBQUssSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBRTVCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronizer.d.ts","sourceRoot":"","sources":["../../src/state_machine/synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"synchronizer.d.ts","sourceRoot":"","sources":["../../src/state_machine/synchronizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,qBAAa,eAAgB,YAAW,sBAAsB;IAIzC,uBAAuB,EAAE,uBAAuB;IAFnE,OAAO,CAAC,WAAW,CAAoB;IAEvC,YAAmB,uBAAuB,EAAE,uBAAuB,EAAI;IAEvE,OAAa,MAAM,6BAIlB;IAEY,aAAa,CAAC,KAAK,EAAE,OAAO,iBAOxC;IAED;;;;;OAKG;IACI,aAAa,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAEhG;IAED,+FAA+F;IACxF,YAAY,IAAI,wBAAwB,CAE9C;IAED,qFAAqF;IAC9E,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAE9D;IAED,uFAAuF;IAChF,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,wBAAwB,CAEhE;IAED,yCAAyC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC,CAElH;IAEM,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5B;IAEM,MAAM,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAErD;IAEM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAEM,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/B;IAEM,UAAU,IAAI,IAAI,CAExB;IAEM,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5B;CACF"}
|
|
@@ -19,11 +19,11 @@ export class TXESynchronizer {
|
|
|
19
19
|
this.blockNumber = block.header.globalVariables.blockNumber;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
22
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
23
23
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
24
|
-
* @param
|
|
24
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
|
|
25
25
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
26
|
-
*/ syncImmediate(_minBlockNumber,
|
|
26
|
+
*/ syncImmediate(_minBlockNumber, _blockHash) {
|
|
27
27
|
return Promise.resolve(this.blockNumber);
|
|
28
28
|
}
|
|
29
29
|
/** Returns an instance of MerkleTreeAdminOperations that will not include uncommitted data. */ getCommitted() {
|
package/dest/txe_session.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import
|
|
6
|
-
import { AddressStore, CapsuleStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
5
|
+
import { AddressStore, CapsuleStore, ContractStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
6
|
import { type IPrivateExecutionOracle, type IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
8
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
@@ -12,7 +11,6 @@ import { RPCTranslator } from './rpc_translator.js';
|
|
|
12
11
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
13
12
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
14
13
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
15
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
16
14
|
type MethodNames<T> = {
|
|
17
15
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
18
16
|
}[keyof T];
|
|
@@ -26,6 +24,38 @@ export interface TXESessionStateHandler {
|
|
|
26
24
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
27
25
|
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
28
26
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
27
|
+
cycleJob(): Promise<string>;
|
|
28
|
+
getCurrentJob(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Runs an executor-style top-level call (private/public call, utility execution) with last-call tracking.
|
|
31
|
+
*/
|
|
32
|
+
withTopLevelCallTracking<T>(work: () => Promise<{
|
|
33
|
+
result: T;
|
|
34
|
+
txHash?: Fr;
|
|
35
|
+
}>): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Captures a raw offchain effect payload for consumption from test environment. Called by the `emit_offchain_effect`
|
|
38
|
+
* oracle handler whenever a contract function emits an offchain message, at any call depth.
|
|
39
|
+
*/
|
|
40
|
+
recordOffchainEffect(data: Fr[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the raw offchain effect payloads emitted by the last top-level call. Each payload follows the protocol
|
|
43
|
+
* convention documented on `OFFCHAIN_MESSAGE_IDENTIFIER`, i.e. `[identifier, recipient, ...ciphertext]`. Decoding into
|
|
44
|
+
* `OffchainMessage` structs happens on the Noir side of the test helper. Marks the buffer as queried so the
|
|
45
|
+
* unqueried-messages warning doesn't fire on the next reset.
|
|
46
|
+
*/
|
|
47
|
+
getLastCallOffchainEffects(): {
|
|
48
|
+
effects: Fr[][];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Returns the context of the last top-level call: its tx hash (`Fr.ZERO` if the call was tx-less) and the anchor
|
|
52
|
+
* block timestamp captured at the start of the call. Does *not* mark the buffer as queried — context reads are
|
|
53
|
+
* metadata, not effect consumption.
|
|
54
|
+
*/
|
|
55
|
+
getLastCallContext(): {
|
|
56
|
+
txHash: Fr;
|
|
57
|
+
anchorBlockTimestamp: bigint;
|
|
58
|
+
};
|
|
29
59
|
}
|
|
30
60
|
/**
|
|
31
61
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
@@ -52,8 +82,9 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
52
82
|
private nextBlockTimestamp;
|
|
53
83
|
private state;
|
|
54
84
|
private authwits;
|
|
55
|
-
|
|
56
|
-
|
|
85
|
+
private lastCallInfo;
|
|
86
|
+
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle, contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, accountStore: TXEAccountStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, jobCoordinator: JobCoordinator, currentJobId: string, chainId: Fr, version: Fr, nextBlockTimestamp: bigint);
|
|
87
|
+
static init(contractStore: ContractStore): Promise<TXESession>;
|
|
57
88
|
/**
|
|
58
89
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
59
90
|
* @param functionName The name of the oracle.
|
|
@@ -61,6 +92,23 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
61
92
|
* @returns The oracle return values.
|
|
62
93
|
*/
|
|
63
94
|
processFunction(functionName: TXEOracleFunctionName, inputs: ForeignCallArgs): Promise<ForeignCallResult>;
|
|
95
|
+
getCurrentJob(): string;
|
|
96
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */
|
|
97
|
+
cycleJob(): Promise<string>;
|
|
98
|
+
private resetLastCall;
|
|
99
|
+
recordOffchainEffect(data: Fr[]): void;
|
|
100
|
+
private setLastCallContext;
|
|
101
|
+
withTopLevelCallTracking<T>(work: () => Promise<{
|
|
102
|
+
result: T;
|
|
103
|
+
txHash?: Fr;
|
|
104
|
+
}>): Promise<T>;
|
|
105
|
+
getLastCallOffchainEffects(): {
|
|
106
|
+
effects: Fr[][];
|
|
107
|
+
};
|
|
108
|
+
getLastCallContext(): {
|
|
109
|
+
txHash: Fr;
|
|
110
|
+
anchorBlockTimestamp: bigint;
|
|
111
|
+
};
|
|
64
112
|
enterTopLevelState(): Promise<void>;
|
|
65
113
|
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
66
114
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
@@ -72,4 +120,4 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
72
120
|
private utilityExecutorForContractSync;
|
|
73
121
|
}
|
|
74
122
|
export {};
|
|
75
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
123
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUNsRSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFNUMsT0FBTyxFQUNMLFlBQVksRUFHWixZQUFZLEVBQ1osYUFBYSxFQUNiLGNBQWMsRUFFZCxTQUFTLEVBQ1QsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUNyQixzQkFBc0IsRUFDdEIsa0JBQWtCLEVBQ25CLE1BQU0sbUJBQW1CLENBQUM7QUFDM0IsT0FBTyxFQUlMLEtBQUssdUJBQXVCLEVBQzVCLEtBQUssdUJBQXVCLEVBSTdCLE1BQU0sc0JBQXNCLENBQUM7QUFXOUIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRzNELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBTzVELE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLG1CQUFtQixFQUFFLE1BQU0sd0JBQXdCLENBQU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ThCO0NBaUR2QyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,
|
|
1
|
+
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EACL,YAAY,EAGZ,YAAY,EACZ,aAAa,EACb,cAAc,EAEd,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAI7B,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAO5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGvF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;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J,OAAa,IAAI,CAAC,aAAa,EAAE,aAAa,uBA0E7C;IAED;;;;;OAKG;IACH,eAAe,CAAC,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuBxG;IAED,aAAa,IAAI,MAAM,CAEtB;IAED,4EAA4E;IACtE,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAIhC;IAED,OAAO,CAAC,aAAa;IAerB,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAErC;IAED,OAAO,CAAC,kBAAkB;IAKpB,wBAAwB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,EAAE,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ7F;IAED,0BAA0B,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAA;KAAE,CAGhD;IAED,kBAAkB,IAAI;QAAE,MAAM,EAAE,EAAE,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,CAGjE;IAEK,kBAAkB,kBA6CvB;IAEK,iBAAiB,CACrB,eAAe,GAAE,YAA8B,EAC/C,iBAAiB,CAAC,EAAE,WAAW,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAsE/B;IAEK,gBAAgB,CAAC,eAAe,CAAC,EAAE,YAAY,iBA0BpD;IAEK,iBAAiB,CAAC,eAAe,GAAE,YAA8B,iBA6CtE;IAED,OAAO,CAAC,iBAAiB;YAiBX,gBAAgB;YA6BhB,eAAe;IAS7B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,8BAA8B;CAiDvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
-
import { AddressStore, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleService, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
7
|
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
8
|
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
9
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
@@ -11,17 +11,25 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
11
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
12
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
13
13
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
14
|
-
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
14
|
+
import { CallContext, OFFCHAIN_MESSAGE_IDENTIFIER, TxContext } from '@aztec/stdlib/tx';
|
|
15
15
|
import { z } from 'zod';
|
|
16
16
|
import { DEFAULT_ADDRESS } from './constants.js';
|
|
17
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
18
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
19
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
20
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
20
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
21
22
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
22
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
23
23
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
24
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
25
|
+
function emptyLastCallState() {
|
|
26
|
+
return {
|
|
27
|
+
offchainEffects: [],
|
|
28
|
+
queried: false,
|
|
29
|
+
txHash: Fr.ZERO,
|
|
30
|
+
anchorBlockTimestamp: 0n
|
|
31
|
+
};
|
|
32
|
+
}
|
|
25
33
|
/**
|
|
26
34
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
27
35
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -46,6 +54,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
46
54
|
nextBlockTimestamp;
|
|
47
55
|
state;
|
|
48
56
|
authwits;
|
|
57
|
+
lastCallInfo;
|
|
49
58
|
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp){
|
|
50
59
|
this.logger = logger;
|
|
51
60
|
this.stateMachine = stateMachine;
|
|
@@ -69,12 +78,12 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
69
78
|
name: 'TOP_LEVEL'
|
|
70
79
|
};
|
|
71
80
|
this.authwits = new Map();
|
|
81
|
+
this.lastCallInfo = emptyLastCallState();
|
|
72
82
|
}
|
|
73
|
-
static async init(
|
|
83
|
+
static async init(contractStore) {
|
|
74
84
|
const store = await openTmpStore('txe-session');
|
|
75
85
|
const addressStore = new AddressStore(store);
|
|
76
86
|
const privateEventStore = new PrivateEventStore(store);
|
|
77
|
-
const contractStore = new TXEContractStore(store);
|
|
78
87
|
const noteStore = new NoteStore(store);
|
|
79
88
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
80
89
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
@@ -91,19 +100,17 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
91
100
|
privateEventStore,
|
|
92
101
|
noteStore
|
|
93
102
|
]);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
await contractStore.addContractInstance(instance);
|
|
98
|
-
}
|
|
99
|
-
const stateMachine = await TXEStateMachine.create(store);
|
|
103
|
+
const archiver = new TXEArchiver(store);
|
|
104
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
105
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
100
106
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
101
107
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
102
108
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
103
109
|
const initialJobId = jobCoordinator.beginJob();
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
const logger = createLogger('txe:session');
|
|
111
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map());
|
|
112
|
+
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
113
|
+
return new TXESession(logger, stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp);
|
|
107
114
|
}
|
|
108
115
|
/**
|
|
109
116
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -126,6 +133,50 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
}
|
|
136
|
+
getCurrentJob() {
|
|
137
|
+
return this.currentJobId;
|
|
138
|
+
}
|
|
139
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */ async cycleJob() {
|
|
140
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
141
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
142
|
+
return this.currentJobId;
|
|
143
|
+
}
|
|
144
|
+
resetLastCall() {
|
|
145
|
+
const notQueriedMessageCount = this.lastCallInfo.queried ? 0 : this.lastCallInfo.offchainEffects.filter((payload)=>payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
|
|
146
|
+
if (notQueriedMessageCount > 0) {
|
|
147
|
+
this.logger.warn(`Dropping ${notQueriedMessageCount} unqueried offchain message(s) from the previous top-level call. ` + `To deliver them, call \`env.offchain_messages()\` and forward the result to the recipient contract's ` + `\`offchain_receive\` utility before issuing another top-level call. To intentionally discard, assign ` + `to \`let _ = env.offchain_messages()\` to silence this warning.`);
|
|
148
|
+
}
|
|
149
|
+
this.lastCallInfo = emptyLastCallState();
|
|
150
|
+
}
|
|
151
|
+
recordOffchainEffect(data) {
|
|
152
|
+
this.lastCallInfo.offchainEffects.push(data);
|
|
153
|
+
}
|
|
154
|
+
setLastCallContext(txHash, anchorBlockTimestamp) {
|
|
155
|
+
this.lastCallInfo.txHash = txHash;
|
|
156
|
+
this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
|
|
157
|
+
}
|
|
158
|
+
async withTopLevelCallTracking(work) {
|
|
159
|
+
this.resetLastCall();
|
|
160
|
+
// Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
|
|
161
|
+
// side effect, and that block's timestamp should not be attributed to this call's anchor.
|
|
162
|
+
const anchorBlockTimestamp = (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.timestamp;
|
|
163
|
+
const { result, txHash } = await work();
|
|
164
|
+
this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
getLastCallOffchainEffects() {
|
|
168
|
+
this.lastCallInfo.queried = true;
|
|
169
|
+
return {
|
|
170
|
+
effects: this.lastCallInfo.offchainEffects
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
getLastCallContext() {
|
|
174
|
+
const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
|
|
175
|
+
return {
|
|
176
|
+
txHash,
|
|
177
|
+
anchorBlockTimestamp
|
|
178
|
+
};
|
|
179
|
+
}
|
|
129
180
|
async enterTopLevelState() {
|
|
130
181
|
switch(this.state.name){
|
|
131
182
|
case 'PRIVATE':
|
|
@@ -153,9 +204,8 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
153
204
|
}
|
|
154
205
|
}
|
|
155
206
|
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
156
|
-
await this.
|
|
157
|
-
this.
|
|
158
|
-
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId, this.nextBlockTimestamp, this.version, this.chainId, this.authwits);
|
|
207
|
+
await this.cycleJob();
|
|
208
|
+
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.nextBlockTimestamp, this.version, this.chainId, this.authwits);
|
|
159
209
|
this.state = {
|
|
160
210
|
name: 'TOP_LEVEL'
|
|
161
211
|
};
|
|
@@ -163,11 +213,12 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
163
213
|
}
|
|
164
214
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
165
215
|
this.exitTopLevelState();
|
|
216
|
+
this.resetLastCall();
|
|
166
217
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
167
218
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
168
219
|
// a single transaction with the effects of what was done in the test.
|
|
169
220
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
170
|
-
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
221
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
171
222
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
172
223
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
173
224
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
@@ -180,7 +231,34 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
180
231
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
181
232
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
182
233
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
183
|
-
this.oracleHandler = new PrivateExecutionOracle(
|
|
234
|
+
this.oracleHandler = new PrivateExecutionOracle({
|
|
235
|
+
argsHash: Fr.ZERO,
|
|
236
|
+
txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
237
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
238
|
+
anchorBlockHeader: anchorBlock,
|
|
239
|
+
utilityExecutor,
|
|
240
|
+
authWitnesses: [],
|
|
241
|
+
capsules: [],
|
|
242
|
+
executionCache: new HashedValuesCache(),
|
|
243
|
+
noteCache,
|
|
244
|
+
taggingIndexCache,
|
|
245
|
+
contractStore: this.contractStore,
|
|
246
|
+
noteStore: this.noteStore,
|
|
247
|
+
keyStore: this.keyStore,
|
|
248
|
+
addressStore: this.addressStore,
|
|
249
|
+
aztecNode: this.stateMachine.node,
|
|
250
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
251
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
252
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
253
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
254
|
+
privateEventStore: this.privateEventStore,
|
|
255
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
256
|
+
l2TipsStore: this.stateMachine.node,
|
|
257
|
+
jobId: this.currentJobId,
|
|
258
|
+
scopes: await this.keyStore.getAccounts(),
|
|
259
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
260
|
+
simulator: new WASMSimulator()
|
|
261
|
+
});
|
|
184
262
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
185
263
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
186
264
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -193,15 +271,19 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
193
271
|
taggingIndexCache
|
|
194
272
|
};
|
|
195
273
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
274
|
+
// Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
|
|
275
|
+
// via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
|
|
276
|
+
this.setLastCallContext(Fr.ZERO, anchorBlock.globalVariables.timestamp);
|
|
196
277
|
return this.oracleHandler.getPrivateContextInputs();
|
|
197
278
|
}
|
|
198
279
|
async enterPublicState(contractAddress) {
|
|
199
280
|
this.exitTopLevelState();
|
|
281
|
+
this.resetLastCall();
|
|
200
282
|
// The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
|
|
201
283
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
202
|
-
const
|
|
284
|
+
const latestHeader = await this.stateMachine.node.getBlockHeader('latest');
|
|
203
285
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
204
|
-
blockNumber: BlockNumber(
|
|
286
|
+
blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
|
|
205
287
|
timestamp: this.nextBlockTimestamp,
|
|
206
288
|
version: this.version,
|
|
207
289
|
chainId: this.chainId
|
|
@@ -211,21 +293,46 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
211
293
|
name: 'PUBLIC'
|
|
212
294
|
};
|
|
213
295
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
296
|
+
// Public state is anchored at the latest block.
|
|
297
|
+
this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
|
|
214
298
|
}
|
|
215
299
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
216
300
|
this.exitTopLevelState();
|
|
301
|
+
this.resetLastCall();
|
|
217
302
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
218
303
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
219
304
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
220
305
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
221
306
|
// be removed from the database.
|
|
222
307
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
223
|
-
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
224
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
308
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
309
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
310
|
+
contractAddress,
|
|
311
|
+
authWitnesses: [],
|
|
312
|
+
capsules: [],
|
|
313
|
+
anchorBlockHeader,
|
|
314
|
+
contractStore: this.contractStore,
|
|
315
|
+
noteStore: this.noteStore,
|
|
316
|
+
keyStore: this.keyStore,
|
|
317
|
+
addressStore: this.addressStore,
|
|
318
|
+
aztecNode: this.stateMachine.node,
|
|
319
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
320
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
321
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
322
|
+
privateEventStore: this.privateEventStore,
|
|
323
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
324
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
325
|
+
l2TipsStore: this.stateMachine.node,
|
|
326
|
+
jobId: this.currentJobId,
|
|
327
|
+
scopes: await this.keyStore.getAccounts(),
|
|
328
|
+
simulator: new WASMSimulator()
|
|
329
|
+
});
|
|
225
330
|
this.state = {
|
|
226
331
|
name: 'UTILITY'
|
|
227
332
|
};
|
|
228
333
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
334
|
+
// Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
|
|
335
|
+
this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
|
|
229
336
|
}
|
|
230
337
|
exitTopLevelState() {
|
|
231
338
|
if (this.state.name != 'TOP_LEVEL') {
|
|
@@ -233,8 +340,8 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
233
340
|
}
|
|
234
341
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
235
342
|
// those, the top level context performs a large number of actions not captured in the following 'close' call. Among
|
|
236
|
-
// others, it will create empty blocks (via `
|
|
237
|
-
// `
|
|
343
|
+
// others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
|
|
344
|
+
// `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
|
|
238
345
|
// slight inconsistency in the working model of this class, but is not too bad.
|
|
239
346
|
// TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
|
|
240
347
|
// level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
|
|
@@ -278,14 +385,35 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
278
385
|
}
|
|
279
386
|
}
|
|
280
387
|
utilityExecutorForContractSync(anchorBlock) {
|
|
281
|
-
return async (call)=>{
|
|
388
|
+
return async (call, scopes)=>{
|
|
282
389
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
283
390
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
284
391
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
285
392
|
}
|
|
286
393
|
try {
|
|
287
|
-
const
|
|
288
|
-
|
|
394
|
+
const simulator = new WASMSimulator();
|
|
395
|
+
const oracle = new UtilityExecutionOracle({
|
|
396
|
+
contractAddress: call.to,
|
|
397
|
+
authWitnesses: [],
|
|
398
|
+
capsules: [],
|
|
399
|
+
anchorBlockHeader: anchorBlock,
|
|
400
|
+
contractStore: this.contractStore,
|
|
401
|
+
noteStore: this.noteStore,
|
|
402
|
+
keyStore: this.keyStore,
|
|
403
|
+
addressStore: this.addressStore,
|
|
404
|
+
aztecNode: this.stateMachine.node,
|
|
405
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
406
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
407
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
408
|
+
privateEventStore: this.privateEventStore,
|
|
409
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
410
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
411
|
+
l2TipsStore: this.stateMachine.node,
|
|
412
|
+
jobId: this.currentJobId,
|
|
413
|
+
scopes,
|
|
414
|
+
simulator
|
|
415
|
+
});
|
|
416
|
+
await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
289
417
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
290
418
|
throw new ExecutionError(err.message, {
|
|
291
419
|
contractAddress: call.to,
|