@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.24de95ac
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 +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +73 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +311 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +99 -0
- package/dest/bench/utils.d.ts +10 -36
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +20 -12
- 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 +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +18 -24
- 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 +48 -69
- package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +58 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +224 -43
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +63 -0
- package/dest/e2e_fees/fees_test.d.ts +20 -9
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +98 -107
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +57 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +9 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
- 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 +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +69 -22
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +180 -129
- package/dest/e2e_p2p/shared.d.ts +41 -5
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +163 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
- package/dest/fixtures/fixtures.d.ts +5 -6
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +44 -18
- package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts +14 -13
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +73 -21
- package/dest/fixtures/snapshot_manager.d.ts +15 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -121
- package/dest/fixtures/token_utils.d.ts +6 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +23 -10
- package/dest/fixtures/utils.d.ts +76 -37
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -368
- 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/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +41 -25
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +32 -24
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +50 -29
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- 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 +13 -11
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +138 -108
- package/dest/simulators/lending_simulator.d.ts +6 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +13 -16
- package/dest/simulators/token_simulator.d.ts +5 -2
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +23 -10
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +167 -58
- package/dest/spartan/utils.d.ts +106 -303
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +434 -130
- package/package.json +61 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +402 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +111 -0
- package/src/bench/utils.ts +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +63 -105
- package/src/e2e_deploy_contract/deploy_test.ts +23 -38
- package/src/e2e_epochs/epochs_test.ts +274 -54
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +137 -136
- package/src/e2e_l1_publisher/write_json.ts +76 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +272 -166
- package/src/e2e_p2p/shared.ts +244 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +101 -145
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +3 -11
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +6 -7
- package/src/fixtures/setup_p2p_test.ts +112 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +29 -12
- package/src/fixtures/utils.ts +552 -425
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +6 -14
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +108 -79
- package/src/shared/gas_portal_test_harness.ts +58 -49
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +173 -176
- package/src/simulators/lending_simulator.ts +12 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +215 -93
- package/src/spartan/utils.ts +490 -130
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
package/dest/fixtures/utils.js
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
2
|
+
import { generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
3
|
import { createArchiver } from '@aztec/archiver';
|
|
4
4
|
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
6
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
7
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
8
|
+
import { createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
|
|
9
|
+
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
7
10
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
8
11
|
import { createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
12
|
+
import { GENESIS_ARCHIVE_ROOT, SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
13
|
+
import { FeeAssetArtifact, NULL_KEY, RollupContract, createExtendedL1Client, deployL1Contracts, deployMulticall3, getL1ContractsConfigEnvVars, isAnvilTestChain } from '@aztec/ethereum';
|
|
14
|
+
import { DelayedTxUtils, EthCheatCodes, EthCheatCodesWithState, createDelayedL1TxUtilsFromViemWallet, startAnvil } from '@aztec/ethereum/test';
|
|
15
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
12
16
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
13
17
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
18
|
import { Fr } from '@aztec/foundation/fields';
|
|
19
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
20
|
+
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
15
21
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
22
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
23
|
+
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
24
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
18
25
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
|
-
import {
|
|
26
|
+
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
27
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
28
|
import { createProverNode } from '@aztec/prover-node';
|
|
21
|
-
import {
|
|
22
|
-
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
23
|
-
import {
|
|
29
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
30
|
+
import { getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
31
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
24
32
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
25
33
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
34
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
26
35
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
27
36
|
import fs from 'fs/promises';
|
|
28
37
|
import getPort from 'get-port';
|
|
29
38
|
import { tmpdir } from 'os';
|
|
30
39
|
import * as path from 'path';
|
|
31
|
-
import { inspect } from 'util';
|
|
32
40
|
import { getContract } from 'viem';
|
|
33
|
-
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
41
|
+
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
34
42
|
import { foundry } from 'viem/chains';
|
|
35
43
|
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
36
44
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
@@ -38,8 +46,8 @@ import { getBBConfig } from './get_bb_config.js';
|
|
|
38
46
|
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
39
47
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
40
48
|
export { startAnvil };
|
|
41
|
-
const {
|
|
42
|
-
const getAztecUrl = ()=>
|
|
49
|
+
const { AZTEC_NODE_URL = '' } = process.env;
|
|
50
|
+
const getAztecUrl = ()=>AZTEC_NODE_URL;
|
|
43
51
|
let telemetry = undefined;
|
|
44
52
|
function getTelemetryClient(partialConfig = {}) {
|
|
45
53
|
if (!telemetry) {
|
|
@@ -65,53 +73,42 @@ export const getPrivateKeyFromIndex = (index)=>{
|
|
|
65
73
|
};
|
|
66
74
|
export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, chain = foundry)=>{
|
|
67
75
|
const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
|
|
68
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
69
76
|
vkTreeRoot: getVKTreeRoot(),
|
|
70
|
-
|
|
77
|
+
protocolContractsHash,
|
|
71
78
|
genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
72
|
-
genesisBlockHash: args.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
|
|
73
79
|
salt: args.salt,
|
|
74
80
|
initialValidators: args.initialValidators,
|
|
75
81
|
...getL1ContractsConfigEnvVars(),
|
|
82
|
+
realVerifier: false,
|
|
76
83
|
...args
|
|
77
84
|
});
|
|
78
85
|
return l1Data;
|
|
79
86
|
};
|
|
80
87
|
/**
|
|
81
|
-
* Sets up Private eXecution Environment (PXE).
|
|
88
|
+
* Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
|
|
82
89
|
* @param aztecNode - An instance of Aztec Node.
|
|
83
|
-
* @param opts - Partial configuration for the PXE
|
|
84
|
-
* @param firstPrivKey - The private key of the first account to be created.
|
|
90
|
+
* @param opts - Partial configuration for the PXE.
|
|
85
91
|
* @param logger - The logger to be used.
|
|
86
92
|
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
87
|
-
* @
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
...getPXEServiceConfig(),
|
|
93
|
+
* @returns A test wallet, logger and teardown function.
|
|
94
|
+
*/ export async function setupPXEAndGetWallet(aztecNode, opts = {}, logger = getLogger(), useLogSuffix = false) {
|
|
95
|
+
const PXEConfig = {
|
|
96
|
+
...getPXEConfig(),
|
|
92
97
|
...opts
|
|
93
98
|
};
|
|
99
|
+
// For tests we only want proving enabled if specifically requested
|
|
100
|
+
PXEConfig.proverEnabled = !!opts.proverEnabled;
|
|
94
101
|
// If no data directory provided, create a temp directory and clean up afterwards
|
|
95
|
-
const configuredDataDirectory =
|
|
102
|
+
const configuredDataDirectory = PXEConfig.dataDirectory;
|
|
96
103
|
if (!configuredDataDirectory) {
|
|
97
|
-
|
|
104
|
+
PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
98
105
|
}
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await fs.rm(pxeServiceConfig.dataDirectory, {
|
|
104
|
-
recursive: true,
|
|
105
|
-
force: true,
|
|
106
|
-
maxRetries: 3
|
|
107
|
-
});
|
|
108
|
-
} catch (err) {
|
|
109
|
-
logger.warn(`Failed to delete tmp PXE data directory ${pxeServiceConfig.dataDirectory}: ${err}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
106
|
+
const teardown = configuredDataDirectory ? ()=>Promise.resolve() : ()=>tryRmDir(PXEConfig.dataDirectory);
|
|
107
|
+
const wallet = await TestWallet.create(aztecNode, PXEConfig, {
|
|
108
|
+
useLogSuffix
|
|
109
|
+
});
|
|
113
110
|
return {
|
|
114
|
-
|
|
111
|
+
wallet,
|
|
115
112
|
logger,
|
|
116
113
|
teardown
|
|
117
114
|
};
|
|
@@ -129,45 +126,45 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
129
126
|
const aztecNodeUrl = getAztecUrl();
|
|
130
127
|
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
131
128
|
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
], true));
|
|
138
|
-
await waitForPXE(pxeClient, logger);
|
|
139
|
-
logger.verbose('JSON RPC client connected to PXE');
|
|
140
|
-
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
|
|
141
|
-
const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses;
|
|
142
|
-
const { walletClient, publicClient } = createL1Clients(config.l1RpcUrls, account, foundry);
|
|
129
|
+
await waitForNode(aztecNode, logger);
|
|
130
|
+
logger.verbose('JSON RPC client connected to Aztec Node');
|
|
131
|
+
logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
|
|
132
|
+
const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
133
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
143
134
|
const deployL1ContractsValues = {
|
|
144
|
-
l1ContractAddresses
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
l1ContractAddresses,
|
|
136
|
+
l1Client,
|
|
137
|
+
rollupVersion
|
|
147
138
|
};
|
|
148
|
-
const
|
|
139
|
+
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
|
|
140
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
141
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
|
|
149
142
|
const teardown = ()=>Promise.resolve();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (wallets.length < numberOfAccounts) {
|
|
155
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
|
|
143
|
+
logger.verbose('Populating wallet from already registered accounts...');
|
|
144
|
+
const initialFundedAccounts = await getInitialTestAccountsData();
|
|
145
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
146
|
+
throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
|
|
156
147
|
// Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
|
|
157
148
|
}
|
|
149
|
+
const testAccounts = await Promise.all(initialFundedAccounts.slice(0, numberOfAccounts).map(async (account)=>{
|
|
150
|
+
const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
|
|
151
|
+
return accountManager.address;
|
|
152
|
+
}));
|
|
158
153
|
return {
|
|
159
154
|
aztecNode,
|
|
155
|
+
aztecNodeAdmin: undefined,
|
|
160
156
|
sequencer: undefined,
|
|
161
157
|
proverNode: undefined,
|
|
162
|
-
pxe: pxeClient,
|
|
163
158
|
deployL1ContractsValues,
|
|
164
|
-
accounts: await pxeClient.getRegisteredAccounts(),
|
|
165
159
|
config,
|
|
166
160
|
initialFundedAccounts,
|
|
167
|
-
wallet
|
|
168
|
-
|
|
161
|
+
wallet,
|
|
162
|
+
accounts: testAccounts,
|
|
169
163
|
logger,
|
|
170
164
|
cheatCodes,
|
|
165
|
+
ethCheatCodes,
|
|
166
|
+
prefilledPublicData: undefined,
|
|
167
|
+
mockGossipSubNetwork: undefined,
|
|
171
168
|
watcher: undefined,
|
|
172
169
|
dateProvider: undefined,
|
|
173
170
|
blobSink: undefined,
|
|
@@ -180,257 +177,329 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
180
177
|
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
181
178
|
* @param opts - Options to pass to the node initialization and to the setup script.
|
|
182
179
|
* @param pxeOpts - Options to pass to the PXE initialization.
|
|
183
|
-
*/ export async function setup(numberOfAccounts = 1, opts = {
|
|
184
|
-
customForwarderContractAddress: EthAddress.ZERO
|
|
185
|
-
}, pxeOpts = {}, chain = foundry) {
|
|
186
|
-
const config = {
|
|
187
|
-
...getConfigEnvVars(),
|
|
188
|
-
...opts
|
|
189
|
-
};
|
|
190
|
-
config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
191
|
-
const logger = getLogger();
|
|
192
|
-
// Create a temp directory for any services that need it and cleanup later
|
|
193
|
-
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
194
|
-
await fs.mkdir(directoryToCleanup, {
|
|
195
|
-
recursive: true
|
|
196
|
-
});
|
|
197
|
-
if (!config.dataDirectory) {
|
|
198
|
-
config.dataDirectory = directoryToCleanup;
|
|
199
|
-
}
|
|
180
|
+
*/ export async function setup(numberOfAccounts = 1, opts = {}, pxeOpts = {}, chain = foundry) {
|
|
200
181
|
let anvil;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
182
|
+
try {
|
|
183
|
+
opts.aztecTargetCommitteeSize ??= 0;
|
|
184
|
+
opts.slasherFlavor ??= 'none';
|
|
185
|
+
const config = {
|
|
186
|
+
...getConfigEnvVars(),
|
|
187
|
+
...opts
|
|
188
|
+
};
|
|
189
|
+
// use initialValidators for the node config
|
|
190
|
+
config.validatorPrivateKeys = new SecretValue(opts.initialValidators?.map((v)=>v.privateKey) ?? []);
|
|
191
|
+
config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
192
|
+
// For tests we only want proving enabled if specifically requested
|
|
193
|
+
config.realProofs = !!opts.realProofs;
|
|
194
|
+
// Only enforce the time table if requested
|
|
195
|
+
config.enforceTimeTable = !!opts.enforceTimeTable;
|
|
196
|
+
const logger = getLogger();
|
|
197
|
+
// Create a temp directory for any services that need it and cleanup later
|
|
198
|
+
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
199
|
+
await fs.mkdir(directoryToCleanup, {
|
|
200
|
+
recursive: true
|
|
201
|
+
});
|
|
202
|
+
if (!config.dataDirectory) {
|
|
203
|
+
config.dataDirectory = directoryToCleanup;
|
|
204
204
|
}
|
|
205
|
-
if (
|
|
206
|
-
|
|
205
|
+
if (!config.l1RpcUrls?.length) {
|
|
206
|
+
if (!isAnvilTestChain(chain.id)) {
|
|
207
|
+
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
208
|
+
}
|
|
209
|
+
if (AZTEC_NODE_URL) {
|
|
210
|
+
throw new Error(`AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`);
|
|
211
|
+
}
|
|
212
|
+
const res = await startAnvil({
|
|
213
|
+
l1BlockTime: opts.ethereumSlotDuration,
|
|
214
|
+
accounts: opts.anvilAccounts,
|
|
215
|
+
port: opts.anvilPort
|
|
216
|
+
});
|
|
217
|
+
anvil = res.anvil;
|
|
218
|
+
config.l1RpcUrls = [
|
|
219
|
+
res.rpcUrl
|
|
220
|
+
];
|
|
207
221
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
222
|
+
// Enable logging metrics to a local file named after the test suite
|
|
223
|
+
if (isMetricsLoggingRequested()) {
|
|
224
|
+
const filename = path.join('log', getJobName() + '.jsonl');
|
|
225
|
+
logger.info(`Logging metrics to ${filename}`);
|
|
226
|
+
setupMetricsLogger(filename);
|
|
227
|
+
}
|
|
228
|
+
const dateProvider = new TestDateProvider();
|
|
229
|
+
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
|
|
230
|
+
if (opts.stateLoad) {
|
|
231
|
+
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
232
|
+
}
|
|
233
|
+
if (opts.l1StartTime) {
|
|
234
|
+
await ethCheatCodes.warp(opts.l1StartTime, {
|
|
235
|
+
resetBlockInterval: true
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
let publisherPrivKey = undefined;
|
|
239
|
+
let publisherHdAccount = undefined;
|
|
240
|
+
if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
|
|
241
|
+
publisherHdAccount = privateKeyToAccount(opts.l1PublisherKey.getValue());
|
|
242
|
+
} else if (config.publisherPrivateKeys && config.publisherPrivateKeys.length > 0 && config.publisherPrivateKeys[0].getValue() != NULL_KEY) {
|
|
243
|
+
publisherHdAccount = privateKeyToAccount(config.publisherPrivateKeys[0].getValue());
|
|
244
|
+
} else if (!MNEMONIC) {
|
|
245
|
+
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
246
|
+
} else {
|
|
247
|
+
publisherHdAccount = mnemonicToAccount(MNEMONIC, {
|
|
248
|
+
addressIndex: 0
|
|
249
|
+
});
|
|
250
|
+
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
251
|
+
publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
252
|
+
config.publisherPrivateKeys = [
|
|
253
|
+
new SecretValue(`0x${publisherPrivKey.toString('hex')}`)
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
257
|
+
if (AZTEC_NODE_URL) {
|
|
258
|
+
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
259
|
+
return await setupWithRemoteEnvironment(publisherHdAccount, config, logger, numberOfAccounts);
|
|
260
|
+
}
|
|
261
|
+
const initialFundedAccounts = opts.initialFundedAccounts ?? await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts);
|
|
262
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address), opts.initialAccountFeeJuice, opts.genesisPublicData);
|
|
263
|
+
const wasAutomining = await ethCheatCodes.isAutoMining();
|
|
264
|
+
const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
|
|
265
|
+
if (enableAutomine) {
|
|
266
|
+
await ethCheatCodes.setAutomine(true);
|
|
267
|
+
}
|
|
268
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount, chain);
|
|
269
|
+
await deployMulticall3(l1Client, logger);
|
|
270
|
+
const deployL1ContractsValues = opts.deployL1ContractsValues ?? await setupL1Contracts(config.l1RpcUrls, publisherHdAccount, logger, {
|
|
271
|
+
...opts,
|
|
272
|
+
genesisArchiveRoot,
|
|
273
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
274
|
+
initialValidators: opts.initialValidators
|
|
275
|
+
}, chain);
|
|
276
|
+
config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
277
|
+
config.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
278
|
+
if (opts.fundRewardDistributor) {
|
|
279
|
+
// Mints block rewards for 10000 blocks to the rewardDistributor contract
|
|
280
|
+
const rollup = new RollupContract(deployL1ContractsValues.l1Client, deployL1ContractsValues.l1ContractAddresses.rollupAddress);
|
|
281
|
+
const blockReward = await rollup.getBlockReward();
|
|
282
|
+
const mintAmount = 10_000n * blockReward;
|
|
283
|
+
const feeJuice = getContract({
|
|
284
|
+
address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
285
|
+
abi: FeeAssetArtifact.contractAbi,
|
|
286
|
+
client: deployL1ContractsValues.l1Client
|
|
287
|
+
});
|
|
288
|
+
const rewardDistributorMintTxHash = await feeJuice.write.mint([
|
|
289
|
+
deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
290
|
+
mintAmount
|
|
291
|
+
], {});
|
|
292
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
293
|
+
hash: rewardDistributorMintTxHash
|
|
294
|
+
});
|
|
295
|
+
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
296
|
+
}
|
|
297
|
+
if (enableAutomine) {
|
|
298
|
+
await ethCheatCodes.setAutomine(false);
|
|
299
|
+
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
300
|
+
dateProvider.setTime(await ethCheatCodes.timestamp() * 1000);
|
|
301
|
+
}
|
|
302
|
+
if (opts.l2StartTime) {
|
|
303
|
+
// This should only be used in synching test or when you need to have a stable
|
|
304
|
+
// timestamp for the first l2 block.
|
|
305
|
+
await ethCheatCodes.warp(opts.l2StartTime, {
|
|
306
|
+
resetBlockInterval: true
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
|
|
310
|
+
if (!opts.disableAnvilTestWatcher) {
|
|
311
|
+
await watcher.start();
|
|
312
|
+
}
|
|
313
|
+
const telemetry = getTelemetryClient(opts.telemetryConfig);
|
|
314
|
+
// Blob sink service - blobs get posted here and served from here
|
|
315
|
+
const blobSinkPort = await getPort();
|
|
316
|
+
const blobSink = await createBlobSinkServer({
|
|
317
|
+
l1ChainId: config.l1ChainId,
|
|
318
|
+
l1RpcUrls: config.l1RpcUrls,
|
|
319
|
+
l1Contracts: config.l1Contracts,
|
|
320
|
+
port: blobSinkPort,
|
|
321
|
+
dataDirectory: config.dataDirectory,
|
|
322
|
+
dataStoreMapSizeKb: config.dataStoreMapSizeKb
|
|
323
|
+
}, telemetry);
|
|
324
|
+
await blobSink.start();
|
|
325
|
+
config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
326
|
+
logger.verbose('Creating and synching an aztec node', config);
|
|
327
|
+
const acvmConfig = await getACVMConfig(logger);
|
|
328
|
+
if (acvmConfig) {
|
|
329
|
+
config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
330
|
+
config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
331
|
+
}
|
|
332
|
+
const bbConfig = await getBBConfig(logger);
|
|
333
|
+
if (bbConfig) {
|
|
334
|
+
config.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
335
|
+
config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
336
|
+
}
|
|
337
|
+
const blobSinkClient = createBlobSinkClient(config, {
|
|
338
|
+
logger: createLogger('node:blob-sink:client')
|
|
277
339
|
});
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
340
|
+
let mockGossipSubNetwork;
|
|
341
|
+
let p2pClientDeps = undefined;
|
|
342
|
+
if (opts.mockGossipSubNetwork) {
|
|
343
|
+
mockGossipSubNetwork = new MockGossipSubNetwork();
|
|
344
|
+
p2pClientDeps = {
|
|
345
|
+
p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
// Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
|
|
349
|
+
// To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
|
|
350
|
+
// For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
|
|
351
|
+
// If no accounts need deployment, we await an empty block to confirm network progression. After either path
|
|
352
|
+
// completes, we restore the original minTxsPerBlock setting. The deployment and waiting for empty block is
|
|
353
|
+
// handled by the if-else branches on line 632.
|
|
354
|
+
// For more details on why the tx would be dropped see `validate_include_by_timestamp` function in
|
|
355
|
+
// `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
|
|
356
|
+
//
|
|
357
|
+
// Note: If the following seems too convoluted or if it starts making problems, we could drop the "progressing
|
|
358
|
+
// past genesis via an account contract deployment" optimization and just call flush() on the sequencer and wait
|
|
359
|
+
// for an empty block to be mined. This would simplify it all quite a bit but the setup would be slower for tests
|
|
360
|
+
// deploying accounts.
|
|
361
|
+
const originalMinTxsPerBlock = config.minTxsPerBlock;
|
|
362
|
+
if (originalMinTxsPerBlock === undefined) {
|
|
363
|
+
throw new Error('minTxsPerBlock is undefined in e2e test setup');
|
|
364
|
+
}
|
|
365
|
+
config.minTxsPerBlock = numberOfAccounts === 0 ? 0 : 1;
|
|
366
|
+
config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
|
|
367
|
+
config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
|
|
368
|
+
if (!config.disableValidator) {
|
|
369
|
+
if ((config.validatorPrivateKeys?.getValue().length ?? 0) === 0) {
|
|
370
|
+
config.validatorPrivateKeys = new SecretValue([
|
|
371
|
+
generatePrivateKey()
|
|
372
|
+
]);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
const aztecNode = await AztecNodeService.createAndSync(config, {
|
|
376
|
+
dateProvider,
|
|
377
|
+
blobSinkClient,
|
|
378
|
+
telemetry,
|
|
379
|
+
p2pClientDeps,
|
|
380
|
+
logger: createLogger('node:MAIN-aztec-node')
|
|
381
|
+
}, {
|
|
382
|
+
prefilledPublicData
|
|
284
383
|
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const bbConfig = await getBBConfig(logger);
|
|
302
|
-
if (bbConfig) {
|
|
303
|
-
config.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
304
|
-
config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
305
|
-
}
|
|
306
|
-
config.l1PublishRetryIntervalMS = 100;
|
|
307
|
-
const telemetry = getTelemetryClient(opts.telemetryConfig);
|
|
308
|
-
const blobSinkClient = createBlobSinkClient(config);
|
|
309
|
-
const aztecNode = await AztecNodeService.createAndSync(config, {
|
|
310
|
-
dateProvider,
|
|
311
|
-
blobSinkClient
|
|
312
|
-
}, {
|
|
313
|
-
prefilledPublicData
|
|
314
|
-
});
|
|
315
|
-
const sequencer = aztecNode.getSequencer();
|
|
316
|
-
if (sequencer) {
|
|
317
|
-
const publisher = sequencer.sequencer.publisher;
|
|
318
|
-
publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration);
|
|
319
|
-
}
|
|
320
|
-
let proverNode = undefined;
|
|
321
|
-
if (opts.startProverNode) {
|
|
322
|
-
logger.verbose('Creating and syncing a simulated prover node...');
|
|
323
|
-
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
324
|
-
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
|
|
325
|
-
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, config, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')));
|
|
326
|
-
}
|
|
327
|
-
logger.verbose('Creating a pxe...');
|
|
328
|
-
const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode, pxeOpts, logger);
|
|
329
|
-
if (!config.skipProtocolContracts) {
|
|
330
|
-
logger.verbose('Setting up Fee Juice...');
|
|
331
|
-
await setupCanonicalFeeJuice(pxe);
|
|
332
|
-
}
|
|
333
|
-
const accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
|
|
334
|
-
const wallets = await Promise.all(accountManagers.map((account)=>account.getWallet()));
|
|
335
|
-
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
336
|
-
// TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
|
|
337
|
-
throw new Error(`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`);
|
|
338
|
-
}
|
|
339
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe);
|
|
340
|
-
const teardown = async ()=>{
|
|
341
|
-
await pxeTeardown();
|
|
342
|
-
if (aztecNode instanceof AztecNodeService) {
|
|
343
|
-
await aztecNode?.stop();
|
|
384
|
+
const sequencerClient = aztecNode.getSequencer();
|
|
385
|
+
if (sequencerClient) {
|
|
386
|
+
const publisher = sequencerClient.sequencer.publisher;
|
|
387
|
+
publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
|
|
388
|
+
}
|
|
389
|
+
let proverNode = undefined;
|
|
390
|
+
if (opts.startProverNode) {
|
|
391
|
+
logger.verbose('Creating and syncing a simulated prover node...');
|
|
392
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
393
|
+
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
|
|
394
|
+
const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
395
|
+
const proverNodeConfig = {
|
|
396
|
+
...config.proverNodeConfig,
|
|
397
|
+
dataDirectory: proverNodeDataDirectory
|
|
398
|
+
};
|
|
399
|
+
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, config, proverNodeConfig, aztecNode, prefilledPublicData);
|
|
344
400
|
}
|
|
345
|
-
|
|
346
|
-
|
|
401
|
+
logger.verbose('Creating a pxe...');
|
|
402
|
+
const { wallet, teardown: pxeTeardown } = await setupPXEAndGetWallet(aztecNode, pxeOpts, logger);
|
|
403
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, dateProvider);
|
|
404
|
+
if (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0 || opts.initialValidators && opts.initialValidators.length > 0) {
|
|
405
|
+
// We need to advance such that the committee is set up.
|
|
406
|
+
await cheatCodes.rollup.advanceToEpoch(await cheatCodes.rollup.getEpoch() + BigInt(config.lagInEpochs + 1));
|
|
407
|
+
await cheatCodes.rollup.setupEpoch();
|
|
408
|
+
await cheatCodes.rollup.debugRollup();
|
|
347
409
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
410
|
+
let accounts = [];
|
|
411
|
+
// Below we continue with what we described in the long comment on line 571.
|
|
412
|
+
if (numberOfAccounts === 0) {
|
|
413
|
+
logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
|
|
414
|
+
while(await aztecNode.getBlockNumber() === 0){
|
|
415
|
+
await sleep(2000);
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
logger.info(`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`);
|
|
419
|
+
const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
420
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, aztecNode, accountsData);
|
|
421
|
+
accounts = accountManagers.map((accountManager)=>accountManager.address);
|
|
352
422
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
423
|
+
// Now we restore the original minTxsPerBlock setting.
|
|
424
|
+
sequencerClient.getSequencer().updateConfig({
|
|
425
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
426
|
+
});
|
|
427
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
428
|
+
// TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
|
|
429
|
+
throw new Error(`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`);
|
|
357
430
|
}
|
|
358
|
-
|
|
359
|
-
await watcher.stop();
|
|
360
|
-
await blobSink?.stop();
|
|
361
|
-
if (directoryToCleanup) {
|
|
431
|
+
const teardown = async ()=>{
|
|
362
432
|
try {
|
|
363
|
-
|
|
364
|
-
await
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
433
|
+
await pxeTeardown();
|
|
434
|
+
await tryStop(aztecNode, logger);
|
|
435
|
+
await tryStop(proverNode, logger);
|
|
436
|
+
if (acvmConfig?.cleanup) {
|
|
437
|
+
await acvmConfig.cleanup();
|
|
438
|
+
}
|
|
439
|
+
if (bbConfig?.cleanup) {
|
|
440
|
+
await bbConfig.cleanup();
|
|
441
|
+
}
|
|
442
|
+
await tryStop(watcher, logger);
|
|
443
|
+
await tryStop(anvil, logger);
|
|
444
|
+
await tryStop(blobSink, logger);
|
|
445
|
+
await tryRmDir(directoryToCleanup, logger);
|
|
369
446
|
} catch (err) {
|
|
370
|
-
logger.
|
|
447
|
+
logger.error(`Error during e2e test teardown`, err);
|
|
371
448
|
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
449
|
+
};
|
|
450
|
+
return {
|
|
451
|
+
aztecNode,
|
|
452
|
+
aztecNodeAdmin: aztecNode,
|
|
453
|
+
blobSink,
|
|
454
|
+
cheatCodes,
|
|
455
|
+
ethCheatCodes,
|
|
456
|
+
config,
|
|
457
|
+
dateProvider,
|
|
458
|
+
deployL1ContractsValues,
|
|
459
|
+
initialFundedAccounts,
|
|
460
|
+
logger,
|
|
461
|
+
mockGossipSubNetwork,
|
|
462
|
+
prefilledPublicData,
|
|
463
|
+
proverNode,
|
|
464
|
+
sequencer: sequencerClient,
|
|
465
|
+
teardown,
|
|
466
|
+
telemetryClient: telemetry,
|
|
467
|
+
wallet,
|
|
468
|
+
accounts,
|
|
469
|
+
watcher
|
|
470
|
+
};
|
|
471
|
+
} catch (err) {
|
|
472
|
+
// TODO: Just hoisted anvil for now to ensure cleanup. Prob need to hoist the rest.
|
|
473
|
+
await anvil?.stop();
|
|
474
|
+
throw err;
|
|
475
|
+
}
|
|
392
476
|
}
|
|
393
477
|
/**
|
|
394
478
|
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
395
479
|
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
396
480
|
* @param sender - Wallet to send the deployment tx.
|
|
397
481
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
398
|
-
*/
|
|
399
|
-
export async function ensureAccountsPubliclyDeployed(sender, accountsToDeploy) {
|
|
482
|
+
*/ export async function ensureAccountContractsPublished(wallet, accountsToDeploy) {
|
|
400
483
|
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
401
484
|
// the sandbox and the test accounts exist
|
|
402
|
-
const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (
|
|
403
|
-
const address = account.getAddress();
|
|
485
|
+
const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (address)=>{
|
|
404
486
|
return {
|
|
405
487
|
address,
|
|
406
|
-
deployed: (await
|
|
488
|
+
deployed: (await wallet.getContractMetadata(address)).isContractPublished
|
|
407
489
|
};
|
|
408
490
|
}));
|
|
409
|
-
const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>
|
|
491
|
+
const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>wallet.getContractMetadata(address)))).map((contractMetadata)=>contractMetadata.contractInstance);
|
|
410
492
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
411
|
-
if (!(await
|
|
412
|
-
await (await
|
|
493
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
494
|
+
await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({
|
|
495
|
+
from: accountsToDeploy[0]
|
|
496
|
+
}).wait();
|
|
413
497
|
}
|
|
414
|
-
const requests = await Promise.all(instances.map(async (instance)=>
|
|
415
|
-
const batch = new BatchCall(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
// docs:end:public_deploy_accounts
|
|
421
|
-
/**
|
|
422
|
-
* Sets the timestamp of the next block.
|
|
423
|
-
* @param rpcUrl - rpc url of the blockchain instance to connect to
|
|
424
|
-
* @param timestamp - the timestamp for the next block
|
|
425
|
-
*/ export async function setNextBlockTimestamp(rpcUrl, timestamp) {
|
|
426
|
-
const params = `[${timestamp}]`;
|
|
427
|
-
await fetch(rpcUrl, {
|
|
428
|
-
body: `{"jsonrpc":"2.0", "method": "evm_setNextBlockTimestamp", "params": ${params}, "id": 1}`,
|
|
429
|
-
method: 'POST',
|
|
430
|
-
headers: {
|
|
431
|
-
'Content-Type': 'application/json'
|
|
432
|
-
}
|
|
433
|
-
});
|
|
498
|
+
const requests = await Promise.all(instances.map(async (instance)=>await publishInstance(wallet, instance)));
|
|
499
|
+
const batch = new BatchCall(wallet, requests);
|
|
500
|
+
await batch.send({
|
|
501
|
+
from: accountsToDeploy[0]
|
|
502
|
+
}).wait();
|
|
434
503
|
}
|
|
435
504
|
/** Returns the job name for the current test. */ function getJobName() {
|
|
436
505
|
return process.env.JOB_NAME ?? expect.getState().currentTestName?.split(' ')[0].replaceAll('/', '_') ?? 'unknown';
|
|
@@ -446,10 +515,12 @@ export async function ensureAccountsPubliclyDeployed(sender, accountsToDeploy) {
|
|
|
446
515
|
}
|
|
447
516
|
return createLogger('e2e:' + describeBlockName);
|
|
448
517
|
}
|
|
449
|
-
export function getBalancesFn(symbol, method, logger) {
|
|
518
|
+
export function getBalancesFn(symbol, method, from, logger) {
|
|
450
519
|
const balances = async (...addressLikes)=>{
|
|
451
520
|
const addresses = addressLikes.map((addressLike)=>'address' in addressLike ? addressLike.address : addressLike);
|
|
452
|
-
const b = await Promise.all(addresses.map((address)=>method(address).simulate(
|
|
521
|
+
const b = await Promise.all(addresses.map((address)=>method(address).simulate({
|
|
522
|
+
from
|
|
523
|
+
})));
|
|
453
524
|
const debugString = `${symbol} balances: ${addresses.map((address, i)=>`${address}: ${b[i]}`).join(', ')}`;
|
|
454
525
|
logger.verbose(debugString);
|
|
455
526
|
return b;
|
|
@@ -468,86 +539,111 @@ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiff
|
|
|
468
539
|
expect(diffs).toEqual(expectedDiffs);
|
|
469
540
|
}
|
|
470
541
|
/**
|
|
471
|
-
*
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
542
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
543
|
+
* but by conventions its address is computed with a salt of 0.
|
|
544
|
+
* @returns The address of the sponsored FPC contract
|
|
545
|
+
*/ export function getSponsoredFPCInstance() {
|
|
546
|
+
return Promise.resolve(getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
547
|
+
salt: new Fr(SPONSORED_FPC_SALT)
|
|
548
|
+
}));
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
552
|
+
* but by conventions its address is computed with a salt of 0.
|
|
553
|
+
* @returns The address of the sponsored FPC contract
|
|
554
|
+
*/ export async function getSponsoredFPCAddress() {
|
|
555
|
+
const sponsoredFPCInstance = await getSponsoredFPCInstance();
|
|
556
|
+
return sponsoredFPCInstance.address;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Deploy a sponsored FPC contract to a running instance.
|
|
560
|
+
*/ export async function setupSponsoredFPC(wallet) {
|
|
561
|
+
const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
562
|
+
salt: new Fr(SPONSORED_FPC_SALT)
|
|
563
|
+
});
|
|
564
|
+
await wallet.registerContract({
|
|
565
|
+
instance,
|
|
566
|
+
artifact: SponsoredFPCContract.artifact
|
|
567
|
+
});
|
|
568
|
+
getLogger().info(`SponsoredFPC: ${instance.address}`);
|
|
569
|
+
return instance;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Registers the SponsoredFPC in this PXE instance
|
|
573
|
+
* @param wallet - The wallet
|
|
574
|
+
*/ export async function registerSponsoredFPC(wallet) {
|
|
575
|
+
await wallet.registerContract({
|
|
576
|
+
instance: await getSponsoredFPCInstance(),
|
|
577
|
+
artifact: SponsoredFPCContract.artifact
|
|
578
|
+
});
|
|
491
579
|
}
|
|
492
580
|
export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, intervalSec = 1) {
|
|
493
581
|
targetBlock ??= await node.getBlockNumber();
|
|
494
582
|
await retryUntil(async ()=>await node.getProvenBlockNumber() >= targetBlock, 'proven chain status', timeoutSec, intervalSec);
|
|
495
583
|
}
|
|
496
|
-
export
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
584
|
+
export function createAndSyncProverNode(proverNodePrivateKey, aztecNodeConfig, proverNodeConfig, aztecNode, prefilledPublicData = [], proverNodeDeps = {}) {
|
|
585
|
+
return withLogNameSuffix('prover-node', async ()=>{
|
|
586
|
+
// Disable stopping the aztec node as the prover coordination test will kill it otherwise
|
|
587
|
+
// This is only required when stopping the prover node for testing
|
|
588
|
+
const aztecNodeTxProvider = aztecNode && {
|
|
589
|
+
getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
|
|
590
|
+
getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
|
|
591
|
+
stop: ()=>Promise.resolve()
|
|
592
|
+
};
|
|
593
|
+
const blobSinkClient = createBlobSinkClient(aztecNodeConfig);
|
|
594
|
+
// Creating temp store and archiver for simulated prover node
|
|
595
|
+
const archiverConfig = {
|
|
596
|
+
...aztecNodeConfig,
|
|
597
|
+
dataDirectory: proverNodeConfig.dataDirectory
|
|
598
|
+
};
|
|
599
|
+
const archiver = await createArchiver(archiverConfig, {
|
|
600
|
+
blobSinkClient
|
|
601
|
+
}, {
|
|
602
|
+
blockUntilSync: true
|
|
603
|
+
});
|
|
604
|
+
// Prover node config is for simulated proofs
|
|
605
|
+
const proverConfig = {
|
|
606
|
+
...aztecNodeConfig,
|
|
607
|
+
txCollectionNodeRpcUrls: [],
|
|
608
|
+
realProofs: false,
|
|
609
|
+
proverAgentCount: 2,
|
|
610
|
+
publisherPrivateKeys: [
|
|
611
|
+
new SecretValue(proverNodePrivateKey)
|
|
612
|
+
],
|
|
613
|
+
proverNodeMaxPendingJobs: 10,
|
|
614
|
+
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
615
|
+
proverNodePollingIntervalMs: 200,
|
|
616
|
+
txGatheringIntervalMs: 1000,
|
|
617
|
+
txGatheringBatchSize: 10,
|
|
618
|
+
txGatheringMaxParallelRequestsPerNode: 10,
|
|
619
|
+
txGatheringTimeoutMs: 24_000,
|
|
620
|
+
proverNodeFailedEpochStore: undefined,
|
|
621
|
+
proverId: EthAddress.fromNumber(1),
|
|
622
|
+
proverNodeEpochProvingDelayMs: undefined,
|
|
623
|
+
...proverNodeConfig
|
|
624
|
+
};
|
|
625
|
+
const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node', proverNodeDeps.dateProvider);
|
|
626
|
+
const proverNode = await createProverNode(proverConfig, {
|
|
627
|
+
...proverNodeDeps,
|
|
628
|
+
aztecNodeTxProvider,
|
|
629
|
+
archiver: archiver,
|
|
630
|
+
l1TxUtils
|
|
631
|
+
}, {
|
|
632
|
+
prefilledPublicData
|
|
633
|
+
});
|
|
634
|
+
getLogger().info(`Created and synced prover node`, {
|
|
635
|
+
publisherAddress: l1TxUtils.client.account.address
|
|
636
|
+
});
|
|
637
|
+
if (!proverNodeConfig.dontStart) {
|
|
638
|
+
await proverNode.start();
|
|
639
|
+
}
|
|
640
|
+
return proverNode;
|
|
538
641
|
});
|
|
539
|
-
proverNode.start();
|
|
540
|
-
return proverNode;
|
|
541
642
|
}
|
|
542
|
-
function createDelayedL1TxUtils(aztecNodeConfig, privateKey, logName) {
|
|
543
|
-
const
|
|
643
|
+
function createDelayedL1TxUtils(aztecNodeConfig, privateKey, logName, dateProvider) {
|
|
644
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
544
645
|
const log = createLogger(logName);
|
|
545
|
-
const l1TxUtils =
|
|
646
|
+
const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
|
|
546
647
|
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
547
648
|
return l1TxUtils;
|
|
548
649
|
}
|
|
549
|
-
export async function createForwarderContract(aztecNodeConfig, privateKey, rollupAddress) {
|
|
550
|
-
const { walletClient, publicClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
551
|
-
const forwarderContract = await ForwarderContract.create(walletClient.account.address, walletClient, publicClient, createLogger('forwarder'), rollupAddress);
|
|
552
|
-
return forwarderContract;
|
|
553
|
-
}
|