@aztec/txe 0.0.1-commit.5daedc8 → 0.0.1-commit.6c91f13
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/constants.d.ts +3 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +2 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -2
- package/dest/oracle/interfaces.d.ts +9 -6
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +4 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts +21 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +93 -62
- package/dest/rpc_translator.d.ts +11 -5
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +57 -15
- package/dest/state_machine/archiver.d.ts +26 -10
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +105 -17
- package/dest/state_machine/dummy_p2p_client.d.ts +1 -1
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +3 -1
- package/dest/state_machine/global_variable_builder.d.ts +5 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +12 -0
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +14 -20
- package/dest/state_machine/synchronizer.d.ts +5 -4
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +19 -13
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +76 -45
- package/dest/util/encoding.d.ts +610 -11
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +1 -1
- package/dest/util/txe_account_store.d.ts +10 -0
- package/dest/util/txe_account_store.d.ts.map +1 -0
- package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
- package/dest/util/txe_contract_store.d.ts +12 -0
- package/dest/util/txe_contract_store.d.ts.map +1 -0
- package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
- package/dest/util/txe_public_contract_data_source.d.ts +7 -6
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +11 -11
- package/dest/utils/block_creation.d.ts +19 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +23 -2
- package/dest/utils/tx_effect_creation.d.ts +4 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +1 -1
- package/package.json +17 -17
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +8 -5
- package/src/oracle/txe_oracle_public_context.ts +6 -11
- package/src/oracle/txe_oracle_top_level_context.ts +137 -88
- package/src/rpc_translator.ts +82 -12
- package/src/state_machine/archiver.ts +136 -25
- package/src/state_machine/dummy_p2p_client.ts +3 -1
- package/src/state_machine/global_variable_builder.ts +20 -3
- package/src/state_machine/index.ts +19 -18
- package/src/state_machine/synchronizer.ts +8 -7
- package/src/txe_session.ts +163 -75
- package/src/util/encoding.ts +1 -1
- package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
- package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
- package/src/util/txe_public_contract_data_source.ts +13 -12
- package/src/utils/block_creation.ts +34 -3
- package/src/utils/tx_effect_creation.ts +3 -2
- 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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AztecNodeService } from '@aztec/aztec-node';
|
|
2
2
|
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
5
|
+
import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
6
6
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
7
7
|
import { TXEArchiver } from './archiver.js';
|
|
8
8
|
import { DummyP2P } from './dummy_p2p_client.js';
|
|
@@ -15,37 +15,31 @@ export class TXEStateMachine {
|
|
|
15
15
|
node;
|
|
16
16
|
synchronizer;
|
|
17
17
|
archiver;
|
|
18
|
-
|
|
19
|
-
constructor(node, synchronizer, archiver,
|
|
18
|
+
anchorBlockStore;
|
|
19
|
+
constructor(node, synchronizer, archiver, anchorBlockStore){
|
|
20
20
|
this.node = node;
|
|
21
21
|
this.synchronizer = synchronizer;
|
|
22
22
|
this.archiver = archiver;
|
|
23
|
-
this.
|
|
23
|
+
this.anchorBlockStore = anchorBlockStore;
|
|
24
24
|
}
|
|
25
25
|
static async create(db) {
|
|
26
26
|
const archiver = new TXEArchiver(db);
|
|
27
27
|
const synchronizer = await TXESynchronizer.create();
|
|
28
|
-
const
|
|
28
|
+
const anchorBlockStore = new AnchorBlockStore(db);
|
|
29
29
|
const aztecNodeConfig = {};
|
|
30
30
|
const log = createLogger('txe_node');
|
|
31
31
|
const node = new AztecNodeService(aztecNodeConfig, new DummyP2P(), archiver, archiver, archiver, archiver, synchronizer, undefined, undefined, undefined, undefined, VERSION, CHAIN_ID, new TXEGlobalVariablesBuilder(), new MockEpochCache(), getPackageVersion() ?? '', new TestCircuitVerifier(), undefined, log);
|
|
32
|
-
return new this(node, synchronizer, archiver,
|
|
32
|
+
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
33
33
|
}
|
|
34
34
|
async handleL2Block(block) {
|
|
35
|
+
const checkpoint = block.toCheckpoint();
|
|
36
|
+
const publishedCheckpoint = new PublishedCheckpoint(checkpoint, new L1PublishedData(BigInt(block.header.globalVariables.blockNumber), block.header.globalVariables.timestamp, block.header.globalVariables.blockNumber.toString()), []);
|
|
35
37
|
await Promise.all([
|
|
36
|
-
this.synchronizer.handleL2Block(block),
|
|
37
|
-
this.archiver.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
blockHash: block.header.globalVariables.blockNumber.toString(),
|
|
42
|
-
blockNumber: BigInt(block.header.globalVariables.blockNumber),
|
|
43
|
-
timestamp: block.header.globalVariables.timestamp
|
|
44
|
-
},
|
|
45
|
-
attestations: []
|
|
46
|
-
})
|
|
47
|
-
]),
|
|
48
|
-
this.syncDataProvider.setHeader(block.getBlockHeader())
|
|
38
|
+
this.synchronizer.handleL2Block(block.toL2Block()),
|
|
39
|
+
this.archiver.addCheckpoints([
|
|
40
|
+
publishedCheckpoint
|
|
41
|
+
], undefined),
|
|
42
|
+
this.anchorBlockStore.setHeader(block.getBlockHeader())
|
|
49
43
|
]);
|
|
50
44
|
}
|
|
51
45
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
2
3
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations, SnapshotDataKeys, WorldStateSynchronizer, WorldStateSynchronizerStatus } from '@aztec/stdlib/interfaces/server';
|
|
3
4
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
4
5
|
export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
@@ -6,14 +7,14 @@ export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
6
7
|
private blockNumber;
|
|
7
8
|
constructor(nativeWorldStateService: NativeWorldStateService);
|
|
8
9
|
static create(): Promise<TXESynchronizer>;
|
|
9
|
-
handleL2Block(block:
|
|
10
|
+
handleL2Block(block: L2BlockNew): Promise<void>;
|
|
10
11
|
/**
|
|
11
12
|
* Forces an immediate sync to an optionally provided minimum block number
|
|
12
13
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
13
14
|
* @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
|
|
14
15
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
15
16
|
*/
|
|
16
|
-
syncImmediate(_minBlockNumber?:
|
|
17
|
+
syncImmediate(_minBlockNumber?: BlockNumber, _skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber>;
|
|
17
18
|
/** Returns an instance of MerkleTreeAdminOperations that will not include uncommitted data. */
|
|
18
19
|
getCommitted(): MerkleTreeReadOperations;
|
|
19
20
|
/** Forks the world state at the given block number, defaulting to the latest one. */
|
|
@@ -29,4 +30,4 @@ export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
29
30
|
resumeSync(): void;
|
|
30
31
|
clear(): Promise<void>;
|
|
31
32
|
}
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RhdGVfbWFjaGluZS9zeW5jaHJvbml6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUNWLHdCQUF3QixFQUN4Qix5QkFBeUIsRUFDekIsZ0JBQWdCLEVBQ2hCLHNCQUFzQixFQUN0Qiw0QkFBNEIsRUFDN0IsTUFBTSxpQ0F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LElBQUksQ0FBQyxDQUUzQjtJQUVNLFFBQVEsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBRS9CO0lBRU0sVUFBVSxJQUFJLElBQUksQ0FFeEI7SUFFTSxLQUFLLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUU1QjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronizer.d.ts","sourceRoot":"","sources":["../../src/state_machine/synchronizer.ts"],"names":[],"mappings":"
|
|
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,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,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,UAAU,iBAO3C;IAED;;;;;OAKG;IACI,aAAa,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,4BAA4B,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAEhH;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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
4
5
|
export class TXESynchronizer {
|
|
5
6
|
nativeWorldStateService;
|
|
@@ -7,7 +8,7 @@ export class TXESynchronizer {
|
|
|
7
8
|
blockNumber;
|
|
8
9
|
constructor(nativeWorldStateService){
|
|
9
10
|
this.nativeWorldStateService = nativeWorldStateService;
|
|
10
|
-
this.blockNumber =
|
|
11
|
+
this.blockNumber = BlockNumber.ZERO;
|
|
11
12
|
}
|
|
12
13
|
static async create() {
|
|
13
14
|
const nativeWorldStateService = await NativeWorldStateService.tmp();
|
|
@@ -29,10 +30,10 @@ export class TXESynchronizer {
|
|
|
29
30
|
return this.nativeWorldStateService.getCommitted();
|
|
30
31
|
}
|
|
31
32
|
/** Forks the world state at the given block number, defaulting to the latest one. */ fork(block) {
|
|
32
|
-
return this.nativeWorldStateService.fork(block);
|
|
33
|
+
return this.nativeWorldStateService.fork(block ? BlockNumber(block) : undefined);
|
|
33
34
|
}
|
|
34
35
|
/** Gets a handle that allows reading the state as it was at the given block number. */ getSnapshot(blockNumber) {
|
|
35
|
-
return this.nativeWorldStateService.getSnapshot(blockNumber);
|
|
36
|
+
return this.nativeWorldStateService.getSnapshot(BlockNumber(blockNumber));
|
|
36
37
|
}
|
|
37
38
|
/** Backups the db to the target path. */ backupTo(dstPath, compact) {
|
|
38
39
|
return this.nativeWorldStateService.backupTo(dstPath, compact);
|
package/dest/txe_session.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
4
|
import { KeyStore } from '@aztec/key-store';
|
|
4
5
|
import type { ProtocolContract } from '@aztec/protocol-contracts';
|
|
5
|
-
import {
|
|
6
|
+
import { AddressStore, CapsuleStore, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
6
7
|
import { type IPrivateExecutionOracle, type IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
7
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
9
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
9
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
10
10
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
11
11
|
import { RPCTranslator } from './rpc_translator.js';
|
|
12
12
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
13
13
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
15
|
+
import { TXEContractStore } from './util/txe_contract_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];
|
|
@@ -24,7 +24,7 @@ export type TXEOracleFunctionName = Exclude<MethodNames<RPCTranslator>, 'constru
|
|
|
24
24
|
export interface TXESessionStateHandler {
|
|
25
25
|
enterTopLevelState(): Promise<void>;
|
|
26
26
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
27
|
-
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?:
|
|
27
|
+
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
28
28
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -35,17 +35,22 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
35
35
|
private logger;
|
|
36
36
|
private stateMachine;
|
|
37
37
|
private oracleHandler;
|
|
38
|
-
private
|
|
38
|
+
private contractStore;
|
|
39
|
+
private noteStore;
|
|
39
40
|
private keyStore;
|
|
40
|
-
private
|
|
41
|
-
private
|
|
41
|
+
private addressStore;
|
|
42
|
+
private accountStore;
|
|
43
|
+
private senderTaggingStore;
|
|
44
|
+
private recipientTaggingStore;
|
|
45
|
+
private senderAddressBookStore;
|
|
46
|
+
private capsuleStore;
|
|
47
|
+
private privateEventStore;
|
|
42
48
|
private chainId;
|
|
43
49
|
private version;
|
|
44
50
|
private nextBlockTimestamp;
|
|
45
|
-
private pxeOracleInterface;
|
|
46
51
|
private state;
|
|
47
52
|
private authwits;
|
|
48
|
-
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle,
|
|
53
|
+
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle, contractStore: TXEContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, accountStore: TXEAccountStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, chainId: Fr, version: Fr, nextBlockTimestamp: bigint);
|
|
49
54
|
static init(protocolContracts: ProtocolContract[]): Promise<TXESession>;
|
|
50
55
|
/**
|
|
51
56
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -55,13 +60,14 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
55
60
|
*/
|
|
56
61
|
processFunction(functionName: TXEOracleFunctionName, inputs: ForeignCallArgs): Promise<ForeignCallResult>;
|
|
57
62
|
enterTopLevelState(): Promise<void>;
|
|
58
|
-
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?:
|
|
63
|
+
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
59
64
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
60
65
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
61
66
|
private exitTopLevelState;
|
|
62
67
|
private exitPrivateState;
|
|
63
68
|
private exitPublicState;
|
|
64
69
|
private exitUtilityContext;
|
|
70
|
+
private utilityExecutorForContractSync;
|
|
65
71
|
}
|
|
66
72
|
export {};
|
|
67
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFn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DdkI7SUFFSyxpQkFBaUIsQ0FDckIsZUFBZSxHQUFFLFlBQThCLEVBQy9DLGlCQUFpQixDQUFDLEVBQUUsV0FBVyxHQUM5QixPQUFPLENBQUMsb0JBQW9CLENBQUMsQ0E2RC9CO0lBRUssZ0JBQWdCLENBQUMsZUFBZSxDQUFDLEVBQUUsWUFBWSxpQkFzQnBEO0lBRUssaUJBQWlCLENBQUMsZUFBZSxHQUFFLFlBQThCLGlCQW1DdEU7SUFFRCxPQUFPLENBQUMsaUJBQWlCO1lBaUJYLGdCQUFnQjtZQWlDaEIsZUFBZTtJQVM3QixPQUFPLENBQUMsa0JBQWtCO0lBTTFCLE9BQU8sQ0FBQyw4QkFBOEI7Q0EyQ3ZDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
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,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,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,o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Ae,CAAC,EAAE,YAAY,iBAsBpD;IAEK,iBAAiB,CAAC,eAAe,GAAE,YAA8B,iBAmCtE;IAED,OAAO,CAAC,iBAAiB;YAiBX,gBAAgB;YAiChB,eAAe;IAS7B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,8BAA8B;CA2CvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { KeyStore } from '@aztec/key-store';
|
|
4
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
5
|
-
import {
|
|
6
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
7
|
-
import {
|
|
6
|
+
import { AddressStore, CapsuleStore, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
|
+
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
|
+
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
8
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
10
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
11
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
12
|
-
import {
|
|
13
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
13
14
|
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
14
15
|
import { z } from 'zod';
|
|
16
|
+
import { DEFAULT_ADDRESS } from './constants.js';
|
|
15
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
16
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
17
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
18
20
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees,
|
|
21
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
22
|
+
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
23
|
+
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
22
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
23
|
-
const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
24
25
|
/**
|
|
25
26
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
26
27
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -28,28 +29,38 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
28
29
|
logger;
|
|
29
30
|
stateMachine;
|
|
30
31
|
oracleHandler;
|
|
31
|
-
|
|
32
|
+
contractStore;
|
|
33
|
+
noteStore;
|
|
32
34
|
keyStore;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
addressStore;
|
|
36
|
+
accountStore;
|
|
37
|
+
senderTaggingStore;
|
|
38
|
+
recipientTaggingStore;
|
|
39
|
+
senderAddressBookStore;
|
|
40
|
+
capsuleStore;
|
|
41
|
+
privateEventStore;
|
|
35
42
|
chainId;
|
|
36
43
|
version;
|
|
37
44
|
nextBlockTimestamp;
|
|
38
|
-
pxeOracleInterface;
|
|
39
45
|
state;
|
|
40
46
|
authwits;
|
|
41
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
47
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, chainId, version, nextBlockTimestamp){
|
|
42
48
|
this.logger = logger;
|
|
43
49
|
this.stateMachine = stateMachine;
|
|
44
50
|
this.oracleHandler = oracleHandler;
|
|
45
|
-
this.
|
|
51
|
+
this.contractStore = contractStore;
|
|
52
|
+
this.noteStore = noteStore;
|
|
46
53
|
this.keyStore = keyStore;
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
54
|
+
this.addressStore = addressStore;
|
|
55
|
+
this.accountStore = accountStore;
|
|
56
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
57
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
58
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
59
|
+
this.capsuleStore = capsuleStore;
|
|
60
|
+
this.privateEventStore = privateEventStore;
|
|
49
61
|
this.chainId = chainId;
|
|
50
62
|
this.version = version;
|
|
51
63
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
52
|
-
this.pxeOracleInterface = pxeOracleInterface;
|
|
53
64
|
this.state = {
|
|
54
65
|
name: 'TOP_LEVEL'
|
|
55
66
|
};
|
|
@@ -57,27 +68,28 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
57
68
|
}
|
|
58
69
|
static async init(protocolContracts) {
|
|
59
70
|
const store = await openTmpStore('txe-session');
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
71
|
+
const addressStore = new AddressStore(store);
|
|
72
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
73
|
+
const contractStore = new TXEContractStore(store);
|
|
74
|
+
const noteStore = await NoteStore.create(store);
|
|
75
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
76
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
77
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
78
|
+
const capsuleStore = new CapsuleStore(store);
|
|
66
79
|
const keyStore = new KeyStore(store);
|
|
67
|
-
const
|
|
80
|
+
const accountStore = new TXEAccountStore(store);
|
|
68
81
|
// Register protocol contracts.
|
|
69
82
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
70
|
-
await
|
|
71
|
-
await
|
|
83
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
84
|
+
await contractStore.addContractInstance(instance);
|
|
72
85
|
}
|
|
73
86
|
const stateMachine = await TXEStateMachine.create(store);
|
|
74
87
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
75
88
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
76
89
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
77
|
-
const
|
|
78
|
-
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractDataProvider, keyStore, addressDataProvider, accountDataProvider, pxeOracleInterface, nextBlockTimestamp, version, chainId, new Map());
|
|
90
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map());
|
|
79
91
|
await topLevelOracleHandler.txeAdvanceBlocksBy(1);
|
|
80
|
-
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler,
|
|
92
|
+
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, version, chainId, nextBlockTimestamp);
|
|
81
93
|
}
|
|
82
94
|
/**
|
|
83
95
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -126,7 +138,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
126
138
|
this.state;
|
|
127
139
|
}
|
|
128
140
|
}
|
|
129
|
-
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.
|
|
141
|
+
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);
|
|
130
142
|
this.state = {
|
|
131
143
|
name: 'TOP_LEVEL'
|
|
132
144
|
};
|
|
@@ -134,19 +146,14 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
134
146
|
}
|
|
135
147
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
136
148
|
this.exitTopLevelState();
|
|
137
|
-
|
|
138
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
139
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
140
|
-
// be removed from the database.
|
|
141
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
142
|
-
await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
|
|
149
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
143
150
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
144
151
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
145
152
|
// a single transaction with the effects of what was done in the test.
|
|
146
153
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
147
154
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
148
155
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
149
|
-
blockNumber: latestBlock.globalVariables.blockNumber + 1,
|
|
156
|
+
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
150
157
|
timestamp: this.nextBlockTimestamp,
|
|
151
158
|
version: this.version,
|
|
152
159
|
chainId: this.chainId
|
|
@@ -155,7 +162,8 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
155
162
|
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
156
163
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
157
164
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
158
|
-
|
|
165
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
166
|
+
this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, utilityExecutor, [], [], new HashedValuesCache(), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
159
167
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
160
168
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
161
169
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -177,7 +185,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
177
185
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
178
186
|
const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.blockNumber;
|
|
179
187
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
180
|
-
blockNumber: latestBlockNumber + 1,
|
|
188
|
+
blockNumber: BlockNumber(latestBlockNumber + 1),
|
|
181
189
|
timestamp: this.nextBlockTimestamp,
|
|
182
190
|
version: this.version,
|
|
183
191
|
chainId: this.chainId
|
|
@@ -195,8 +203,9 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
195
203
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
196
204
|
// be removed from the database.
|
|
197
205
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
198
|
-
await this.
|
|
199
|
-
|
|
206
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
207
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
208
|
+
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
200
209
|
this.state = {
|
|
201
210
|
name: 'UTILITY'
|
|
202
211
|
};
|
|
@@ -230,9 +239,9 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
230
239
|
// We build a block holding just this transaction
|
|
231
240
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
232
241
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
233
|
-
const block =
|
|
242
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
|
|
234
243
|
txEffect
|
|
235
|
-
])
|
|
244
|
+
]);
|
|
236
245
|
await this.stateMachine.handleL2Block(block);
|
|
237
246
|
await forkedWorldTrees.close();
|
|
238
247
|
this.logger.debug('Exited PublicContext with built block', {
|
|
@@ -252,4 +261,26 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
252
261
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
253
262
|
}
|
|
254
263
|
}
|
|
264
|
+
utilityExecutorForContractSync(anchorBlock) {
|
|
265
|
+
return async (call)=>{
|
|
266
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
267
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
268
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlock, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
272
|
+
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
273
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
274
|
+
throw new ExecutionError(err.message, {
|
|
275
|
+
contractAddress: call.to,
|
|
276
|
+
functionSelector: call.selector
|
|
277
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
278
|
+
cause: err
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
} catch (err) {
|
|
282
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
255
286
|
}
|