@aztec/txe 0.0.1-commit.9b94fc1 → 0.0.1-commit.c7c42ec
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 +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 +20 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +77 -54
- 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 +50 -38
- 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/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 +109 -80
- 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 +107 -68
- 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RhdGVfbWFjaGluZS9zeW5jaHJvbml6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUNWLHdCQUF3QixFQUN4Qix5QkFBeUIsRUFDekIsZ0JBQWdCLEVBQ2hCLHNCQUFzQixFQUN0Qiw0QkFBNEIsRUFDN0IsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6QyxPQUFPLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSwyQkFBMkIsQ0FB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S9CO0lBRU0sVUFBVSxJQUFJLElBQUksQ0FFeEI7SUFFTSxLQUFLLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUU1QjtDQUNGIn0=
|
|
@@ -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,9 +24,10 @@ 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
|
+
export declare const DEFAULT_ADDRESS: AztecAddress;
|
|
30
31
|
/**
|
|
31
32
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
32
33
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -35,17 +36,22 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
35
36
|
private logger;
|
|
36
37
|
private stateMachine;
|
|
37
38
|
private oracleHandler;
|
|
38
|
-
private
|
|
39
|
+
private contractStore;
|
|
40
|
+
private noteStore;
|
|
39
41
|
private keyStore;
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
+
private addressStore;
|
|
43
|
+
private accountStore;
|
|
44
|
+
private senderTaggingStore;
|
|
45
|
+
private recipientTaggingStore;
|
|
46
|
+
private senderAddressBookStore;
|
|
47
|
+
private capsuleStore;
|
|
48
|
+
private privateEventStore;
|
|
42
49
|
private chainId;
|
|
43
50
|
private version;
|
|
44
51
|
private nextBlockTimestamp;
|
|
45
|
-
private pxeOracleInterface;
|
|
46
52
|
private state;
|
|
47
53
|
private authwits;
|
|
48
|
-
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle,
|
|
54
|
+
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
55
|
static init(protocolContracts: ProtocolContract[]): Promise<TXESession>;
|
|
50
56
|
/**
|
|
51
57
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -55,7 +61,7 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
55
61
|
*/
|
|
56
62
|
processFunction(functionName: TXEOracleFunctionName, inputs: ForeignCallArgs): Promise<ForeignCallResult>;
|
|
57
63
|
enterTopLevelState(): Promise<void>;
|
|
58
|
-
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?:
|
|
64
|
+
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
59
65
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
60
66
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
61
67
|
private exitTopLevelState;
|
|
@@ -64,4 +70,4 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
64
70
|
private exitUtilityContext;
|
|
65
71
|
}
|
|
66
72
|
export {};
|
|
67
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQU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lBQVksRUFBRSxxQkFBcUIsRUFBRSxNQUFNLEVBQUUsZUFBZSxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQXVCeEc7SUFFSyxrQkFBa0Isa0JBMEN2QjtJQUVLLGlCQUFpQixDQUNyQixlQUFlLEdBQUUsWUFBOEIsRUFDL0MsaUJBQWlCLENBQUMsRUFBRSxXQUFXLEdBQzlCLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQWdFL0I7SUFFSyxnQkFBZ0IsQ0FBQyxlQUFlLENBQUMsRUFBRSxZQUFZLGlCQXNCcEQ7SUFFSyxpQkFBaUIsQ0FBQyxlQUFlLEdBQUUsWUFBOEIsaUJBbUN0RTtJQUVELE9BQU8sQ0FBQyxpQkFBaUI7WUFpQlgsZ0JBQWdCO1lBaUNoQixlQUFlO0lBUzdCLE9BQU8sQ0FBQyxrQkFBa0I7Q0FLM0IifQ==
|
|
@@ -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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AAkB,kBA0CvB;IAEK,iBAAiB,CACrB,eAAe,GAAE,YAA8B,EAC/C,iBAAiB,CAAC,EAAE,WAAW,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAgE/B;IAEK,gBAAgB,CAAC,eAAe,CAAC,EAAE,YAAY,iBAsBpD;IAEK,iBAAiB,CAAC,eAAe,GAAE,YAA8B,iBAmCtE;IAED,OAAO,CAAC,iBAAiB;YAiBX,gBAAgB;YAiChB,eAAe;IAS7B,OAAO,CAAC,kBAAkB;CAK3B"}
|
package/dest/txe_session.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
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 { AddressStore, CapsuleStore, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
6
7
|
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
7
8
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
10
10
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
11
11
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
12
|
-
import {
|
|
12
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
13
13
|
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
16
16
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
17
17
|
import { RPCTranslator } from './rpc_translator.js';
|
|
18
18
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees,
|
|
19
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
20
|
+
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
21
|
+
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
22
22
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
23
|
-
const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
23
|
+
export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
24
24
|
/**
|
|
25
25
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
26
26
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -28,28 +28,38 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
28
28
|
logger;
|
|
29
29
|
stateMachine;
|
|
30
30
|
oracleHandler;
|
|
31
|
-
|
|
31
|
+
contractStore;
|
|
32
|
+
noteStore;
|
|
32
33
|
keyStore;
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
addressStore;
|
|
35
|
+
accountStore;
|
|
36
|
+
senderTaggingStore;
|
|
37
|
+
recipientTaggingStore;
|
|
38
|
+
senderAddressBookStore;
|
|
39
|
+
capsuleStore;
|
|
40
|
+
privateEventStore;
|
|
35
41
|
chainId;
|
|
36
42
|
version;
|
|
37
43
|
nextBlockTimestamp;
|
|
38
|
-
pxeOracleInterface;
|
|
39
44
|
state;
|
|
40
45
|
authwits;
|
|
41
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
46
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, chainId, version, nextBlockTimestamp){
|
|
42
47
|
this.logger = logger;
|
|
43
48
|
this.stateMachine = stateMachine;
|
|
44
49
|
this.oracleHandler = oracleHandler;
|
|
45
|
-
this.
|
|
50
|
+
this.contractStore = contractStore;
|
|
51
|
+
this.noteStore = noteStore;
|
|
46
52
|
this.keyStore = keyStore;
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
53
|
+
this.addressStore = addressStore;
|
|
54
|
+
this.accountStore = accountStore;
|
|
55
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
56
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
57
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
58
|
+
this.capsuleStore = capsuleStore;
|
|
59
|
+
this.privateEventStore = privateEventStore;
|
|
49
60
|
this.chainId = chainId;
|
|
50
61
|
this.version = version;
|
|
51
62
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
52
|
-
this.pxeOracleInterface = pxeOracleInterface;
|
|
53
63
|
this.state = {
|
|
54
64
|
name: 'TOP_LEVEL'
|
|
55
65
|
};
|
|
@@ -57,27 +67,28 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
57
67
|
}
|
|
58
68
|
static async init(protocolContracts) {
|
|
59
69
|
const store = await openTmpStore('txe-session');
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
70
|
+
const addressStore = new AddressStore(store);
|
|
71
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
72
|
+
const contractStore = new TXEContractStore(store);
|
|
73
|
+
const noteStore = await NoteStore.create(store);
|
|
74
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
75
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
76
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
77
|
+
const capsuleStore = new CapsuleStore(store);
|
|
66
78
|
const keyStore = new KeyStore(store);
|
|
67
|
-
const
|
|
79
|
+
const accountStore = new TXEAccountStore(store);
|
|
68
80
|
// Register protocol contracts.
|
|
69
81
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
70
|
-
await
|
|
71
|
-
await
|
|
82
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
83
|
+
await contractStore.addContractInstance(instance);
|
|
72
84
|
}
|
|
73
85
|
const stateMachine = await TXEStateMachine.create(store);
|
|
74
86
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
75
87
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
76
88
|
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());
|
|
89
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map());
|
|
79
90
|
await topLevelOracleHandler.txeAdvanceBlocksBy(1);
|
|
80
|
-
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler,
|
|
91
|
+
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, version, chainId, nextBlockTimestamp);
|
|
81
92
|
}
|
|
82
93
|
/**
|
|
83
94
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -126,7 +137,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
126
137
|
this.state;
|
|
127
138
|
}
|
|
128
139
|
}
|
|
129
|
-
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.
|
|
140
|
+
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
141
|
this.state = {
|
|
131
142
|
name: 'TOP_LEVEL'
|
|
132
143
|
};
|
|
@@ -139,14 +150,14 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
139
150
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
140
151
|
// be removed from the database.
|
|
141
152
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
142
|
-
await this.
|
|
153
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
143
154
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
144
155
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
145
156
|
// a single transaction with the effects of what was done in the test.
|
|
146
157
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
147
158
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
148
159
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
149
|
-
blockNumber: latestBlock.globalVariables.blockNumber + 1,
|
|
160
|
+
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
150
161
|
timestamp: this.nextBlockTimestamp,
|
|
151
162
|
version: this.version,
|
|
152
163
|
chainId: this.chainId
|
|
@@ -155,7 +166,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
155
166
|
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
156
167
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
157
168
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
158
|
-
this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, [], [], new HashedValuesCache(), noteCache, taggingIndexCache, this.
|
|
169
|
+
this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, [], [], 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
170
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
160
171
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
161
172
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -177,7 +188,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
177
188
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
178
189
|
const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.blockNumber;
|
|
179
190
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
180
|
-
blockNumber: latestBlockNumber + 1,
|
|
191
|
+
blockNumber: BlockNumber(latestBlockNumber + 1),
|
|
181
192
|
timestamp: this.nextBlockTimestamp,
|
|
182
193
|
version: this.version,
|
|
183
194
|
chainId: this.chainId
|
|
@@ -195,8 +206,9 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
195
206
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
196
207
|
// be removed from the database.
|
|
197
208
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
198
|
-
await this.
|
|
199
|
-
|
|
209
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
210
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
211
|
+
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
212
|
this.state = {
|
|
201
213
|
name: 'UTILITY'
|
|
202
214
|
};
|
|
@@ -230,9 +242,9 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
230
242
|
// We build a block holding just this transaction
|
|
231
243
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
232
244
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
233
|
-
const block =
|
|
245
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
|
|
234
246
|
txEffect
|
|
235
|
-
])
|
|
247
|
+
]);
|
|
236
248
|
await this.stateMachine.handleL2Block(block);
|
|
237
249
|
await forkedWorldTrees.close();
|
|
238
250
|
this.logger.debug('Exited PublicContext with built block', {
|