@aztec/txe 3.0.0-rc.5 → 4.0.0-nightly.20260107
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 +4 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +3 -5
- package/dest/oracle/txe_oracle_top_level_context.d.ts +18 -10
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +83 -52
- package/dest/rpc_translator.d.ts +9 -3
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +33 -3
- package/dest/state_machine/archiver.d.ts +19 -7
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +93 -15
- 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 +3 -2
- 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 +13 -19
- package/dest/txe_session.d.ts +15 -9
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +72 -42
- package/dest/util/encoding.d.ts +601 -2
- package/dest/util/encoding.d.ts.map +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 +4 -4
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +10 -10
- package/dest/utils/block_creation.d.ts +16 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +22 -1
- package/package.json +15 -15
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +3 -1
- package/src/oracle/txe_oracle_public_context.ts +3 -8
- package/src/oracle/txe_oracle_top_level_context.ts +125 -76
- package/src/rpc_translator.ts +45 -3
- package/src/state_machine/archiver.ts +119 -21
- package/src/state_machine/dummy_p2p_client.ts +3 -1
- package/src/state_machine/global_variable_builder.ts +18 -1
- package/src/state_machine/index.ts +18 -17
- package/src/txe_session.ts +157 -69
- 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 +9 -9
- package/src/utils/block_creation.ts +31 -1
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
|
@@ -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
38
|
this.synchronizer.handleL2Block(block.toL2Block()),
|
|
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())
|
|
39
|
+
this.archiver.addCheckpoints([
|
|
40
|
+
publishedCheckpoint
|
|
41
|
+
], undefined),
|
|
42
|
+
this.anchorBlockStore.setHeader(block.getBlockHeader())
|
|
49
43
|
]);
|
|
50
44
|
}
|
|
51
45
|
}
|
package/dest/txe_session.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
5
|
import type { ProtocolContract } from '@aztec/protocol-contracts';
|
|
6
|
-
import {
|
|
6
|
+
import { AddressStore, CapsuleStore, 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
9
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
@@ -11,8 +11,8 @@ import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfac
|
|
|
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];
|
|
@@ -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.
|
|
@@ -62,6 +67,7 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUNsRSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFNUMsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNsRSxPQUFPLEVBQ0wsWUFBWSxFQUNaLFlBQVksRUFFWixTQUFTLEVBQ1QsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUNyQixzQkFBc0IsRUFDdEIsa0JBQWtCLEVBQ25CLE1BQU0sbUJBQW1CLENBQUM7QUFDM0IsT0FBTyxFQUlMLEtBQUssdUJBQXVCLEVBQzVCLEtBQUssdUJBQXVCLEVBSTdCLE1BQU0sc0JBQXNCLENBQUM7QUFXOUIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRzNELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBTzVELE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLG1CQUFtQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHdkYsT0FBTyxFQU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,mBAAmB,EACf,aAAa,EAAE,gBAAgB,EAC/B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,EAC7B,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,kBAAkB,EAAE,MAAM,EAChC;IAEJ,OAAa,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,uBA+DtD;IAED;;;;;OAKG;IACH,eAAe,CAAC,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuBxG;IAEK,kBAAkB,kBA0CvB;IAEK,iBAAiB,CACrB,eAAe,GAAE,YAA8B,EAC/C,iBAAiB,CAAC,EAAE,WAAW,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CA6D/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;IAM1B,OAAO,CAAC,8BAA8B;CA2CvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -3,25 +3,25 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
-
import {
|
|
7
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
|
-
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';
|
|
9
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
12
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
13
|
-
import {
|
|
13
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
14
14
|
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
+
import { DEFAULT_ADDRESS } from './constants.js';
|
|
16
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
17
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
18
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
19
20
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
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';
|
|
23
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
24
|
-
const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
25
25
|
/**
|
|
26
26
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
27
27
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -29,28 +29,38 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
29
29
|
logger;
|
|
30
30
|
stateMachine;
|
|
31
31
|
oracleHandler;
|
|
32
|
-
|
|
32
|
+
contractStore;
|
|
33
|
+
noteStore;
|
|
33
34
|
keyStore;
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
addressStore;
|
|
36
|
+
accountStore;
|
|
37
|
+
senderTaggingStore;
|
|
38
|
+
recipientTaggingStore;
|
|
39
|
+
senderAddressBookStore;
|
|
40
|
+
capsuleStore;
|
|
41
|
+
privateEventStore;
|
|
36
42
|
chainId;
|
|
37
43
|
version;
|
|
38
44
|
nextBlockTimestamp;
|
|
39
|
-
pxeOracleInterface;
|
|
40
45
|
state;
|
|
41
46
|
authwits;
|
|
42
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
47
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, chainId, version, nextBlockTimestamp){
|
|
43
48
|
this.logger = logger;
|
|
44
49
|
this.stateMachine = stateMachine;
|
|
45
50
|
this.oracleHandler = oracleHandler;
|
|
46
|
-
this.
|
|
51
|
+
this.contractStore = contractStore;
|
|
52
|
+
this.noteStore = noteStore;
|
|
47
53
|
this.keyStore = keyStore;
|
|
48
|
-
this.
|
|
49
|
-
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;
|
|
50
61
|
this.chainId = chainId;
|
|
51
62
|
this.version = version;
|
|
52
63
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
53
|
-
this.pxeOracleInterface = pxeOracleInterface;
|
|
54
64
|
this.state = {
|
|
55
65
|
name: 'TOP_LEVEL'
|
|
56
66
|
};
|
|
@@ -58,27 +68,28 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
58
68
|
}
|
|
59
69
|
static async init(protocolContracts) {
|
|
60
70
|
const store = await openTmpStore('txe-session');
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
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);
|
|
67
79
|
const keyStore = new KeyStore(store);
|
|
68
|
-
const
|
|
80
|
+
const accountStore = new TXEAccountStore(store);
|
|
69
81
|
// Register protocol contracts.
|
|
70
82
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
71
|
-
await
|
|
72
|
-
await
|
|
83
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
84
|
+
await contractStore.addContractInstance(instance);
|
|
73
85
|
}
|
|
74
86
|
const stateMachine = await TXEStateMachine.create(store);
|
|
75
87
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
76
88
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
77
89
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
78
|
-
const
|
|
79
|
-
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());
|
|
80
91
|
await topLevelOracleHandler.txeAdvanceBlocksBy(1);
|
|
81
|
-
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);
|
|
82
93
|
}
|
|
83
94
|
/**
|
|
84
95
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -127,7 +138,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
127
138
|
this.state;
|
|
128
139
|
}
|
|
129
140
|
}
|
|
130
|
-
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);
|
|
131
142
|
this.state = {
|
|
132
143
|
name: 'TOP_LEVEL'
|
|
133
144
|
};
|
|
@@ -135,12 +146,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
135
146
|
}
|
|
136
147
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
137
148
|
this.exitTopLevelState();
|
|
138
|
-
|
|
139
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
140
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
141
|
-
// be removed from the database.
|
|
142
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
143
|
-
await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
|
|
149
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
144
150
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
145
151
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
146
152
|
// a single transaction with the effects of what was done in the test.
|
|
@@ -156,7 +162,8 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
156
162
|
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
157
163
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
158
164
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
159
|
-
|
|
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);
|
|
160
167
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
161
168
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
162
169
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -196,8 +203,9 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
196
203
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
197
204
|
// be removed from the database.
|
|
198
205
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
199
|
-
await this.
|
|
200
|
-
|
|
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);
|
|
201
209
|
this.state = {
|
|
202
210
|
name: 'UTILITY'
|
|
203
211
|
};
|
|
@@ -231,9 +239,9 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
231
239
|
// We build a block holding just this transaction
|
|
232
240
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
233
241
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
234
|
-
const block =
|
|
242
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
|
|
235
243
|
txEffect
|
|
236
|
-
])
|
|
244
|
+
]);
|
|
237
245
|
await this.stateMachine.handleL2Block(block);
|
|
238
246
|
await forkedWorldTrees.close();
|
|
239
247
|
this.logger.debug('Exited PublicContext with built block', {
|
|
@@ -253,4 +261,26 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
253
261
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
254
262
|
}
|
|
255
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
|
+
}
|
|
256
286
|
}
|