@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,10 +1,10 @@
|
|
|
1
1
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
-
import {
|
|
2
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
3
3
|
/*
|
|
4
|
-
* A contract
|
|
4
|
+
* A contract store that stores contract artifacts with their hashes. Since
|
|
5
5
|
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
6
6
|
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
7
|
-
*/ export class
|
|
7
|
+
*/ export class TXEContractStore extends ContractStore {
|
|
8
8
|
#artifactHashes = new Map();
|
|
9
9
|
async addContractArtifact(id, artifact) {
|
|
10
10
|
if ('artifactHash' in artifact) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type {
|
|
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
6
|
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
7
|
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
8
8
|
#private;
|
|
9
9
|
private blockNumber;
|
|
10
|
-
private
|
|
11
|
-
constructor(blockNumber: BlockNumber,
|
|
10
|
+
private contractStore;
|
|
11
|
+
constructor(blockNumber: BlockNumber, contractStore: ContractStore);
|
|
12
12
|
getBlockNumber(): Promise<BlockNumber>;
|
|
13
13
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
14
14
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
@@ -18,4 +18,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
18
18
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
19
19
|
registerContractFunctionSignatures(_signatures: []): Promise<void>;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF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VBQUUsRUFBRSxDQUFDLENBRW5DO0lBRUssbUJBQW1CLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsZ0JBQWdCLEdBQUcsU0FBUyxDQUFDLENBR3RGO0lBRUssb0JBQW9CLENBQUMsT0FBTyxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUMsQ0FFekc7SUFFRCxrQ0FBa0MsQ0FBQyxXQUFXLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFakU7Q0FDRiJ9
|
|
@@ -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,
|
|
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,EAAgB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,2BAA4B,YAAW,kBAAkB;;IAGlE,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,CAgCvE;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"}
|
|
@@ -3,22 +3,22 @@ import { FunctionType } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
|
|
4
4
|
export class TXEPublicContractDataSource {
|
|
5
5
|
blockNumber;
|
|
6
|
-
|
|
6
|
+
contractStore;
|
|
7
7
|
#privateFunctionsRoot;
|
|
8
|
-
constructor(blockNumber,
|
|
8
|
+
constructor(blockNumber, contractStore){
|
|
9
9
|
this.blockNumber = blockNumber;
|
|
10
|
-
this.
|
|
10
|
+
this.contractStore = contractStore;
|
|
11
11
|
this.#privateFunctionsRoot = new Map();
|
|
12
12
|
}
|
|
13
13
|
getBlockNumber() {
|
|
14
14
|
return Promise.resolve(this.blockNumber);
|
|
15
15
|
}
|
|
16
16
|
async getContractClass(id) {
|
|
17
|
-
const contractClass = await this.
|
|
17
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
18
18
|
if (!contractClass) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const artifact = await this.
|
|
21
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
22
22
|
if (!artifact) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -41,11 +41,11 @@ export class TXEPublicContractDataSource {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async getBytecodeCommitment(id) {
|
|
44
|
-
const contractClass = await this.
|
|
44
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
45
45
|
return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
46
46
|
}
|
|
47
47
|
async getContract(address) {
|
|
48
|
-
const instance = await this.
|
|
48
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
49
49
|
return instance && {
|
|
50
50
|
...instance,
|
|
51
51
|
address
|
|
@@ -55,11 +55,11 @@ export class TXEPublicContractDataSource {
|
|
|
55
55
|
throw new Error('Method not implemented.');
|
|
56
56
|
}
|
|
57
57
|
async getContractArtifact(address) {
|
|
58
|
-
const instance = await this.
|
|
59
|
-
return instance && this.
|
|
58
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
59
|
+
return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
60
60
|
}
|
|
61
61
|
async getDebugFunctionName(address, selector) {
|
|
62
|
-
return await this.
|
|
62
|
+
return await this.contractStore.getDebugFunctionName(address, selector);
|
|
63
63
|
}
|
|
64
64
|
registerContractFunctionSignatures(_signatures) {
|
|
65
65
|
return Promise.resolve();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { L2BlockHeader } from '@aztec/stdlib/block';
|
|
3
|
+
import { L2Block, L2BlockHeader } from '@aztec/stdlib/block';
|
|
4
4
|
import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
5
5
|
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
6
6
|
/**
|
|
@@ -11,4 +11,18 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
|
11
11
|
export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
|
|
12
12
|
export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
|
|
13
13
|
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<L2BlockHeader>;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Creates an L2Block with proper archive chaining.
|
|
16
|
+
* This function:
|
|
17
|
+
* 1. Gets the current archive state as lastArchive for the header
|
|
18
|
+
* 2. Creates the block header
|
|
19
|
+
* 3. Updates the archive tree with the header hash
|
|
20
|
+
* 4. Gets the new archive state for the block's archive
|
|
21
|
+
*
|
|
22
|
+
* @param worldTrees - The world trees to read/write from
|
|
23
|
+
* @param globalVariables - Global variables for the block
|
|
24
|
+
* @param txEffects - Transaction effects to include in the block
|
|
25
|
+
* @returns The created L2Block with proper archive chaining
|
|
26
|
+
*/
|
|
27
|
+
export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7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"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAQ,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,aAAa,CAAC,CAcxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { L2BlockHeader } from '@aztec/stdlib/block';
|
|
4
|
+
import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
|
|
5
5
|
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
6
6
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
7
|
/**
|
|
@@ -22,3 +22,24 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
|
22
22
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
23
23
|
return new L2BlockHeader(new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)), makeContentCommitment(), stateReference, globalVariables, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO);
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an L2Block with proper archive chaining.
|
|
27
|
+
* This function:
|
|
28
|
+
* 1. Gets the current archive state as lastArchive for the header
|
|
29
|
+
* 2. Creates the block header
|
|
30
|
+
* 3. Updates the archive tree with the header hash
|
|
31
|
+
* 4. Gets the new archive state for the block's archive
|
|
32
|
+
*
|
|
33
|
+
* @param worldTrees - The world trees to read/write from
|
|
34
|
+
* @param globalVariables - Global variables for the block
|
|
35
|
+
* @param txEffects - Transaction effects to include in the block
|
|
36
|
+
* @returns The created L2Block with proper archive chaining
|
|
37
|
+
*/ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
|
|
38
|
+
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
39
|
+
// Update the archive tree with this block's header hash
|
|
40
|
+
await worldTrees.updateArchive(header.toBlockHeader());
|
|
41
|
+
// Get the new archive state after updating
|
|
42
|
+
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
43
|
+
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
44
|
+
return new L2Block(newArchive, header, new Body(txEffects));
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-nightly.20260107",
|
|
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": "
|
|
65
|
-
"@aztec/archiver": "
|
|
66
|
-
"@aztec/aztec-node": "
|
|
67
|
-
"@aztec/aztec.js": "
|
|
68
|
-
"@aztec/bb-prover": "
|
|
69
|
-
"@aztec/constants": "
|
|
70
|
-
"@aztec/foundation": "
|
|
71
|
-
"@aztec/key-store": "
|
|
72
|
-
"@aztec/kv-store": "
|
|
73
|
-
"@aztec/protocol-contracts": "
|
|
74
|
-
"@aztec/pxe": "
|
|
75
|
-
"@aztec/simulator": "
|
|
76
|
-
"@aztec/stdlib": "
|
|
77
|
-
"@aztec/world-state": "
|
|
64
|
+
"@aztec/accounts": "4.0.0-nightly.20260107",
|
|
65
|
+
"@aztec/archiver": "4.0.0-nightly.20260107",
|
|
66
|
+
"@aztec/aztec-node": "4.0.0-nightly.20260107",
|
|
67
|
+
"@aztec/aztec.js": "4.0.0-nightly.20260107",
|
|
68
|
+
"@aztec/bb-prover": "4.0.0-nightly.20260107",
|
|
69
|
+
"@aztec/constants": "4.0.0-nightly.20260107",
|
|
70
|
+
"@aztec/foundation": "4.0.0-nightly.20260107",
|
|
71
|
+
"@aztec/key-store": "4.0.0-nightly.20260107",
|
|
72
|
+
"@aztec/kv-store": "4.0.0-nightly.20260107",
|
|
73
|
+
"@aztec/protocol-contracts": "4.0.0-nightly.20260107",
|
|
74
|
+
"@aztec/pxe": "4.0.0-nightly.20260107",
|
|
75
|
+
"@aztec/simulator": "4.0.0-nightly.20260107",
|
|
76
|
+
"@aztec/stdlib": "4.0.0-nightly.20260107",
|
|
77
|
+
"@aztec/world-state": "4.0.0-nightly.20260107",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/constants.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -12,7 +12,8 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
12
12
|
import { type ProtocolContract, protocolContractNames } from '@aztec/protocol-contracts';
|
|
13
13
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
14
14
|
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
15
|
-
import type { ApiSchemaFor
|
|
15
|
+
import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
|
|
16
|
+
import { zodFor } from '@aztec/stdlib/schemas';
|
|
16
17
|
|
|
17
18
|
import { createHash } from 'crypto';
|
|
18
19
|
import { createReadStream } from 'fs';
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
fromSingle,
|
|
33
34
|
toSingle,
|
|
34
35
|
} from './util/encoding.js';
|
|
35
|
-
import type { ContractArtifactWithHash } from './util/
|
|
36
|
+
import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
|
|
36
37
|
|
|
37
38
|
const sessions = new Map<number, TXESession>();
|
|
38
39
|
|
|
@@ -53,16 +54,18 @@ type TXEForeignCallInput = {
|
|
|
53
54
|
inputs: ForeignCallArgs;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
const TXEForeignCallInputSchema =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
const TXEForeignCallInputSchema = zodFor<TXEForeignCallInput>()(
|
|
58
|
+
z.object({
|
|
59
|
+
// eslint-disable-next-line camelcase
|
|
60
|
+
session_id: z.number().int().nonnegative(),
|
|
61
|
+
function: z.string() as z.ZodType<TXEOracleFunctionName>,
|
|
62
|
+
// eslint-disable-next-line camelcase
|
|
63
|
+
root_path: z.string(),
|
|
64
|
+
// eslint-disable-next-line camelcase
|
|
65
|
+
package_name: z.string(),
|
|
66
|
+
inputs: ForeignCallArgsSchema,
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
66
69
|
|
|
67
70
|
class TXEDispatcher {
|
|
68
71
|
private protocolContracts!: ProtocolContract[];
|
package/src/oracle/interfaces.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
|
4
4
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
5
5
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
6
6
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
|
+
import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
10
10
|
|
|
@@ -44,6 +44,7 @@ export interface IAvmExecutionOracle {
|
|
|
44
44
|
export interface ITxeExecutionOracle {
|
|
45
45
|
isTxe: true;
|
|
46
46
|
|
|
47
|
+
txeGetDefaultAddress(): AztecAddress;
|
|
47
48
|
txeGetNextBlockNumber(): Promise<BlockNumber>;
|
|
48
49
|
txeGetNextBlockTimestamp(): Promise<UInt64>;
|
|
49
50
|
txeAdvanceBlocksBy(blocks: number): Promise<void>;
|
|
@@ -62,6 +63,7 @@ export interface ITxeExecutionOracle {
|
|
|
62
63
|
noteHashes: Fr[];
|
|
63
64
|
nullifiers: Fr[];
|
|
64
65
|
}>;
|
|
66
|
+
txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
65
67
|
txePrivateCallNewFlow(
|
|
66
68
|
from: AztecAddress,
|
|
67
69
|
targetContractAddress: AztecAddress,
|
|
@@ -3,9 +3,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
6
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
8
|
-
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
9
8
|
import {
|
|
10
9
|
MerkleTreeId,
|
|
11
10
|
type MerkleTreeWriteOperations,
|
|
@@ -14,7 +13,7 @@ import {
|
|
|
14
13
|
} from '@aztec/stdlib/trees';
|
|
15
14
|
import { GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
16
15
|
|
|
17
|
-
import { insertTxEffectIntoWorldTrees,
|
|
16
|
+
import { insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
18
17
|
import type { IAvmExecutionOracle } from './interfaces.js';
|
|
19
18
|
|
|
20
19
|
export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
@@ -133,11 +132,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
133
132
|
const txEffect = this.makeTxEffect();
|
|
134
133
|
await insertTxEffectIntoWorldTrees(txEffect, this.forkedWorldTrees);
|
|
135
134
|
|
|
136
|
-
const block =
|
|
137
|
-
makeAppendOnlyTreeSnapshot(),
|
|
138
|
-
await makeTXEBlockHeader(this.forkedWorldTrees, this.globalVariables),
|
|
139
|
-
new Body([txEffect]),
|
|
140
|
-
);
|
|
135
|
+
const block = await makeTXEBlock(this.forkedWorldTrees, this.globalVariables, [txEffect]);
|
|
141
136
|
|
|
142
137
|
await this.forkedWorldTrees.close();
|
|
143
138
|
|