@aztec/end-to-end 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dest/bench/client_flows/benchmark.d.ts +17 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +38 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +14 -15
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +132 -150
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/client_flows/data_extractor.js +3 -1
- package/dest/bench/utils.d.ts +9 -8
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +33 -19
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
- 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 +120 -117
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +30 -14
- 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 +122 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +6 -5
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +20 -14
- package/dest/e2e_epochs/epochs_test.d.ts +39 -8
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +172 -51
- package/dest/e2e_fees/bridging_race.notest.js +3 -5
- package/dest/e2e_fees/fees_test.d.ts +18 -15
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +158 -143
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +14 -16
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +32 -41
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +8 -6
- package/dest/e2e_p2p/p2p_network.d.ts +20 -17
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +167 -124
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +206 -0
- package/dest/e2e_p2p/shared.d.ts +30 -12
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +88 -68
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +20 -11
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +103 -93
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +15 -20
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +115 -135
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +78 -2
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +75 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +5 -5
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
- package/dest/fixtures/setup.d.ts +266 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +714 -0
- package/dest/fixtures/setup_p2p_test.d.ts +22 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +43 -32
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +7 -6
- package/dest/fixtures/utils.d.ts +5 -194
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -619
- package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
- package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
- package/dest/forward-compatibility/wallet_service.d.ts +3 -0
- package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_service.js +109 -0
- package/dest/install_legacy_contracts.d.cts +10 -0
- package/dest/install_legacy_contracts.d.cts.map +1 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- 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 +18 -6
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +33 -29
- package/dest/shared/gas_portal_test_harness.d.ts +18 -5
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +20 -11
- package/dest/shared/index.d.ts +3 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +4 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +9 -11
- package/dest/shared/uniswap_l1_l2.d.ts +3 -28
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +88 -47
- package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
- package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
- package/dest/simulators/lending_simulator.d.ts +14 -3
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +28 -16
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +15 -5
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +133 -43
- package/dest/spartan/tx_metrics.d.ts +68 -5
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +399 -19
- package/dest/spartan/utils/bot.d.ts +28 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +142 -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 +19 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +23 -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 +11 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +22 -0
- package/dest/spartan/utils/k8s.d.ts +128 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +381 -0
- package/dest/spartan/utils/nodes.d.ts +40 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/spartan/utils/scripts.d.ts +30 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +81 -0
- package/dest/spartan/utils.d.ts +2 -231
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -853
- package/dest/test-wallet/test_wallet.d.ts +85 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +273 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +66 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +53 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +155 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +22 -0
- package/package.json +53 -45
- package/src/bench/client_flows/benchmark.ts +43 -2
- package/src/bench/client_flows/client_flows_benchmark.ts +189 -240
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +38 -22
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +166 -118
- package/src/e2e_deploy_contract/deploy_test.ts +24 -16
- package/src/e2e_epochs/epochs_test.ts +218 -94
- package/src/e2e_fees/bridging_race.notest.ts +4 -10
- package/src/e2e_fees/fees_test.ts +207 -230
- package/src/e2e_l1_publisher/write_json.ts +16 -16
- package/src/e2e_nested_contract/nested_contract_test.ts +38 -57
- package/src/e2e_p2p/inactivity_slash_test.ts +8 -6
- package/src/e2e_p2p/p2p_network.ts +239 -191
- package/src/e2e_p2p/reqresp/utils.ts +274 -0
- package/src/e2e_p2p/shared.ts +115 -86
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +129 -117
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +143 -185
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +97 -1
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +1037 -0
- package/src/fixtures/setup_p2p_test.ts +52 -52
- package/src/fixtures/token_utils.ts +7 -6
- package/src/fixtures/utils.ts +29 -907
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/guides/up_quick_start.sh +3 -5
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +112 -0
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +34 -40
- package/src/shared/gas_portal_test_harness.ts +22 -12
- package/src/shared/index.ts +2 -1
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +11 -16
- package/src/shared/uniswap_l1_l2.ts +114 -108
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +34 -16
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/setup_test_wallets.ts +191 -29
- package/src/spartan/tx_metrics.ts +329 -25
- package/src/spartan/utils/bot.ts +188 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +29 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +71 -0
- package/src/spartan/utils/k8s.ts +535 -0
- package/src/spartan/utils/nodes.ts +543 -0
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/spartan/utils/scripts.ts +99 -0
- package/src/spartan/utils.ts +1 -1077
- package/src/test-wallet/test_wallet.ts +376 -0
- package/src/test-wallet/utils.ts +108 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +218 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
- package/dest/fixtures/snapshot_manager.d.ts +0 -93
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -493
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/src/fixtures/snapshot_manager.ts +0 -651
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
|
+
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
5
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
6
|
+
import { BatchCall, getContractClassFromArtifact, waitForProven } from '@aztec/aztec.js/contracts';
|
|
7
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
9
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
10
|
+
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
11
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
12
|
+
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
13
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
14
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
15
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
16
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
17
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
18
|
+
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
19
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
20
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
21
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
22
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
23
|
+
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
24
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
25
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
26
|
+
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
27
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
28
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
29
|
+
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
30
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
31
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
32
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
33
|
+
import { PublicChecksArtifact, getStandardPublicChecks } from '@aztec/standard-contracts/public-checks';
|
|
34
|
+
import { ARTIFACT_VERSION_BEFORE_INJECTION } from '@aztec/stdlib/abi';
|
|
35
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
36
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
37
|
+
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
38
|
+
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
39
|
+
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
40
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
41
|
+
import fs from 'fs/promises';
|
|
42
|
+
import { tmpdir } from 'os';
|
|
43
|
+
import path from 'path';
|
|
44
|
+
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
45
|
+
import { foundry } from 'viem/chains';
|
|
46
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
47
|
+
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
48
|
+
import { getACVMConfig } from './get_acvm_config.js';
|
|
49
|
+
import { getBBConfig } from './get_bb_config.js';
|
|
50
|
+
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
51
|
+
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
52
|
+
export { startAnvil };
|
|
53
|
+
let telemetry = undefined;
|
|
54
|
+
async function getTelemetryClient(partialConfig = {}) {
|
|
55
|
+
if (!telemetry) {
|
|
56
|
+
const config = {
|
|
57
|
+
...getTelemetryConfig(),
|
|
58
|
+
...partialConfig
|
|
59
|
+
};
|
|
60
|
+
telemetry = config.benchmark ? new BenchmarkTelemetryClient() : await initTelemetryClient(config);
|
|
61
|
+
}
|
|
62
|
+
return telemetry;
|
|
63
|
+
}
|
|
64
|
+
export const getPrivateKeyFromIndex = (index)=>{
|
|
65
|
+
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
66
|
+
addressIndex: index
|
|
67
|
+
});
|
|
68
|
+
const privKeyRaw = hdAccount.getHdKey().privateKey;
|
|
69
|
+
return privKeyRaw === null ? null : Buffer.from(privKeyRaw);
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Sets up shared blob storage using FileStore in the data directory.
|
|
73
|
+
*/ export async function setupSharedBlobStorage(config) {
|
|
74
|
+
const sharedBlobPath = path.join(config.dataDirectory, 'shared-blobs');
|
|
75
|
+
await fs.mkdir(sharedBlobPath, {
|
|
76
|
+
recursive: true
|
|
77
|
+
});
|
|
78
|
+
config.blobFileStoreUrls = [
|
|
79
|
+
`file://${sharedBlobPath}`
|
|
80
|
+
];
|
|
81
|
+
config.blobFileStoreUploadUrl = `file://${sharedBlobPath}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
|
|
85
|
+
* @param aztecNode - An instance of Aztec Node.
|
|
86
|
+
* @param opts - Partial configuration for the PXE.
|
|
87
|
+
* @param logger - The logger to be used.
|
|
88
|
+
* @param actor - Actor label to include in log output (e.g., 'pxe-test').
|
|
89
|
+
* @returns A test wallet, logger and teardown function.
|
|
90
|
+
*/ export async function setupPXEAndGetWallet(aztecNode, opts = {}, logger = getLogger(), actor) {
|
|
91
|
+
const PXEConfig = {
|
|
92
|
+
...getPXEConfig(),
|
|
93
|
+
...opts
|
|
94
|
+
};
|
|
95
|
+
// For tests we only want proving enabled if specifically requested
|
|
96
|
+
PXEConfig.proverEnabled = !!opts.proverEnabled;
|
|
97
|
+
// If no data directory provided, create a temp directory and clean up afterwards
|
|
98
|
+
const configuredDataDirectory = PXEConfig.dataDirectory;
|
|
99
|
+
if (!configuredDataDirectory) {
|
|
100
|
+
PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
101
|
+
}
|
|
102
|
+
const teardown = configuredDataDirectory ? ()=>Promise.resolve() : ()=>tryRmDir(PXEConfig.dataDirectory);
|
|
103
|
+
const wallet = await TestWallet.create(aztecNode, PXEConfig, {
|
|
104
|
+
loggerActorLabel: actor
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
wallet,
|
|
108
|
+
logger,
|
|
109
|
+
teardown
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* When CONTRACT_ARTIFACTS_VERSION is set (backwards compatibility testing), asserts that the loaded artifact's
|
|
114
|
+
* aztecVersion matches the expected version. This is a sanity check verifying that the legacy artifact resolver
|
|
115
|
+
* actually swapped in the correct version.
|
|
116
|
+
*/ function assertContractArtifactsVersion() {
|
|
117
|
+
const expected = process.env.CONTRACT_ARTIFACTS_VERSION;
|
|
118
|
+
if (!expected) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const { aztecVersion } = SponsoredFPCContract.artifact;
|
|
122
|
+
// TODO(F-557): Remove this bypass once pre-version artifacts are no longer tested.
|
|
123
|
+
if (aztecVersion === ARTIFACT_VERSION_BEFORE_INJECTION) {
|
|
124
|
+
createLogger('e2e:setup').info(`Skipping artifact version check: artifact predates version injection (CONTRACT_ARTIFACTS_VERSION=${expected})`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (aztecVersion !== expected) {
|
|
128
|
+
throw new Error(`Artifact version mismatch: expected ${expected} but got ${aztecVersion}. ` + `The legacy artifact resolver may not have swapped in the correct version.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Sets up the environment for the end-to-end tests.
|
|
133
|
+
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
134
|
+
* @param opts - Options to pass to the node initialization and to the setup script.
|
|
135
|
+
* @param pxeOpts - Options to pass to the PXE initialization.
|
|
136
|
+
*/ export async function setup(numberOfAccounts = 1, opts = {}, pxeOpts = {}, chain = foundry) {
|
|
137
|
+
assertContractArtifactsVersion();
|
|
138
|
+
let anvil;
|
|
139
|
+
try {
|
|
140
|
+
opts.aztecTargetCommitteeSize ??= 0;
|
|
141
|
+
opts.slasherEnabled ??= false;
|
|
142
|
+
const config = {
|
|
143
|
+
...getConfigEnvVars(),
|
|
144
|
+
...opts
|
|
145
|
+
};
|
|
146
|
+
// use initialValidators for the node config
|
|
147
|
+
config.validatorPrivateKeys = new SecretValue(opts.initialValidators?.map((v)=>v.privateKey) ?? []);
|
|
148
|
+
config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
149
|
+
config.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
|
|
150
|
+
// For tests we only want proving enabled if specifically requested
|
|
151
|
+
config.realProofs = !!opts.realProofs;
|
|
152
|
+
// Only enforce the time table if requested
|
|
153
|
+
config.enforceTimeTable = !!opts.enforceTimeTable;
|
|
154
|
+
// Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
|
|
155
|
+
config.enableDelayer = true;
|
|
156
|
+
config.listenAddress = '127.0.0.1';
|
|
157
|
+
config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
|
|
158
|
+
const logger = getLogger();
|
|
159
|
+
// Create a temp directory for any services that need it and cleanup later
|
|
160
|
+
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
161
|
+
await fs.mkdir(directoryToCleanup, {
|
|
162
|
+
recursive: true
|
|
163
|
+
});
|
|
164
|
+
if (!config.dataDirectory) {
|
|
165
|
+
config.dataDirectory = directoryToCleanup;
|
|
166
|
+
}
|
|
167
|
+
const dateProvider = new TestDateProvider();
|
|
168
|
+
if (!config.l1RpcUrls?.length) {
|
|
169
|
+
if (!isAnvilTestChain(chain.id)) {
|
|
170
|
+
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
171
|
+
}
|
|
172
|
+
const res = await startAnvil({
|
|
173
|
+
l1BlockTime: opts.ethereumSlotDuration,
|
|
174
|
+
accounts: opts.anvilAccounts,
|
|
175
|
+
port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
|
|
176
|
+
slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
|
|
177
|
+
dateProvider
|
|
178
|
+
});
|
|
179
|
+
anvil = res.anvil;
|
|
180
|
+
config.l1RpcUrls = [
|
|
181
|
+
res.rpcUrl
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
// Enable logging metrics to a local file named after the test suite
|
|
185
|
+
if (isMetricsLoggingRequested()) {
|
|
186
|
+
const filename = path.join('log', getJobName() + '.jsonl');
|
|
187
|
+
logger.info(`Logging metrics to ${filename}`);
|
|
188
|
+
setupMetricsLogger(filename);
|
|
189
|
+
}
|
|
190
|
+
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
|
|
191
|
+
if (opts.stateLoad) {
|
|
192
|
+
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
193
|
+
}
|
|
194
|
+
if (opts.l1StartTime) {
|
|
195
|
+
await ethCheatCodes.warp(opts.l1StartTime, {
|
|
196
|
+
resetBlockInterval: true
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
let publisherPrivKeyHex = undefined;
|
|
200
|
+
let publisherHdAccount = undefined;
|
|
201
|
+
if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
|
|
202
|
+
publisherPrivKeyHex = opts.l1PublisherKey.getValue();
|
|
203
|
+
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
204
|
+
} else if (config.sequencerPublisherPrivateKeys && config.sequencerPublisherPrivateKeys.length > 0 && config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY) {
|
|
205
|
+
publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
|
|
206
|
+
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
207
|
+
} else if (!MNEMONIC) {
|
|
208
|
+
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
209
|
+
} else {
|
|
210
|
+
publisherHdAccount = mnemonicToAccount(MNEMONIC, {
|
|
211
|
+
addressIndex: 0
|
|
212
|
+
});
|
|
213
|
+
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
214
|
+
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
215
|
+
publisherPrivKeyHex = `0x${publisherPrivKey.toString('hex')}`;
|
|
216
|
+
config.sequencerPublisherPrivateKeys = [
|
|
217
|
+
new SecretValue(publisherPrivKeyHex)
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
if (config.coinbase === undefined) {
|
|
221
|
+
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
222
|
+
}
|
|
223
|
+
// Determine which addresses to fund in genesis
|
|
224
|
+
const initialFundedAccounts = opts.initialFundedAccounts ?? await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? Math.max(numberOfAccounts, 10));
|
|
225
|
+
const addressesToFund = initialFundedAccounts.map((a)=>a.address);
|
|
226
|
+
// Optionally fund the sponsored FPC
|
|
227
|
+
if (opts.fundSponsoredFPC) {
|
|
228
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
229
|
+
addressesToFund.push(sponsoredFPCAddress);
|
|
230
|
+
}
|
|
231
|
+
const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
|
|
232
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(addressesToFund, opts.initialAccountFeeJuice, opts.genesisPublicData, genesisTimestamp);
|
|
233
|
+
const wasAutomining = await ethCheatCodes.isAutoMining();
|
|
234
|
+
const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
|
|
235
|
+
if (enableAutomine) {
|
|
236
|
+
await ethCheatCodes.setAutomine(true);
|
|
237
|
+
}
|
|
238
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount, chain);
|
|
239
|
+
// Deploy Multicall3 if running locally
|
|
240
|
+
await deployMulticall3(l1Client, logger);
|
|
241
|
+
// Force viem to refresh its nonce cache to avoid "nonce too low" errors in subsequent transactions
|
|
242
|
+
// This is necessary because deployMulticall3 sends multiple transactions and viem may cache a stale nonce
|
|
243
|
+
await l1Client.getTransactionCount({
|
|
244
|
+
address: l1Client.account.address
|
|
245
|
+
});
|
|
246
|
+
const deployL1ContractsValues = await deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex, chain.id, {
|
|
247
|
+
...getL1ContractsConfigEnvVars(),
|
|
248
|
+
...opts,
|
|
249
|
+
...opts.l1ContractsArgs,
|
|
250
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
251
|
+
protocolContractsHash,
|
|
252
|
+
genesisArchiveRoot,
|
|
253
|
+
initialValidators: opts.initialValidators,
|
|
254
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
255
|
+
realVerifier: false
|
|
256
|
+
});
|
|
257
|
+
Object.assign(config, deployL1ContractsValues.l1ContractAddresses);
|
|
258
|
+
config.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
259
|
+
// Propagate L1-contracts-config overrides back to the node config so the archiver's
|
|
260
|
+
// `l1Constants` (and any other node-side consumer) agrees with what was actually deployed.
|
|
261
|
+
// Without this, a per-test override like `aztecEpochDuration: 4` lands on the rollup contract
|
|
262
|
+
// but the node config keeps the default (32), so `archiver.isEpochComplete(0)` computes
|
|
263
|
+
// `endSlot=31` and `EpochTestSettler`/`EpochMonitor` never fires — letting the
|
|
264
|
+
// `aztecProofSubmissionEpochs` window expire mid-test and prune the pending chain.
|
|
265
|
+
// Skip undefined values: callers (e.g. `P2PNetworkTest`) sometimes build `l1ContractsArgs`
|
|
266
|
+
// by spreading a partial `AztecNodeConfig`, which leaves unset fields (notably `dataDirectory`)
|
|
267
|
+
// as `undefined`. A blind Object.assign would then clobber the temp `dataDirectory` set earlier
|
|
268
|
+
// in this function and crash `setupSharedBlobStorage`.
|
|
269
|
+
if (opts.l1ContractsArgs) {
|
|
270
|
+
for (const [key, value] of Object.entries(opts.l1ContractsArgs)){
|
|
271
|
+
if (value !== undefined) {
|
|
272
|
+
config[key] = value;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (enableAutomine) {
|
|
277
|
+
await ethCheatCodes.setAutomine(false);
|
|
278
|
+
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
279
|
+
}
|
|
280
|
+
// In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
|
|
281
|
+
// ahead of system time due to the local-network watcher warping time forward on each filled slot.
|
|
282
|
+
// When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
|
|
283
|
+
if (!anvil) {
|
|
284
|
+
dateProvider.setTime(await ethCheatCodes.lastBlockTimestamp() * 1000);
|
|
285
|
+
}
|
|
286
|
+
if (opts.l2StartTime) {
|
|
287
|
+
await ethCheatCodes.warp(opts.l2StartTime, {
|
|
288
|
+
resetBlockInterval: true
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider, opts.anvilTestWatcherOpts);
|
|
292
|
+
if (!opts.disableAnvilTestWatcher) {
|
|
293
|
+
await watcher.start();
|
|
294
|
+
}
|
|
295
|
+
// Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
|
|
296
|
+
const telemetryClient = opts.metricsPort ? await getEndToEndTestTelemetryClient(opts.metricsPort) : await getTelemetryClient(opts.telemetryConfig);
|
|
297
|
+
await setupSharedBlobStorage(config);
|
|
298
|
+
logger.verbose('Creating and synching an aztec node', config);
|
|
299
|
+
const acvmConfig = await getACVMConfig(logger);
|
|
300
|
+
if (acvmConfig) {
|
|
301
|
+
config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
302
|
+
config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
303
|
+
}
|
|
304
|
+
const bbConfig = await getBBConfig(logger);
|
|
305
|
+
if (bbConfig) {
|
|
306
|
+
config.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
307
|
+
config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
308
|
+
}
|
|
309
|
+
let mockGossipSubNetwork;
|
|
310
|
+
let p2pClientDeps = undefined;
|
|
311
|
+
if (opts.mockGossipSubNetwork) {
|
|
312
|
+
mockGossipSubNetwork = new MockGossipSubNetwork(opts.mockGossipSubNetworkLatency);
|
|
313
|
+
p2pClientDeps = {
|
|
314
|
+
p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
// Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
|
|
318
|
+
// To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
|
|
319
|
+
// For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
|
|
320
|
+
// If no accounts need deployment, we await an empty block to confirm network progression.
|
|
321
|
+
const originalMinTxsPerBlock = config.minTxsPerBlock;
|
|
322
|
+
if (originalMinTxsPerBlock === undefined) {
|
|
323
|
+
throw new Error('minTxsPerBlock is undefined in e2e test setup');
|
|
324
|
+
}
|
|
325
|
+
// Only set minTxsPerBlock=1 if we're going to deploy accounts and need reliable block inclusion
|
|
326
|
+
const shouldDeployAccounts = numberOfAccounts > 0 && !opts.skipAccountDeployment;
|
|
327
|
+
// Only set minTxsPerBlock=0 if we need an empty block (no accounts at all, not skipped deployment)
|
|
328
|
+
const needsEmptyBlock = numberOfAccounts === 0 && !opts.skipAccountDeployment;
|
|
329
|
+
// Under proposer pipelining the sequencer builds during slot N-1 for slot N. A tx submitted at
|
|
330
|
+
// slot N start is too late -- it arrives after the build. Forcing minTxsPerBlock=1 then stalls
|
|
331
|
+
// the chain on alternating slots, so allow empty checkpoints under pipelining.
|
|
332
|
+
const accountsDeployMinTxs = config.enableProposerPipelining ? 0 : 1;
|
|
333
|
+
config.minTxsPerBlock = shouldDeployAccounts ? accountsDeployMinTxs : needsEmptyBlock ? 0 : originalMinTxsPerBlock;
|
|
334
|
+
config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
|
|
335
|
+
config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
|
|
336
|
+
if (!config.disableValidator) {
|
|
337
|
+
if ((config.validatorPrivateKeys?.getValue().length ?? 0) === 0) {
|
|
338
|
+
config.validatorPrivateKeys = new SecretValue([
|
|
339
|
+
generatePrivateKey()
|
|
340
|
+
]);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// When skipInitialSequencer is set, the initial node is a lightweight RPC-only node.
|
|
344
|
+
// We apply these overrides to a copy so they don't leak into the returned config.
|
|
345
|
+
// Keep P2P enabled if mockGossipSubNetwork is used (needed for tx propagation to validators).
|
|
346
|
+
const initialNodeConfig = opts.skipInitialSequencer ? {
|
|
347
|
+
...config,
|
|
348
|
+
disableValidator: true,
|
|
349
|
+
...opts.mockGossipSubNetwork ? {} : {
|
|
350
|
+
p2pEnabled: false,
|
|
351
|
+
bootstrapNodes: []
|
|
352
|
+
}
|
|
353
|
+
} : config;
|
|
354
|
+
const aztecNodeService = await withLoggerBindings({
|
|
355
|
+
actor: 'node-0'
|
|
356
|
+
}, ()=>AztecNodeService.createAndSync(initialNodeConfig, {
|
|
357
|
+
dateProvider,
|
|
358
|
+
telemetry: telemetryClient,
|
|
359
|
+
p2pClientDeps
|
|
360
|
+
}, {
|
|
361
|
+
genesis,
|
|
362
|
+
dontStartSequencer: opts.skipInitialSequencer
|
|
363
|
+
}));
|
|
364
|
+
const sequencerClient = aztecNodeService.getSequencer();
|
|
365
|
+
let proverNode = undefined;
|
|
366
|
+
if (opts.startProverNode) {
|
|
367
|
+
logger.verbose('Creating and syncing a simulated prover node...');
|
|
368
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
369
|
+
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
|
|
370
|
+
const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
371
|
+
const p2pClientDeps = {
|
|
372
|
+
p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork),
|
|
373
|
+
rpcTxProviders: [
|
|
374
|
+
aztecNodeService
|
|
375
|
+
]
|
|
376
|
+
};
|
|
377
|
+
({ proverNode } = await createAndSyncProverNode(proverNodePrivateKeyHex, config, {
|
|
378
|
+
...config.proverNodeConfig,
|
|
379
|
+
dataDirectory: proverNodeDataDirectory
|
|
380
|
+
}, {
|
|
381
|
+
dateProvider,
|
|
382
|
+
p2pClientDeps,
|
|
383
|
+
telemetry: telemetryClient
|
|
384
|
+
}, {
|
|
385
|
+
genesis
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
const sequencerDelayer = sequencerClient?.getDelayer();
|
|
389
|
+
const proverDelayer = proverNode?.getProverNode()?.getDelayer();
|
|
390
|
+
logger.verbose('Creating a pxe...');
|
|
391
|
+
const pxeConfig = {
|
|
392
|
+
...getPXEConfig(),
|
|
393
|
+
...pxeOpts
|
|
394
|
+
};
|
|
395
|
+
pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
396
|
+
// For tests we only want proving enabled if specifically requested
|
|
397
|
+
pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
|
|
398
|
+
const wallet = await TestWallet.create(aztecNodeService, pxeConfig, {
|
|
399
|
+
loggerActorLabel: 'pxe-0',
|
|
400
|
+
...opts.pxeCreationOptions
|
|
401
|
+
});
|
|
402
|
+
if (opts.walletMinFeePadding !== undefined) {
|
|
403
|
+
wallet.setMinFeePadding(opts.walletMinFeePadding);
|
|
404
|
+
}
|
|
405
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNodeService, dateProvider, aztecNodeService.getAutomineSequencer());
|
|
406
|
+
if (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0 || opts.initialValidators && opts.initialValidators.length > 0) {
|
|
407
|
+
// We need to advance such that the committee is set up.
|
|
408
|
+
await cheatCodes.rollup.advanceToEpoch(EpochNumber.fromBigInt(BigInt(await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochsForValidatorSet + 1)));
|
|
409
|
+
await cheatCodes.rollup.setupEpoch();
|
|
410
|
+
await cheatCodes.rollup.debugRollup();
|
|
411
|
+
}
|
|
412
|
+
let accounts = [];
|
|
413
|
+
if (opts.skipInitialSequencer) {
|
|
414
|
+
logger.info('Sequencer not started on initial node, skipping block progression');
|
|
415
|
+
} else if (shouldDeployAccounts) {
|
|
416
|
+
logger.info(`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`);
|
|
417
|
+
const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
418
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, accountsData);
|
|
419
|
+
accounts = accountManagers.map((accountManager)=>accountManager.address);
|
|
420
|
+
} else if (needsEmptyBlock) {
|
|
421
|
+
logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
|
|
422
|
+
// AutomineSequencer only builds on tx arrival; explicitly request an empty block.
|
|
423
|
+
const automine = aztecNodeService.getAutomineSequencer();
|
|
424
|
+
if (automine) {
|
|
425
|
+
await automine.buildEmptyBlock();
|
|
426
|
+
}
|
|
427
|
+
while(await aztecNodeService.getBlockNumber() === 0){
|
|
428
|
+
await sleep(2000);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
// If skipAccountDeployment is true, we don't deploy or wait - tests will handle account deployment later
|
|
432
|
+
// Now we restore the original minTxsPerBlock setting if we changed it.
|
|
433
|
+
if (sequencerClient && config.minTxsPerBlock !== originalMinTxsPerBlock) {
|
|
434
|
+
sequencerClient.getSequencer().updateConfig({
|
|
435
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
439
|
+
throw new Error(`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`);
|
|
440
|
+
}
|
|
441
|
+
const teardown = async ()=>{
|
|
442
|
+
try {
|
|
443
|
+
await tryStop(wallet, logger);
|
|
444
|
+
await tryStop(aztecNodeService, logger);
|
|
445
|
+
await tryStop(proverNode, logger);
|
|
446
|
+
if (acvmConfig?.cleanup) {
|
|
447
|
+
await acvmConfig.cleanup();
|
|
448
|
+
}
|
|
449
|
+
if (bbConfig?.cleanup) {
|
|
450
|
+
await bbConfig.cleanup();
|
|
451
|
+
}
|
|
452
|
+
await tryStop(watcher, logger);
|
|
453
|
+
await tryStop(anvil, logger);
|
|
454
|
+
await tryRmDir(directoryToCleanup, logger);
|
|
455
|
+
} catch (err) {
|
|
456
|
+
logger.error(`Error during e2e test teardown`, err);
|
|
457
|
+
} finally{
|
|
458
|
+
try {
|
|
459
|
+
await telemetryClient.stop();
|
|
460
|
+
} catch (err) {
|
|
461
|
+
logger.error(`Error during telemetry client stop`, err);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
return {
|
|
466
|
+
anvil,
|
|
467
|
+
aztecNode: aztecNodeService,
|
|
468
|
+
aztecNodeService,
|
|
469
|
+
aztecNodeAdmin: aztecNodeService,
|
|
470
|
+
cheatCodes,
|
|
471
|
+
ethCheatCodes,
|
|
472
|
+
config,
|
|
473
|
+
aztecNodeConfig: config,
|
|
474
|
+
dateProvider,
|
|
475
|
+
deployL1ContractsValues,
|
|
476
|
+
initialFundedAccounts,
|
|
477
|
+
logger,
|
|
478
|
+
mockGossipSubNetwork,
|
|
479
|
+
genesis,
|
|
480
|
+
proverNode,
|
|
481
|
+
sequencerDelayer,
|
|
482
|
+
proverDelayer,
|
|
483
|
+
sequencer: sequencerClient,
|
|
484
|
+
teardown,
|
|
485
|
+
telemetryClient,
|
|
486
|
+
wallet,
|
|
487
|
+
accounts,
|
|
488
|
+
watcher,
|
|
489
|
+
acvmConfig,
|
|
490
|
+
bbConfig,
|
|
491
|
+
directoryToCleanup
|
|
492
|
+
};
|
|
493
|
+
} catch (err) {
|
|
494
|
+
await anvil?.stop();
|
|
495
|
+
throw err;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/** Returns the job name for the current test. */ function getJobName() {
|
|
499
|
+
return process.env.JOB_NAME ?? expect.getState().currentTestName?.split(' ')[0].replaceAll('/', '_') ?? 'unknown';
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Returns a logger instance for the current test.
|
|
503
|
+
*/ export function getLogger() {
|
|
504
|
+
const describeBlockName = expect.getState().currentTestName?.split(' ')[0].replaceAll('/', ':');
|
|
505
|
+
if (!describeBlockName) {
|
|
506
|
+
const name = expect.getState().testPath?.split('/').pop()?.split('.')[0] ?? 'unknown';
|
|
507
|
+
return createLogger('e2e:' + name);
|
|
508
|
+
}
|
|
509
|
+
return createLogger('e2e:' + describeBlockName);
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Computes the address of the "canonical" SponsoredFPCContract.
|
|
513
|
+
*/ export function getSponsoredFPCInstance() {
|
|
514
|
+
return Promise.resolve(getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
515
|
+
salt: new Fr(SPONSORED_FPC_SALT)
|
|
516
|
+
}));
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Computes the address of the "canonical" SponsoredFPCContract.
|
|
520
|
+
*/ export async function getSponsoredFPCAddress() {
|
|
521
|
+
const sponsoredFPCInstance = await getSponsoredFPCInstance();
|
|
522
|
+
return sponsoredFPCInstance.address;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Deploy a sponsored FPC contract to a running instance.
|
|
526
|
+
*/ export async function setupSponsoredFPC(wallet) {
|
|
527
|
+
const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
528
|
+
salt: new Fr(SPONSORED_FPC_SALT)
|
|
529
|
+
});
|
|
530
|
+
await wallet.registerContract(instance, SponsoredFPCContract.artifact);
|
|
531
|
+
getLogger().info(`SponsoredFPC: ${instance.address}`);
|
|
532
|
+
return instance;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Registers the SponsoredFPC in this PXE instance.
|
|
536
|
+
*/ export async function registerSponsoredFPC(wallet) {
|
|
537
|
+
await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
|
|
538
|
+
}
|
|
539
|
+
export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, intervalSec = 1) {
|
|
540
|
+
targetBlock ??= await node.getBlockNumber();
|
|
541
|
+
await retryUntil(async ()=>await node.getBlockNumber('proven') >= targetBlock, 'proven chain status', timeoutSec, intervalSec);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Creates an AztecNodeService with the prover node enabled as a subsystem.
|
|
545
|
+
* Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
|
|
546
|
+
*/ export function createAndSyncProverNode(proverNodePrivateKey, baseConfig, configOverrides, deps, options) {
|
|
547
|
+
return withLoggerBindings({
|
|
548
|
+
actor: 'prover-0'
|
|
549
|
+
}, async ()=>{
|
|
550
|
+
const proverNode = await AztecNodeService.createAndSync({
|
|
551
|
+
...baseConfig,
|
|
552
|
+
...configOverrides,
|
|
553
|
+
p2pPort: 0,
|
|
554
|
+
enableProverNode: true,
|
|
555
|
+
disableValidator: true,
|
|
556
|
+
proverPublisherPrivateKeys: [
|
|
557
|
+
new SecretValue(proverNodePrivateKey)
|
|
558
|
+
]
|
|
559
|
+
}, deps, {
|
|
560
|
+
genesis: options.genesis,
|
|
561
|
+
dontStartProverNode: options.dontStart
|
|
562
|
+
});
|
|
563
|
+
if (!proverNode.getProverNode()) {
|
|
564
|
+
throw new Error('Prover node subsystem was not created despite enableProverNode being set');
|
|
565
|
+
}
|
|
566
|
+
getLogger().info(`Created and synced prover node`);
|
|
567
|
+
return {
|
|
568
|
+
proverNode
|
|
569
|
+
};
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
export function getBalancesFn(symbol, method, logger) {
|
|
573
|
+
const balances = async (...addressLikes)=>{
|
|
574
|
+
const addresses = addressLikes.map((addressLike)=>'address' in addressLike ? addressLike.address : addressLike);
|
|
575
|
+
const b = await Promise.all(addresses.map(async (address)=>(await method(address).simulate({
|
|
576
|
+
from: address
|
|
577
|
+
})).result));
|
|
578
|
+
const debugString = `${symbol} balances: ${addresses.map((address, i)=>`${address}: ${b[i]}`).join(', ')}`;
|
|
579
|
+
logger.verbose(debugString);
|
|
580
|
+
return b;
|
|
581
|
+
};
|
|
582
|
+
return balances;
|
|
583
|
+
}
|
|
584
|
+
export async function expectMapping(fn, inputs, expectedOutputs) {
|
|
585
|
+
expect(inputs.length).toBe(expectedOutputs.length);
|
|
586
|
+
const outputs = await fn(...inputs);
|
|
587
|
+
expect(outputs).toEqual(expectedOutputs);
|
|
588
|
+
}
|
|
589
|
+
export async function expectMappingDelta(initialValues, fn, inputs, expectedDiffs) {
|
|
590
|
+
expect(inputs.length).toBe(expectedDiffs.length);
|
|
591
|
+
const outputs = await fn(...inputs);
|
|
592
|
+
const diffs = outputs.map((output, i)=>output - initialValues[i]);
|
|
593
|
+
expect(diffs).toEqual(expectedDiffs);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Registers the auth_registry contract class and publishes its standard instance if not already
|
|
597
|
+
* present, and registers the artifact with PXE. Publishing is required before exercising the public
|
|
598
|
+
* authwit path (which relies on the AVM's deployment-nullifier check); the PXE-side registration is
|
|
599
|
+
* required so revert messages from AuthRegistry calls can be enriched (otherwise assertion strings
|
|
600
|
+
* surface as generic "Assertion failed:" and tests that match on the real message fail).
|
|
601
|
+
*/ export async function ensureAuthRegistryPublished(wallet, from) {
|
|
602
|
+
const { instance, contractClass } = await getStandardAuthRegistry();
|
|
603
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
604
|
+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({
|
|
605
|
+
from
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
609
|
+
await publishInstance(wallet, instance).send({
|
|
610
|
+
from
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
await wallet.registerContract(instance, AuthRegistryArtifact);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Registers the public_checks contract class and publishes its standard instance if not already
|
|
617
|
+
* present, and registers the artifact with PXE. Required for any contract that calls
|
|
618
|
+
* `privately_check_timestamp` / `privately_check_block_number` (which dispatch into the
|
|
619
|
+
* deployed PublicChecks contract via an enqueued public call).
|
|
620
|
+
*/ export async function ensurePublicChecksPublished(wallet, from) {
|
|
621
|
+
const { instance, contractClass } = await getStandardPublicChecks();
|
|
622
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
623
|
+
await (await publishContractClass(wallet, PublicChecksArtifact)).send({
|
|
624
|
+
from
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
628
|
+
await publishInstance(wallet, instance).send({
|
|
629
|
+
from
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
await wallet.registerContract(instance, PublicChecksArtifact);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
636
|
+
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
637
|
+
*/ export async function ensureAccountContractsPublished(wallet, accountsToDeploy) {
|
|
638
|
+
const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (address)=>{
|
|
639
|
+
return {
|
|
640
|
+
address,
|
|
641
|
+
deployed: (await wallet.getContractMetadata(address)).isContractPublished
|
|
642
|
+
};
|
|
643
|
+
}));
|
|
644
|
+
const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>wallet.getContractMetadata(address)))).map((contractMetadata)=>contractMetadata.instance);
|
|
645
|
+
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
646
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
647
|
+
await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({
|
|
648
|
+
from: accountsToDeploy[0]
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
const requests = instances.map((instance)=>publishInstance(wallet, instance));
|
|
652
|
+
const batch = new BatchCall(wallet, requests);
|
|
653
|
+
await batch.send({
|
|
654
|
+
from: accountsToDeploy[0]
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Helper function to deploy accounts.
|
|
659
|
+
* Returns deployed account data that can be used by tests.
|
|
660
|
+
*/ export const deployAccounts = (numberOfAccounts, logger, deployOptions)=>async ({ wallet, initialFundedAccounts })=>{
|
|
661
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
662
|
+
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
663
|
+
}
|
|
664
|
+
logger.verbose('Deploying accounts funded with fee juice...');
|
|
665
|
+
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
666
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
667
|
+
for(let i = 0; i < deployedAccounts.length; i++){
|
|
668
|
+
const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
|
|
669
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
670
|
+
await deployMethod.send({
|
|
671
|
+
from: NO_FROM,
|
|
672
|
+
skipClassPublication: i !== 0,
|
|
673
|
+
...deployOptions
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
return {
|
|
677
|
+
deployedAccounts
|
|
678
|
+
};
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
682
|
+
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
683
|
+
*/ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
|
|
684
|
+
const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.instance);
|
|
685
|
+
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
686
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
687
|
+
const calls = await Promise.all([
|
|
688
|
+
...!alreadyRegistered ? [
|
|
689
|
+
publishContractClass(wallet, SchnorrAccountContractArtifact)
|
|
690
|
+
] : [],
|
|
691
|
+
...instances.map((instance)=>publishInstance(wallet, instance))
|
|
692
|
+
]);
|
|
693
|
+
const batch = new BatchCall(wallet, calls);
|
|
694
|
+
const { receipt: txReceipt } = await batch.send({
|
|
695
|
+
from: accountsToDeploy[0]
|
|
696
|
+
});
|
|
697
|
+
if (waitUntilProven) {
|
|
698
|
+
if (!node) {
|
|
699
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
700
|
+
} else {
|
|
701
|
+
await waitForProven(node, txReceipt);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Destroys the current context.
|
|
707
|
+
*/ export async function teardown(context) {
|
|
708
|
+
if (!context) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
await context.teardown();
|
|
712
|
+
}
|
|
713
|
+
// Re-export for backward compatibility
|
|
714
|
+
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|