@aztec/txe 0.0.1-commit.d3ec352c → 0.0.1-commit.e310a4c8
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 +7 -5
- 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 +10 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +20 -11
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +105 -66
- package/dest/rpc_translator.d.ts +24 -12
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +95 -43
- package/dest/state_machine/archiver.d.ts +21 -57
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +61 -107
- package/dest/state_machine/dummy_p2p_client.d.ts +8 -7
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +16 -11
- package/dest/state_machine/global_variable_builder.d.ts +4 -3
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +13 -1
- 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 +32 -20
- package/dest/state_machine/mock_epoch_cache.d.ts +7 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +10 -7
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +2 -2
- package/dest/txe_session.d.ts +18 -10
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +91 -45
- package/dest/util/encoding.d.ts +618 -19
- 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 +5 -5
- 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 -5
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +36 -4
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +4 -7
- package/package.json +16 -16
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +6 -4
- package/src/oracle/txe_oracle_public_context.ts +10 -17
- package/src/oracle/txe_oracle_top_level_context.ts +168 -91
- package/src/rpc_translator.ts +122 -51
- package/src/state_machine/archiver.ts +57 -131
- package/src/state_machine/dummy_p2p_client.ts +21 -14
- package/src/state_machine/global_variable_builder.ts +19 -2
- package/src/state_machine/index.ts +41 -18
- package/src/state_machine/mock_epoch_cache.ts +10 -11
- package/src/state_machine/synchronizer.ts +3 -4
- package/src/txe_session.ts +183 -78
- 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 +10 -10
- package/src/utils/block_creation.ts +46 -15
- package/src/utils/tx_effect_creation.ts +4 -12
- 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,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
-
import type {
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
4
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import {
|
|
@@ -16,7 +16,7 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
16
16
|
#privateFunctionsRoot: Map<string, Buffer> = new Map();
|
|
17
17
|
constructor(
|
|
18
18
|
private blockNumber: BlockNumber,
|
|
19
|
-
private
|
|
19
|
+
private contractStore: ContractStore,
|
|
20
20
|
) {}
|
|
21
21
|
|
|
22
22
|
getBlockNumber(): Promise<BlockNumber> {
|
|
@@ -24,11 +24,11 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
27
|
-
const contractClass = await this.
|
|
27
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
28
28
|
if (!contractClass) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const artifact = await this.
|
|
31
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
32
32
|
if (!artifact) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -58,12 +58,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
61
|
-
const contractClass = await this.
|
|
61
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
62
62
|
return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
66
|
-
const instance = await this.
|
|
66
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
67
67
|
return instance && { ...instance, address };
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -72,12 +72,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
async getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
|
|
75
|
-
const instance = await this.
|
|
76
|
-
return instance && this.
|
|
75
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
76
|
+
return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
80
|
-
return await this.
|
|
80
|
+
return await this.contractStore.getDebugFunctionName(address, selector);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
registerContractFunctionSignatures(_signatures: []): Promise<void> {
|
|
@@ -4,13 +4,12 @@ import {
|
|
|
4
4
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
5
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
-
import {
|
|
11
|
-
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
9
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
12
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
13
|
-
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
12
|
+
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
@@ -47,18 +46,50 @@ export async function insertTxEffectIntoWorldTrees(
|
|
|
47
46
|
export async function makeTXEBlockHeader(
|
|
48
47
|
worldTrees: MerkleTreeWriteOperations,
|
|
49
48
|
globalVariables: GlobalVariables,
|
|
50
|
-
): Promise<
|
|
49
|
+
): Promise<BlockHeader> {
|
|
51
50
|
const stateReference = await worldTrees.getStateReference();
|
|
52
51
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
53
52
|
|
|
54
|
-
return
|
|
55
|
-
new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
56
|
-
|
|
57
|
-
stateReference,
|
|
53
|
+
return BlockHeader.from({
|
|
54
|
+
lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
55
|
+
spongeBlobHash: Fr.ZERO,
|
|
56
|
+
state: stateReference,
|
|
58
57
|
globalVariables,
|
|
59
|
-
Fr.ZERO,
|
|
60
|
-
Fr.ZERO,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
totalFees: Fr.ZERO,
|
|
59
|
+
totalManaUsed: Fr.ZERO,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates an L2Block with proper archive chaining.
|
|
65
|
+
* This function:
|
|
66
|
+
* 1. Gets the current archive state as lastArchive for the header
|
|
67
|
+
* 2. Creates the block header
|
|
68
|
+
* 3. Updates the archive tree with the header hash
|
|
69
|
+
* 4. Gets the new archive state for the block's archive
|
|
70
|
+
*
|
|
71
|
+
* @param worldTrees - The world trees to read/write from
|
|
72
|
+
* @param globalVariables - Global variables for the block
|
|
73
|
+
* @param txEffects - Transaction effects to include in the block
|
|
74
|
+
* @returns The created L2Block with proper archive chaining
|
|
75
|
+
*/
|
|
76
|
+
export async function makeTXEBlock(
|
|
77
|
+
worldTrees: MerkleTreeWriteOperations,
|
|
78
|
+
globalVariables: GlobalVariables,
|
|
79
|
+
txEffects: TxEffect[],
|
|
80
|
+
): Promise<L2Block> {
|
|
81
|
+
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
82
|
+
|
|
83
|
+
// Update the archive tree with this block's header hash
|
|
84
|
+
await worldTrees.updateArchive(header);
|
|
85
|
+
|
|
86
|
+
// Get the new archive state after updating
|
|
87
|
+
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
88
|
+
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
89
|
+
|
|
90
|
+
// L2Block requires checkpointNumber and indexWithinCheckpoint
|
|
91
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
92
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
93
|
+
|
|
94
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
64
95
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
4
4
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
5
5
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
|
-
export async function makeTxEffect(
|
|
8
|
-
noteCache: ExecutionNoteCache,
|
|
9
|
-
protocolNullifier: Fr,
|
|
10
|
-
txBlockNumber: BlockNumber,
|
|
11
|
-
): Promise<TxEffect> {
|
|
7
|
+
export async function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect> {
|
|
12
8
|
const txEffect = TxEffect.empty();
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
|
|
10
|
+
noteCache.finish();
|
|
16
11
|
|
|
12
|
+
const nonceGenerator = noteCache.getNonceGenerator();
|
|
17
13
|
txEffect.noteHashes = await Promise.all(
|
|
18
14
|
noteCache
|
|
19
15
|
.getAllNotes()
|
|
@@ -28,10 +24,6 @@ export async function makeTxEffect(
|
|
|
28
24
|
// Nullifiers are already siloed
|
|
29
25
|
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
30
26
|
|
|
31
|
-
if (usedProtocolNullifierForNonces) {
|
|
32
|
-
txEffect.nullifiers.unshift(protocolNullifier);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|
|
36
28
|
|
|
37
29
|
return txEffect;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
-
export declare class TXEAccountDataProvider {
|
|
5
|
-
#private;
|
|
6
|
-
constructor(store: AztecAsyncKVStore);
|
|
7
|
-
getAccount(key: AztecAddress): Promise<CompleteAddress>;
|
|
8
|
-
setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfZGF0YV9wcm92aWRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX2FjY291bnRfZGF0YV9wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsc0JBQXNCOztJQUdqQyxZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"txe_account_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAsB;;IAGjC,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { ContractDataProvider } from '@aztec/pxe/server';
|
|
4
|
-
export type ContractArtifactWithHash = ContractArtifact & {
|
|
5
|
-
artifactHash: Fr;
|
|
6
|
-
};
|
|
7
|
-
export declare class TXEContractDataProvider extends ContractDataProvider {
|
|
8
|
-
#private;
|
|
9
|
-
addContractArtifact(id: Fr, artifact: ContractArtifact | ContractArtifactWithHash): Promise<void>;
|
|
10
|
-
getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | ContractArtifactWithHash | undefined>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X2RhdGFfcHJvdmlkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9jb250cmFjdF9kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzVDLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRXpELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLHVCQUF3QixTQUFRLG9CQUFvQjs7SUFHekMsbUJBQW1CLENBQ3ZDLEVBQUUsRUFBRSxFQUFFLEVBQ04sUUFBUSxFQUFFLGdCQUFnQixHQUFHLHdCQUF3QixHQUNwRCxPQUFPLENBQUMsSUFBSSxDQUFDLENBS2Y7SUFFcUIsbUJBQW1CLENBQ3ZDLGVBQWUsRUFBRSxFQUFFLEdBQ2xCLE9BQU8sQ0FBQyxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FBRyxTQUFTLENBQUMsQ0FRbEU7Q0FDRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"txe_contract_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,uBAAwB,SAAQ,oBAAoB;;IAGzC,mBAAmB,CACvC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,gBAAgB,GAAG,wBAAwB,GACpD,OAAO,CAAC,IAAI,CAAC,CAKf;IAEqB,mBAAmB,CACvC,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,gBAAgB,GAAG,wBAAwB,GAAG,SAAS,CAAC,CAQlE;CACF"}
|