@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.0b941701
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 +62 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +281 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +321 -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 +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +41 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
- 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 +114 -102
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
- 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 +104 -104
- package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +26 -27
- 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 +236 -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 +61 -0
- package/dest/e2e_fees/fees_test.d.ts +38 -23
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +162 -183
- 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 +62 -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 +15 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
- 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 +281 -27
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +237 -175
- package/dest/e2e_p2p/shared.d.ts +44 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +165 -27
- package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +96 -74
- package/dest/fixtures/e2e_prover_test.d.ts +55 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +278 -0
- 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.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +690 -0
- 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/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +31 -12
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- 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/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +44 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +105 -51
- package/dest/shared/gas_portal_test_harness.d.ts +33 -25
- 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 +2 -2
- package/dest/shared/index.d.ts.map +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 +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +176 -126
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +17 -18
- 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 +27 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +233 -62
- package/dest/spartan/tx_metrics.d.ts +54 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +272 -0
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +98 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +257 -0
- package/dest/spartan/utils/nodes.d.ts +31 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +290 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- package/package.json +66 -58
- package/src/bench/client_flows/benchmark.ts +363 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +384 -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 +41 -85
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
- package/src/e2e_deploy_contract/deploy_test.ts +40 -48
- package/src/e2e_epochs/epochs_test.ts +315 -76
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +220 -258
- package/src/e2e_l1_publisher/write_json.ts +82 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +341 -234
- package/src/e2e_p2p/shared.ts +253 -40
- package/src/e2e_token_contract/token_contract_test.ts +115 -126
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +336 -0
- 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.ts +1017 -0
- package/src/fixtures/setup_p2p_test.ts +127 -39
- package/src/fixtures/token_utils.ts +33 -15
- package/src/fixtures/utils.ts +27 -820
- 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 → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +103 -91
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +18 -20
- package/src/shared/uniswap_l1_l2.ts +197 -221
- package/src/simulators/lending_simulator.ts +16 -17
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +308 -95
- package/src/spartan/tx_metrics.ts +250 -0
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +62 -0
- package/src/spartan/utils/k8s.ts +375 -0
- package/src/spartan/utils/nodes.ts +323 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -582
- 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/e2e_prover/e2e_prover_test.js +0 -291
- 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/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.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/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- 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,553 +1,5 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { deployFundedSchnorrAccounts, generateSchnorrAccounts, getDeployedTestAccounts, getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
-
import { createArchiver } from '@aztec/archiver';
|
|
4
|
-
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
-
import { AnvilTestWatcher, BatchCall, CheatCodes, FeeJuicePaymentMethod, SignerlessWallet, createAztecNodeClient, createLogger, createPXEClient, deployL1Contracts, makeFetch, waitForPXE } from '@aztec/aztec.js';
|
|
6
|
-
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
|
|
7
|
-
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
8
|
-
import { createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
9
|
-
import { FEE_JUICE_INITIAL_MINT, GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
|
|
10
|
-
import { ForwarderContract, NULL_KEY, createL1Clients, getL1ContractsConfigEnvVars, isAnvilTestChain, l1Artifacts } from '@aztec/ethereum';
|
|
11
|
-
import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
12
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
13
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
15
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
16
|
-
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
17
|
-
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
18
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
|
-
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
20
|
-
import { createProverNode } from '@aztec/prover-node';
|
|
21
|
-
import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
22
|
-
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
23
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
24
|
-
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
25
|
-
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
26
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
27
|
-
import fs from 'fs/promises';
|
|
28
|
-
import getPort from 'get-port';
|
|
29
|
-
import { tmpdir } from 'os';
|
|
30
|
-
import * as path from 'path';
|
|
31
|
-
import { inspect } from 'util';
|
|
32
|
-
import { getContract } from 'viem';
|
|
33
|
-
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
34
|
-
import { foundry } from 'viem/chains';
|
|
35
|
-
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
36
|
-
import { getACVMConfig } from './get_acvm_config.js';
|
|
37
|
-
import { getBBConfig } from './get_bb_config.js';
|
|
38
|
-
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
39
|
-
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
40
|
-
export { startAnvil };
|
|
41
|
-
const { PXE_URL = '' } = process.env;
|
|
42
|
-
const getAztecUrl = ()=>PXE_URL;
|
|
43
|
-
let telemetry = undefined;
|
|
44
|
-
function getTelemetryClient(partialConfig = {}) {
|
|
45
|
-
if (!telemetry) {
|
|
46
|
-
const config = {
|
|
47
|
-
...getTelemetryConfig(),
|
|
48
|
-
...partialConfig
|
|
49
|
-
};
|
|
50
|
-
telemetry = config.benchmark ? new BenchmarkTelemetryClient() : initTelemetryClient(config);
|
|
51
|
-
}
|
|
52
|
-
return telemetry;
|
|
53
|
-
}
|
|
54
|
-
if (typeof afterAll === 'function') {
|
|
55
|
-
afterAll(async ()=>{
|
|
56
|
-
await telemetry?.stop();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
export const getPrivateKeyFromIndex = (index)=>{
|
|
60
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
61
|
-
addressIndex: index
|
|
62
|
-
});
|
|
63
|
-
const privKeyRaw = hdAccount.getHdKey().privateKey;
|
|
64
|
-
return privKeyRaw === null ? null : Buffer.from(privKeyRaw);
|
|
65
|
-
};
|
|
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
|
-
/**
|
|
81
|
-
* Sets up Private eXecution Environment (PXE).
|
|
82
|
-
* @param aztecNode - An instance of Aztec Node.
|
|
83
|
-
* @param opts - Partial configuration for the PXE service.
|
|
84
|
-
* @param firstPrivKey - The private key of the first account to be created.
|
|
85
|
-
* @param logger - The logger to be used.
|
|
86
|
-
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
87
|
-
* @param proofCreator - An optional proof creator to use
|
|
88
|
-
* @returns Private eXecution Environment (PXE), accounts, wallets and logger.
|
|
89
|
-
*/ export async function setupPXEService(aztecNode, opts = {}, logger = getLogger(), useLogSuffix = false, proofCreator) {
|
|
90
|
-
const pxeServiceConfig = {
|
|
91
|
-
...getPXEServiceConfig(),
|
|
92
|
-
...opts
|
|
93
|
-
};
|
|
94
|
-
// If no data directory provided, create a temp directory and clean up afterwards
|
|
95
|
-
const configuredDataDirectory = pxeServiceConfig.dataDirectory;
|
|
96
|
-
if (!configuredDataDirectory) {
|
|
97
|
-
pxeServiceConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
98
|
-
}
|
|
99
|
-
const pxe = await createPXEService(aztecNode, pxeServiceConfig, useLogSuffix, proofCreator);
|
|
100
|
-
const teardown = async ()=>{
|
|
101
|
-
if (!configuredDataDirectory) {
|
|
102
|
-
try {
|
|
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
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
pxe,
|
|
115
|
-
logger,
|
|
116
|
-
teardown
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Function to setup the test against a remote deployment. It is assumed that L1 contract are already deployed
|
|
121
|
-
* @param account - The account for use in create viem wallets.
|
|
122
|
-
* @param config - The aztec Node Configuration
|
|
123
|
-
* @param logger - The logger to be used
|
|
124
|
-
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
125
|
-
* (will create extra accounts if the environment doesn't already have enough accounts)
|
|
126
|
-
* @returns Private eXecution Environment (PXE) client, viem wallets, contract addresses etc.
|
|
127
|
-
*/ async function setupWithRemoteEnvironment(account, config, logger, numberOfAccounts) {
|
|
128
|
-
// we are setting up against a remote environment, l1 contracts are already deployed
|
|
129
|
-
const aztecNodeUrl = getAztecUrl();
|
|
130
|
-
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
131
|
-
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
132
|
-
logger.verbose(`Creating PXE client to remote host ${PXE_URL}`);
|
|
133
|
-
const pxeClient = createPXEClient(PXE_URL, {}, makeFetch([
|
|
134
|
-
1,
|
|
135
|
-
2,
|
|
136
|
-
3
|
|
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);
|
|
143
|
-
const deployL1ContractsValues = {
|
|
144
|
-
l1ContractAddresses: l1Contracts,
|
|
145
|
-
walletClient,
|
|
146
|
-
publicClient
|
|
147
|
-
};
|
|
148
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient);
|
|
149
|
-
const teardown = ()=>Promise.resolve();
|
|
150
|
-
await setupCanonicalFeeJuice(pxeClient);
|
|
151
|
-
logger.verbose('Constructing available wallets from already registered accounts...');
|
|
152
|
-
const initialFundedAccounts = await getDeployedTestAccounts(pxeClient);
|
|
153
|
-
const wallets = await getDeployedTestAccountsWallets(pxeClient);
|
|
154
|
-
if (wallets.length < numberOfAccounts) {
|
|
155
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
|
|
156
|
-
// Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
aztecNode,
|
|
160
|
-
sequencer: undefined,
|
|
161
|
-
proverNode: undefined,
|
|
162
|
-
pxe: pxeClient,
|
|
163
|
-
deployL1ContractsValues,
|
|
164
|
-
accounts: await pxeClient.getRegisteredAccounts(),
|
|
165
|
-
config,
|
|
166
|
-
initialFundedAccounts,
|
|
167
|
-
wallet: wallets[0],
|
|
168
|
-
wallets: wallets.slice(0, numberOfAccounts),
|
|
169
|
-
logger,
|
|
170
|
-
cheatCodes,
|
|
171
|
-
watcher: undefined,
|
|
172
|
-
dateProvider: undefined,
|
|
173
|
-
blobSink: undefined,
|
|
174
|
-
telemetryClient: undefined,
|
|
175
|
-
teardown
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Sets up the environment for the end-to-end tests.
|
|
180
|
-
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
181
|
-
* @param opts - Options to pass to the node initialization and to the setup script.
|
|
182
|
-
* @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
|
-
}
|
|
200
|
-
let anvil;
|
|
201
|
-
if (!config.l1RpcUrls?.length) {
|
|
202
|
-
if (!isAnvilTestChain(chain.id)) {
|
|
203
|
-
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
204
|
-
}
|
|
205
|
-
if (PXE_URL) {
|
|
206
|
-
throw new Error(`PXE_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`);
|
|
207
|
-
}
|
|
208
|
-
const res = await startAnvil({
|
|
209
|
-
l1BlockTime: opts.ethereumSlotDuration
|
|
210
|
-
});
|
|
211
|
-
anvil = res.anvil;
|
|
212
|
-
config.l1RpcUrls = [
|
|
213
|
-
res.rpcUrl
|
|
214
|
-
];
|
|
215
|
-
}
|
|
216
|
-
// Enable logging metrics to a local file named after the test suite
|
|
217
|
-
if (isMetricsLoggingRequested()) {
|
|
218
|
-
const filename = path.join('log', getJobName() + '.jsonl');
|
|
219
|
-
logger.info(`Logging metrics to ${filename}`);
|
|
220
|
-
setupMetricsLogger(filename);
|
|
221
|
-
}
|
|
222
|
-
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
|
|
223
|
-
if (opts.stateLoad) {
|
|
224
|
-
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
225
|
-
}
|
|
226
|
-
if (opts.l1StartTime) {
|
|
227
|
-
await ethCheatCodes.warp(opts.l1StartTime);
|
|
228
|
-
}
|
|
229
|
-
let publisherPrivKey = undefined;
|
|
230
|
-
let publisherHdAccount = undefined;
|
|
231
|
-
if (config.publisherPrivateKey && config.publisherPrivateKey != NULL_KEY) {
|
|
232
|
-
publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey);
|
|
233
|
-
} else if (!MNEMONIC) {
|
|
234
|
-
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
235
|
-
} else {
|
|
236
|
-
publisherHdAccount = mnemonicToAccount(MNEMONIC, {
|
|
237
|
-
addressIndex: 0
|
|
238
|
-
});
|
|
239
|
-
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
240
|
-
publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
241
|
-
config.publisherPrivateKey = `0x${publisherPrivKey.toString('hex')}`;
|
|
242
|
-
}
|
|
243
|
-
// Made as separate values such that keys can change, but for test they will be the same.
|
|
244
|
-
config.validatorPrivateKey = config.publisherPrivateKey;
|
|
245
|
-
if (PXE_URL) {
|
|
246
|
-
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
247
|
-
return await setupWithRemoteEnvironment(publisherHdAccount, config, logger, numberOfAccounts);
|
|
248
|
-
}
|
|
249
|
-
// Blob sink service - blobs get posted here and served from here
|
|
250
|
-
const blobSinkPort = await getPort();
|
|
251
|
-
const blobSink = await createBlobSinkServer({
|
|
252
|
-
port: blobSinkPort
|
|
253
|
-
});
|
|
254
|
-
await blobSink.start();
|
|
255
|
-
config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
256
|
-
const initialFundedAccounts = opts.initialFundedAccounts ?? await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts);
|
|
257
|
-
const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address), opts.initialAccountFeeJuice, opts.genesisPublicData);
|
|
258
|
-
const deployL1ContractsValues = opts.deployL1ContractsValues ?? await setupL1Contracts(config.l1RpcUrls, publisherHdAccount, logger, {
|
|
259
|
-
...opts,
|
|
260
|
-
genesisArchiveRoot,
|
|
261
|
-
genesisBlockHash
|
|
262
|
-
}, chain);
|
|
263
|
-
config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
264
|
-
if (opts.fundRewardDistributor) {
|
|
265
|
-
// Mints block rewards for 10000 blocks to the rewardDistributor contract
|
|
266
|
-
const rewardDistributor = getContract({
|
|
267
|
-
address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
268
|
-
abi: l1Artifacts.rewardDistributor.contractAbi,
|
|
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
|
|
277
|
-
});
|
|
278
|
-
const rewardDistributorMintTxHash = await feeJuice.write.mint([
|
|
279
|
-
rewardDistributor.address,
|
|
280
|
-
mintAmount
|
|
281
|
-
], {});
|
|
282
|
-
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
|
|
283
|
-
hash: rewardDistributorMintTxHash
|
|
284
|
-
});
|
|
285
|
-
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
286
|
-
}
|
|
287
|
-
if (opts.l2StartTime) {
|
|
288
|
-
// This should only be used in synching test or when you need to have a stable
|
|
289
|
-
// timestamp for the first l2 block.
|
|
290
|
-
await ethCheatCodes.warp(opts.l2StartTime);
|
|
291
|
-
}
|
|
292
|
-
const dateProvider = new TestDateProvider();
|
|
293
|
-
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.publicClient, dateProvider);
|
|
294
|
-
await watcher.start();
|
|
295
|
-
logger.verbose('Creating and synching an aztec node...');
|
|
296
|
-
const acvmConfig = await getACVMConfig(logger);
|
|
297
|
-
if (acvmConfig) {
|
|
298
|
-
config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
299
|
-
config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
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();
|
|
344
|
-
}
|
|
345
|
-
if (proverNode) {
|
|
346
|
-
await proverNode.stop();
|
|
347
|
-
}
|
|
348
|
-
if (acvmConfig?.cleanup) {
|
|
349
|
-
// remove the temp directory created for the acvm
|
|
350
|
-
logger.verbose(`Cleaning up ACVM state`);
|
|
351
|
-
await acvmConfig.cleanup();
|
|
352
|
-
}
|
|
353
|
-
if (bbConfig?.cleanup) {
|
|
354
|
-
// remove the temp directory created for the acvm
|
|
355
|
-
logger.verbose(`Cleaning up BB state`);
|
|
356
|
-
await bbConfig.cleanup();
|
|
357
|
-
}
|
|
358
|
-
await anvil?.stop().catch((err)=>getLogger().error(err));
|
|
359
|
-
await watcher.stop();
|
|
360
|
-
await blobSink?.stop();
|
|
361
|
-
if (directoryToCleanup) {
|
|
362
|
-
try {
|
|
363
|
-
logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
|
|
364
|
-
await fs.rm(directoryToCleanup, {
|
|
365
|
-
recursive: true,
|
|
366
|
-
force: true,
|
|
367
|
-
maxRetries: 3
|
|
368
|
-
});
|
|
369
|
-
} catch (err) {
|
|
370
|
-
logger.warn(`Failed to delete data directory at ${directoryToCleanup}: ${err}`);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
return {
|
|
375
|
-
aztecNode,
|
|
376
|
-
blobSink,
|
|
377
|
-
cheatCodes,
|
|
378
|
-
config,
|
|
379
|
-
dateProvider,
|
|
380
|
-
deployL1ContractsValues,
|
|
381
|
-
initialFundedAccounts,
|
|
382
|
-
logger,
|
|
383
|
-
proverNode,
|
|
384
|
-
pxe,
|
|
385
|
-
sequencer,
|
|
386
|
-
teardown,
|
|
387
|
-
telemetryClient: telemetry,
|
|
388
|
-
wallet: wallets[0],
|
|
389
|
-
wallets,
|
|
390
|
-
watcher
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
1
|
/**
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
*/ // docs:start:public_deploy_accounts
|
|
399
|
-
export async function ensureAccountsPubliclyDeployed(sender, accountsToDeploy) {
|
|
400
|
-
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
401
|
-
// the sandbox and the test accounts exist
|
|
402
|
-
const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (account)=>{
|
|
403
|
-
const address = account.getAddress();
|
|
404
|
-
return {
|
|
405
|
-
address,
|
|
406
|
-
deployed: (await sender.getContractMetadata(address)).isContractPubliclyDeployed
|
|
407
|
-
};
|
|
408
|
-
}));
|
|
409
|
-
const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>sender.getContractMetadata(address)))).map((contractMetadata)=>contractMetadata.contractInstance);
|
|
410
|
-
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
411
|
-
if (!(await sender.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
412
|
-
await (await registerContractClass(sender, SchnorrAccountContractArtifact)).send().wait();
|
|
413
|
-
}
|
|
414
|
-
const requests = await Promise.all(instances.map(async (instance)=>(await deployInstance(sender, instance)).request()));
|
|
415
|
-
const batch = new BatchCall(sender, [
|
|
416
|
-
...requests
|
|
417
|
-
]);
|
|
418
|
-
await batch.send().wait();
|
|
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
|
-
});
|
|
434
|
-
}
|
|
435
|
-
/** Returns the job name for the current test. */ function getJobName() {
|
|
436
|
-
return process.env.JOB_NAME ?? expect.getState().currentTestName?.split(' ')[0].replaceAll('/', '_') ?? 'unknown';
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Returns a logger instance for the current test.
|
|
440
|
-
* @returns a logger instance for the current test.
|
|
441
|
-
*/ export function getLogger() {
|
|
442
|
-
const describeBlockName = expect.getState().currentTestName?.split(' ')[0].replaceAll('/', ':');
|
|
443
|
-
if (!describeBlockName) {
|
|
444
|
-
const name = expect.getState().testPath?.split('/').pop()?.split('.')[0] ?? 'unknown';
|
|
445
|
-
return createLogger('e2e:' + name);
|
|
446
|
-
}
|
|
447
|
-
return createLogger('e2e:' + describeBlockName);
|
|
448
|
-
}
|
|
449
|
-
export function getBalancesFn(symbol, method, logger) {
|
|
450
|
-
const balances = async (...addressLikes)=>{
|
|
451
|
-
const addresses = addressLikes.map((addressLike)=>'address' in addressLike ? addressLike.address : addressLike);
|
|
452
|
-
const b = await Promise.all(addresses.map((address)=>method(address).simulate()));
|
|
453
|
-
const debugString = `${symbol} balances: ${addresses.map((address, i)=>`${address}: ${b[i]}`).join(', ')}`;
|
|
454
|
-
logger.verbose(debugString);
|
|
455
|
-
return b;
|
|
456
|
-
};
|
|
457
|
-
return balances;
|
|
458
|
-
}
|
|
459
|
-
export async function expectMapping(fn, inputs, expectedOutputs) {
|
|
460
|
-
expect(inputs.length).toBe(expectedOutputs.length);
|
|
461
|
-
const outputs = await fn(...inputs);
|
|
462
|
-
expect(outputs).toEqual(expectedOutputs);
|
|
463
|
-
}
|
|
464
|
-
export async function expectMappingDelta(initialValues, fn, inputs, expectedDiffs) {
|
|
465
|
-
expect(inputs.length).toBe(expectedDiffs.length);
|
|
466
|
-
const outputs = await fn(...inputs);
|
|
467
|
-
const diffs = outputs.map((output, i)=>output - initialValues[i]);
|
|
468
|
-
expect(diffs).toEqual(expectedDiffs);
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Deploy the protocol contracts to a running instance.
|
|
472
|
-
*/ export async function setupCanonicalFeeJuice(pxe) {
|
|
473
|
-
// "deploy" the Fee Juice as it contains public functions
|
|
474
|
-
const feeJuicePortalAddress = (await pxe.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
|
|
475
|
-
const wallet = new SignerlessWallet(pxe);
|
|
476
|
-
const feeJuice = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
|
|
477
|
-
try {
|
|
478
|
-
const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
|
|
479
|
-
await feeJuice.methods.initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT).send({
|
|
480
|
-
fee: {
|
|
481
|
-
paymentMethod,
|
|
482
|
-
gasSettings: {
|
|
483
|
-
teardownGasLimits: Gas.empty()
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}).wait();
|
|
487
|
-
getLogger().info(`Fee Juice successfully setup. Portal address: ${feeJuicePortalAddress}`);
|
|
488
|
-
} catch (error) {
|
|
489
|
-
getLogger().warn(`Fee Juice might have already been setup. Got error: ${inspect(error)}.`);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, intervalSec = 1) {
|
|
493
|
-
targetBlock ??= await node.getBlockNumber();
|
|
494
|
-
await retryUntil(async ()=>await node.getProvenBlockNumber() >= targetBlock, 'proven chain status', timeoutSec, intervalSec);
|
|
495
|
-
}
|
|
496
|
-
export async function createAndSyncProverNode(proverNodePrivateKey, aztecNodeConfig, aztecNode, dataDirectory, prefilledPublicData = []) {
|
|
497
|
-
// Disable stopping the aztec node as the prover coordination test will kill it otherwise
|
|
498
|
-
// This is only required when stopping the prover node for testing
|
|
499
|
-
const aztecNodeWithoutStop = {
|
|
500
|
-
getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
|
|
501
|
-
getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
|
|
502
|
-
stop: ()=>Promise.resolve()
|
|
503
|
-
};
|
|
504
|
-
const blobSinkClient = createBlobSinkClient(aztecNodeConfig);
|
|
505
|
-
// Creating temp store and archiver for simulated prover node
|
|
506
|
-
const archiverConfig = {
|
|
507
|
-
...aztecNodeConfig,
|
|
508
|
-
dataDirectory
|
|
509
|
-
};
|
|
510
|
-
const archiver = await createArchiver(archiverConfig, blobSinkClient, {
|
|
511
|
-
blockUntilSync: true
|
|
512
|
-
});
|
|
513
|
-
// Prover node config is for simulated proofs
|
|
514
|
-
const proverConfig = {
|
|
515
|
-
...aztecNodeConfig,
|
|
516
|
-
proverCoordinationNodeUrl: undefined,
|
|
517
|
-
dataDirectory: undefined,
|
|
518
|
-
realProofs: false,
|
|
519
|
-
proverAgentCount: 2,
|
|
520
|
-
publisherPrivateKey: proverNodePrivateKey,
|
|
521
|
-
proverNodeMaxPendingJobs: 10,
|
|
522
|
-
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
523
|
-
proverNodePollingIntervalMs: 200,
|
|
524
|
-
txGatheringTimeoutMs: 60000,
|
|
525
|
-
txGatheringIntervalMs: 1000,
|
|
526
|
-
txGatheringMaxParallelRequests: 100
|
|
527
|
-
};
|
|
528
|
-
const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node');
|
|
529
|
-
const proverNode = await createProverNode(proverConfig, {
|
|
530
|
-
aztecNodeTxProvider: aztecNodeWithoutStop,
|
|
531
|
-
archiver: archiver,
|
|
532
|
-
l1TxUtils
|
|
533
|
-
}, {
|
|
534
|
-
prefilledPublicData
|
|
535
|
-
});
|
|
536
|
-
getLogger().info(`Created and synced prover node`, {
|
|
537
|
-
publisherAddress: l1TxUtils.walletClient.account.address
|
|
538
|
-
});
|
|
539
|
-
proverNode.start();
|
|
540
|
-
return proverNode;
|
|
541
|
-
}
|
|
542
|
-
function createDelayedL1TxUtils(aztecNodeConfig, privateKey, logName) {
|
|
543
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
544
|
-
const log = createLogger(logName);
|
|
545
|
-
const l1TxUtils = new DelayedTxUtils(publicClient, walletClient, log, aztecNodeConfig);
|
|
546
|
-
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
547
|
-
return l1TxUtils;
|
|
548
|
-
}
|
|
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
|
-
}
|
|
2
|
+
* Re-exports from the unified setup module for backward compatibility.
|
|
3
|
+
* Tests that previously used utils.ts should continue to work.
|
|
4
|
+
*/ export { createAndSyncProverNode, deployAccounts, ensureAccountContractsPublished, expectMapping, expectMappingDelta, getBalancesFn, getLogger, getPrivateKeyFromIndex, getSponsoredFPCAddress, getSponsoredFPCInstance, publicDeployAccounts, registerSponsoredFPC, setup, setupPXEAndGetWallet, setupSharedBlobStorage, setupSponsoredFPC, startAnvil, teardown, waitForProvenChain } from './setup.js';
|
|
5
|
+
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]): Promise<void>;
|
|
2
|
+
export declare function refreshWeb3Signer(url: string, ...expectedAddresses: string[]): Promise<void>;
|
|
3
|
+
export declare function getWeb3SignerTestKeystoreDir(): string;
|
|
4
|
+
export declare function getWeb3SignerUrl(): string;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2ViM3NpZ25lci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZpeHR1cmVzL3dlYjNzaWduZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBU0Esd0JBQXNCLHdCQUF3QixDQUFDLEdBQUcsRUFBRSxNQUFNLEVBQUUsR0FBRyxXQUFXLEVBQUUsTUFBTSxFQUFFLGlCQWNuRjtBQUVELHdCQUFzQixpQkFBaUIsQ0FBQyxHQUFHLEVBQUUsTUFBTSxFQUFFLEdBQUcsaUJBQWlCLEVBQUUsTUFBTSxFQUFFLGlCQW9CbEY7QUFFRCx3QkFBZ0IsNEJBQTRCLElBQUksTUFBTSxDQU9yRDtBQUVELHdCQUFnQixnQkFBZ0IsSUFBSSxNQUFNLENBTXpDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3signer.d.ts","sourceRoot":"","sources":["../../src/fixtures/web3signer.ts"],"names":[],"mappings":"AASA,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,iBAcnF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE,MAAM,EAAE,iBAoBlF;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAOrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
|
+
import { RemoteSigner } from '@aztec/node-keystore';
|
|
5
|
+
import { mkdirSync } from 'node:fs';
|
|
6
|
+
import { writeFile } from 'node:fs/promises';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
export async function createWeb3SignerKeystore(dir, ...privateKeys) {
|
|
9
|
+
const yaml = privateKeys.map((pk)=>`\
|
|
10
|
+
type: file-raw
|
|
11
|
+
keyType: SECP256K1
|
|
12
|
+
privateKey: ${pk}`).join('\n---\n');
|
|
13
|
+
// NOTE: nodejs stdlib can only create temp directories, not temp files!
|
|
14
|
+
// this write uses wx (write-exclusive) so it'll throw if the file already exists
|
|
15
|
+
const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
|
|
16
|
+
await writeFile(path, yaml, {
|
|
17
|
+
flag: 'wx'
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export async function refreshWeb3Signer(url, ...expectedAddresses) {
|
|
21
|
+
await fetch(new URL('reload', url), {
|
|
22
|
+
method: 'POST'
|
|
23
|
+
});
|
|
24
|
+
if (expectedAddresses.length > 0) {
|
|
25
|
+
await retryUntil(async ()=>{
|
|
26
|
+
try {
|
|
27
|
+
await RemoteSigner.validateAccess(url, expectedAddresses);
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}, 'web3signer refresh', 10, 0.5);
|
|
33
|
+
} else {
|
|
34
|
+
await sleep(1000);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function getWeb3SignerTestKeystoreDir() {
|
|
38
|
+
if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
|
|
39
|
+
mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, {
|
|
40
|
+
recursive: true
|
|
41
|
+
});
|
|
42
|
+
return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
|
|
43
|
+
} else {
|
|
44
|
+
throw new Error('Web3signer not running');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function getWeb3SignerUrl() {
|
|
48
|
+
if (process.env.WEB3_SIGNER_URL) {
|
|
49
|
+
return process.env.WEB3_SIGNER_URL;
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error('Web3signer not running');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
2
|
-
export declare function getEndToEndTestTelemetryClient(metricsPort?: number): TelemetryClient
|
|
3
|
-
//# sourceMappingURL=
|
|
2
|
+
export declare function getEndToEndTestTelemetryClient(metricsPort?: number): Promise<TelemetryClient>;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2l0aF90ZWxlbWV0cnlfdXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maXh0dXJlcy93aXRoX3RlbGVtZXRyeV91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQ0wsS0FBSyxlQUFlLEVBSXJCLE1BQU0seUJBQXlCLENBQUM7QUFHakMsd0JBQXNCLDhCQUE4QixDQUFDLFdBQVcsQ0FBQyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsZUFBZSxDQUFDLENBTW5HIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_telemetry_utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/with_telemetry_utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAGjC,
|
|
1
|
+
{"version":3,"file":"with_telemetry_utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/with_telemetry_utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAGjC,wBAAsB,8BAA8B,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAMnG"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { levels, registerLoggingStream } from '@aztec/foundation/log';
|
|
2
2
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
import { OTelPinoStream } from '@aztec/telemetry-client/otel-pino-stream';
|
|
4
|
-
export function getEndToEndTestTelemetryClient(metricsPort) {
|
|
4
|
+
export async function getEndToEndTestTelemetryClient(metricsPort) {
|
|
5
5
|
if (metricsPort) {
|
|
6
6
|
const otelStream = new OTelPinoStream({
|
|
7
7
|
levels
|
|
8
8
|
});
|
|
9
9
|
registerLoggingStream(otelStream);
|
|
10
10
|
}
|
|
11
|
-
return initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
|
|
11
|
+
return await initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Utility functions for setting up end-to-end tests with telemetry.
|
package/dest/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './shared/index.js';
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxjQUFjLG1CQUFtQixDQUFDIn0=
|