@aztec/txe 0.0.1-commit.1bb068fb5 → 0.0.1-commit.217f559981
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 +82 -50
- package/dest/oracle/interfaces.d.ts +2 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +4 -5
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +6 -6
- package/dest/rpc_translator.d.ts +2 -2
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +2 -2
- package/dest/state_machine/dummy_p2p_client.d.ts +5 -4
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +6 -3
- package/dest/state_machine/index.d.ts +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +1 -1
- package/dest/txe_session.d.ts +4 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +1 -8
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +5 -22
- package/package.json +15 -15
- package/src/index.ts +83 -49
- package/src/oracle/interfaces.ts +1 -1
- package/src/oracle/txe_oracle_top_level_context.ts +8 -12
- package/src/rpc_translator.ts +2 -2
- package/src/state_machine/dummy_p2p_client.ts +10 -6
- package/src/state_machine/index.ts +1 -0
- package/src/txe_session.ts +3 -11
- package/src/util/txe_public_contract_data_source.ts +10 -36
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
package/dest/txe_session.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import
|
|
6
|
-
import { AddressStore, CapsuleStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
5
|
+
import { AddressStore, CapsuleStore, ContractStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
6
|
import { type IPrivateExecutionOracle, type IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
8
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
@@ -12,7 +11,6 @@ import { RPCTranslator } from './rpc_translator.js';
|
|
|
12
11
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
13
12
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
14
13
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
15
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
16
14
|
type MethodNames<T> = {
|
|
17
15
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
18
16
|
}[keyof T];
|
|
@@ -52,8 +50,8 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
52
50
|
private nextBlockTimestamp;
|
|
53
51
|
private state;
|
|
54
52
|
private authwits;
|
|
55
|
-
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle, contractStore:
|
|
56
|
-
static init(
|
|
53
|
+
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle, contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, accountStore: TXEAccountStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, jobCoordinator: JobCoordinator, currentJobId: string, chainId: Fr, version: Fr, nextBlockTimestamp: bigint);
|
|
54
|
+
static init(contractStore: ContractStore): Promise<TXESession>;
|
|
57
55
|
/**
|
|
58
56
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
59
57
|
* @param functionName The name of the oracle.
|
|
@@ -72,4 +70,4 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
72
70
|
private utilityExecutorForContractSync;
|
|
73
71
|
}
|
|
74
72
|
export {};
|
|
75
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUNsRSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFHNUMsT0FBTyxFQUNMLFlBQVksRUFFWixZQUFZLEVBQ1osYUFBYSxFQUNiLGNBQWMsRUFFZCxTQUFTLEVBQ1QsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUNyQixzQkFBc0IsRUFDdEIsa0JBQWtCLEVBQ25CLE1BQ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LGVBQWU7SUFTN0IsT0FBTyxDQUFDLGtCQUFrQjtJQU0xQixPQUFPLENBQUMsOEJBQThCO0NBNEN2QyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EACL,YAAY,EAEZ,YAAY,EACZ,aAAa,EACb,cAAc,EAEd,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAI7B,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAO5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGvF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OA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;CA4CvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -20,7 +20,6 @@ import { RPCTranslator } from './rpc_translator.js';
|
|
|
20
20
|
import { TXEArchiver } from './state_machine/archiver.js';
|
|
21
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
22
22
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
23
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
24
23
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
25
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
26
25
|
/**
|
|
@@ -71,11 +70,10 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
71
70
|
};
|
|
72
71
|
this.authwits = new Map();
|
|
73
72
|
}
|
|
74
|
-
static async init(
|
|
73
|
+
static async init(contractStore) {
|
|
75
74
|
const store = await openTmpStore('txe-session');
|
|
76
75
|
const addressStore = new AddressStore(store);
|
|
77
76
|
const privateEventStore = new PrivateEventStore(store);
|
|
78
|
-
const contractStore = new TXEContractStore(store);
|
|
79
77
|
const noteStore = new NoteStore(store);
|
|
80
78
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
81
79
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
@@ -92,11 +90,6 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
92
90
|
privateEventStore,
|
|
93
91
|
noteStore
|
|
94
92
|
]);
|
|
95
|
-
// Register protocol contracts.
|
|
96
|
-
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
97
|
-
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
98
|
-
await contractStore.addContractInstance(instance);
|
|
99
|
-
}
|
|
100
93
|
const archiver = new TXEArchiver(store);
|
|
101
94
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
102
95
|
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
@@ -3,9 +3,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
4
|
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
7
|
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
8
|
-
#private;
|
|
9
8
|
private blockNumber;
|
|
10
9
|
private contractStore;
|
|
11
10
|
constructor(blockNumber: BlockNumber, contractStore: ContractStore);
|
|
@@ -18,4 +17,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
18
17
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
19
18
|
registerContractFunctionSignatures(_signatures: []): Promise<void>;
|
|
20
19
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDNUUsT0FBT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xDQUVqRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAEnH,qBAAa,2BAA4B,YAAW,kBAAkB;IAElE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IAFvB,YACU,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAClC;IAEJ,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAErC;IAEK,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAcvE;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAG3D;IAEK,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAGzF;IAED,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAEnC;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAGtF;IAEK,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEzG;IAED,kCAAkC,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;CACF"}
|
|
@@ -1,48 +1,31 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
-
import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
|
|
4
1
|
export class TXEPublicContractDataSource {
|
|
5
2
|
blockNumber;
|
|
6
3
|
contractStore;
|
|
7
|
-
#privateFunctionsRoot;
|
|
8
4
|
constructor(blockNumber, contractStore){
|
|
9
5
|
this.blockNumber = blockNumber;
|
|
10
6
|
this.contractStore = contractStore;
|
|
11
|
-
this.#privateFunctionsRoot = new Map();
|
|
12
7
|
}
|
|
13
8
|
getBlockNumber() {
|
|
14
9
|
return Promise.resolve(this.blockNumber);
|
|
15
10
|
}
|
|
16
11
|
async getContractClass(id) {
|
|
17
|
-
const contractClass = await this.contractStore.
|
|
12
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
18
13
|
if (!contractClass) {
|
|
19
14
|
return;
|
|
20
15
|
}
|
|
21
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
22
|
-
if (!artifact) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
let privateFunctionsRoot;
|
|
26
|
-
if (!this.#privateFunctionsRoot.has(id.toString())) {
|
|
27
|
-
const privateFunctions = await Promise.all(artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE).map((fn)=>getContractClassPrivateFunctionFromArtifact(fn)));
|
|
28
|
-
privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
29
|
-
this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
|
|
30
|
-
} else {
|
|
31
|
-
privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString()));
|
|
32
|
-
}
|
|
33
16
|
return {
|
|
34
|
-
id,
|
|
17
|
+
id: contractClass.id,
|
|
35
18
|
artifactHash: contractClass.artifactHash,
|
|
36
19
|
packedBytecode: contractClass.packedBytecode,
|
|
37
|
-
privateFunctionsRoot,
|
|
20
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
38
21
|
version: contractClass.version,
|
|
39
22
|
privateFunctions: [],
|
|
40
23
|
utilityFunctions: []
|
|
41
24
|
};
|
|
42
25
|
}
|
|
43
26
|
async getBytecodeCommitment(id) {
|
|
44
|
-
const contractClass = await this.contractStore.
|
|
45
|
-
return contractClass
|
|
27
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
28
|
+
return contractClass?.publicBytecodeCommitment;
|
|
46
29
|
}
|
|
47
30
|
async getContract(address) {
|
|
48
31
|
const instance = await this.contractStore.getContractInstance(address);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.217f559981",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
65
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
66
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
67
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
68
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
69
|
-
"@aztec/constants": "0.0.1-commit.
|
|
70
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
71
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
72
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
73
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
74
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
75
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
76
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
64
|
+
"@aztec/accounts": "0.0.1-commit.217f559981",
|
|
65
|
+
"@aztec/archiver": "0.0.1-commit.217f559981",
|
|
66
|
+
"@aztec/aztec-node": "0.0.1-commit.217f559981",
|
|
67
|
+
"@aztec/aztec.js": "0.0.1-commit.217f559981",
|
|
68
|
+
"@aztec/bb-prover": "0.0.1-commit.217f559981",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.217f559981",
|
|
70
|
+
"@aztec/foundation": "0.0.1-commit.217f559981",
|
|
71
|
+
"@aztec/key-store": "0.0.1-commit.217f559981",
|
|
72
|
+
"@aztec/kv-store": "0.0.1-commit.217f559981",
|
|
73
|
+
"@aztec/protocol-contracts": "0.0.1-commit.217f559981",
|
|
74
|
+
"@aztec/pxe": "0.0.1-commit.217f559981",
|
|
75
|
+
"@aztec/simulator": "0.0.1-commit.217f559981",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.217f559981",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.217f559981",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,12 @@ import { Fr } from '@aztec/aztec.js/fields';
|
|
|
9
9
|
import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
|
|
10
10
|
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
11
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
12
|
-
import {
|
|
12
|
+
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
13
|
+
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
13
14
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
15
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
14
16
|
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
17
|
+
import type { ContractArtifactWithHash } from '@aztec/stdlib/contract';
|
|
15
18
|
import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
|
|
16
19
|
import { zodFor } from '@aztec/stdlib/schemas';
|
|
17
20
|
|
|
@@ -33,18 +36,24 @@ import {
|
|
|
33
36
|
fromSingle,
|
|
34
37
|
toSingle,
|
|
35
38
|
} from './util/encoding.js';
|
|
36
|
-
import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
|
|
37
39
|
|
|
38
40
|
const sessions = new Map<number, TXESession>();
|
|
39
41
|
|
|
40
42
|
/*
|
|
41
43
|
* TXE typically has to load the same contract artifacts over and over again for multiple tests,
|
|
42
|
-
* so we cache them here to avoid
|
|
44
|
+
* so we cache them here to avoid loading from disk repeatedly.
|
|
45
|
+
*
|
|
46
|
+
* The in-flight map coalesces concurrent requests for the same cache key so that
|
|
47
|
+
* computeArtifactHash (very expensive) is only run once even under parallelism.
|
|
43
48
|
*/
|
|
44
49
|
const TXEArtifactsCache = new Map<
|
|
45
50
|
string,
|
|
46
51
|
{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }
|
|
47
52
|
>();
|
|
53
|
+
const TXEArtifactsCacheInFlight = new Map<
|
|
54
|
+
string,
|
|
55
|
+
Promise<{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }>
|
|
56
|
+
>();
|
|
48
57
|
|
|
49
58
|
type TXEForeignCallInput = {
|
|
50
59
|
session_id: number;
|
|
@@ -68,7 +77,7 @@ const TXEForeignCallInputSchema = zodFor<TXEForeignCallInput>()(
|
|
|
68
77
|
);
|
|
69
78
|
|
|
70
79
|
class TXEDispatcher {
|
|
71
|
-
private
|
|
80
|
+
private contractStore!: ContractStore;
|
|
72
81
|
|
|
73
82
|
constructor(private logger: Logger) {}
|
|
74
83
|
|
|
@@ -135,29 +144,36 @@ class TXEDispatcher {
|
|
|
135
144
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
136
145
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
|
|
137
146
|
} else {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
148
|
+
this.logger.debug(`Loading compiled artifact ${artifactPath}`);
|
|
149
|
+
const compute = async () => {
|
|
150
|
+
const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8')) as NoirCompiledContract;
|
|
151
|
+
const artifactWithoutHash = loadContractArtifact(artifactJSON);
|
|
152
|
+
const computedArtifact: ContractArtifactWithHash = {
|
|
153
|
+
...artifactWithoutHash,
|
|
154
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
155
|
+
// and the TXE contract data provider can cache it
|
|
156
|
+
artifactHash: await computeArtifactHash(artifactWithoutHash),
|
|
157
|
+
};
|
|
158
|
+
this.logger.debug(
|
|
159
|
+
`Deploy ${computedArtifact.name} with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`,
|
|
160
|
+
);
|
|
161
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
162
|
+
constructorArgs: decodedArgs,
|
|
163
|
+
skipArgsDecoding: true,
|
|
164
|
+
salt: Fr.ONE,
|
|
165
|
+
publicKeys,
|
|
166
|
+
constructorArtifact: initializer ? initializer : undefined,
|
|
167
|
+
deployer: AztecAddress.ZERO,
|
|
168
|
+
});
|
|
169
|
+
const result = { artifact: computedArtifact, instance: computedInstance };
|
|
170
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
171
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
172
|
+
return result;
|
|
173
|
+
};
|
|
174
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
175
|
+
}
|
|
176
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
|
|
161
177
|
}
|
|
162
178
|
|
|
163
179
|
inputs.splice(0, 1, artifact, instance, toSingle(secret));
|
|
@@ -175,23 +191,35 @@ class TXEDispatcher {
|
|
|
175
191
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
176
192
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
|
|
177
193
|
} else {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
195
|
+
const compute = async () => {
|
|
196
|
+
const keys = await deriveKeys(secret);
|
|
197
|
+
const args = [
|
|
198
|
+
keys.publicKeys.masterIncomingViewingPublicKey.x,
|
|
199
|
+
keys.publicKeys.masterIncomingViewingPublicKey.y,
|
|
200
|
+
];
|
|
201
|
+
const computedArtifact: ContractArtifactWithHash = {
|
|
202
|
+
...SchnorrAccountContractArtifact,
|
|
203
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
204
|
+
// and the TXE contract data provider can cache it
|
|
205
|
+
artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact),
|
|
206
|
+
};
|
|
207
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
208
|
+
constructorArgs: args,
|
|
209
|
+
skipArgsDecoding: true,
|
|
210
|
+
salt: Fr.ONE,
|
|
211
|
+
publicKeys: keys.publicKeys,
|
|
212
|
+
constructorArtifact: 'constructor',
|
|
213
|
+
deployer: AztecAddress.ZERO,
|
|
214
|
+
});
|
|
215
|
+
const result = { artifact: computedArtifact, instance: computedInstance };
|
|
216
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
217
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
218
|
+
return result;
|
|
219
|
+
};
|
|
220
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
221
|
+
}
|
|
222
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
|
|
195
223
|
}
|
|
196
224
|
|
|
197
225
|
inputs.splice(0, 0, artifact, instance);
|
|
@@ -204,12 +232,18 @@ class TXEDispatcher {
|
|
|
204
232
|
|
|
205
233
|
if (!sessions.has(sessionId)) {
|
|
206
234
|
this.logger.debug(`Creating new session ${sessionId}`);
|
|
207
|
-
if (!this.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
);
|
|
235
|
+
if (!this.contractStore) {
|
|
236
|
+
const kvStore = await openTmpStore('txe-contracts');
|
|
237
|
+
this.contractStore = new ContractStore(kvStore);
|
|
238
|
+
const provider = new BundledProtocolContractsProvider();
|
|
239
|
+
for (const name of protocolContractNames) {
|
|
240
|
+
const { instance, artifact } = await provider.getProtocolContractArtifact(name);
|
|
241
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
242
|
+
await this.contractStore.addContractInstance(instance);
|
|
243
|
+
}
|
|
244
|
+
this.logger.debug('Registered protocol contracts in shared contract store');
|
|
211
245
|
}
|
|
212
|
-
sessions.set(sessionId, await TXESession.init(this.
|
|
246
|
+
sessions.set(sessionId, await TXESession.init(this.contractStore));
|
|
213
247
|
}
|
|
214
248
|
|
|
215
249
|
switch (functionName) {
|
package/src/oracle/interfaces.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
|
16
16
|
import {
|
|
17
17
|
AddressStore,
|
|
18
18
|
CapsuleStore,
|
|
19
|
+
type ContractStore,
|
|
19
20
|
NoteStore,
|
|
20
21
|
ORACLE_VERSION,
|
|
21
22
|
PrivateEventStore,
|
|
@@ -84,7 +85,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
84
85
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
85
86
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
86
87
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
87
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
88
88
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
89
89
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
90
90
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -97,7 +97,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
97
97
|
|
|
98
98
|
constructor(
|
|
99
99
|
private stateMachine: TXEStateMachine,
|
|
100
|
-
private contractStore:
|
|
100
|
+
private contractStore: ContractStore,
|
|
101
101
|
private noteStore: NoteStore,
|
|
102
102
|
private keyStore: KeyStore,
|
|
103
103
|
private addressStore: AddressStore,
|
|
@@ -211,7 +211,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
211
211
|
await this.txeAddAccount(artifact, instance, secret);
|
|
212
212
|
} else {
|
|
213
213
|
await this.contractStore.addContractInstance(instance);
|
|
214
|
-
await this.contractStore.addContractArtifact(
|
|
214
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
215
215
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
@@ -221,7 +221,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
221
221
|
|
|
222
222
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
223
223
|
await this.contractStore.addContractInstance(instance);
|
|
224
|
-
await this.contractStore.addContractArtifact(
|
|
224
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
225
225
|
|
|
226
226
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
227
227
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -591,7 +591,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
591
591
|
constantData,
|
|
592
592
|
/*gasUsed=*/ new Gas(0, 0),
|
|
593
593
|
/*feePayer=*/ AztecAddress.zero(),
|
|
594
|
-
/*
|
|
594
|
+
/*expirationTimestamp=*/ 0n,
|
|
595
595
|
inputsForPublic,
|
|
596
596
|
undefined,
|
|
597
597
|
);
|
|
@@ -659,11 +659,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
659
659
|
return returnValues ?? [];
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
async
|
|
663
|
-
targetContractAddress: AztecAddress,
|
|
664
|
-
functionSelector: FunctionSelector,
|
|
665
|
-
args: Fr[],
|
|
666
|
-
) {
|
|
662
|
+
async txeExecuteUtilityFunction(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, args: Fr[]) {
|
|
667
663
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
668
664
|
if (!artifact) {
|
|
669
665
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
@@ -741,10 +737,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
741
737
|
);
|
|
742
738
|
});
|
|
743
739
|
|
|
744
|
-
this.logger.verbose(`Utility
|
|
740
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
745
741
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
746
742
|
} catch (err) {
|
|
747
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
743
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
748
744
|
}
|
|
749
745
|
}
|
|
750
746
|
|
package/src/rpc_translator.ts
CHANGED
|
@@ -1043,7 +1043,7 @@ export class RPCTranslator {
|
|
|
1043
1043
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1044
1044
|
}
|
|
1045
1045
|
|
|
1046
|
-
async
|
|
1046
|
+
async txeExecuteUtilityFunction(
|
|
1047
1047
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
1048
1048
|
foreignFunctionSelector: ForeignCallSingle,
|
|
1049
1049
|
foreignArgs: ForeignCallArray,
|
|
@@ -1052,7 +1052,7 @@ export class RPCTranslator {
|
|
|
1052
1052
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1053
1053
|
const args = fromArray(foreignArgs);
|
|
1054
1054
|
|
|
1055
|
-
const returnValues = await this.handlerAsTxe().
|
|
1055
|
+
const returnValues = await this.handlerAsTxe().txeExecuteUtilityFunction(
|
|
1056
1056
|
targetContractAddress,
|
|
1057
1057
|
functionSelector,
|
|
1058
1058
|
args,
|
|
@@ -16,8 +16,8 @@ import type {
|
|
|
16
16
|
StatusMessage,
|
|
17
17
|
} from '@aztec/p2p';
|
|
18
18
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
19
|
-
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
20
|
-
import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
19
|
+
import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
21
21
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
22
22
|
|
|
23
23
|
export class DummyP2P implements P2P {
|
|
@@ -41,6 +41,10 @@ export class DummyP2P implements P2P {
|
|
|
41
41
|
throw new Error('DummyP2P does not implement "getPeers"');
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
|
|
45
|
+
return Promise.resolve(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
public broadcastProposal(_proposal: BlockProposal): Promise<void> {
|
|
45
49
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
46
50
|
}
|
|
@@ -131,6 +135,10 @@ export class DummyP2P implements P2P {
|
|
|
131
135
|
throw new Error('DummyP2P does not implement "isP2PClient"');
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
public getTxProvider(): ITxProvider {
|
|
139
|
+
throw new Error('DummyP2P does not implement "getTxProvider"');
|
|
140
|
+
}
|
|
141
|
+
|
|
134
142
|
public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
135
143
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
136
144
|
}
|
|
@@ -171,10 +179,6 @@ export class DummyP2P implements P2P {
|
|
|
171
179
|
throw new Error('DummyP2P does not implement "hasTxsInPool"');
|
|
172
180
|
}
|
|
173
181
|
|
|
174
|
-
public addTxsToPool(_txs: Tx[]): Promise<number> {
|
|
175
|
-
throw new Error('DummyP2P does not implement "addTxs"');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
182
|
public getSyncedLatestBlockNum(): Promise<number> {
|
|
179
183
|
throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
|
|
180
184
|
}
|
package/src/txe_session.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, 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 type { ProtocolContract } from '@aztec/protocol-contracts';
|
|
7
6
|
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
8
7
|
import {
|
|
9
8
|
AddressStore,
|
|
10
9
|
AnchorBlockStore,
|
|
11
10
|
CapsuleStore,
|
|
11
|
+
ContractStore,
|
|
12
12
|
JobCoordinator,
|
|
13
13
|
NoteService,
|
|
14
14
|
NoteStore,
|
|
@@ -55,7 +55,6 @@ import { TXEArchiver } from './state_machine/archiver.js';
|
|
|
55
55
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
56
56
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
57
57
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
58
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
59
58
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
60
59
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
61
60
|
|
|
@@ -132,7 +131,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
132
131
|
| IPrivateExecutionOracle
|
|
133
132
|
| IAvmExecutionOracle
|
|
134
133
|
| ITxeExecutionOracle,
|
|
135
|
-
private contractStore:
|
|
134
|
+
private contractStore: ContractStore,
|
|
136
135
|
private noteStore: NoteStore,
|
|
137
136
|
private keyStore: KeyStore,
|
|
138
137
|
private addressStore: AddressStore,
|
|
@@ -149,12 +148,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
149
148
|
private nextBlockTimestamp: bigint,
|
|
150
149
|
) {}
|
|
151
150
|
|
|
152
|
-
static async init(
|
|
151
|
+
static async init(contractStore: ContractStore) {
|
|
153
152
|
const store = await openTmpStore('txe-session');
|
|
154
153
|
|
|
155
154
|
const addressStore = new AddressStore(store);
|
|
156
155
|
const privateEventStore = new PrivateEventStore(store);
|
|
157
|
-
const contractStore = new TXEContractStore(store);
|
|
158
156
|
const noteStore = new NoteStore(store);
|
|
159
157
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
160
158
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
@@ -173,12 +171,6 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
173
171
|
noteStore,
|
|
174
172
|
]);
|
|
175
173
|
|
|
176
|
-
// Register protocol contracts.
|
|
177
|
-
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
178
|
-
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
179
|
-
await contractStore.addContractInstance(instance);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
174
|
const archiver = new TXEArchiver(store);
|
|
183
175
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
184
176
|
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|