@aztec/txe 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/ContractClassRegistry-KKNT527R.js +3 -0
- package/dest/ContractClassRegistry-KKNT527R.js.map +7 -0
- package/dest/ContractInstanceRegistry-GSKBNL3Q.js +3 -0
- package/dest/ContractInstanceRegistry-GSKBNL3Q.js.map +7 -0
- package/dest/FeeJuice-GUJ5O6GB.js +3 -0
- package/dest/FeeJuice-GUJ5O6GB.js.map +7 -0
- package/dest/MultiCallEntrypoint-ZQPCKVKL.js +3 -0
- package/dest/MultiCallEntrypoint-ZQPCKVKL.js.map +7 -0
- package/dest/SchnorrAccount-QIXE5DXA.js +3 -0
- package/dest/SchnorrAccount-QIXE5DXA.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 +32 -0
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-DF6RMOC6.js +304 -0
- package/dest/chunk-DF6RMOC6.js.map +7 -0
- package/dest/chunk-PPJTNNUG.js +265 -0
- package/dest/chunk-PPJTNNUG.js.map +7 -0
- package/dest/constants.d.ts +3 -2
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +5 -1
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +188 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +148 -75
- package/dest/metafile.json +38147 -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 +40 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +18 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +31 -16
- package/dest/oracle/txe_oracle_top_level_context.d.ts +39 -23
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +225 -89
- 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 +144 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +599 -238
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +20 -69
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +47 -187
- package/dest/state_machine/dummy_p2p_client.d.ts +26 -16
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +44 -20
- 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 +10 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +55 -14
- package/dest/state_machine/mock_epoch_cache.d.ts +25 -8
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +46 -9
- package/dest/state_machine/synchronizer.d.ts +6 -6
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +4 -4
- package/dest/txe_oracle_version.d.ts +17 -0
- package/dest/txe_oracle_version.d.ts.map +1 -0
- package/dest/txe_oracle_version.js +14 -0
- package/dest/txe_session.d.ts +73 -10
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +242 -39
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +18 -4
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +7 -2
- 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 -6
- package/dest/{util → utils}/txe_account_store.d.ts +1 -1
- package/dest/utils/txe_account_store.d.ts.map +1 -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/{util → utils}/txe_public_contract_data_source.js +6 -25
- 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 +38 -22
- package/src/bin/check_txe_oracle_version.ts +37 -0
- package/src/bin/index.ts +11 -2
- package/src/constants.ts +6 -1
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +166 -80
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +48 -34
- package/src/oracle/txe_oracle_public_context.ts +46 -18
- package/src/oracle/txe_oracle_top_level_context.ts +282 -151
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +687 -326
- package/src/state_machine/archiver.ts +53 -235
- package/src/state_machine/dummy_p2p_client.ts +70 -32
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +72 -15
- package/src/state_machine/mock_epoch_cache.ts +57 -14
- package/src/state_machine/synchronizer.ts +6 -6
- package/src/txe_oracle_version.ts +17 -0
- package/src/txe_session.ts +352 -104
- package/src/utils/block_creation.ts +19 -16
- package/src/{util → utils}/encoding.ts +8 -2
- package/src/utils/tx_effect_creation.ts +3 -11
- package/src/{util → utils}/txe_public_contract_data_source.ts +10 -38
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -720
- 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_store.d.ts.map +0 -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/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/src/util/txe_contract_store.ts +0 -36
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/dest/{util → utils}/txe_account_store.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
- /package/src/{util → utils}/txe_account_store.ts +0 -0
package/dest/txe_session.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ 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 type {
|
|
6
|
-
import { AddressStore, CapsuleStore, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
5
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
+
import { AddressStore, CapsuleStore, ContractStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
7
|
import { type IPrivateExecutionOracle, type IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
9
10
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
10
11
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
11
12
|
import { RPCTranslator } from './rpc_translator.js';
|
|
12
13
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
13
|
-
import type { ForeignCallArgs, ForeignCallResult } from './
|
|
14
|
-
import { TXEAccountStore } from './
|
|
15
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
14
|
+
import type { ForeignCallArgs, ForeignCallResult } from './utils/encoding.js';
|
|
15
|
+
import { TXEAccountStore } from './utils/txe_account_store.js';
|
|
16
16
|
type MethodNames<T> = {
|
|
17
17
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
18
18
|
}[keyof T];
|
|
@@ -22,10 +22,44 @@ type MethodNames<T> = {
|
|
|
22
22
|
*/
|
|
23
23
|
export type TXEOracleFunctionName = Exclude<MethodNames<RPCTranslator>, 'constructor' | 'handlerAsMisc' | 'handlerAsUtility' | 'handlerAsPrivate' | 'handlerAsAvm' | 'handlerAsTxe'>;
|
|
24
24
|
export interface TXESessionStateHandler {
|
|
25
|
+
/** Records the TXE oracle version reported by the Noir test code for diagnostics. */
|
|
26
|
+
setTxeOracleVersion(major: number, minor: number): void;
|
|
25
27
|
enterTopLevelState(): Promise<void>;
|
|
26
28
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
27
|
-
enterPrivateState(contractAddress
|
|
29
|
+
enterPrivateState(contractAddress: AztecAddress | undefined, anchorBlockNumber: BlockNumber | undefined, gasSettings: GasSettings): Promise<PrivateContextInputs>;
|
|
28
30
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
31
|
+
cycleJob(): Promise<string>;
|
|
32
|
+
getCurrentJob(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Runs an executor-style top-level call (private/public call, utility execution) with last-call tracking.
|
|
35
|
+
*/
|
|
36
|
+
withTopLevelCallTracking<T>(work: () => Promise<{
|
|
37
|
+
result: T;
|
|
38
|
+
txHash?: Fr;
|
|
39
|
+
}>): Promise<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Captures a raw offchain effect payload for consumption from test environment. Called by the `emit_offchain_effect`
|
|
42
|
+
* oracle handler whenever a contract function emits an offchain message, at any call depth.
|
|
43
|
+
*/
|
|
44
|
+
recordOffchainEffect(data: Fr[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the raw offchain effect payloads emitted by the last top-level call. Each payload follows the protocol
|
|
47
|
+
* convention documented on `OFFCHAIN_MESSAGE_IDENTIFIER`, i.e. `[identifier, recipient, ...ciphertext]`. Decoding into
|
|
48
|
+
* `OffchainMessage` structs happens on the Noir side of the test helper. Marks the buffer as queried so the
|
|
49
|
+
* unqueried-messages warning doesn't fire on the next reset.
|
|
50
|
+
*/
|
|
51
|
+
getLastCallOffchainEffects(): {
|
|
52
|
+
effects: Fr[][];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Returns the context of the last top-level call: its tx hash (`Fr.ZERO` if the call was tx-less) and the anchor
|
|
56
|
+
* block timestamp captured at the start of the call. Does *not* mark the buffer as queried — context reads are
|
|
57
|
+
* metadata, not effect consumption.
|
|
58
|
+
*/
|
|
59
|
+
getLastCallContext(): {
|
|
60
|
+
txHash: Fr;
|
|
61
|
+
anchorBlockTimestamp: bigint;
|
|
62
|
+
};
|
|
29
63
|
}
|
|
30
64
|
/**
|
|
31
65
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
@@ -33,6 +67,7 @@ export interface TXESessionStateHandler {
|
|
|
33
67
|
*/
|
|
34
68
|
export declare class TXESession implements TXESessionStateHandler {
|
|
35
69
|
private logger;
|
|
70
|
+
private sessionStore;
|
|
36
71
|
private stateMachine;
|
|
37
72
|
private oracleHandler;
|
|
38
73
|
private contractStore;
|
|
@@ -45,13 +80,23 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
45
80
|
private senderAddressBookStore;
|
|
46
81
|
private capsuleStore;
|
|
47
82
|
private privateEventStore;
|
|
83
|
+
private jobCoordinator;
|
|
84
|
+
private currentJobId;
|
|
48
85
|
private chainId;
|
|
49
86
|
private version;
|
|
50
87
|
private nextBlockTimestamp;
|
|
51
88
|
private state;
|
|
52
89
|
private authwits;
|
|
53
|
-
|
|
54
|
-
|
|
90
|
+
private lastCallInfo;
|
|
91
|
+
private txeOracleVersion;
|
|
92
|
+
private disposed;
|
|
93
|
+
constructor(logger: Logger, sessionStore: AztecAsyncKVStore, 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);
|
|
94
|
+
/**
|
|
95
|
+
* Closes the per-session `txe-session` LMDB and the `NativeWorldStateService` .
|
|
96
|
+
* Called via IPC when the dispatcher detects the end of a test. Idempotent.
|
|
97
|
+
*/
|
|
98
|
+
dispose(): Promise<void>;
|
|
99
|
+
static init(contractStore: ContractStore): Promise<TXESession>;
|
|
55
100
|
/**
|
|
56
101
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
57
102
|
* @param functionName The name of the oracle.
|
|
@@ -59,8 +104,26 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
59
104
|
* @returns The oracle return values.
|
|
60
105
|
*/
|
|
61
106
|
processFunction(functionName: TXEOracleFunctionName, inputs: ForeignCallArgs): Promise<ForeignCallResult>;
|
|
107
|
+
getCurrentJob(): string;
|
|
108
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */
|
|
109
|
+
cycleJob(): Promise<string>;
|
|
110
|
+
private resetLastCall;
|
|
111
|
+
recordOffchainEffect(data: Fr[]): void;
|
|
112
|
+
private setLastCallContext;
|
|
113
|
+
withTopLevelCallTracking<T>(work: () => Promise<{
|
|
114
|
+
result: T;
|
|
115
|
+
txHash?: Fr;
|
|
116
|
+
}>): Promise<T>;
|
|
117
|
+
getLastCallOffchainEffects(): {
|
|
118
|
+
effects: Fr[][];
|
|
119
|
+
};
|
|
120
|
+
getLastCallContext(): {
|
|
121
|
+
txHash: Fr;
|
|
122
|
+
anchorBlockTimestamp: bigint;
|
|
123
|
+
};
|
|
124
|
+
setTxeOracleVersion(major: number, minor: number): void;
|
|
62
125
|
enterTopLevelState(): Promise<void>;
|
|
63
|
-
enterPrivateState(contractAddress
|
|
126
|
+
enterPrivateState(contractAddress: AztecAddress | undefined, anchorBlockNumber: BlockNumber | undefined, gasSettings: GasSettings): Promise<PrivateContextInputs>;
|
|
64
127
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
65
128
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
66
129
|
private exitTopLevelState;
|
|
@@ -70,4 +133,4 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
70
133
|
private utilityExecutorForContractSync;
|
|
71
134
|
}
|
|
72
135
|
export {};
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
136
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFD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U8sQ0FBQyxvQkFBb0IsQ0FBQyxDQXNFL0I7SUFFSyxnQkFBZ0IsQ0FBQyxlQUFlLENBQUMsRUFBRSxZQUFZLGlCQTBCcEQ7SUFFSyxpQkFBaUIsQ0FBQyxlQUFlLEdBQUUsWUFBOEIsaUJBOEN0RTtJQUVELE9BQU8sQ0FBQyxpQkFBaUI7WUFpQlgsZ0JBQWdCO1lBNkJoQixlQUFlO0lBUzdCLE9BQU8sQ0FBQyxrQkFBa0I7SUFNMUIsT0FBTyxDQUFDLDhCQUE4QjtDQWtEdkMifQ==
|
|
@@ -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;
|
|
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;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,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,EAG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AAE,EAAE,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAS7F;IAED,0BAA0B,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAA;KAAE,CAYhD;IAED,kBAAkB,IAAI;QAAE,MAAM,EAAE,EAAE,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,CAGjE;IAED,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAatD;IAEK,kBAAkB,kBA6CvB;IAEK,iBAAiB,CACrB,eAAe,0BAAgC,EAC/C,iBAAiB,EAAE,WAAW,GAAG,SAAS,EAC1C,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAsE/B;IAEK,gBAAgB,CAAC,eAAe,CAAC,EAAE,YAAY,iBA0BpD;IAEK,iBAAiB,CAAC,eAAe,GAAE,YAA8B,iBA8CtE;IAED,OAAO,CAAC,iBAAiB;YAiBX,gBAAgB;YA6BhB,eAAe;IAS7B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,8BAA8B;CAkDvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -2,31 +2,42 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import {
|
|
6
|
-
import { AddressStore, CapsuleStore, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle,
|
|
5
|
+
import { openEphemeralStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleService, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
|
+
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
8
|
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
|
+
import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-registry/constants';
|
|
9
10
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
10
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
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
|
-
import { DEFAULT_ADDRESS,
|
|
16
|
+
import { DEFAULT_ADDRESS, MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY, MAX_OFFCHAIN_EFFECT_LEN } 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
|
+
import { TXEPrivateExecutionOracle } from './oracle/txe_private_execution_oracle.js';
|
|
19
20
|
import { RPCTranslator } from './rpc_translator.js';
|
|
21
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
20
22
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
21
|
-
import {
|
|
22
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
23
|
+
import { TXE_ORACLE_VERSION_MAJOR, TXE_ORACLE_VERSION_MINOR } from './txe_oracle_version.js';
|
|
23
24
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
24
25
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
26
|
+
import { TXEAccountStore } from './utils/txe_account_store.js';
|
|
27
|
+
function emptyLastCallState() {
|
|
28
|
+
return {
|
|
29
|
+
offchainEffects: [],
|
|
30
|
+
queried: false,
|
|
31
|
+
txHash: Fr.ZERO,
|
|
32
|
+
anchorBlockTimestamp: 0n
|
|
33
|
+
};
|
|
34
|
+
}
|
|
25
35
|
/**
|
|
26
36
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
27
37
|
* state, etc., independent of all other tests running in parallel.
|
|
28
38
|
*/ export class TXESession {
|
|
29
39
|
logger;
|
|
40
|
+
sessionStore;
|
|
30
41
|
stateMachine;
|
|
31
42
|
oracleHandler;
|
|
32
43
|
contractStore;
|
|
@@ -39,13 +50,19 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
39
50
|
senderAddressBookStore;
|
|
40
51
|
capsuleStore;
|
|
41
52
|
privateEventStore;
|
|
53
|
+
jobCoordinator;
|
|
54
|
+
currentJobId;
|
|
42
55
|
chainId;
|
|
43
56
|
version;
|
|
44
57
|
nextBlockTimestamp;
|
|
45
58
|
state;
|
|
46
59
|
authwits;
|
|
47
|
-
|
|
60
|
+
lastCallInfo;
|
|
61
|
+
txeOracleVersion;
|
|
62
|
+
disposed;
|
|
63
|
+
constructor(logger, sessionStore, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp){
|
|
48
64
|
this.logger = logger;
|
|
65
|
+
this.sessionStore = sessionStore;
|
|
49
66
|
this.stateMachine = stateMachine;
|
|
50
67
|
this.oracleHandler = oracleHandler;
|
|
51
68
|
this.contractStore = contractStore;
|
|
@@ -58,6 +75,8 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
58
75
|
this.senderAddressBookStore = senderAddressBookStore;
|
|
59
76
|
this.capsuleStore = capsuleStore;
|
|
60
77
|
this.privateEventStore = privateEventStore;
|
|
78
|
+
this.jobCoordinator = jobCoordinator;
|
|
79
|
+
this.currentJobId = currentJobId;
|
|
61
80
|
this.chainId = chainId;
|
|
62
81
|
this.version = version;
|
|
63
82
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
@@ -65,31 +84,64 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
65
84
|
name: 'TOP_LEVEL'
|
|
66
85
|
};
|
|
67
86
|
this.authwits = new Map();
|
|
87
|
+
this.lastCallInfo = emptyLastCallState();
|
|
88
|
+
this.disposed = false;
|
|
68
89
|
}
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Closes the per-session `txe-session` LMDB and the `NativeWorldStateService` .
|
|
92
|
+
* Called via IPC when the dispatcher detects the end of a test. Idempotent.
|
|
93
|
+
*/ async dispose() {
|
|
94
|
+
if (this.disposed) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.disposed = true;
|
|
98
|
+
try {
|
|
99
|
+
await this.stateMachine.synchronizer.nativeWorldStateService.close();
|
|
100
|
+
} catch (err) {
|
|
101
|
+
this.logger.warn(`Error closing native world state during session dispose`, err);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
await this.sessionStore.close();
|
|
105
|
+
} catch (err) {
|
|
106
|
+
this.logger.warn(`Error closing session LMDB during dispose`, err);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
static async init(contractStore) {
|
|
110
|
+
// Size LMDB's reader slots to the libuv pool (capped to 2 in bin/index.ts via
|
|
111
|
+
// HARDWARE_CONCURRENCY): each native LMDB read needs a libuv worker thread to run, so any
|
|
112
|
+
// slot beyond the pool size would sit idle while still consuming a semaphore + reader-table
|
|
113
|
+
// entry per session.
|
|
114
|
+
const store = await openEphemeralStore('txe-session', undefined, 2);
|
|
71
115
|
const addressStore = new AddressStore(store);
|
|
72
116
|
const privateEventStore = new PrivateEventStore(store);
|
|
73
|
-
const
|
|
74
|
-
const noteStore = await NoteStore.create(store);
|
|
117
|
+
const noteStore = new NoteStore(store);
|
|
75
118
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
76
119
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
77
120
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
78
121
|
const capsuleStore = new CapsuleStore(store);
|
|
79
122
|
const keyStore = new KeyStore(store);
|
|
80
123
|
const accountStore = new TXEAccountStore(store);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
124
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
125
|
+
jobCoordinator.registerStores([
|
|
126
|
+
capsuleStore,
|
|
127
|
+
senderTaggingStore,
|
|
128
|
+
recipientTaggingStore,
|
|
129
|
+
privateEventStore,
|
|
130
|
+
noteStore
|
|
131
|
+
]);
|
|
132
|
+
const archiver = new TXEArchiver(store);
|
|
133
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
134
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
87
135
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
88
136
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
89
137
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
138
|
+
const initialJobId = jobCoordinator.beginJob();
|
|
139
|
+
const logger = createLogger('txe:session');
|
|
90
140
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map());
|
|
91
|
-
await topLevelOracleHandler.
|
|
92
|
-
|
|
141
|
+
await topLevelOracleHandler.mineDeploymentNullifiers([
|
|
142
|
+
STANDARD_AUTH_REGISTRY_ADDRESS
|
|
143
|
+
]);
|
|
144
|
+
return new TXESession(logger, store, stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp);
|
|
93
145
|
}
|
|
94
146
|
/**
|
|
95
147
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -104,7 +156,15 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
104
156
|
return translator[validatedFunctionName](...inputs);
|
|
105
157
|
} catch (error) {
|
|
106
158
|
if (error instanceof z.ZodError) {
|
|
107
|
-
|
|
159
|
+
let versionHint;
|
|
160
|
+
if (!this.txeOracleVersion) {
|
|
161
|
+
versionHint = ' The test appears to use an older version of Aztec.nr that does not' + ' support test environment oracle versioning. Update Aztec.nr to a compatible version.' + ' See https://docs.aztec.network/errors/12';
|
|
162
|
+
} else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
|
|
163
|
+
versionHint = ` The test uses Aztec.nr test oracle version` + ` ${this.txeOracleVersion.major}.${this.txeOracleVersion.minor}, but this test environment` + ` only supports up to ${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}.` + ` Upgrade the Aztec CLI to a compatible version.` + ` See https://docs.aztec.network/errors/12`;
|
|
164
|
+
} else {
|
|
165
|
+
versionHint = ` The test's oracle version (${this.txeOracleVersion.major}.${this.txeOracleVersion.minor})` + ` is compatible with this test environment` + ` (${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}), so this oracle should be` + ` available. This is an unexpected error, please report it.` + ` See https://docs.aztec.network/errors/13`;
|
|
166
|
+
}
|
|
167
|
+
throw new Error(`Unknown oracle '${functionName}'.${versionHint}`);
|
|
108
168
|
} else if (error instanceof Error) {
|
|
109
169
|
throw new Error(`Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`);
|
|
110
170
|
} else {
|
|
@@ -112,6 +172,68 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
112
172
|
}
|
|
113
173
|
}
|
|
114
174
|
}
|
|
175
|
+
getCurrentJob() {
|
|
176
|
+
return this.currentJobId;
|
|
177
|
+
}
|
|
178
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */ async cycleJob() {
|
|
179
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
180
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
181
|
+
return this.currentJobId;
|
|
182
|
+
}
|
|
183
|
+
resetLastCall() {
|
|
184
|
+
const notQueriedMessageCount = this.lastCallInfo.queried ? 0 : this.lastCallInfo.offchainEffects.filter((payload)=>payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
|
|
185
|
+
if (notQueriedMessageCount > 0) {
|
|
186
|
+
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.`);
|
|
187
|
+
}
|
|
188
|
+
this.lastCallInfo = emptyLastCallState();
|
|
189
|
+
}
|
|
190
|
+
recordOffchainEffect(data) {
|
|
191
|
+
this.lastCallInfo.offchainEffects.push(data);
|
|
192
|
+
}
|
|
193
|
+
setLastCallContext(txHash, anchorBlockTimestamp) {
|
|
194
|
+
this.lastCallInfo.txHash = txHash;
|
|
195
|
+
this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
|
|
196
|
+
}
|
|
197
|
+
async withTopLevelCallTracking(work) {
|
|
198
|
+
this.resetLastCall();
|
|
199
|
+
// Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
|
|
200
|
+
// side effect, and that block's timestamp should not be attributed to this call's anchor.
|
|
201
|
+
const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest')).header.globalVariables.timestamp;
|
|
202
|
+
const { result, txHash } = await work();
|
|
203
|
+
this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
getLastCallOffchainEffects() {
|
|
207
|
+
this.lastCallInfo.queried = true;
|
|
208
|
+
const effects = this.lastCallInfo.offchainEffects;
|
|
209
|
+
if (effects.length > MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY) {
|
|
210
|
+
throw new Error(`${effects.length} offchain effects exceed max ${MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY}`);
|
|
211
|
+
}
|
|
212
|
+
if (effects.some((e)=>e.length > MAX_OFFCHAIN_EFFECT_LEN)) {
|
|
213
|
+
throw new Error(`Some offchain effect has length larger than max ${MAX_OFFCHAIN_EFFECT_LEN}`);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
effects
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
getLastCallContext() {
|
|
220
|
+
const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
|
|
221
|
+
return {
|
|
222
|
+
txHash,
|
|
223
|
+
anchorBlockTimestamp
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
setTxeOracleVersion(major, minor) {
|
|
227
|
+
if (major !== TXE_ORACLE_VERSION_MAJOR) {
|
|
228
|
+
const hint = major > TXE_ORACLE_VERSION_MAJOR ? 'The test was compiled with a newer version of Aztec.nr than your test environment supports. Upgrade your test environment to a compatible version.' : '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.';
|
|
229
|
+
throw new Error(`Incompatible test environment version: ${hint} See https://docs.aztec.network/errors/12 (expected test oracle major version ${TXE_ORACLE_VERSION_MAJOR}, got ${major})`);
|
|
230
|
+
}
|
|
231
|
+
this.txeOracleVersion = {
|
|
232
|
+
major,
|
|
233
|
+
minor
|
|
234
|
+
};
|
|
235
|
+
this.logger.debug(`Test compiled with test oracle version ${major}.${minor}`);
|
|
236
|
+
}
|
|
115
237
|
async enterTopLevelState() {
|
|
116
238
|
switch(this.state.name){
|
|
117
239
|
case 'PRIVATE':
|
|
@@ -138,20 +260,23 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
138
260
|
this.state;
|
|
139
261
|
}
|
|
140
262
|
}
|
|
263
|
+
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
264
|
+
await this.cycleJob();
|
|
141
265
|
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);
|
|
142
266
|
this.state = {
|
|
143
267
|
name: 'TOP_LEVEL'
|
|
144
268
|
};
|
|
145
269
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
146
270
|
}
|
|
147
|
-
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
271
|
+
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber, gasSettings) {
|
|
148
272
|
this.exitTopLevelState();
|
|
149
|
-
|
|
273
|
+
this.resetLastCall();
|
|
150
274
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
151
275
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
152
276
|
// a single transaction with the effects of what was done in the test.
|
|
153
|
-
const anchorBlock = await this.stateMachine.node.
|
|
154
|
-
|
|
277
|
+
const anchorBlock = await this.stateMachine.node.getBlock(anchorBlockNumber ?? 'latest').then((b)=>b?.header);
|
|
278
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
279
|
+
const latestBlock = await this.stateMachine.node.getBlock('latest').then((b)=>b?.header);
|
|
155
280
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
156
281
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
157
282
|
timestamp: this.nextBlockTimestamp,
|
|
@@ -163,7 +288,34 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
163
288
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
164
289
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
165
290
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
166
|
-
this.oracleHandler = new
|
|
291
|
+
this.oracleHandler = new TXEPrivateExecutionOracle({
|
|
292
|
+
argsHash: Fr.ZERO,
|
|
293
|
+
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
294
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
295
|
+
anchorBlockHeader: anchorBlock,
|
|
296
|
+
utilityExecutor,
|
|
297
|
+
authWitnesses: [],
|
|
298
|
+
capsules: [],
|
|
299
|
+
executionCache: new HashedValuesCache(),
|
|
300
|
+
noteCache,
|
|
301
|
+
taggingIndexCache,
|
|
302
|
+
contractStore: this.contractStore,
|
|
303
|
+
noteStore: this.noteStore,
|
|
304
|
+
keyStore: this.keyStore,
|
|
305
|
+
addressStore: this.addressStore,
|
|
306
|
+
aztecNode: this.stateMachine.node,
|
|
307
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
308
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
309
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
310
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
311
|
+
privateEventStore: this.privateEventStore,
|
|
312
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
313
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
314
|
+
jobId: this.currentJobId,
|
|
315
|
+
scopes: await this.keyStore.getAccounts(),
|
|
316
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
317
|
+
simulator: new WASMSimulator()
|
|
318
|
+
});
|
|
167
319
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
168
320
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
169
321
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -172,20 +324,23 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
172
324
|
this.state = {
|
|
173
325
|
name: 'PRIVATE',
|
|
174
326
|
nextBlockGlobalVariables,
|
|
175
|
-
protocolNullifier,
|
|
176
327
|
noteCache,
|
|
177
328
|
taggingIndexCache
|
|
178
329
|
};
|
|
179
330
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
331
|
+
// Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
|
|
332
|
+
// via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
|
|
333
|
+
this.setLastCallContext(Fr.ZERO, anchorBlock.globalVariables.timestamp);
|
|
180
334
|
return this.oracleHandler.getPrivateContextInputs();
|
|
181
335
|
}
|
|
182
336
|
async enterPublicState(contractAddress) {
|
|
183
337
|
this.exitTopLevelState();
|
|
338
|
+
this.resetLastCall();
|
|
184
339
|
// The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
|
|
185
340
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
186
|
-
const
|
|
341
|
+
const latestHeader = (await this.stateMachine.node.getBlockData('latest')).header;
|
|
187
342
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
188
|
-
blockNumber: BlockNumber(
|
|
343
|
+
blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
|
|
189
344
|
timestamp: this.nextBlockTimestamp,
|
|
190
345
|
version: this.version,
|
|
191
346
|
chainId: this.chainId
|
|
@@ -195,21 +350,47 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
195
350
|
name: 'PUBLIC'
|
|
196
351
|
};
|
|
197
352
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
353
|
+
// Public state is anchored at the latest block.
|
|
354
|
+
this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
|
|
198
355
|
}
|
|
199
356
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
200
357
|
this.exitTopLevelState();
|
|
358
|
+
this.resetLastCall();
|
|
359
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
201
360
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
202
361
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
203
362
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
204
363
|
// be removed from the database.
|
|
205
364
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
206
|
-
await new NoteService(this.noteStore, this.stateMachine.node, this.
|
|
207
|
-
|
|
208
|
-
|
|
365
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
366
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
367
|
+
contractAddress,
|
|
368
|
+
authWitnesses: [],
|
|
369
|
+
capsules: [],
|
|
370
|
+
anchorBlockHeader,
|
|
371
|
+
contractStore: this.contractStore,
|
|
372
|
+
noteStore: this.noteStore,
|
|
373
|
+
keyStore: this.keyStore,
|
|
374
|
+
addressStore: this.addressStore,
|
|
375
|
+
aztecNode: this.stateMachine.node,
|
|
376
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
377
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
378
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
379
|
+
privateEventStore: this.privateEventStore,
|
|
380
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
381
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
382
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
383
|
+
jobId: this.currentJobId,
|
|
384
|
+
scopes: await this.keyStore.getAccounts(),
|
|
385
|
+
simulator: new WASMSimulator(),
|
|
386
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlockHeader)
|
|
387
|
+
});
|
|
209
388
|
this.state = {
|
|
210
389
|
name: 'UTILITY'
|
|
211
390
|
};
|
|
212
391
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
392
|
+
// Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
|
|
393
|
+
this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
|
|
213
394
|
}
|
|
214
395
|
exitTopLevelState() {
|
|
215
396
|
if (this.state.name != 'TOP_LEVEL') {
|
|
@@ -217,8 +398,8 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
217
398
|
}
|
|
218
399
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
219
400
|
// those, the top level context performs a large number of actions not captured in the following 'close' call. Among
|
|
220
|
-
// others, it will create empty blocks (via `
|
|
221
|
-
// `
|
|
401
|
+
// others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
|
|
402
|
+
// `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
|
|
222
403
|
// slight inconsistency in the working model of this class, but is not too bad.
|
|
223
404
|
// TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
|
|
224
405
|
// level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
|
|
@@ -235,7 +416,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
235
416
|
});
|
|
236
417
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
237
418
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
238
|
-
const txEffect = await makeTxEffect(this.state.noteCache, this.state.
|
|
419
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
239
420
|
// We build a block holding just this transaction
|
|
240
421
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
241
422
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
@@ -262,14 +443,36 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
262
443
|
}
|
|
263
444
|
}
|
|
264
445
|
utilityExecutorForContractSync(anchorBlock) {
|
|
265
|
-
return async (call)=>{
|
|
446
|
+
return async (call, scopes)=>{
|
|
266
447
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
267
448
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
268
449
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
269
450
|
}
|
|
270
451
|
try {
|
|
271
|
-
const
|
|
272
|
-
|
|
452
|
+
const simulator = new WASMSimulator();
|
|
453
|
+
const oracle = new UtilityExecutionOracle({
|
|
454
|
+
contractAddress: call.to,
|
|
455
|
+
authWitnesses: [],
|
|
456
|
+
capsules: [],
|
|
457
|
+
anchorBlockHeader: anchorBlock,
|
|
458
|
+
contractStore: this.contractStore,
|
|
459
|
+
noteStore: this.noteStore,
|
|
460
|
+
keyStore: this.keyStore,
|
|
461
|
+
addressStore: this.addressStore,
|
|
462
|
+
aztecNode: this.stateMachine.node,
|
|
463
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
464
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
465
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
466
|
+
privateEventStore: this.privateEventStore,
|
|
467
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
468
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
469
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
470
|
+
jobId: this.currentJobId,
|
|
471
|
+
scopes,
|
|
472
|
+
simulator,
|
|
473
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlock)
|
|
474
|
+
});
|
|
475
|
+
await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
273
476
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
274
477
|
throw new ExecutionError(err.message, {
|
|
275
478
|
contractAddress: call.to,
|