@aztec/txe 0.0.1-commit.fce3e4f → 0.0.1-commit.ffe5b04ea
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 +91 -56
- package/dest/oracle/interfaces.d.ts +33 -29
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +16 -16
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +20 -22
- package/dest/oracle/txe_oracle_top_level_context.d.ts +36 -27
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +206 -98
- package/dest/rpc_translator.d.ts +91 -79
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +330 -170
- package/dest/state_machine/archiver.d.ts +21 -52
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +63 -94
- package/dest/state_machine/dummy_p2p_client.d.ts +20 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +42 -25
- package/dest/state_machine/global_variable_builder.d.ts +6 -5
- 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 +7 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +40 -23
- package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +14 -7
- package/dest/state_machine/synchronizer.d.ts +3 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +26 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +161 -55
- 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_public_contract_data_source.d.ts +8 -8
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +12 -29
- package/dest/utils/block_creation.d.ts +21 -6
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +38 -4
- package/dest/utils/tx_effect_creation.d.ts +3 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +4 -7
- package/package.json +18 -18
- package/src/constants.ts +3 -0
- package/src/index.ts +103 -63
- package/src/oracle/interfaces.ts +36 -32
- package/src/oracle/txe_oracle_public_context.ts +21 -28
- package/src/oracle/txe_oracle_top_level_context.ts +251 -138
- package/src/rpc_translator.ts +368 -174
- package/src/state_machine/archiver.ts +59 -114
- package/src/state_machine/dummy_p2p_client.ts +58 -33
- package/src/state_machine/global_variable_builder.ts +21 -4
- package/src/state_machine/index.ts +60 -21
- package/src/state_machine/mock_epoch_cache.ts +15 -11
- package/src/state_machine/synchronizer.ts +6 -5
- package/src/txe_session.ts +222 -103
- 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_public_contract_data_source.ts +20 -45
- package/src/utils/block_creation.ts +49 -15
- package/src/utils/tx_effect_creation.ts +5 -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
- package/dest/util/txe_contract_data_provider.js +0 -22
- package/src/util/txe_contract_data_provider.ts +0 -36
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
5
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
7
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
8
|
-
import { Fr } from '@aztec/foundation/
|
|
9
|
-
import {
|
|
10
|
-
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
9
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
12
|
-
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
12
|
+
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
16
16
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
17
17
|
* @returns The transaction request hash.
|
|
18
18
|
*/
|
|
19
|
-
export function getSingleTxBlockRequestHash(blockNumber:
|
|
19
|
+
export function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr {
|
|
20
20
|
return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -46,18 +46,52 @@ export async function insertTxEffectIntoWorldTrees(
|
|
|
46
46
|
export async function makeTXEBlockHeader(
|
|
47
47
|
worldTrees: MerkleTreeWriteOperations,
|
|
48
48
|
globalVariables: GlobalVariables,
|
|
49
|
-
): Promise<
|
|
49
|
+
): Promise<BlockHeader> {
|
|
50
50
|
const stateReference = await worldTrees.getStateReference();
|
|
51
51
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
52
52
|
|
|
53
|
-
return
|
|
54
|
-
new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
55
|
-
|
|
56
|
-
stateReference,
|
|
53
|
+
return BlockHeader.from({
|
|
54
|
+
lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
55
|
+
spongeBlobHash: Fr.ZERO,
|
|
56
|
+
state: stateReference,
|
|
57
57
|
globalVariables,
|
|
58
|
-
Fr.ZERO,
|
|
59
|
-
Fr.ZERO,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
92
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
93
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
94
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
95
|
+
|
|
96
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
63
97
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
3
4
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
4
5
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
5
6
|
|
|
6
|
-
export async function makeTxEffect(
|
|
7
|
-
noteCache: ExecutionNoteCache,
|
|
8
|
-
protocolNullifier: Fr,
|
|
9
|
-
txBlockNumber: number,
|
|
10
|
-
): Promise<TxEffect> {
|
|
7
|
+
export async function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect> {
|
|
11
8
|
const txEffect = TxEffect.empty();
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
|
|
10
|
+
noteCache.finish();
|
|
15
11
|
|
|
12
|
+
const nonceGenerator = noteCache.getNonceGenerator();
|
|
16
13
|
txEffect.noteHashes = await Promise.all(
|
|
17
14
|
noteCache
|
|
18
15
|
.getAllNotes()
|
|
@@ -27,10 +24,6 @@ export async function makeTxEffect(
|
|
|
27
24
|
// Nullifiers are already siloed
|
|
28
25
|
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
29
26
|
|
|
30
|
-
if (usedProtocolNullifierForNonces) {
|
|
31
|
-
txEffect.nullifiers.unshift(protocolNullifier);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
27
|
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|
|
35
28
|
|
|
36
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,eyJ2ZXJzaW9uI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B,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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
-
import { ContractDataProvider } from '@aztec/pxe/server';
|
|
3
|
-
/*
|
|
4
|
-
* A contract data provider that stores contract artifacts with their hashes. Since
|
|
5
|
-
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
6
|
-
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
7
|
-
*/ export class TXEContractDataProvider extends ContractDataProvider {
|
|
8
|
-
#artifactHashes = new Map();
|
|
9
|
-
async addContractArtifact(id, artifact) {
|
|
10
|
-
if ('artifactHash' in artifact) {
|
|
11
|
-
this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
|
|
12
|
-
}
|
|
13
|
-
await super.addContractArtifact(id, artifact);
|
|
14
|
-
}
|
|
15
|
-
async getContractArtifact(contractClassId) {
|
|
16
|
-
const artifact = await super.getContractArtifact(contractClassId);
|
|
17
|
-
if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
|
|
18
|
-
artifact.artifactHash = Fr.fromBuffer(this.#artifactHashes.get(contractClassId.toString()));
|
|
19
|
-
}
|
|
20
|
-
return artifact;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,36 +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
|
-
|
|
5
|
-
export type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* A contract data provider that stores contract artifacts with their hashes. Since
|
|
9
|
-
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
10
|
-
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
11
|
-
*/
|
|
12
|
-
export class TXEContractDataProvider extends ContractDataProvider {
|
|
13
|
-
#artifactHashes: Map<string, Buffer> = new Map();
|
|
14
|
-
|
|
15
|
-
public override async addContractArtifact(
|
|
16
|
-
id: Fr,
|
|
17
|
-
artifact: ContractArtifact | ContractArtifactWithHash,
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
if ('artifactHash' in artifact) {
|
|
20
|
-
this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
|
|
21
|
-
}
|
|
22
|
-
await super.addContractArtifact(id, artifact);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public override async getContractArtifact(
|
|
26
|
-
contractClassId: Fr,
|
|
27
|
-
): Promise<ContractArtifact | ContractArtifactWithHash | undefined> {
|
|
28
|
-
const artifact = await super.getContractArtifact(contractClassId);
|
|
29
|
-
if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
|
|
30
|
-
(artifact as ContractArtifactWithHash).artifactHash = Fr.fromBuffer(
|
|
31
|
-
this.#artifactHashes.get(contractClassId.toString())!,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return artifact;
|
|
35
|
-
}
|
|
36
|
-
}
|