@aztec/end-to-end 0.0.0-test.0 → 0.0.1-commit.023c3e5
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 +71 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +260 -54
- 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 +11 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +56 -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/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +153 -0
- 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 +695 -0
- package/dest/fixtures/setup_p2p_test.d.ts +15 -15
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +96 -31
- 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 +88 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +422 -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 +126 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +375 -0
- package/dest/spartan/utils/nodes.d.ts +41 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -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 +341 -81
- 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 +77 -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/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +260 -39
- 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 +133 -50
- 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 +376 -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 +64 -0
- package/src/spartan/utils/k8s.ts +527 -0
- package/src/spartan/utils/nodes.ts +538 -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/src/fixtures/utils.ts
CHANGED
|
@@ -1,823 +1,30 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
3
|
-
type InitialAccountData,
|
|
4
|
-
deployFundedSchnorrAccounts,
|
|
5
|
-
generateSchnorrAccounts,
|
|
6
|
-
getDeployedTestAccounts,
|
|
7
|
-
getDeployedTestAccountsWallets,
|
|
8
|
-
} from '@aztec/accounts/testing';
|
|
9
|
-
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
10
|
-
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
11
|
-
import {
|
|
12
|
-
type AccountWalletWithSecretKey,
|
|
13
|
-
AnvilTestWatcher,
|
|
14
|
-
type AztecAddress,
|
|
15
|
-
type AztecNode,
|
|
16
|
-
BatchCall,
|
|
17
|
-
CheatCodes,
|
|
18
|
-
type ContractMethod,
|
|
19
|
-
type DeployL1ContractsReturnType,
|
|
20
|
-
FeeJuicePaymentMethod,
|
|
21
|
-
type Logger,
|
|
22
|
-
type PXE,
|
|
23
|
-
SignerlessWallet,
|
|
24
|
-
type Wallet,
|
|
25
|
-
createAztecNodeClient,
|
|
26
|
-
createLogger,
|
|
27
|
-
createPXEClient,
|
|
28
|
-
deployL1Contracts,
|
|
29
|
-
makeFetch,
|
|
30
|
-
waitForPXE,
|
|
31
|
-
} from '@aztec/aztec.js';
|
|
32
|
-
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
|
|
33
|
-
import type { BBNativePrivateKernelProver } from '@aztec/bb-prover';
|
|
34
|
-
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
35
|
-
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
36
|
-
import { FEE_JUICE_INITIAL_MINT, GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
|
|
37
|
-
import {
|
|
38
|
-
type DeployL1ContractsArgs,
|
|
39
|
-
ForwarderContract,
|
|
40
|
-
NULL_KEY,
|
|
41
|
-
createL1Clients,
|
|
42
|
-
getL1ContractsConfigEnvVars,
|
|
43
|
-
isAnvilTestChain,
|
|
44
|
-
l1Artifacts,
|
|
45
|
-
} from '@aztec/ethereum';
|
|
46
|
-
import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
47
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
48
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
49
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
50
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
51
|
-
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
52
|
-
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
53
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
54
|
-
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
55
|
-
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
|
|
56
|
-
import { type PXEService, type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
57
|
-
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
58
|
-
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
59
|
-
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
60
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
61
|
-
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
62
|
-
import {
|
|
63
|
-
type TelemetryClient,
|
|
64
|
-
type TelemetryClientConfig,
|
|
65
|
-
getConfigEnvVars as getTelemetryConfig,
|
|
66
|
-
initTelemetryClient,
|
|
67
|
-
} from '@aztec/telemetry-client';
|
|
68
|
-
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
69
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
70
|
-
|
|
71
|
-
import type { Anvil } from '@viem/anvil';
|
|
72
|
-
import fs from 'fs/promises';
|
|
73
|
-
import getPort from 'get-port';
|
|
74
|
-
import { tmpdir } from 'os';
|
|
75
|
-
import * as path from 'path';
|
|
76
|
-
import { inspect } from 'util';
|
|
77
|
-
import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
|
|
78
|
-
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
79
|
-
import { foundry } from 'viem/chains';
|
|
80
|
-
|
|
81
|
-
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
82
|
-
import { getACVMConfig } from './get_acvm_config.js';
|
|
83
|
-
import { getBBConfig } from './get_bb_config.js';
|
|
84
|
-
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
85
|
-
|
|
86
|
-
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
87
|
-
export { startAnvil };
|
|
88
|
-
|
|
89
|
-
const { PXE_URL = '' } = process.env;
|
|
90
|
-
const getAztecUrl = () => PXE_URL;
|
|
91
|
-
|
|
92
|
-
let telemetry: TelemetryClient | undefined = undefined;
|
|
93
|
-
function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
|
|
94
|
-
if (!telemetry) {
|
|
95
|
-
const config = { ...getTelemetryConfig(), ...partialConfig };
|
|
96
|
-
telemetry = config.benchmark ? new BenchmarkTelemetryClient() : initTelemetryClient(config);
|
|
97
|
-
}
|
|
98
|
-
return telemetry;
|
|
99
|
-
}
|
|
100
|
-
if (typeof afterAll === 'function') {
|
|
101
|
-
afterAll(async () => {
|
|
102
|
-
await telemetry?.stop();
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const getPrivateKeyFromIndex = (index: number): Buffer | null => {
|
|
107
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: index });
|
|
108
|
-
const privKeyRaw = hdAccount.getHdKey().privateKey;
|
|
109
|
-
return privKeyRaw === null ? null : Buffer.from(privKeyRaw);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const setupL1Contracts = async (
|
|
113
|
-
l1RpcUrls: string[],
|
|
114
|
-
account: HDAccount | PrivateKeyAccount,
|
|
115
|
-
logger: Logger,
|
|
116
|
-
args: Partial<DeployL1ContractsArgs> = {},
|
|
117
|
-
chain: Chain = foundry,
|
|
118
|
-
) => {
|
|
119
|
-
const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
|
|
120
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
121
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
122
|
-
protocolContractTreeRoot,
|
|
123
|
-
genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
124
|
-
genesisBlockHash: args.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
|
|
125
|
-
salt: args.salt,
|
|
126
|
-
initialValidators: args.initialValidators,
|
|
127
|
-
...getL1ContractsConfigEnvVars(),
|
|
128
|
-
...args,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
return l1Data;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Sets up Private eXecution Environment (PXE).
|
|
136
|
-
* @param aztecNode - An instance of Aztec Node.
|
|
137
|
-
* @param opts - Partial configuration for the PXE service.
|
|
138
|
-
* @param firstPrivKey - The private key of the first account to be created.
|
|
139
|
-
* @param logger - The logger to be used.
|
|
140
|
-
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
141
|
-
* @param proofCreator - An optional proof creator to use
|
|
142
|
-
* @returns Private eXecution Environment (PXE), accounts, wallets and logger.
|
|
143
|
-
*/
|
|
144
|
-
export async function setupPXEService(
|
|
145
|
-
aztecNode: AztecNode,
|
|
146
|
-
opts: Partial<PXEServiceConfig> = {},
|
|
147
|
-
logger = getLogger(),
|
|
148
|
-
useLogSuffix = false,
|
|
149
|
-
proofCreator?: BBNativePrivateKernelProver,
|
|
150
|
-
): Promise<{
|
|
151
|
-
/**
|
|
152
|
-
* The PXE instance.
|
|
153
|
-
*/
|
|
154
|
-
pxe: PXEService;
|
|
155
|
-
/**
|
|
156
|
-
* Logger instance named as the current test.
|
|
157
|
-
*/
|
|
158
|
-
logger: Logger;
|
|
159
|
-
/**
|
|
160
|
-
* Teardown function
|
|
161
|
-
*/
|
|
162
|
-
teardown: () => Promise<void>;
|
|
163
|
-
}> {
|
|
164
|
-
const pxeServiceConfig = { ...getPXEServiceConfig(), ...opts };
|
|
165
|
-
|
|
166
|
-
// If no data directory provided, create a temp directory and clean up afterwards
|
|
167
|
-
const configuredDataDirectory = pxeServiceConfig.dataDirectory;
|
|
168
|
-
if (!configuredDataDirectory) {
|
|
169
|
-
pxeServiceConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const pxe = await createPXEService(aztecNode, pxeServiceConfig, useLogSuffix, proofCreator);
|
|
173
|
-
|
|
174
|
-
const teardown = async () => {
|
|
175
|
-
if (!configuredDataDirectory) {
|
|
176
|
-
try {
|
|
177
|
-
await fs.rm(pxeServiceConfig.dataDirectory!, { recursive: true, force: true, maxRetries: 3 });
|
|
178
|
-
} catch (err) {
|
|
179
|
-
logger.warn(`Failed to delete tmp PXE data directory ${pxeServiceConfig.dataDirectory}: ${err}`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
pxe,
|
|
186
|
-
logger,
|
|
187
|
-
teardown,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Function to setup the test against a remote deployment. It is assumed that L1 contract are already deployed
|
|
193
|
-
* @param account - The account for use in create viem wallets.
|
|
194
|
-
* @param config - The aztec Node Configuration
|
|
195
|
-
* @param logger - The logger to be used
|
|
196
|
-
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
197
|
-
* (will create extra accounts if the environment doesn't already have enough accounts)
|
|
198
|
-
* @returns Private eXecution Environment (PXE) client, viem wallets, contract addresses etc.
|
|
199
|
-
*/
|
|
200
|
-
async function setupWithRemoteEnvironment(
|
|
201
|
-
account: HDAccount | PrivateKeyAccount,
|
|
202
|
-
config: AztecNodeConfig,
|
|
203
|
-
logger: Logger,
|
|
204
|
-
numberOfAccounts: number,
|
|
205
|
-
) {
|
|
206
|
-
// we are setting up against a remote environment, l1 contracts are already deployed
|
|
207
|
-
const aztecNodeUrl = getAztecUrl();
|
|
208
|
-
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
209
|
-
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
210
|
-
logger.verbose(`Creating PXE client to remote host ${PXE_URL}`);
|
|
211
|
-
const pxeClient = createPXEClient(PXE_URL, {}, makeFetch([1, 2, 3], true));
|
|
212
|
-
await waitForPXE(pxeClient, logger);
|
|
213
|
-
logger.verbose('JSON RPC client connected to PXE');
|
|
214
|
-
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
|
|
215
|
-
const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses;
|
|
216
|
-
|
|
217
|
-
const { walletClient, publicClient } = createL1Clients(config.l1RpcUrls, account, foundry);
|
|
218
|
-
|
|
219
|
-
const deployL1ContractsValues: DeployL1ContractsReturnType = {
|
|
220
|
-
l1ContractAddresses: l1Contracts,
|
|
221
|
-
walletClient,
|
|
222
|
-
publicClient,
|
|
223
|
-
};
|
|
224
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
|
|
225
|
-
const teardown = () => Promise.resolve();
|
|
226
|
-
|
|
227
|
-
await setupCanonicalFeeJuice(pxeClient);
|
|
228
|
-
|
|
229
|
-
logger.verbose('Constructing available wallets from already registered accounts...');
|
|
230
|
-
const initialFundedAccounts = await getDeployedTestAccounts(pxeClient);
|
|
231
|
-
const wallets = await getDeployedTestAccountsWallets(pxeClient);
|
|
232
|
-
|
|
233
|
-
if (wallets.length < numberOfAccounts) {
|
|
234
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
|
|
235
|
-
// Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return {
|
|
239
|
-
aztecNode,
|
|
240
|
-
sequencer: undefined,
|
|
241
|
-
proverNode: undefined,
|
|
242
|
-
pxe: pxeClient,
|
|
243
|
-
deployL1ContractsValues,
|
|
244
|
-
accounts: await pxeClient!.getRegisteredAccounts(),
|
|
245
|
-
config,
|
|
246
|
-
initialFundedAccounts,
|
|
247
|
-
wallet: wallets[0],
|
|
248
|
-
wallets: wallets.slice(0, numberOfAccounts),
|
|
249
|
-
logger,
|
|
250
|
-
cheatCodes,
|
|
251
|
-
watcher: undefined,
|
|
252
|
-
dateProvider: undefined,
|
|
253
|
-
blobSink: undefined,
|
|
254
|
-
telemetryClient: undefined,
|
|
255
|
-
teardown,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/** Options for the e2e tests setup */
|
|
260
|
-
export type SetupOptions = {
|
|
261
|
-
/** State load */
|
|
262
|
-
stateLoad?: string;
|
|
263
|
-
/** Whether to enable metrics collection, if undefined, metrics collection is disabled */
|
|
264
|
-
metricsPort?: number | undefined;
|
|
265
|
-
/** Previously deployed contracts on L1 */
|
|
266
|
-
deployL1ContractsValues?: DeployL1ContractsReturnType;
|
|
267
|
-
/** Whether to skip deployment of protocol contracts (auth registry, etc) */
|
|
268
|
-
skipProtocolContracts?: boolean;
|
|
269
|
-
/** Initial fee juice for default accounts */
|
|
270
|
-
initialAccountFeeJuice?: Fr;
|
|
271
|
-
/** Number of initial accounts funded with fee juice */
|
|
272
|
-
numberOfInitialFundedAccounts?: number;
|
|
273
|
-
/** Data of the initial funded accounts */
|
|
274
|
-
initialFundedAccounts?: InitialAccountData[];
|
|
275
|
-
/** Salt to use in L1 contract deployment */
|
|
276
|
-
salt?: number;
|
|
277
|
-
/** An initial set of validators */
|
|
278
|
-
initialValidators?: EthAddress[];
|
|
279
|
-
/** Anvil Start time */
|
|
280
|
-
l1StartTime?: number;
|
|
281
|
-
/** The anvil time where we should at the earliest be seeing L2 blocks */
|
|
282
|
-
l2StartTime?: number;
|
|
283
|
-
/** Whether to start a prover node */
|
|
284
|
-
startProverNode?: boolean;
|
|
285
|
-
/** Whether to fund the rewardDistributor */
|
|
286
|
-
fundRewardDistributor?: boolean;
|
|
287
|
-
/** Manual config for the telemetry client */
|
|
288
|
-
telemetryConfig?: Partial<TelemetryClientConfig> & { benchmark?: boolean };
|
|
289
|
-
/** Public data that will be inserted in the tree in genesis */
|
|
290
|
-
genesisPublicData?: PublicDataTreeLeaf[];
|
|
291
|
-
} & Partial<AztecNodeConfig>;
|
|
292
|
-
|
|
293
|
-
/** Context for an end-to-end test as returned by the `setup` function */
|
|
294
|
-
export type EndToEndContext = {
|
|
295
|
-
/** The Aztec Node service or client a connected to it. */
|
|
296
|
-
aztecNode: AztecNode;
|
|
297
|
-
/** The prover node service (only set if startProverNode is true) */
|
|
298
|
-
proverNode: ProverNode | undefined;
|
|
299
|
-
/** A client to the sequencer service (undefined if connected to remote environment) */
|
|
300
|
-
sequencer: SequencerClient | undefined;
|
|
301
|
-
/** The Private eXecution Environment (PXE). */
|
|
302
|
-
pxe: PXE;
|
|
303
|
-
/** Return values from deployL1Contracts function. */
|
|
304
|
-
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
305
|
-
/** The Aztec Node configuration. */
|
|
306
|
-
config: AztecNodeConfig;
|
|
307
|
-
/** The data for the initial funded accounts. */
|
|
308
|
-
initialFundedAccounts: InitialAccountData[];
|
|
309
|
-
/** The first wallet to be used. */
|
|
310
|
-
wallet: AccountWalletWithSecretKey;
|
|
311
|
-
/** The wallets to be used. */
|
|
312
|
-
wallets: AccountWalletWithSecretKey[];
|
|
313
|
-
/** Logger instance named as the current test. */
|
|
314
|
-
logger: Logger;
|
|
315
|
-
/** The cheat codes. */
|
|
316
|
-
cheatCodes: CheatCodes;
|
|
317
|
-
/** The anvil test watcher (undefined if connected to remote environment) */
|
|
318
|
-
watcher: AnvilTestWatcher | undefined;
|
|
319
|
-
/** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
|
|
320
|
-
dateProvider: TestDateProvider | undefined;
|
|
321
|
-
/** The blob sink (undefined if connected to remote environment) */
|
|
322
|
-
blobSink: BlobSinkServer | undefined;
|
|
323
|
-
/** Telemetry client */
|
|
324
|
-
telemetryClient: TelemetryClient | undefined;
|
|
325
|
-
/** Function to stop the started services. */
|
|
326
|
-
teardown: () => Promise<void>;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Sets up the environment for the end-to-end tests.
|
|
331
|
-
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
332
|
-
* @param opts - Options to pass to the node initialization and to the setup script.
|
|
333
|
-
* @param pxeOpts - Options to pass to the PXE initialization.
|
|
334
|
-
*/
|
|
335
|
-
export async function setup(
|
|
336
|
-
numberOfAccounts = 1,
|
|
337
|
-
opts: SetupOptions = {
|
|
338
|
-
customForwarderContractAddress: EthAddress.ZERO,
|
|
339
|
-
},
|
|
340
|
-
pxeOpts: Partial<PXEServiceConfig> = {},
|
|
341
|
-
chain: Chain = foundry,
|
|
342
|
-
): Promise<EndToEndContext> {
|
|
343
|
-
const config = { ...getConfigEnvVars(), ...opts };
|
|
344
|
-
config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
345
|
-
|
|
346
|
-
const logger = getLogger();
|
|
347
|
-
|
|
348
|
-
// Create a temp directory for any services that need it and cleanup later
|
|
349
|
-
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
350
|
-
await fs.mkdir(directoryToCleanup, { recursive: true });
|
|
351
|
-
if (!config.dataDirectory) {
|
|
352
|
-
config.dataDirectory = directoryToCleanup;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
let anvil: Anvil | undefined;
|
|
356
|
-
|
|
357
|
-
if (!config.l1RpcUrls?.length) {
|
|
358
|
-
if (!isAnvilTestChain(chain.id)) {
|
|
359
|
-
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
360
|
-
}
|
|
361
|
-
if (PXE_URL) {
|
|
362
|
-
throw new Error(
|
|
363
|
-
`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`,
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
368
|
-
anvil = res.anvil;
|
|
369
|
-
config.l1RpcUrls = [res.rpcUrl];
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Enable logging metrics to a local file named after the test suite
|
|
373
|
-
if (isMetricsLoggingRequested()) {
|
|
374
|
-
const filename = path.join('log', getJobName() + '.jsonl');
|
|
375
|
-
logger.info(`Logging metrics to ${filename}`);
|
|
376
|
-
setupMetricsLogger(filename);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
|
|
380
|
-
|
|
381
|
-
if (opts.stateLoad) {
|
|
382
|
-
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (opts.l1StartTime) {
|
|
386
|
-
await ethCheatCodes.warp(opts.l1StartTime);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
let publisherPrivKey = undefined;
|
|
390
|
-
let publisherHdAccount = undefined;
|
|
391
|
-
|
|
392
|
-
if (config.publisherPrivateKey && config.publisherPrivateKey != NULL_KEY) {
|
|
393
|
-
publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey);
|
|
394
|
-
} else if (!MNEMONIC) {
|
|
395
|
-
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
396
|
-
} else {
|
|
397
|
-
publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
398
|
-
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
399
|
-
publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
400
|
-
config.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// Made as separate values such that keys can change, but for test they will be the same.
|
|
404
|
-
config.validatorPrivateKey = config.publisherPrivateKey;
|
|
405
|
-
|
|
406
|
-
if (PXE_URL) {
|
|
407
|
-
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
408
|
-
return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Blob sink service - blobs get posted here and served from here
|
|
412
|
-
const blobSinkPort = await getPort();
|
|
413
|
-
const blobSink = await createBlobSinkServer({ port: blobSinkPort });
|
|
414
|
-
await blobSink.start();
|
|
415
|
-
config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
416
|
-
|
|
417
|
-
const initialFundedAccounts =
|
|
418
|
-
opts.initialFundedAccounts ??
|
|
419
|
-
(await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
|
|
420
|
-
const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(
|
|
421
|
-
initialFundedAccounts.map(a => a.address),
|
|
422
|
-
opts.initialAccountFeeJuice,
|
|
423
|
-
opts.genesisPublicData,
|
|
424
|
-
);
|
|
425
|
-
|
|
426
|
-
const deployL1ContractsValues =
|
|
427
|
-
opts.deployL1ContractsValues ??
|
|
428
|
-
(await setupL1Contracts(
|
|
429
|
-
config.l1RpcUrls,
|
|
430
|
-
publisherHdAccount!,
|
|
431
|
-
logger,
|
|
432
|
-
{ ...opts, genesisArchiveRoot, genesisBlockHash },
|
|
433
|
-
chain,
|
|
434
|
-
));
|
|
435
|
-
|
|
436
|
-
config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
437
|
-
|
|
438
|
-
if (opts.fundRewardDistributor) {
|
|
439
|
-
// Mints block rewards for 10000 blocks to the rewardDistributor contract
|
|
440
|
-
|
|
441
|
-
const rewardDistributor = getContract({
|
|
442
|
-
address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
443
|
-
abi: l1Artifacts.rewardDistributor.contractAbi,
|
|
444
|
-
client: deployL1ContractsValues.publicClient,
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
const blockReward = await rewardDistributor.read.BLOCK_REWARD();
|
|
448
|
-
const mintAmount = 10_000n * (blockReward as bigint);
|
|
449
|
-
|
|
450
|
-
const feeJuice = getContract({
|
|
451
|
-
address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
452
|
-
abi: l1Artifacts.feeAsset.contractAbi,
|
|
453
|
-
client: deployL1ContractsValues.walletClient,
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
|
|
457
|
-
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
|
|
458
|
-
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
if (opts.l2StartTime) {
|
|
462
|
-
// This should only be used in synching test or when you need to have a stable
|
|
463
|
-
// timestamp for the first l2 block.
|
|
464
|
-
await ethCheatCodes.warp(opts.l2StartTime);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const dateProvider = new TestDateProvider();
|
|
468
|
-
|
|
469
|
-
const watcher = new AnvilTestWatcher(
|
|
470
|
-
new EthCheatCodesWithState(config.l1RpcUrls),
|
|
471
|
-
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
472
|
-
deployL1ContractsValues.publicClient,
|
|
473
|
-
dateProvider,
|
|
474
|
-
);
|
|
475
|
-
|
|
476
|
-
await watcher.start();
|
|
477
|
-
|
|
478
|
-
logger.verbose('Creating and synching an aztec node...');
|
|
479
|
-
|
|
480
|
-
const acvmConfig = await getACVMConfig(logger);
|
|
481
|
-
if (acvmConfig) {
|
|
482
|
-
config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
483
|
-
config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
const bbConfig = await getBBConfig(logger);
|
|
487
|
-
if (bbConfig) {
|
|
488
|
-
config.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
489
|
-
config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
490
|
-
}
|
|
491
|
-
config.l1PublishRetryIntervalMS = 100;
|
|
492
|
-
|
|
493
|
-
const telemetry = getTelemetryClient(opts.telemetryConfig);
|
|
494
|
-
|
|
495
|
-
const blobSinkClient = createBlobSinkClient(config);
|
|
496
|
-
const aztecNode = await AztecNodeService.createAndSync(
|
|
497
|
-
config,
|
|
498
|
-
{
|
|
499
|
-
dateProvider,
|
|
500
|
-
blobSinkClient,
|
|
501
|
-
},
|
|
502
|
-
{ prefilledPublicData },
|
|
503
|
-
);
|
|
504
|
-
const sequencer = aztecNode.getSequencer();
|
|
505
|
-
|
|
506
|
-
if (sequencer) {
|
|
507
|
-
const publisher = (sequencer as TestSequencerClient).sequencer.publisher;
|
|
508
|
-
publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
let proverNode: ProverNode | undefined = undefined;
|
|
512
|
-
if (opts.startProverNode) {
|
|
513
|
-
logger.verbose('Creating and syncing a simulated prover node...');
|
|
514
|
-
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
515
|
-
const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
|
|
516
|
-
proverNode = await createAndSyncProverNode(
|
|
517
|
-
proverNodePrivateKeyHex,
|
|
518
|
-
config,
|
|
519
|
-
aztecNode,
|
|
520
|
-
path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
logger.verbose('Creating a pxe...');
|
|
525
|
-
const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger);
|
|
526
|
-
|
|
527
|
-
if (!config.skipProtocolContracts) {
|
|
528
|
-
logger.verbose('Setting up Fee Juice...');
|
|
529
|
-
await setupCanonicalFeeJuice(pxe);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
|
|
533
|
-
const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
|
|
534
|
-
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
535
|
-
// TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
|
|
536
|
-
throw new Error(
|
|
537
|
-
`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!);
|
|
542
|
-
|
|
543
|
-
const teardown = async () => {
|
|
544
|
-
await pxeTeardown();
|
|
545
|
-
|
|
546
|
-
if (aztecNode instanceof AztecNodeService) {
|
|
547
|
-
await aztecNode?.stop();
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (proverNode) {
|
|
551
|
-
await proverNode.stop();
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (acvmConfig?.cleanup) {
|
|
555
|
-
// remove the temp directory created for the acvm
|
|
556
|
-
logger.verbose(`Cleaning up ACVM state`);
|
|
557
|
-
await acvmConfig.cleanup();
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
if (bbConfig?.cleanup) {
|
|
561
|
-
// remove the temp directory created for the acvm
|
|
562
|
-
logger.verbose(`Cleaning up BB state`);
|
|
563
|
-
await bbConfig.cleanup();
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
await anvil?.stop().catch(err => getLogger().error(err));
|
|
567
|
-
await watcher.stop();
|
|
568
|
-
await blobSink?.stop();
|
|
569
|
-
|
|
570
|
-
if (directoryToCleanup) {
|
|
571
|
-
try {
|
|
572
|
-
logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
|
|
573
|
-
await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
|
|
574
|
-
} catch (err) {
|
|
575
|
-
logger.warn(`Failed to delete data directory at ${directoryToCleanup}: ${err}`);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
return {
|
|
581
|
-
aztecNode,
|
|
582
|
-
blobSink,
|
|
583
|
-
cheatCodes,
|
|
584
|
-
config,
|
|
585
|
-
dateProvider,
|
|
586
|
-
deployL1ContractsValues,
|
|
587
|
-
initialFundedAccounts,
|
|
588
|
-
logger,
|
|
589
|
-
proverNode,
|
|
590
|
-
pxe,
|
|
591
|
-
sequencer,
|
|
592
|
-
teardown,
|
|
593
|
-
telemetryClient: telemetry,
|
|
594
|
-
wallet: wallets[0],
|
|
595
|
-
wallets,
|
|
596
|
-
watcher,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
602
|
-
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
603
|
-
* @param sender - Wallet to send the deployment tx.
|
|
604
|
-
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
605
|
-
*/
|
|
606
|
-
|
|
607
|
-
// docs:start:public_deploy_accounts
|
|
608
|
-
export async function ensureAccountsPubliclyDeployed(sender: Wallet, accountsToDeploy: Wallet[]) {
|
|
609
|
-
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
610
|
-
// the sandbox and the test accounts exist
|
|
611
|
-
const accountsAndAddresses = await Promise.all(
|
|
612
|
-
accountsToDeploy.map(async account => {
|
|
613
|
-
const address = account.getAddress();
|
|
614
|
-
return {
|
|
615
|
-
address,
|
|
616
|
-
deployed: (await sender.getContractMetadata(address)).isContractPubliclyDeployed,
|
|
617
|
-
};
|
|
618
|
-
}),
|
|
619
|
-
);
|
|
620
|
-
const instances = (
|
|
621
|
-
await Promise.all(
|
|
622
|
-
accountsAndAddresses
|
|
623
|
-
.filter(({ deployed }) => !deployed)
|
|
624
|
-
.map(({ address }) => sender.getContractMetadata(address)),
|
|
625
|
-
)
|
|
626
|
-
).map(contractMetadata => contractMetadata.contractInstance);
|
|
627
|
-
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
628
|
-
if (!(await sender.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
629
|
-
await (await registerContractClass(sender, SchnorrAccountContractArtifact)).send().wait();
|
|
630
|
-
}
|
|
631
|
-
const requests = await Promise.all(
|
|
632
|
-
instances.map(async instance => (await deployInstance(sender, instance!)).request()),
|
|
633
|
-
);
|
|
634
|
-
const batch = new BatchCall(sender, [...requests]);
|
|
635
|
-
await batch.send().wait();
|
|
636
|
-
}
|
|
637
|
-
// docs:end:public_deploy_accounts
|
|
638
|
-
|
|
639
1
|
/**
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
* @param timestamp - the timestamp for the next block
|
|
2
|
+
* Re-exports from the unified setup module for backward compatibility.
|
|
3
|
+
* Tests that previously used utils.ts should continue to work.
|
|
643
4
|
*/
|
|
644
|
-
export
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
5
|
+
export {
|
|
6
|
+
type BalancesFn,
|
|
7
|
+
type EndToEndContext,
|
|
8
|
+
type SetupOptions,
|
|
9
|
+
createAndSyncProverNode,
|
|
10
|
+
deployAccounts,
|
|
11
|
+
ensureAccountContractsPublished,
|
|
12
|
+
expectMapping,
|
|
13
|
+
expectMappingDelta,
|
|
14
|
+
getBalancesFn,
|
|
15
|
+
getLogger,
|
|
16
|
+
getPrivateKeyFromIndex,
|
|
17
|
+
getSponsoredFPCAddress,
|
|
18
|
+
getSponsoredFPCInstance,
|
|
19
|
+
publicDeployAccounts,
|
|
20
|
+
registerSponsoredFPC,
|
|
21
|
+
setup,
|
|
22
|
+
setupPXEAndGetWallet,
|
|
23
|
+
setupSharedBlobStorage,
|
|
24
|
+
setupSponsoredFPC,
|
|
25
|
+
startAnvil,
|
|
26
|
+
teardown,
|
|
27
|
+
waitForProvenChain,
|
|
28
|
+
} from './setup.js';
|
|
652
29
|
|
|
653
|
-
|
|
654
|
-
function getJobName() {
|
|
655
|
-
return process.env.JOB_NAME ?? expect.getState().currentTestName?.split(' ')[0].replaceAll('/', '_') ?? 'unknown';
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
/**
|
|
659
|
-
* Returns a logger instance for the current test.
|
|
660
|
-
* @returns a logger instance for the current test.
|
|
661
|
-
*/
|
|
662
|
-
export function getLogger() {
|
|
663
|
-
const describeBlockName = expect.getState().currentTestName?.split(' ')[0].replaceAll('/', ':');
|
|
664
|
-
if (!describeBlockName) {
|
|
665
|
-
const name = expect.getState().testPath?.split('/').pop()?.split('.')[0] ?? 'unknown';
|
|
666
|
-
return createLogger('e2e:' + name);
|
|
667
|
-
}
|
|
668
|
-
return createLogger('e2e:' + describeBlockName);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
export type BalancesFn = ReturnType<typeof getBalancesFn>;
|
|
672
|
-
export function getBalancesFn(
|
|
673
|
-
symbol: string,
|
|
674
|
-
method: ContractMethod,
|
|
675
|
-
logger: any,
|
|
676
|
-
): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
|
|
677
|
-
const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
|
|
678
|
-
const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
|
|
679
|
-
const b = await Promise.all(addresses.map(address => method(address).simulate()));
|
|
680
|
-
const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
|
|
681
|
-
logger.verbose(debugString);
|
|
682
|
-
return b;
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
return balances;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
export async function expectMapping<K, V>(
|
|
689
|
-
fn: (...k: K[]) => Promise<V[]>,
|
|
690
|
-
inputs: K[],
|
|
691
|
-
expectedOutputs: V[],
|
|
692
|
-
): Promise<void> {
|
|
693
|
-
expect(inputs.length).toBe(expectedOutputs.length);
|
|
694
|
-
|
|
695
|
-
const outputs = await fn(...inputs);
|
|
696
|
-
|
|
697
|
-
expect(outputs).toEqual(expectedOutputs);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
export async function expectMappingDelta<K, V extends number | bigint>(
|
|
701
|
-
initialValues: V[],
|
|
702
|
-
fn: (...k: K[]) => Promise<V[]>,
|
|
703
|
-
inputs: K[],
|
|
704
|
-
expectedDiffs: V[],
|
|
705
|
-
): Promise<void> {
|
|
706
|
-
expect(inputs.length).toBe(expectedDiffs.length);
|
|
707
|
-
|
|
708
|
-
const outputs = await fn(...inputs);
|
|
709
|
-
const diffs = outputs.map((output, i) => output - initialValues[i]);
|
|
710
|
-
|
|
711
|
-
expect(diffs).toEqual(expectedDiffs);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
/**
|
|
715
|
-
* Deploy the protocol contracts to a running instance.
|
|
716
|
-
*/
|
|
717
|
-
export async function setupCanonicalFeeJuice(pxe: PXE) {
|
|
718
|
-
// "deploy" the Fee Juice as it contains public functions
|
|
719
|
-
const feeJuicePortalAddress = (await pxe.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
|
|
720
|
-
const wallet = new SignerlessWallet(pxe);
|
|
721
|
-
const feeJuice = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
|
|
722
|
-
|
|
723
|
-
try {
|
|
724
|
-
const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
|
|
725
|
-
await feeJuice.methods
|
|
726
|
-
.initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT)
|
|
727
|
-
.send({ fee: { paymentMethod, gasSettings: { teardownGasLimits: Gas.empty() } } })
|
|
728
|
-
.wait();
|
|
729
|
-
getLogger().info(`Fee Juice successfully setup. Portal address: ${feeJuicePortalAddress}`);
|
|
730
|
-
} catch (error) {
|
|
731
|
-
getLogger().warn(`Fee Juice might have already been setup. Got error: ${inspect(error)}.`);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) {
|
|
736
|
-
targetBlock ??= await node.getBlockNumber();
|
|
737
|
-
|
|
738
|
-
await retryUntil(
|
|
739
|
-
async () => (await node.getProvenBlockNumber()) >= targetBlock,
|
|
740
|
-
'proven chain status',
|
|
741
|
-
timeoutSec,
|
|
742
|
-
intervalSec,
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
export async function createAndSyncProverNode(
|
|
747
|
-
proverNodePrivateKey: `0x${string}`,
|
|
748
|
-
aztecNodeConfig: AztecNodeConfig,
|
|
749
|
-
aztecNode: AztecNode,
|
|
750
|
-
dataDirectory: string,
|
|
751
|
-
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
752
|
-
) {
|
|
753
|
-
// Disable stopping the aztec node as the prover coordination test will kill it otherwise
|
|
754
|
-
// This is only required when stopping the prover node for testing
|
|
755
|
-
const aztecNodeWithoutStop = {
|
|
756
|
-
getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
|
|
757
|
-
getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
|
|
758
|
-
stop: () => Promise.resolve(),
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
const blobSinkClient = createBlobSinkClient(aztecNodeConfig);
|
|
762
|
-
// Creating temp store and archiver for simulated prover node
|
|
763
|
-
const archiverConfig = { ...aztecNodeConfig, dataDirectory };
|
|
764
|
-
const archiver = await createArchiver(archiverConfig, blobSinkClient, {
|
|
765
|
-
blockUntilSync: true,
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
// Prover node config is for simulated proofs
|
|
769
|
-
const proverConfig: ProverNodeConfig = {
|
|
770
|
-
...aztecNodeConfig,
|
|
771
|
-
proverCoordinationNodeUrl: undefined,
|
|
772
|
-
dataDirectory: undefined,
|
|
773
|
-
realProofs: false,
|
|
774
|
-
proverAgentCount: 2,
|
|
775
|
-
publisherPrivateKey: proverNodePrivateKey,
|
|
776
|
-
proverNodeMaxPendingJobs: 10,
|
|
777
|
-
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
778
|
-
proverNodePollingIntervalMs: 200,
|
|
779
|
-
txGatheringTimeoutMs: 60000,
|
|
780
|
-
txGatheringIntervalMs: 1000,
|
|
781
|
-
txGatheringMaxParallelRequests: 100,
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node');
|
|
785
|
-
|
|
786
|
-
const proverNode = await createProverNode(
|
|
787
|
-
proverConfig,
|
|
788
|
-
{
|
|
789
|
-
aztecNodeTxProvider: aztecNodeWithoutStop,
|
|
790
|
-
archiver: archiver as Archiver,
|
|
791
|
-
l1TxUtils,
|
|
792
|
-
},
|
|
793
|
-
{ prefilledPublicData },
|
|
794
|
-
);
|
|
795
|
-
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.walletClient.account.address });
|
|
796
|
-
proverNode.start();
|
|
797
|
-
return proverNode;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
function createDelayedL1TxUtils(aztecNodeConfig: AztecNodeConfig, privateKey: `0x${string}`, logName: string) {
|
|
801
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
802
|
-
|
|
803
|
-
const log = createLogger(logName);
|
|
804
|
-
const l1TxUtils = new DelayedTxUtils(publicClient, walletClient, log, aztecNodeConfig);
|
|
805
|
-
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
806
|
-
return l1TxUtils;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
export async function createForwarderContract(
|
|
810
|
-
aztecNodeConfig: AztecNodeConfig,
|
|
811
|
-
privateKey: `0x${string}`,
|
|
812
|
-
rollupAddress: Hex,
|
|
813
|
-
) {
|
|
814
|
-
const { walletClient, publicClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
815
|
-
const forwarderContract = await ForwarderContract.create(
|
|
816
|
-
walletClient.account.address,
|
|
817
|
-
walletClient,
|
|
818
|
-
publicClient,
|
|
819
|
-
createLogger('forwarder'),
|
|
820
|
-
rollupAddress,
|
|
821
|
-
);
|
|
822
|
-
return forwarderContract;
|
|
823
|
-
}
|
|
30
|
+
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|