@aztec/end-to-end 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.17
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/README.md +2 -0
- package/dest/bench/utils.d.ts +70 -0
- package/dest/bench/utils.d.ts.map +1 -0
- package/dest/bench/utils.js +24 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +46 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +17 -17
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +47 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +27 -16
- package/dest/e2e_deploy_contract/deploy_test.d.ts +28 -0
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -0
- package/dest/e2e_deploy_contract/deploy_test.js +4 -7
- package/dest/e2e_epochs/epochs_test.d.ts +51 -0
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -0
- package/dest/e2e_epochs/epochs_test.js +155 -0
- package/dest/e2e_fees/fees_test.d.ts +73 -0
- package/dest/e2e_fees/fees_test.d.ts.map +1 -0
- package/dest/e2e_fees/fees_test.js +75 -32
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +26 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -0
- package/dest/e2e_nested_contract/nested_contract_test.js +14 -12
- package/dest/e2e_p2p/p2p_network.d.ts +61 -0
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -0
- package/dest/e2e_p2p/p2p_network.js +54 -30
- package/dest/e2e_p2p/shared.d.ts +10 -0
- package/dest/e2e_p2p/shared.d.ts.map +1 -0
- package/dest/e2e_p2p/shared.js +7 -8
- package/dest/e2e_prover/e2e_prover_test.d.ts +56 -0
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -0
- package/dest/e2e_prover/e2e_prover_test.js +20 -24
- package/dest/e2e_token_contract/token_contract_test.d.ts +29 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -0
- package/dest/e2e_token_contract/token_contract_test.js +4 -7
- package/dest/fixtures/fixtures.d.ts +17 -0
- package/dest/fixtures/fixtures.d.ts.map +1 -0
- package/dest/fixtures/fixtures.js +2 -2
- package/dest/fixtures/get_acvm_config.d.ts +8 -0
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -0
- package/dest/fixtures/get_acvm_config.js +10 -5
- package/dest/fixtures/get_bb_config.d.ts +6 -0
- package/dest/fixtures/get_bb_config.d.ts.map +1 -0
- package/dest/fixtures/get_bb_config.js +9 -4
- package/dest/fixtures/index.d.ts +6 -0
- package/dest/fixtures/index.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts +13 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.js +1 -1
- package/dest/fixtures/logging.d.ts +8 -0
- package/dest/fixtures/logging.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.d.ts +6 -0
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.js +6 -4
- package/dest/fixtures/setup_p2p_test.d.ts +22 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -0
- package/dest/fixtures/setup_p2p_test.js +5 -3
- package/dest/fixtures/snapshot_manager.d.ts +87 -0
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -0
- package/dest/fixtures/snapshot_manager.js +67 -74
- package/dest/fixtures/token_utils.d.ts +6 -0
- package/dest/fixtures/token_utils.d.ts.map +1 -0
- package/dest/fixtures/token_utils.js +1 -1
- package/dest/fixtures/utils.d.ts +155 -0
- package/dest/fixtures/utils.d.ts.map +1 -0
- package/dest/fixtures/utils.js +97 -71
- package/dest/fixtures/with_telemetry_utils.d.ts +3 -0
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.d.ts +41 -0
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.js +4 -1
- package/dest/sample-dapp/index.js +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +124 -0
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -0
- package/dest/shared/cross_chain_test_harness.js +6 -17
- package/dest/shared/gas_portal_test_harness.d.ts +80 -0
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -0
- package/dest/shared/gas_portal_test_harness.js +11 -4
- package/dest/shared/index.d.ts +2 -0
- package/dest/shared/index.d.ts.map +1 -0
- package/dest/shared/index.js +0 -1
- package/dest/shared/jest_setup.d.ts +2 -0
- package/dest/shared/jest_setup.d.ts.map +1 -0
- package/dest/shared/submit-transactions.d.ts +4 -0
- package/dest/shared/submit-transactions.d.ts.map +1 -0
- package/dest/shared/submit-transactions.js +9 -17
- package/dest/shared/uniswap_l1_l2.d.ts +25 -0
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -0
- package/dest/shared/uniswap_l1_l2.js +5 -10
- package/dest/simulators/index.d.ts +3 -0
- package/dest/simulators/index.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.d.ts +69 -0
- package/dest/simulators/lending_simulator.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.js +1 -3
- package/dest/simulators/token_simulator.d.ts +29 -0
- package/dest/simulators/token_simulator.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.d.ts +20 -0
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.js +72 -38
- package/dest/spartan/utils.d.ts +485 -0
- package/dest/spartan/utils.d.ts.map +1 -0
- package/dest/spartan/utils.js +110 -2
- package/package.json +35 -40
- package/src/bench/utils.ts +30 -13
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +40 -30
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +34 -18
- package/src/e2e_deploy_contract/deploy_test.ts +6 -11
- package/src/e2e_epochs/epochs_test.ts +217 -0
- package/src/e2e_fees/fees_test.ts +84 -38
- package/src/e2e_nested_contract/nested_contract_test.ts +14 -16
- package/src/e2e_p2p/p2p_network.ts +67 -47
- package/src/e2e_p2p/shared.ts +16 -10
- package/src/e2e_prover/e2e_prover_test.ts +56 -37
- package/src/e2e_token_contract/token_contract_test.ts +10 -11
- package/src/fixtures/fixtures.ts +2 -2
- package/src/fixtures/get_acvm_config.ts +7 -3
- package/src/fixtures/get_bb_config.ts +6 -2
- package/src/fixtures/l1_to_l2_messaging.ts +6 -13
- package/src/fixtures/setup_l1_contracts.ts +8 -7
- package/src/fixtures/setup_p2p_test.ts +8 -6
- package/src/fixtures/snapshot_manager.ts +72 -79
- package/src/fixtures/token_utils.ts +2 -2
- package/src/fixtures/utils.ts +135 -97
- package/src/guides/up_quick_start.sh +10 -5
- package/src/quality_of_service/alert_checker.ts +6 -2
- package/src/sample-dapp/index.mjs +1 -1
- package/src/shared/cross_chain_test_harness.ts +17 -35
- package/src/shared/gas_portal_test_harness.ts +21 -11
- package/src/shared/index.ts +0 -1
- package/src/shared/submit-transactions.ts +16 -20
- package/src/shared/uniswap_l1_l2.ts +35 -26
- package/src/simulators/lending_simulator.ts +5 -6
- package/src/simulators/token_simulator.ts +1 -1
- package/src/spartan/setup_test_wallets.ts +111 -37
- package/src/spartan/utils.ts +88 -3
- package/dest/shared/browser.js +0 -163
- package/src/shared/browser.ts +0 -272
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/fixtures/logging.ts"],"names":[],"mappings":"AAKA,wGAAwG;AACxG,wBAAgB,yBAAyB,YAExC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,QAOlD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Logger } from '@aztec/aztec.js';
|
|
2
|
+
import type { DeployL1ContractsArgs, L1ContractsConfig } from '@aztec/ethereum';
|
|
3
|
+
import type { HDAccount, PrivateKeyAccount } from 'viem';
|
|
4
|
+
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
5
|
+
export declare const setupL1Contracts: (l1RpcUrl: string, account: HDAccount | PrivateKeyAccount, logger: Logger, args: Pick<DeployL1ContractsArgs, 'genesisArchiveRoot' | 'genesisBlockHash' | 'initialValidators'> & L1ContractsConfig) => Promise<import("@aztec/aztec.js").DeployL1ContractsReturnType>;
|
|
6
|
+
//# sourceMappingURL=setup_l1_contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup_l1_contracts.d.ts","sourceRoot":"","sources":["../../src/fixtures/setup_l1_contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIhF,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAGzD,OAAO,EAAE,0CAA0C,EAAE,MAAM,uCAAuC,CAAC;AAEnG,eAAO,MAAM,gBAAgB,aACjB,MAAM,WACP,SAAS,GAAG,iBAAiB,UAC9B,MAAM,QACR,KAAK,qBAAqB,EAAE,oBAAoB,GAAG,kBAAkB,GAAG,mBAAmB,CAAC,GAChG,iBAAiB,mEAWpB,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { deployL1Contracts } from '@aztec/aztec.js';
|
|
2
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/
|
|
2
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
3
|
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
4
4
|
import { foundry } from 'viem/chains';
|
|
5
5
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
6
6
|
export const setupL1Contracts = async (l1RpcUrl, account, logger, args)=>{
|
|
7
|
-
const l1Data = await deployL1Contracts(
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const l1Data = await deployL1Contracts([
|
|
8
|
+
l1RpcUrl
|
|
9
|
+
], account, foundry, logger, {
|
|
10
|
+
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
11
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
10
12
|
protocolContractTreeRoot,
|
|
11
13
|
salt: undefined,
|
|
12
14
|
...args
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/**
|
|
3
|
+
* Test fixtures and utilities to set up and run a test using multiple validators
|
|
4
|
+
*/
|
|
5
|
+
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
6
|
+
import type { SentTx } from '@aztec/aztec.js';
|
|
7
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
8
|
+
import type { PXEService } from '@aztec/pxe';
|
|
9
|
+
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
|
+
export declare const PROPOSER_PRIVATE_KEYS_START_INDEX = 1;
|
|
12
|
+
export declare const ATTESTER_PRIVATE_KEYS_START_INDEX = 1001;
|
|
13
|
+
export interface NodeContext {
|
|
14
|
+
node: AztecNodeService;
|
|
15
|
+
pxeService: PXEService;
|
|
16
|
+
txs: SentTx[];
|
|
17
|
+
}
|
|
18
|
+
export declare function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[];
|
|
19
|
+
export declare function createNodes(config: AztecNodeConfig, dateProvider: DateProvider, bootstrapNodeEnr: string, numNodes: number, bootNodePort: number, prefilledPublicData?: PublicDataTreeLeaf[], dataDirectory?: string, metricsPort?: number): Promise<AztecNodeService[]>;
|
|
20
|
+
export declare function createNode(config: AztecNodeConfig, dateProvider: DateProvider, tcpPort: number, bootstrapNode: string | undefined, accountIndex: number, prefilledPublicData?: PublicDataTreeLeaf[], dataDirectory?: string, metricsPort?: number, loggerIdStorage?: AsyncLocalStorage<string>): Promise<AztecNodeService>;
|
|
21
|
+
export declare function createValidatorConfig(config: AztecNodeConfig, bootstrapNodeEnr?: string, port?: number, accountIndex?: number, dataDirectory?: string): Promise<AztecNodeConfig>;
|
|
22
|
+
//# sourceMappingURL=setup_p2p_test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup_p2p_test.d.ts","sourceRoot":"","sources":["../../src/fixtures/setup_p2p_test.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iCAAiC,OAAO,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,EAAE,CAO7F;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,EAC1C,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA4B7B;AAGD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,EAC1C,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,6BAQ5C;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,eAAe,EACvB,gBAAgB,CAAC,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,GAAE,MAAU,EACxB,aAAa,CAAC,EAAE,MAAM,4BA6BvB"}
|
|
@@ -19,7 +19,7 @@ export function generatePrivateKeys(startIndex, numberOfKeys) {
|
|
|
19
19
|
}
|
|
20
20
|
return privateKeys;
|
|
21
21
|
}
|
|
22
|
-
export async function createNodes(config, dateProvider, bootstrapNodeEnr, numNodes, bootNodePort, dataDirectory, metricsPort) {
|
|
22
|
+
export async function createNodes(config, dateProvider, bootstrapNodeEnr, numNodes, bootNodePort, prefilledPublicData, dataDirectory, metricsPort) {
|
|
23
23
|
const nodePromises = [];
|
|
24
24
|
const loggerIdStorage = new AsyncLocalStorage();
|
|
25
25
|
const logNameHandler = (module)=>loggerIdStorage.getStore() ? `${module}:${loggerIdStorage.getStore()}` : module;
|
|
@@ -28,7 +28,7 @@ export async function createNodes(config, dateProvider, bootstrapNodeEnr, numNod
|
|
|
28
28
|
// We run on ports from the bootnode upwards
|
|
29
29
|
const port = bootNodePort + i + 1;
|
|
30
30
|
const dataDir = dataDirectory ? `${dataDirectory}-${i}` : undefined;
|
|
31
|
-
const nodePromise = createNode(config, dateProvider, port, bootstrapNodeEnr, i, dataDir, metricsPort, loggerIdStorage);
|
|
31
|
+
const nodePromise = createNode(config, dateProvider, port, bootstrapNodeEnr, i, prefilledPublicData, dataDir, metricsPort, loggerIdStorage);
|
|
32
32
|
nodePromises.push(nodePromise);
|
|
33
33
|
}
|
|
34
34
|
const nodes = await Promise.all(nodePromises);
|
|
@@ -36,13 +36,15 @@ export async function createNodes(config, dateProvider, bootstrapNodeEnr, numNod
|
|
|
36
36
|
return nodes;
|
|
37
37
|
}
|
|
38
38
|
// creates a P2P enabled instance of Aztec Node Service
|
|
39
|
-
export async function createNode(config, dateProvider, tcpPort, bootstrapNode, accountIndex, dataDirectory, metricsPort, loggerIdStorage) {
|
|
39
|
+
export async function createNode(config, dateProvider, tcpPort, bootstrapNode, accountIndex, prefilledPublicData, dataDirectory, metricsPort, loggerIdStorage) {
|
|
40
40
|
const createNode = async ()=>{
|
|
41
41
|
const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, accountIndex, dataDirectory);
|
|
42
42
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
43
43
|
return await AztecNodeService.createAndSync(validatorConfig, {
|
|
44
44
|
telemetry,
|
|
45
45
|
dateProvider
|
|
46
|
+
}, {
|
|
47
|
+
prefilledPublicData
|
|
46
48
|
});
|
|
47
49
|
};
|
|
48
50
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
+
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
+
import { AnvilTestWatcher, type AztecAddress, CheatCodes, type CompleteAddress, type DeployL1ContractsReturnType, type Logger, type PXE, type Wallet } from '@aztec/aztec.js';
|
|
4
|
+
import { type BlobSinkServer } from '@aztec/blob-sink/server';
|
|
5
|
+
import { type DeployL1ContractsArgs } from '@aztec/ethereum';
|
|
6
|
+
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
|
+
import type { ProverNode } from '@aztec/prover-node';
|
|
8
|
+
import { type PXEService } from '@aztec/pxe';
|
|
9
|
+
import type { Anvil } from '@viem/anvil';
|
|
10
|
+
import { type SetupOptions } from './utils.js';
|
|
11
|
+
export type SubsystemsContext = {
|
|
12
|
+
anvil: Anvil;
|
|
13
|
+
acvmConfig: any;
|
|
14
|
+
bbConfig: any;
|
|
15
|
+
aztecNode: AztecNodeService;
|
|
16
|
+
aztecNodeConfig: AztecNodeConfig;
|
|
17
|
+
pxe: PXEService;
|
|
18
|
+
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
19
|
+
proverNode?: ProverNode;
|
|
20
|
+
watcher: AnvilTestWatcher;
|
|
21
|
+
cheatCodes: CheatCodes;
|
|
22
|
+
dateProvider: TestDateProvider;
|
|
23
|
+
blobSink: BlobSinkServer;
|
|
24
|
+
initialFundedAccounts: InitialAccountData[];
|
|
25
|
+
directoryToCleanup?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function createSnapshotManager(testName: string, dataPath?: string, config?: Partial<SetupOptions>, deployL1ContractsArgs?: Partial<DeployL1ContractsArgs>): SnapshotManager | MockSnapshotManager;
|
|
28
|
+
export interface ISnapshotManager {
|
|
29
|
+
snapshot<T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>): Promise<void>;
|
|
30
|
+
setup(): Promise<SubsystemsContext>;
|
|
31
|
+
teardown(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/** Snapshot manager that does not perform snapshotting, it just applies transition and restoration functions as it receives them. */
|
|
34
|
+
declare class MockSnapshotManager implements ISnapshotManager {
|
|
35
|
+
private config;
|
|
36
|
+
private deployL1ContractsArgs;
|
|
37
|
+
private context?;
|
|
38
|
+
private logger;
|
|
39
|
+
constructor(testName: string, config?: Partial<AztecNodeConfig>, deployL1ContractsArgs?: Partial<DeployL1ContractsArgs>);
|
|
40
|
+
snapshot<T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>): Promise<void>;
|
|
41
|
+
setup(): Promise<SubsystemsContext>;
|
|
42
|
+
teardown(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Snapshot engine for local e2e tests. Read more:
|
|
46
|
+
* https://github.com/AztecProtocol/aztec-packages/pull/5526
|
|
47
|
+
*/
|
|
48
|
+
declare class SnapshotManager implements ISnapshotManager {
|
|
49
|
+
private dataPath;
|
|
50
|
+
private config;
|
|
51
|
+
private deployL1ContractsArgs;
|
|
52
|
+
private snapshotStack;
|
|
53
|
+
private context?;
|
|
54
|
+
private livePath;
|
|
55
|
+
private logger;
|
|
56
|
+
constructor(testName: string, dataPath: string, config?: Partial<SetupOptions>, deployL1ContractsArgs?: Partial<DeployL1ContractsArgs>);
|
|
57
|
+
snapshot<T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Creates and returns the subsystem context based on the current snapshot stack.
|
|
60
|
+
* If the subsystem context already exists, just return it.
|
|
61
|
+
* If you want to be sure to get a clean snapshot, be sure to call teardown() before calling setup().
|
|
62
|
+
*/
|
|
63
|
+
setup(): Promise<SubsystemsContext>;
|
|
64
|
+
/**
|
|
65
|
+
* Destroys the current subsystem context.
|
|
66
|
+
*/
|
|
67
|
+
teardown(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Snapshot 'apply' helper function to add accounts.
|
|
71
|
+
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
72
|
+
*/
|
|
73
|
+
export declare const deployAccounts: (numberOfAccounts: number, logger: Logger, waitUntilProven?: boolean) => ({ pxe, initialFundedAccounts }: {
|
|
74
|
+
pxe: PXE;
|
|
75
|
+
initialFundedAccounts: InitialAccountData[];
|
|
76
|
+
}) => Promise<{
|
|
77
|
+
deployedAccounts: InitialAccountData[];
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
81
|
+
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
82
|
+
* @param sender - Wallet to send the deployment tx.
|
|
83
|
+
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
84
|
+
*/
|
|
85
|
+
export declare function publicDeployAccounts(sender: Wallet, accountsToDeploy: (CompleteAddress | AztecAddress)[], waitUntilProven?: boolean): Promise<void>;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=snapshot_manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot_manager.d.ts","sourceRoot":"","sources":["../../src/fixtures/snapshot_manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact
|
|
1
|
+
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { deployFundedSchnorrAccounts, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
3
|
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
|
-
import { AnvilTestWatcher, BatchCall, CheatCodes,
|
|
4
|
+
import { AnvilTestWatcher, BatchCall, CheatCodes, getContractClassFromArtifact } from '@aztec/aztec.js';
|
|
4
5
|
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
|
|
5
6
|
import { createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
6
7
|
import { createL1Clients, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum';
|
|
@@ -12,6 +13,7 @@ import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
|
12
13
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
13
14
|
import { createPXEService, getPXEServiceConfig } from '@aztec/pxe';
|
|
14
15
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
16
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
15
17
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
16
18
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
17
19
|
import fs from 'fs/promises';
|
|
@@ -27,7 +29,6 @@ import { setupL1Contracts } from './setup_l1_contracts.js';
|
|
|
27
29
|
import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex } from './utils.js';
|
|
28
30
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
29
31
|
export function createSnapshotManager(testName, dataPath, config = {}, deployL1ContractsArgs = {
|
|
30
|
-
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
|
|
31
32
|
initialValidators: []
|
|
32
33
|
}) {
|
|
33
34
|
return dataPath ? new SnapshotManager(testName, dataPath, config, deployL1ContractsArgs) : new MockSnapshotManager(testName, config, deployL1ContractsArgs);
|
|
@@ -37,9 +38,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
37
38
|
deployL1ContractsArgs;
|
|
38
39
|
context;
|
|
39
40
|
logger;
|
|
40
|
-
constructor(testName, config = {}, deployL1ContractsArgs = {
|
|
41
|
-
assumeProvenThrough: Number.MAX_SAFE_INTEGER
|
|
42
|
-
}){
|
|
41
|
+
constructor(testName, config = {}, deployL1ContractsArgs = {}){
|
|
43
42
|
this.config = config;
|
|
44
43
|
this.deployL1ContractsArgs = deployL1ContractsArgs;
|
|
45
44
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
@@ -77,9 +76,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
77
76
|
context;
|
|
78
77
|
livePath;
|
|
79
78
|
logger;
|
|
80
|
-
constructor(testName, dataPath, config = {}, deployL1ContractsArgs = {
|
|
81
|
-
assumeProvenThrough: Number.MAX_SAFE_INTEGER
|
|
82
|
-
}){
|
|
79
|
+
constructor(testName, dataPath, config = {}, deployL1ContractsArgs = {}){
|
|
83
80
|
this.dataPath = dataPath;
|
|
84
81
|
this.config = config;
|
|
85
82
|
this.deployL1ContractsArgs = deployL1ContractsArgs;
|
|
@@ -117,7 +114,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
117
114
|
// Execute the restoration function.
|
|
118
115
|
await restore(snapshotData, context);
|
|
119
116
|
// Save the snapshot data.
|
|
120
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.
|
|
117
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
121
118
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
122
119
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
123
120
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -189,10 +186,15 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
189
186
|
await context.watcher.stop();
|
|
190
187
|
await context.blobSink.stop();
|
|
191
188
|
if (context.directoryToCleanup) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
try {
|
|
190
|
+
await fs.rm(context.directoryToCleanup, {
|
|
191
|
+
recursive: true,
|
|
192
|
+
force: true,
|
|
193
|
+
maxRetries: 3
|
|
194
|
+
});
|
|
195
|
+
} catch (err) {
|
|
196
|
+
getLogger().warn(`Failed to delete tmp directory ${context.directoryToCleanup}: ${err}`);
|
|
197
|
+
}
|
|
196
198
|
}
|
|
197
199
|
} catch (err) {
|
|
198
200
|
getLogger().error('Error during teardown', err);
|
|
@@ -202,8 +204,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
202
204
|
* Initializes a fresh set of subsystems.
|
|
203
205
|
* If given a statePath, the state will be written to the path.
|
|
204
206
|
* If there is no statePath, in-memory and temporary state locations will be used.
|
|
205
|
-
*/ async function setupFromFresh(statePath, logger, opts = {}, deployL1ContractsArgs = {
|
|
206
|
-
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
|
|
207
|
+
*/ async function setupFromFresh(statePath, logger, { numberOfInitialFundedAccounts = 10, ...opts } = {}, deployL1ContractsArgs = {
|
|
207
208
|
initialValidators: []
|
|
208
209
|
}) {
|
|
209
210
|
logger.verbose(`Initializing state...`);
|
|
@@ -237,9 +238,13 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
237
238
|
await blobSink.start();
|
|
238
239
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
239
240
|
logger.verbose('Starting anvil...');
|
|
240
|
-
const res = await startAnvil(
|
|
241
|
+
const res = await startAnvil({
|
|
242
|
+
l1BlockTime: opts.ethereumSlotDuration
|
|
243
|
+
});
|
|
241
244
|
const anvil = res.anvil;
|
|
242
|
-
aztecNodeConfig.
|
|
245
|
+
aztecNodeConfig.l1RpcUrls = [
|
|
246
|
+
res.rpcUrl
|
|
247
|
+
];
|
|
243
248
|
// Deploy our L1 contracts.
|
|
244
249
|
logger.verbose('Deploying L1 contracts...');
|
|
245
250
|
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
@@ -251,12 +256,16 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
251
256
|
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
252
257
|
aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey.toString('hex')}`;
|
|
253
258
|
aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey.toString('hex')}`;
|
|
254
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.
|
|
259
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
255
260
|
if (opts.l1StartTime) {
|
|
256
261
|
await ethCheatCodes.warp(opts.l1StartTime);
|
|
257
262
|
}
|
|
258
|
-
const
|
|
263
|
+
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
264
|
+
const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address), opts.initialAccountFeeJuice);
|
|
265
|
+
const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrls[0], hdAccount, logger, {
|
|
259
266
|
...getL1ContractsConfigEnvVars(),
|
|
267
|
+
genesisArchiveRoot,
|
|
268
|
+
genesisBlockHash,
|
|
260
269
|
salt: opts.salt,
|
|
261
270
|
...deployL1ContractsArgs,
|
|
262
271
|
initialValidators: opts.initialValidators
|
|
@@ -286,7 +295,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
286
295
|
});
|
|
287
296
|
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
288
297
|
}
|
|
289
|
-
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.
|
|
298
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.publicClient);
|
|
290
299
|
await watcher.start();
|
|
291
300
|
const acvmConfig = await getACVMConfig(logger);
|
|
292
301
|
if (acvmConfig) {
|
|
@@ -304,19 +313,22 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
304
313
|
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
305
314
|
telemetry,
|
|
306
315
|
dateProvider
|
|
316
|
+
}, {
|
|
317
|
+
prefilledPublicData
|
|
307
318
|
});
|
|
308
319
|
let proverNode = undefined;
|
|
309
320
|
if (opts.startProverNode) {
|
|
310
321
|
logger.verbose('Creating and syncing a simulated prover node...');
|
|
311
|
-
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')));
|
|
322
|
+
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')), prefilledPublicData);
|
|
312
323
|
}
|
|
313
324
|
logger.verbose('Creating pxe...');
|
|
314
325
|
const pxeConfig = getPXEServiceConfig();
|
|
315
326
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
316
327
|
const pxe = await createPXEService(aztecNode, pxeConfig);
|
|
317
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.
|
|
328
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
318
329
|
if (statePath) {
|
|
319
330
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
331
|
+
writeFileSync(`${statePath}/accounts.json`, JSON.stringify(initialFundedAccounts, resolver));
|
|
320
332
|
}
|
|
321
333
|
return {
|
|
322
334
|
aztecNodeConfig,
|
|
@@ -331,6 +343,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
331
343
|
cheatCodes,
|
|
332
344
|
dateProvider,
|
|
333
345
|
blobSink,
|
|
346
|
+
initialFundedAccounts,
|
|
334
347
|
directoryToCleanup
|
|
335
348
|
};
|
|
336
349
|
}
|
|
@@ -348,6 +361,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
348
361
|
const aztecNodeConfig = JSON.parse(readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'), reviver);
|
|
349
362
|
aztecNodeConfig.dataDirectory = statePath;
|
|
350
363
|
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
364
|
+
const initialFundedAccounts = JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
365
|
+
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address));
|
|
351
366
|
const blobSink = await createBlobSinkServer({
|
|
352
367
|
port: blobSinkPort,
|
|
353
368
|
dataStoreConfig: {
|
|
@@ -358,10 +373,12 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
358
373
|
await blobSink.start();
|
|
359
374
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
360
375
|
const { anvil, rpcUrl } = await startAnvil();
|
|
361
|
-
aztecNodeConfig.
|
|
376
|
+
aztecNodeConfig.l1RpcUrls = [
|
|
377
|
+
rpcUrl
|
|
378
|
+
];
|
|
362
379
|
// Load anvil state.
|
|
363
380
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
364
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.
|
|
381
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
365
382
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
366
383
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
367
384
|
const acvmConfig = await getACVMConfig(logger);
|
|
@@ -375,8 +392,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
375
392
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
376
393
|
}
|
|
377
394
|
logger.verbose('Creating ETH clients...');
|
|
378
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.
|
|
379
|
-
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.
|
|
395
|
+
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
396
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls), aztecNodeConfig.l1Contracts.rollupAddress, publicClient);
|
|
380
397
|
await watcher.start();
|
|
381
398
|
logger.verbose('Creating aztec node...');
|
|
382
399
|
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
@@ -384,19 +401,21 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
384
401
|
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
385
402
|
telemetry,
|
|
386
403
|
dateProvider
|
|
404
|
+
}, {
|
|
405
|
+
prefilledPublicData
|
|
387
406
|
});
|
|
388
407
|
let proverNode = undefined;
|
|
389
408
|
if (aztecNodeConfig.startProverNode) {
|
|
390
409
|
logger.verbose('Creating and syncing a simulated prover node...');
|
|
391
410
|
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
392
411
|
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
|
|
393
|
-
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')));
|
|
412
|
+
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')), prefilledPublicData);
|
|
394
413
|
}
|
|
395
414
|
logger.verbose('Creating pxe...');
|
|
396
415
|
const pxeConfig = getPXEServiceConfig();
|
|
397
416
|
pxeConfig.dataDirectory = statePath;
|
|
398
417
|
const pxe = await createPXEService(aztecNode, pxeConfig);
|
|
399
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.
|
|
418
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
400
419
|
return {
|
|
401
420
|
aztecNodeConfig,
|
|
402
421
|
anvil,
|
|
@@ -414,52 +433,24 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
414
433
|
cheatCodes,
|
|
415
434
|
dateProvider,
|
|
416
435
|
blobSink,
|
|
436
|
+
initialFundedAccounts,
|
|
417
437
|
directoryToCleanup
|
|
418
438
|
};
|
|
419
439
|
}
|
|
420
440
|
/**
|
|
421
441
|
* Snapshot 'apply' helper function to add accounts.
|
|
422
442
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
423
|
-
*/ export const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
length: numberOfAccounts
|
|
427
|
-
}).map((_)=>[
|
|
428
|
-
Fr.random(),
|
|
429
|
-
GrumpkinScalar.random()
|
|
430
|
-
]);
|
|
431
|
-
logger.verbose('Simulating account deployment...');
|
|
432
|
-
const provenTxs = await Promise.all(accountKeys.map(async ([secretKey, signPk], index)=>{
|
|
433
|
-
const account = await getSchnorrAccount(pxe, secretKey, signPk, 1);
|
|
434
|
-
// only register the contract class once
|
|
435
|
-
let skipClassRegistration = true;
|
|
436
|
-
if (index === 0) {
|
|
437
|
-
// for the first account, check if the contract class is already registered, otherwise we should register now
|
|
438
|
-
if (!(await pxe.getContractClassMetadata(account.getInstance().contractClassId)).isContractClassPubliclyRegistered) {
|
|
439
|
-
skipClassRegistration = false;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
const deployMethod = await account.getDeployMethod();
|
|
443
|
-
const provenTx = await deployMethod.prove({
|
|
444
|
-
contractAddressSalt: new Fr(account.salt),
|
|
445
|
-
skipClassRegistration,
|
|
446
|
-
skipPublicDeployment: true,
|
|
447
|
-
universalDeploy: true
|
|
448
|
-
});
|
|
449
|
-
return provenTx;
|
|
450
|
-
}));
|
|
451
|
-
logger.verbose('Account deployment tx hashes:');
|
|
452
|
-
for (const provenTx of provenTxs){
|
|
453
|
-
logger.verbose((await provenTx.getTxHash()).toString());
|
|
443
|
+
*/ export const deployAccounts = (numberOfAccounts, logger, waitUntilProven = false)=>async ({ pxe, initialFundedAccounts })=>{
|
|
444
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
445
|
+
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
454
446
|
}
|
|
455
|
-
logger.verbose('Deploying accounts...');
|
|
456
|
-
const
|
|
457
|
-
await
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
})));
|
|
447
|
+
logger.verbose('Deploying accounts funded with fee juice...');
|
|
448
|
+
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
449
|
+
await deployFundedSchnorrAccounts(pxe, deployedAccounts, {
|
|
450
|
+
proven: waitUntilProven
|
|
451
|
+
});
|
|
461
452
|
return {
|
|
462
|
-
|
|
453
|
+
deployedAccounts
|
|
463
454
|
};
|
|
464
455
|
};
|
|
465
456
|
/**
|
|
@@ -472,14 +463,16 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
472
463
|
const instances = (await Promise.all(accountAddressesToDeploy.map((account)=>sender.getContractMetadata(account)))).map((metadata)=>metadata.contractInstance);
|
|
473
464
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
474
465
|
const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
calls.
|
|
466
|
+
const fns = await Promise.all([
|
|
467
|
+
...!alreadyRegistered ? [
|
|
468
|
+
registerContractClass(sender, SchnorrAccountContractArtifact)
|
|
469
|
+
] : [],
|
|
470
|
+
...instances.map((instance)=>deployInstance(sender, instance))
|
|
471
|
+
]);
|
|
472
|
+
const calls = await Promise.all(fns.map((fn)=>fn.request()));
|
|
473
|
+
const capsules = fns.map((fn)=>fn.getCapsules()).flat();
|
|
482
474
|
const batch = new BatchCall(sender, calls);
|
|
475
|
+
batch.addCapsules(capsules);
|
|
483
476
|
await batch.send().wait({
|
|
484
477
|
proven: waitUntilProven
|
|
485
478
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AztecAddress, Logger, Wallet } from '@aztec/aztec.js';
|
|
2
|
+
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
|
+
export declare function deployToken(adminWallet: Wallet, initialAdminBalance: bigint, logger: Logger): Promise<TokenContract>;
|
|
4
|
+
export declare function mintTokensToPrivate(token: TokenContract, minterWallet: Wallet, recipient: AztecAddress, amount: bigint): Promise<void>;
|
|
5
|
+
export declare function expectTokenBalance(wallet: Wallet, token: TokenContract, owner: AztecAddress, expectedBalance: bigint, logger: Logger): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=token_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token_utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/token_utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0BAcjG;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,MAAM,iBAKf;AAGD,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,iBAOf"}
|
|
@@ -12,7 +12,7 @@ export async function deployToken(adminWallet, initialAdminBalance, logger) {
|
|
|
12
12
|
}
|
|
13
13
|
export async function mintTokensToPrivate(token, minterWallet, recipient, amount) {
|
|
14
14
|
const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
|
|
15
|
-
const from = minterWallet.getAddress(); // we are setting from to minter here because
|
|
15
|
+
const from = minterWallet.getAddress(); // we are setting from to minter here because we need a sender to calculate the tag
|
|
16
16
|
await tokenAsMinter.methods.mint_to_private(from, recipient, amount).send().wait();
|
|
17
17
|
}
|
|
18
18
|
// docs:end:token_utils
|