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