@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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/bench/client_flows/benchmark.d.ts +4 -3
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +25 -14
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +111 -90
- package/dest/bench/client_flows/config.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.js +8 -30
- package/dest/bench/utils.d.ts +4 -13
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +10 -34
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +8 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +12 -9
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +35 -35
- package/dest/e2e_deploy_contract/deploy_test.d.ts +12 -6
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +19 -12
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +30 -22
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +14 -11
- package/dest/e2e_fees/fees_test.d.ts +10 -8
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +35 -38
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +9 -8
- package/dest/e2e_multi_validator/utils.d.ts +2 -2
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +4 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -4
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +11 -12
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +238 -17
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +46 -19
- package/dest/e2e_p2p/shared.d.ts +16 -17
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +56 -55
- package/dest/e2e_token_contract/token_contract_test.d.ts +6 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +12 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +53 -58
- package/dest/fixtures/fixtures.d.ts +1 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +1 -1
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +1 -1
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +2 -2
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +3 -3
- package/dest/fixtures/setup_p2p_test.d.ts +12 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +50 -24
- package/dest/fixtures/snapshot_manager.d.ts +13 -10
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +66 -51
- package/dest/fixtures/token_utils.d.ts +10 -5
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +17 -18
- package/dest/fixtures/utils.d.ts +479 -35
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +106 -125
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +20 -23
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +14 -16
- package/dest/shared/gas_portal_test_harness.d.ts +10 -17
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +11 -8
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +12 -8
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +44 -58
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +4 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +8 -5
- package/dest/simulators/token_simulator.d.ts +4 -2
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +22 -14
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +144 -86
- package/dest/spartan/tx_metrics.d.ts +39 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +95 -0
- package/dest/spartan/utils.d.ts +92 -17
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +386 -63
- package/package.json +43 -40
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +141 -114
- package/src/bench/client_flows/data_extractor.ts +9 -31
- package/src/bench/utils.ts +9 -37
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +38 -51
- package/src/e2e_deploy_contract/deploy_test.ts +18 -36
- package/src/e2e_epochs/epochs_test.ts +41 -35
- package/src/e2e_fees/bridging_race.notest.ts +16 -11
- package/src/e2e_fees/fees_test.ts +42 -47
- package/src/e2e_l1_publisher/write_json.ts +12 -9
- package/src/e2e_multi_validator/utils.ts +5 -11
- package/src/e2e_nested_contract/nested_contract_test.ts +15 -13
- package/src/e2e_p2p/inactivity_slash_test.ts +184 -0
- package/src/e2e_p2p/p2p_network.ts +124 -82
- package/src/e2e_p2p/shared.ts +66 -58
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +60 -97
- package/src/fixtures/fixtures.ts +1 -2
- package/src/fixtures/get_acvm_config.ts +2 -2
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/setup_l1_contracts.ts +5 -4
- package/src/fixtures/setup_p2p_test.ts +79 -32
- package/src/fixtures/snapshot_manager.ts +87 -82
- package/src/fixtures/token_utils.ts +16 -24
- package/src/fixtures/utils.ts +142 -172
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +3 -11
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +23 -31
- package/src/shared/gas_portal_test_harness.ts +14 -21
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +77 -86
- package/src/simulators/lending_simulator.ts +9 -6
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +15 -3
- package/src/spartan/setup_test_wallets.ts +171 -127
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +463 -64
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
2
2
|
import type { BBConfig } from '@aztec/bb-prover';
|
|
3
3
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
4
4
|
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
6
|
import { tmpdir } from 'node:os';
|
|
7
7
|
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
8
9
|
|
|
9
10
|
const {
|
|
10
11
|
BB_RELEASE_DIR = 'barretenberg/cpp/build/bin',
|
|
@@ -22,7 +23,7 @@ export const getBBConfig = async (
|
|
|
22
23
|
try {
|
|
23
24
|
const bbBinaryPath =
|
|
24
25
|
BB_BINARY_PATH ??
|
|
25
|
-
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb');
|
|
26
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb-avm');
|
|
26
27
|
await fs.access(bbBinaryPath, fs.constants.R_OK);
|
|
27
28
|
|
|
28
29
|
let bbWorkingDirectory: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { tryJsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
6
|
import { InboxAbi } from '@aztec/l1-artifacts';
|
|
5
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Logger } from '@aztec/aztec.js';
|
|
2
|
-
import
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
2
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import { type DeployL1ContractsArgs, deployL1Contracts } from '@aztec/ethereum/deploy-l1-contracts';
|
|
3
4
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
-
import {
|
|
5
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
5
6
|
|
|
6
7
|
import type { HDAccount, PrivateKeyAccount } from 'viem';
|
|
7
8
|
import { foundry } from 'viem/chains';
|
|
@@ -16,7 +17,7 @@ export const setupL1Contracts = async (
|
|
|
16
17
|
) => {
|
|
17
18
|
const l1Data = await deployL1Contracts([l1RpcUrl], account, foundry, logger, {
|
|
18
19
|
vkTreeRoot: getVKTreeRoot(),
|
|
19
|
-
|
|
20
|
+
protocolContractsHash,
|
|
20
21
|
salt: undefined,
|
|
21
22
|
realVerifier: false,
|
|
22
23
|
...args,
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* Test fixtures and utilities to set up and run a test using multiple validators
|
|
3
3
|
*/
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
5
|
-
import
|
|
5
|
+
import { range } from '@aztec/foundation/array';
|
|
6
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
7
|
import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
|
|
8
8
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
10
|
import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
|
|
11
|
-
import type { PXEService } from '@aztec/pxe/server';
|
|
12
11
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
13
12
|
|
|
14
13
|
import getPort from 'get-port';
|
|
@@ -23,12 +22,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
|
23
22
|
// to avoid running validators with the same key
|
|
24
23
|
export const ATTESTER_PRIVATE_KEYS_START_INDEX = 3;
|
|
25
24
|
|
|
26
|
-
export interface NodeContext {
|
|
27
|
-
node: AztecNodeService;
|
|
28
|
-
pxeService: PXEService;
|
|
29
|
-
txs: SentTx[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[] {
|
|
33
26
|
const privateKeys: `0x${string}`[] = [];
|
|
34
27
|
// Do not start from 0 as it is used during setup
|
|
@@ -39,7 +32,7 @@ export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `
|
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
export async function createNodes(
|
|
42
|
-
config: AztecNodeConfig,
|
|
35
|
+
config: AztecNodeConfig & { dontStartSequencer?: boolean },
|
|
43
36
|
dateProvider: DateProvider,
|
|
44
37
|
bootstrapNodeEnr: string,
|
|
45
38
|
numNodes: number,
|
|
@@ -48,6 +41,7 @@ export async function createNodes(
|
|
|
48
41
|
dataDirectory?: string,
|
|
49
42
|
metricsPort?: number,
|
|
50
43
|
indexOffset = 0,
|
|
44
|
+
validatorsPerNode = 1,
|
|
51
45
|
): Promise<AztecNodeService[]> {
|
|
52
46
|
const nodePromises: Promise<AztecNodeService>[] = [];
|
|
53
47
|
const loggerIdStorage = new AsyncLocalStorage<string>();
|
|
@@ -60,13 +54,18 @@ export async function createNodes(
|
|
|
60
54
|
// We run on ports from the bootnode upwards
|
|
61
55
|
const port = bootNodePort + 1 + index;
|
|
62
56
|
|
|
57
|
+
// Determine validator indices for this node
|
|
58
|
+
const validatorIndices = validatorsPerNode === 1 ? index : range(validatorsPerNode, validatorsPerNode * index);
|
|
59
|
+
|
|
60
|
+
// Assign data directory
|
|
63
61
|
const dataDir = dataDirectory ? `${dataDirectory}-${index}` : undefined;
|
|
62
|
+
|
|
64
63
|
const nodePromise = createNode(
|
|
65
64
|
config,
|
|
66
65
|
dateProvider,
|
|
67
66
|
port,
|
|
68
67
|
bootstrapNodeEnr,
|
|
69
|
-
|
|
68
|
+
validatorIndices,
|
|
70
69
|
prefilledPublicData,
|
|
71
70
|
dataDir,
|
|
72
71
|
metricsPort,
|
|
@@ -86,13 +85,13 @@ export async function createNodes(
|
|
|
86
85
|
return nodes;
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
/** Creates a P2P enabled instance of Aztec Node Service with a validator */
|
|
90
89
|
export async function createNode(
|
|
91
|
-
config: AztecNodeConfig,
|
|
90
|
+
config: AztecNodeConfig & { dontStartSequencer?: boolean },
|
|
92
91
|
dateProvider: DateProvider,
|
|
93
92
|
tcpPort: number,
|
|
94
93
|
bootstrapNode: string | undefined,
|
|
95
|
-
addressIndex: number,
|
|
94
|
+
addressIndex: number | number[],
|
|
96
95
|
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
97
96
|
dataDirectory?: string,
|
|
98
97
|
metricsPort?: number,
|
|
@@ -100,8 +99,37 @@ export async function createNode(
|
|
|
100
99
|
) {
|
|
101
100
|
const createNode = async () => {
|
|
102
101
|
const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, addressIndex, dataDirectory);
|
|
103
|
-
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
104
|
-
return await AztecNodeService.createAndSync(
|
|
102
|
+
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
103
|
+
return await AztecNodeService.createAndSync(
|
|
104
|
+
validatorConfig,
|
|
105
|
+
{ telemetry, dateProvider },
|
|
106
|
+
{ prefilledPublicData, dontStartSequencer: config.dontStartSequencer },
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Creates a P2P enabled instance of Aztec Node Service without a validator */
|
|
113
|
+
export async function createNonValidatorNode(
|
|
114
|
+
baseConfig: AztecNodeConfig,
|
|
115
|
+
dateProvider: DateProvider,
|
|
116
|
+
tcpPort: number,
|
|
117
|
+
bootstrapNode: string | undefined,
|
|
118
|
+
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
119
|
+
dataDirectory?: string,
|
|
120
|
+
metricsPort?: number,
|
|
121
|
+
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
122
|
+
) {
|
|
123
|
+
const createNode = async () => {
|
|
124
|
+
const p2pConfig = await createP2PConfig(baseConfig, bootstrapNode, tcpPort, dataDirectory);
|
|
125
|
+
const config: AztecNodeConfig = {
|
|
126
|
+
...p2pConfig,
|
|
127
|
+
disableValidator: true,
|
|
128
|
+
validatorPrivateKeys: undefined,
|
|
129
|
+
publisherPrivateKeys: [],
|
|
130
|
+
};
|
|
131
|
+
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
132
|
+
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
|
|
105
133
|
};
|
|
106
134
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
107
135
|
}
|
|
@@ -119,16 +147,15 @@ export async function createProverNode(
|
|
|
119
147
|
) {
|
|
120
148
|
const createProverNode = async () => {
|
|
121
149
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
122
|
-
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
123
|
-
|
|
124
|
-
const proverConfig: Partial<ProverNodeConfig> =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
};
|
|
150
|
+
const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
|
|
151
|
+
|
|
152
|
+
const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
|
|
153
|
+
config,
|
|
154
|
+
bootstrapNode,
|
|
155
|
+
tcpPort,
|
|
156
|
+
dataDirectory,
|
|
157
|
+
);
|
|
158
|
+
|
|
132
159
|
const aztecNodeRpcTxProvider = undefined;
|
|
133
160
|
return await createAndSyncProverNode(
|
|
134
161
|
bufferToHex(proverNodePrivateKey),
|
|
@@ -142,20 +169,14 @@ export async function createProverNode(
|
|
|
142
169
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
|
|
143
170
|
}
|
|
144
171
|
|
|
145
|
-
export async function
|
|
172
|
+
export async function createP2PConfig(
|
|
146
173
|
config: AztecNodeConfig,
|
|
147
174
|
bootstrapNodeEnr?: string,
|
|
148
175
|
port?: number,
|
|
149
|
-
addressIndex: number = 1,
|
|
150
176
|
dataDirectory?: string,
|
|
151
177
|
) {
|
|
152
178
|
port = port ?? (await getPort());
|
|
153
179
|
|
|
154
|
-
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
155
|
-
|
|
156
|
-
config.validatorPrivateKeys = new SecretValue([attesterPrivateKey]);
|
|
157
|
-
config.publisherPrivateKeys = [new SecretValue(attesterPrivateKey)];
|
|
158
|
-
|
|
159
180
|
const nodeConfig: AztecNodeConfig = {
|
|
160
181
|
...config,
|
|
161
182
|
p2pIp: `127.0.0.1`,
|
|
@@ -169,3 +190,29 @@ export async function createValidatorConfig(
|
|
|
169
190
|
|
|
170
191
|
return nodeConfig;
|
|
171
192
|
}
|
|
193
|
+
|
|
194
|
+
export async function createValidatorConfig(
|
|
195
|
+
config: AztecNodeConfig,
|
|
196
|
+
bootstrapNodeEnr?: string,
|
|
197
|
+
port?: number,
|
|
198
|
+
addressIndex: number | number[] = 1,
|
|
199
|
+
dataDirectory?: string,
|
|
200
|
+
) {
|
|
201
|
+
const addressIndices = Array.isArray(addressIndex) ? addressIndex : [addressIndex];
|
|
202
|
+
if (addressIndices.length === 0) {
|
|
203
|
+
throw new Error('At least one address index must be provided to create a validator config');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const attesterPrivateKeys = addressIndices.map(index =>
|
|
207
|
+
bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + index)!),
|
|
208
|
+
);
|
|
209
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
|
|
210
|
+
const nodeConfig: AztecNodeConfig = {
|
|
211
|
+
...config,
|
|
212
|
+
...p2pConfig,
|
|
213
|
+
validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
|
|
214
|
+
publisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
return nodeConfig;
|
|
218
|
+
}
|
|
@@ -1,43 +1,33 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type InitialAccountData,
|
|
2
|
+
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
BatchCall,
|
|
8
|
-
type CompleteAddress,
|
|
9
|
-
type ContractFunctionInteraction,
|
|
10
|
-
DefaultWaitForProvenOpts,
|
|
11
|
-
EthAddress,
|
|
12
|
-
type Logger,
|
|
13
|
-
type PXE,
|
|
14
|
-
type Wallet,
|
|
15
|
-
getContractClassFromArtifact,
|
|
16
|
-
waitForProven,
|
|
17
|
-
} from '@aztec/aztec.js';
|
|
4
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
5
|
+
import { getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
|
|
6
|
+
import { BatchCall, type ContractFunctionInteraction, waitForProven } from '@aztec/aztec.js/contracts';
|
|
18
7
|
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
9
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
10
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
19
11
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
20
12
|
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
deployMulticall3,
|
|
26
|
-
getL1ContractsConfigEnvVars,
|
|
27
|
-
} from '@aztec/ethereum';
|
|
13
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
14
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
15
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
16
|
+
import type { DeployL1ContractsArgs, DeployL1ContractsReturnType } from '@aztec/ethereum/deploy-l1-contracts';
|
|
28
17
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
29
18
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
30
19
|
import { SecretValue } from '@aztec/foundation/config';
|
|
31
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
20
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
32
21
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
33
22
|
import { createLogger } from '@aztec/foundation/log';
|
|
34
23
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
35
24
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
36
25
|
import type { ProverNode } from '@aztec/prover-node';
|
|
37
|
-
import {
|
|
26
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
38
27
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
39
28
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
40
29
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
30
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
41
31
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
42
32
|
|
|
43
33
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -70,7 +60,7 @@ export type SubsystemsContext = {
|
|
|
70
60
|
bbConfig: any;
|
|
71
61
|
aztecNode: AztecNodeService;
|
|
72
62
|
aztecNodeConfig: AztecNodeConfig;
|
|
73
|
-
|
|
63
|
+
wallet: TestWallet;
|
|
74
64
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
75
65
|
proverNode?: ProverNode;
|
|
76
66
|
watcher: AnvilTestWatcher;
|
|
@@ -206,7 +196,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
206
196
|
await restore(snapshotData, context);
|
|
207
197
|
|
|
208
198
|
// Save the snapshot data.
|
|
209
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
199
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
|
|
210
200
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
211
201
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
212
202
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -333,14 +323,6 @@ async function setupFromFresh(
|
|
|
333
323
|
}
|
|
334
324
|
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
335
325
|
|
|
336
|
-
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
337
|
-
logger.verbose('Starting anvil...');
|
|
338
|
-
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
339
|
-
const anvil = res.anvil;
|
|
340
|
-
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
341
|
-
|
|
342
|
-
// Deploy our L1 contracts.
|
|
343
|
-
logger.verbose('Deploying L1 contracts...');
|
|
344
326
|
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
345
327
|
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
346
328
|
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
@@ -354,8 +336,19 @@ async function setupFromFresh(
|
|
|
354
336
|
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
|
|
355
337
|
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
356
338
|
|
|
357
|
-
|
|
339
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
340
|
+
|
|
341
|
+
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
342
|
+
logger.verbose('Starting anvil...');
|
|
343
|
+
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
344
|
+
const anvil = res.anvil;
|
|
345
|
+
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
346
|
+
|
|
347
|
+
const dateProvider = new TestDateProvider();
|
|
348
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
358
349
|
|
|
350
|
+
// Deploy our L1 contracts.
|
|
351
|
+
logger.verbose('Deploying L1 contracts...');
|
|
359
352
|
if (opts.l1StartTime) {
|
|
360
353
|
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
361
354
|
}
|
|
@@ -379,12 +372,9 @@ async function setupFromFresh(
|
|
|
379
372
|
});
|
|
380
373
|
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
381
374
|
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
382
|
-
aztecNodeConfig.l1PublishRetryIntervalMS = 100;
|
|
383
|
-
|
|
384
|
-
const dateProvider = new TestDateProvider();
|
|
385
375
|
|
|
386
376
|
const watcher = new AnvilTestWatcher(
|
|
387
|
-
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
377
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
|
|
388
378
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
389
379
|
deployL1ContractsValues.l1Client,
|
|
390
380
|
dateProvider,
|
|
@@ -403,7 +393,7 @@ async function setupFromFresh(
|
|
|
403
393
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
404
394
|
}
|
|
405
395
|
|
|
406
|
-
const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
396
|
+
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
407
397
|
|
|
408
398
|
// Setup blob sink service
|
|
409
399
|
const blobSink = await createBlobSinkServer(
|
|
@@ -413,7 +403,7 @@ async function setupFromFresh(
|
|
|
413
403
|
l1Contracts: aztecNodeConfig.l1Contracts,
|
|
414
404
|
port: blobSinkPort,
|
|
415
405
|
dataDirectory: aztecNodeConfig.dataDirectory,
|
|
416
|
-
|
|
406
|
+
dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
|
|
417
407
|
},
|
|
418
408
|
telemetry,
|
|
419
409
|
);
|
|
@@ -432,20 +422,23 @@ async function setupFromFresh(
|
|
|
432
422
|
proverNode = await createAndSyncProverNode(
|
|
433
423
|
`0x${proverNodePrivateKey!.toString('hex')}`,
|
|
434
424
|
aztecNodeConfig,
|
|
435
|
-
{
|
|
425
|
+
{
|
|
426
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
427
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
428
|
+
p2pEnabled: false,
|
|
429
|
+
},
|
|
436
430
|
aztecNode,
|
|
437
431
|
prefilledPublicData,
|
|
438
432
|
);
|
|
439
433
|
}
|
|
440
434
|
|
|
441
435
|
logger.verbose('Creating pxe...');
|
|
442
|
-
const pxeConfig =
|
|
436
|
+
const pxeConfig = getPXEConfig();
|
|
443
437
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
444
438
|
// Only enable proving if specifically requested.
|
|
445
439
|
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
440
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
441
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
449
442
|
|
|
450
443
|
if (statePath) {
|
|
451
444
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
@@ -456,7 +449,7 @@ async function setupFromFresh(
|
|
|
456
449
|
aztecNodeConfig,
|
|
457
450
|
anvil,
|
|
458
451
|
aztecNode,
|
|
459
|
-
|
|
452
|
+
wallet,
|
|
460
453
|
sequencer: aztecNode.getSequencer()!,
|
|
461
454
|
acvmConfig,
|
|
462
455
|
bbConfig,
|
|
@@ -501,7 +494,9 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
501
494
|
aztecNodeConfig.l1RpcUrls = [rpcUrl];
|
|
502
495
|
// Load anvil state.
|
|
503
496
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
504
|
-
|
|
497
|
+
|
|
498
|
+
const dateProvider = new TestDateProvider();
|
|
499
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
505
500
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
506
501
|
|
|
507
502
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
@@ -520,16 +515,15 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
520
515
|
logger.verbose('Creating ETH clients...');
|
|
521
516
|
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
522
517
|
|
|
523
|
-
const dateProvider = new TestDateProvider();
|
|
524
518
|
const watcher = new AnvilTestWatcher(
|
|
525
|
-
|
|
519
|
+
ethCheatCodes,
|
|
526
520
|
aztecNodeConfig.l1Contracts.rollupAddress,
|
|
527
521
|
l1Client,
|
|
528
522
|
dateProvider,
|
|
529
523
|
);
|
|
530
524
|
await watcher.start();
|
|
531
525
|
|
|
532
|
-
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
526
|
+
const telemetry = await initTelemetryClient(getTelemetryConfig());
|
|
533
527
|
const blobSink = await createBlobSinkServer(
|
|
534
528
|
{
|
|
535
529
|
l1ChainId: aztecNodeConfig.l1ChainId,
|
|
@@ -537,7 +531,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
537
531
|
l1Contracts: aztecNodeConfig.l1Contracts,
|
|
538
532
|
port: blobSinkPort,
|
|
539
533
|
dataDirectory: statePath,
|
|
540
|
-
|
|
534
|
+
dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
|
|
541
535
|
},
|
|
542
536
|
telemetry,
|
|
543
537
|
);
|
|
@@ -558,24 +552,27 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
558
552
|
proverNode = await createAndSyncProverNode(
|
|
559
553
|
proverNodePrivateKeyHex,
|
|
560
554
|
aztecNodeConfig,
|
|
561
|
-
{
|
|
555
|
+
{
|
|
556
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
557
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
558
|
+
p2pEnabled: false,
|
|
559
|
+
},
|
|
562
560
|
aztecNode,
|
|
563
561
|
prefilledPublicData,
|
|
564
562
|
);
|
|
565
563
|
}
|
|
566
564
|
|
|
567
565
|
logger.verbose('Creating pxe...');
|
|
568
|
-
const pxeConfig =
|
|
566
|
+
const pxeConfig = getPXEConfig();
|
|
569
567
|
pxeConfig.dataDirectory = statePath;
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
568
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
569
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
573
570
|
|
|
574
571
|
return {
|
|
575
572
|
aztecNodeConfig,
|
|
576
573
|
anvil,
|
|
577
574
|
aztecNode,
|
|
578
|
-
|
|
575
|
+
wallet,
|
|
579
576
|
sequencer: aztecNode.getSequencer()!,
|
|
580
577
|
acvmConfig,
|
|
581
578
|
bbConfig,
|
|
@@ -599,20 +596,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
599
596
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
600
597
|
*/
|
|
601
598
|
export const deployAccounts =
|
|
602
|
-
(numberOfAccounts: number, logger: Logger
|
|
603
|
-
async ({
|
|
599
|
+
(numberOfAccounts: number, logger: Logger) =>
|
|
600
|
+
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
|
|
604
601
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
605
602
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
606
603
|
}
|
|
607
604
|
|
|
608
605
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
609
606
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
607
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
608
|
+
for (let i = 0; i < deployedAccounts.length; i++) {
|
|
609
|
+
const accountManager = await wallet.createSchnorrAccount(
|
|
610
|
+
deployedAccounts[i].secret,
|
|
611
|
+
deployedAccounts[i].salt,
|
|
612
|
+
deployedAccounts[i].signingKey,
|
|
613
|
+
);
|
|
614
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
615
|
+
await deployMethod
|
|
616
|
+
.send({
|
|
617
|
+
from: AztecAddress.ZERO,
|
|
618
|
+
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
619
|
+
})
|
|
620
|
+
.wait();
|
|
621
|
+
}
|
|
616
622
|
|
|
617
623
|
return { deployedAccounts };
|
|
618
624
|
};
|
|
@@ -623,35 +629,34 @@ export const deployAccounts =
|
|
|
623
629
|
* @param sender - Wallet to send the deployment tx.
|
|
624
630
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
625
631
|
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
626
|
-
* @param
|
|
632
|
+
* @param node - AztecNode used to wait for proven tx.
|
|
627
633
|
*/
|
|
628
634
|
export async function publicDeployAccounts(
|
|
629
|
-
|
|
630
|
-
accountsToDeploy:
|
|
635
|
+
wallet: Wallet,
|
|
636
|
+
accountsToDeploy: AztecAddress[],
|
|
631
637
|
waitUntilProven = false,
|
|
632
|
-
|
|
638
|
+
node?: AztecNode,
|
|
633
639
|
) {
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
).map(metadata => metadata.contractInstance);
|
|
640
|
+
const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
|
|
641
|
+
metadata => metadata.contractInstance,
|
|
642
|
+
);
|
|
638
643
|
|
|
639
644
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
640
|
-
const alreadyRegistered = (await
|
|
645
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
641
646
|
|
|
642
647
|
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
643
|
-
...(!alreadyRegistered ? [publishContractClass(
|
|
644
|
-
...instances.map(instance => publishInstance(
|
|
648
|
+
...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
|
|
649
|
+
...instances.map(instance => publishInstance(wallet, instance!)),
|
|
645
650
|
]);
|
|
646
651
|
|
|
647
|
-
const batch = new BatchCall(
|
|
652
|
+
const batch = new BatchCall(wallet, calls);
|
|
648
653
|
|
|
649
|
-
const txReceipt = await batch.send({ from:
|
|
654
|
+
const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
650
655
|
if (waitUntilProven) {
|
|
651
|
-
if (!
|
|
652
|
-
throw new Error('Need to provide
|
|
656
|
+
if (!node) {
|
|
657
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
653
658
|
} else {
|
|
654
|
-
await waitForProven(
|
|
659
|
+
await waitForProven(node, txReceipt);
|
|
655
660
|
}
|
|
656
661
|
}
|
|
657
662
|
}
|