@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.1142ef1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bench/client_flows/benchmark.d.ts +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +336 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +79 -0
- package/dest/bench/utils.d.ts +14 -40
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +37 -70
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +29 -28
- 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 +79 -82
- package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +65 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +233 -49
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +63 -0
- package/dest/e2e_fees/fees_test.d.ts +27 -12
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +107 -110
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +55 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +10 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +276 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +188 -133
- package/dest/e2e_p2p/shared.d.ts +43 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +164 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/fixtures/e2e_prover_test.d.ts +61 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +108 -113
- package/dest/fixtures/fixtures.d.ts +6 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +5 -5
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +3 -15
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +82 -22
- package/dest/fixtures/snapshot_manager.d.ts +20 -14
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -138
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +28 -12
- package/dest/fixtures/utils.d.ts +92 -54
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +452 -389
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/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/shared/cross_chain_test_harness.d.ts +42 -35
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +106 -52
- package/dest/shared/gas_portal_test_harness.d.ts +29 -31
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +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 +8 -7
- 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 +170 -120
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -11
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +16 -17
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +27 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +202 -58
- package/dest/spartan/tx_metrics.d.ts +39 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +95 -0
- package/dest/spartan/utils.d.ts +151 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +598 -151
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +450 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +35 -81
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +103 -122
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +299 -65
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +150 -142
- package/src/e2e_l1_publisher/write_json.ts +74 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +29 -19
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +274 -171
- package/src/e2e_p2p/shared.ts +252 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +112 -160
- package/src/fixtures/fixtures.ts +5 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup_p2p_test.ts +127 -39
- package/src/fixtures/snapshot_manager.ts +189 -160
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +556 -475
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/shared/cross_chain_test_harness.ts +113 -87
- 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 +12 -8
- package/src/shared/uniswap_l1_l2.ts +194 -211
- package/src/simulators/lending_simulator.ts +15 -16
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +258 -93
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +722 -146
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
- package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.js +0 -17
- package/dest/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/fixtures/setup_l1_contracts.ts +0 -27
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
package/src/fixtures/utils.ts
CHANGED
|
@@ -1,63 +1,60 @@
|
|
|
1
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';
|
|
2
|
+
import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
9
3
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
10
4
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
6
|
+
import { BatchCall, type ContractMethod } from '@aztec/aztec.js/contracts';
|
|
7
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
9
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
10
|
+
import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
|
|
11
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
12
|
+
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
13
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
14
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
15
|
+
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
16
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
17
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
18
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
11
19
|
import {
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
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';
|
|
20
|
+
type DeployAztecL1ContractsReturnType,
|
|
21
|
+
type Operator,
|
|
22
|
+
type ZKPassportArgs,
|
|
23
|
+
deployAztecL1Contracts,
|
|
24
|
+
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
37
25
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} from '@aztec/
|
|
46
|
-
import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
47
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
26
|
+
DelayedTxUtils,
|
|
27
|
+
EthCheatCodes,
|
|
28
|
+
EthCheatCodesWithState,
|
|
29
|
+
createDelayedL1TxUtilsFromViemWallet,
|
|
30
|
+
startAnvil,
|
|
31
|
+
} from '@aztec/ethereum/test';
|
|
32
|
+
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
33
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
48
34
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
49
|
-
import {
|
|
35
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
36
|
+
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
50
37
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
38
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
39
|
+
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
40
|
+
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
41
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
53
42
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
43
|
+
import type { P2PClientDeps } from '@aztec/p2p';
|
|
44
|
+
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
45
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
46
|
+
import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
47
|
+
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
|
|
57
48
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
58
49
|
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
59
|
-
import {
|
|
60
|
-
|
|
50
|
+
import {
|
|
51
|
+
type ContractInstanceWithAddress,
|
|
52
|
+
getContractClassFromArtifact,
|
|
53
|
+
getContractInstanceFromInstantiationParams,
|
|
54
|
+
} from '@aztec/stdlib/contract';
|
|
55
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
56
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
57
|
+
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
61
58
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
62
59
|
import {
|
|
63
60
|
type TelemetryClient,
|
|
@@ -66,17 +63,23 @@ import {
|
|
|
66
63
|
initTelemetryClient,
|
|
67
64
|
} from '@aztec/telemetry-client';
|
|
68
65
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
66
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
69
67
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
70
68
|
|
|
71
69
|
import type { Anvil } from '@viem/anvil';
|
|
70
|
+
import { randomBytes } from 'crypto';
|
|
72
71
|
import fs from 'fs/promises';
|
|
73
|
-
import getPort from 'get-port';
|
|
74
72
|
import { tmpdir } from 'os';
|
|
75
73
|
import * as path from 'path';
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
import type { Hex } from 'viem';
|
|
75
|
+
import {
|
|
76
|
+
type HDAccount,
|
|
77
|
+
type PrivateKeyAccount,
|
|
78
|
+
generatePrivateKey,
|
|
79
|
+
mnemonicToAccount,
|
|
80
|
+
privateKeyToAccount,
|
|
81
|
+
} from 'viem/accounts';
|
|
82
|
+
import { type Chain, foundry } from 'viem/chains';
|
|
80
83
|
|
|
81
84
|
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
82
85
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
@@ -86,14 +89,24 @@ import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
|
86
89
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
87
90
|
export { startAnvil };
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Sets up shared blob storage using FileStore in the data directory.
|
|
94
|
+
*/
|
|
95
|
+
export async function setupSharedBlobStorage(config: { dataDirectory?: string } & Record<string, any>): Promise<void> {
|
|
96
|
+
const sharedBlobPath = path.join(config.dataDirectory!, 'shared-blobs');
|
|
97
|
+
await fs.mkdir(sharedBlobPath, { recursive: true });
|
|
98
|
+
config.blobFileStoreUrls = [`file://${sharedBlobPath}`];
|
|
99
|
+
config.blobFileStoreUploadUrl = `file://${sharedBlobPath}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const { AZTEC_NODE_URL = '' } = process.env;
|
|
103
|
+
const getAztecUrl = () => AZTEC_NODE_URL;
|
|
91
104
|
|
|
92
105
|
let telemetry: TelemetryClient | undefined = undefined;
|
|
93
|
-
function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
|
|
106
|
+
async function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
|
|
94
107
|
if (!telemetry) {
|
|
95
108
|
const config = { ...getTelemetryConfig(), ...partialConfig };
|
|
96
|
-
telemetry = config.benchmark ? new BenchmarkTelemetryClient() : initTelemetryClient(config);
|
|
109
|
+
telemetry = config.benchmark ? new BenchmarkTelemetryClient() : await initTelemetryClient(config);
|
|
97
110
|
}
|
|
98
111
|
return telemetry;
|
|
99
112
|
}
|
|
@@ -109,49 +122,24 @@ export const getPrivateKeyFromIndex = (index: number): Buffer | null => {
|
|
|
109
122
|
return privKeyRaw === null ? null : Buffer.from(privKeyRaw);
|
|
110
123
|
};
|
|
111
124
|
|
|
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
125
|
/**
|
|
135
|
-
* Sets up Private eXecution Environment (PXE).
|
|
126
|
+
* Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
|
|
136
127
|
* @param aztecNode - An instance of Aztec Node.
|
|
137
|
-
* @param opts - Partial configuration for the PXE
|
|
138
|
-
* @param firstPrivKey - The private key of the first account to be created.
|
|
128
|
+
* @param opts - Partial configuration for the PXE.
|
|
139
129
|
* @param logger - The logger to be used.
|
|
140
130
|
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
141
|
-
* @
|
|
142
|
-
* @returns Private eXecution Environment (PXE), accounts, wallets and logger.
|
|
131
|
+
* @returns A test wallet, logger and teardown function.
|
|
143
132
|
*/
|
|
144
|
-
export async function
|
|
133
|
+
export async function setupPXEAndGetWallet(
|
|
145
134
|
aztecNode: AztecNode,
|
|
146
|
-
opts: Partial<
|
|
135
|
+
opts: Partial<PXEConfig> = {},
|
|
147
136
|
logger = getLogger(),
|
|
148
137
|
useLogSuffix = false,
|
|
149
|
-
proofCreator?: BBNativePrivateKernelProver,
|
|
150
138
|
): Promise<{
|
|
151
139
|
/**
|
|
152
|
-
* The
|
|
140
|
+
* The wallet instance.
|
|
153
141
|
*/
|
|
154
|
-
|
|
142
|
+
wallet: TestWallet;
|
|
155
143
|
/**
|
|
156
144
|
* Logger instance named as the current test.
|
|
157
145
|
*/
|
|
@@ -161,28 +149,24 @@ export async function setupPXEService(
|
|
|
161
149
|
*/
|
|
162
150
|
teardown: () => Promise<void>;
|
|
163
151
|
}> {
|
|
164
|
-
const
|
|
152
|
+
const PXEConfig = { ...getPXEConfig(), ...opts };
|
|
153
|
+
// For tests we only want proving enabled if specifically requested
|
|
154
|
+
PXEConfig.proverEnabled = !!opts.proverEnabled;
|
|
165
155
|
|
|
166
156
|
// If no data directory provided, create a temp directory and clean up afterwards
|
|
167
|
-
const configuredDataDirectory =
|
|
157
|
+
const configuredDataDirectory = PXEConfig.dataDirectory;
|
|
168
158
|
if (!configuredDataDirectory) {
|
|
169
|
-
|
|
159
|
+
PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
const
|
|
162
|
+
const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
|
|
173
163
|
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
};
|
|
164
|
+
const wallet = await TestWallet.create(aztecNode, PXEConfig, {
|
|
165
|
+
useLogSuffix,
|
|
166
|
+
});
|
|
183
167
|
|
|
184
168
|
return {
|
|
185
|
-
|
|
169
|
+
wallet,
|
|
186
170
|
logger,
|
|
187
171
|
teardown,
|
|
188
172
|
};
|
|
@@ -202,55 +186,60 @@ async function setupWithRemoteEnvironment(
|
|
|
202
186
|
config: AztecNodeConfig,
|
|
203
187
|
logger: Logger,
|
|
204
188
|
numberOfAccounts: number,
|
|
205
|
-
) {
|
|
189
|
+
): Promise<EndToEndContext> {
|
|
206
190
|
// we are setting up against a remote environment, l1 contracts are already deployed
|
|
207
191
|
const aztecNodeUrl = getAztecUrl();
|
|
208
192
|
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
209
193
|
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
walletClient,
|
|
222
|
-
publicClient,
|
|
194
|
+
await waitForNode(aztecNode, logger);
|
|
195
|
+
logger.verbose('JSON RPC client connected to Aztec Node');
|
|
196
|
+
logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
|
|
197
|
+
const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
198
|
+
|
|
199
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
200
|
+
|
|
201
|
+
const deployL1ContractsValues: DeployAztecL1ContractsReturnType = {
|
|
202
|
+
l1ContractAddresses,
|
|
203
|
+
l1Client,
|
|
204
|
+
rollupVersion,
|
|
223
205
|
};
|
|
224
|
-
const
|
|
206
|
+
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
|
|
207
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
208
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
|
|
225
209
|
const teardown = () => Promise.resolve();
|
|
226
210
|
|
|
227
|
-
|
|
211
|
+
logger.verbose('Populating wallet from already registered accounts...');
|
|
212
|
+
const initialFundedAccounts = await getInitialTestAccountsData();
|
|
228
213
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const wallets = await getDeployedTestAccountsWallets(pxeClient);
|
|
232
|
-
|
|
233
|
-
if (wallets.length < numberOfAccounts) {
|
|
234
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
|
|
214
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
215
|
+
throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
|
|
235
216
|
// Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
|
|
236
217
|
}
|
|
237
218
|
|
|
219
|
+
const testAccounts = await Promise.all(
|
|
220
|
+
initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
|
|
221
|
+
const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
|
|
222
|
+
return accountManager.address;
|
|
223
|
+
}),
|
|
224
|
+
);
|
|
225
|
+
|
|
238
226
|
return {
|
|
239
227
|
aztecNode,
|
|
228
|
+
aztecNodeAdmin: undefined,
|
|
240
229
|
sequencer: undefined,
|
|
241
230
|
proverNode: undefined,
|
|
242
|
-
pxe: pxeClient,
|
|
243
231
|
deployL1ContractsValues,
|
|
244
|
-
accounts: await pxeClient!.getRegisteredAccounts(),
|
|
245
232
|
config,
|
|
246
233
|
initialFundedAccounts,
|
|
247
|
-
wallet
|
|
248
|
-
|
|
234
|
+
wallet,
|
|
235
|
+
accounts: testAccounts,
|
|
249
236
|
logger,
|
|
250
237
|
cheatCodes,
|
|
238
|
+
ethCheatCodes,
|
|
239
|
+
prefilledPublicData: undefined,
|
|
240
|
+
mockGossipSubNetwork: undefined,
|
|
251
241
|
watcher: undefined,
|
|
252
242
|
dateProvider: undefined,
|
|
253
|
-
blobSink: undefined,
|
|
254
243
|
telemetryClient: undefined,
|
|
255
244
|
teardown,
|
|
256
245
|
};
|
|
@@ -263,65 +252,79 @@ export type SetupOptions = {
|
|
|
263
252
|
/** Whether to enable metrics collection, if undefined, metrics collection is disabled */
|
|
264
253
|
metricsPort?: number | undefined;
|
|
265
254
|
/** Previously deployed contracts on L1 */
|
|
266
|
-
deployL1ContractsValues?:
|
|
267
|
-
/** Whether to skip deployment of protocol contracts (auth registry, etc) */
|
|
268
|
-
skipProtocolContracts?: boolean;
|
|
255
|
+
deployL1ContractsValues?: DeployAztecL1ContractsReturnType;
|
|
269
256
|
/** Initial fee juice for default accounts */
|
|
270
257
|
initialAccountFeeJuice?: Fr;
|
|
271
258
|
/** Number of initial accounts funded with fee juice */
|
|
272
259
|
numberOfInitialFundedAccounts?: number;
|
|
273
260
|
/** Data of the initial funded accounts */
|
|
274
261
|
initialFundedAccounts?: InitialAccountData[];
|
|
275
|
-
/** Salt to use in L1 contract deployment */
|
|
276
|
-
salt?: number;
|
|
277
262
|
/** An initial set of validators */
|
|
278
|
-
initialValidators?:
|
|
263
|
+
initialValidators?: (Operator & { privateKey: `0x${string}` })[];
|
|
279
264
|
/** Anvil Start time */
|
|
280
265
|
l1StartTime?: number;
|
|
281
266
|
/** The anvil time where we should at the earliest be seeing L2 blocks */
|
|
282
267
|
l2StartTime?: number;
|
|
283
268
|
/** Whether to start a prover node */
|
|
284
269
|
startProverNode?: boolean;
|
|
285
|
-
/** Whether to fund the rewardDistributor */
|
|
286
|
-
fundRewardDistributor?: boolean;
|
|
287
270
|
/** Manual config for the telemetry client */
|
|
288
271
|
telemetryConfig?: Partial<TelemetryClientConfig> & { benchmark?: boolean };
|
|
289
272
|
/** Public data that will be inserted in the tree in genesis */
|
|
290
273
|
genesisPublicData?: PublicDataTreeLeaf[];
|
|
274
|
+
/** Specific config for the prover node, if set. */
|
|
275
|
+
proverNodeConfig?: Partial<ProverNodeConfig>;
|
|
276
|
+
/** Whether to use a mock gossip sub network for p2p clients. */
|
|
277
|
+
mockGossipSubNetwork?: boolean;
|
|
278
|
+
/** Whether to disable the anvil test watcher (can still be manually started) */
|
|
279
|
+
disableAnvilTestWatcher?: boolean;
|
|
280
|
+
/** Whether to enable anvil automine during deployment of L1 contracts (consider defaulting this to true). */
|
|
281
|
+
automineL1Setup?: boolean;
|
|
282
|
+
/** How many accounts to seed and unlock in anvil. */
|
|
283
|
+
anvilAccounts?: number;
|
|
284
|
+
/** Port to start anvil (defaults to 8545) */
|
|
285
|
+
anvilPort?: number;
|
|
286
|
+
/** Key to use for publishing L1 contracts */
|
|
287
|
+
l1PublisherKey?: SecretValue<`0x${string}`>;
|
|
288
|
+
/** ZkPassport configuration (domain, scope, mock verifier) */
|
|
289
|
+
zkPassportArgs?: ZKPassportArgs;
|
|
291
290
|
} & Partial<AztecNodeConfig>;
|
|
292
291
|
|
|
293
292
|
/** Context for an end-to-end test as returned by the `setup` function */
|
|
294
293
|
export type EndToEndContext = {
|
|
295
294
|
/** The Aztec Node service or client a connected to it. */
|
|
296
295
|
aztecNode: AztecNode;
|
|
296
|
+
/** Client to the Aztec Node admin interface (undefined if connected to remote environment) */
|
|
297
|
+
aztecNodeAdmin?: AztecNodeAdmin;
|
|
297
298
|
/** The prover node service (only set if startProverNode is true) */
|
|
298
299
|
proverNode: ProverNode | undefined;
|
|
299
300
|
/** A client to the sequencer service (undefined if connected to remote environment) */
|
|
300
301
|
sequencer: SequencerClient | undefined;
|
|
301
|
-
/**
|
|
302
|
-
|
|
303
|
-
/** Return values from deployL1Contracts function. */
|
|
304
|
-
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
302
|
+
/** Return values from deployAztecL1Contracts function. */
|
|
303
|
+
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
305
304
|
/** The Aztec Node configuration. */
|
|
306
305
|
config: AztecNodeConfig;
|
|
307
306
|
/** The data for the initial funded accounts. */
|
|
308
307
|
initialFundedAccounts: InitialAccountData[];
|
|
309
|
-
/** The
|
|
310
|
-
wallet:
|
|
308
|
+
/** The wallet to be used. */
|
|
309
|
+
wallet: TestWallet;
|
|
311
310
|
/** The wallets to be used. */
|
|
312
|
-
|
|
311
|
+
accounts: AztecAddress[];
|
|
313
312
|
/** Logger instance named as the current test. */
|
|
314
313
|
logger: Logger;
|
|
315
314
|
/** The cheat codes. */
|
|
316
315
|
cheatCodes: CheatCodes;
|
|
316
|
+
/** The cheat codes for L1 */
|
|
317
|
+
ethCheatCodes: EthCheatCodes;
|
|
317
318
|
/** The anvil test watcher (undefined if connected to remote environment) */
|
|
318
319
|
watcher: AnvilTestWatcher | undefined;
|
|
319
320
|
/** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
|
|
320
321
|
dateProvider: TestDateProvider | undefined;
|
|
321
|
-
/** The blob sink (undefined if connected to remote environment) */
|
|
322
|
-
blobSink: BlobSinkServer | undefined;
|
|
323
322
|
/** Telemetry client */
|
|
324
323
|
telemetryClient: TelemetryClient | undefined;
|
|
324
|
+
/** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
|
|
325
|
+
mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
326
|
+
/** Prefilled public data used for setting up nodes. */
|
|
327
|
+
prefilledPublicData: PublicDataTreeLeaf[] | undefined;
|
|
325
328
|
/** Function to stop the started services. */
|
|
326
329
|
teardown: () => Promise<void>;
|
|
327
330
|
};
|
|
@@ -334,267 +337,336 @@ export type EndToEndContext = {
|
|
|
334
337
|
*/
|
|
335
338
|
export async function setup(
|
|
336
339
|
numberOfAccounts = 1,
|
|
337
|
-
opts: SetupOptions = {
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
pxeOpts: Partial<PXEServiceConfig> = {},
|
|
340
|
+
opts: SetupOptions = {},
|
|
341
|
+
pxeOpts: Partial<PXEConfig> = {},
|
|
341
342
|
chain: Chain = foundry,
|
|
342
343
|
): 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
344
|
let anvil: Anvil | undefined;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
345
|
+
try {
|
|
346
|
+
opts.aztecTargetCommitteeSize ??= 0;
|
|
347
|
+
opts.slasherFlavor ??= 'none';
|
|
348
|
+
|
|
349
|
+
const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
|
|
350
|
+
// use initialValidators for the node config
|
|
351
|
+
config.validatorPrivateKeys = new SecretValue(opts.initialValidators?.map(v => v.privateKey) ?? []);
|
|
352
|
+
|
|
353
|
+
config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
354
|
+
// For tests we only want proving enabled if specifically requested
|
|
355
|
+
config.realProofs = !!opts.realProofs;
|
|
356
|
+
// Only enforce the time table if requested
|
|
357
|
+
config.enforceTimeTable = !!opts.enforceTimeTable;
|
|
358
|
+
|
|
359
|
+
const logger = getLogger();
|
|
360
|
+
|
|
361
|
+
// Create a temp directory for any services that need it and cleanup later
|
|
362
|
+
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
363
|
+
await fs.mkdir(directoryToCleanup, { recursive: true });
|
|
364
|
+
if (!config.dataDirectory) {
|
|
365
|
+
config.dataDirectory = directoryToCleanup;
|
|
365
366
|
}
|
|
366
367
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
368
|
+
if (!config.l1RpcUrls?.length) {
|
|
369
|
+
if (!isAnvilTestChain(chain.id)) {
|
|
370
|
+
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
371
|
+
}
|
|
372
|
+
if (AZTEC_NODE_URL) {
|
|
373
|
+
throw new Error(
|
|
374
|
+
`AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
371
377
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
+
const res = await startAnvil({
|
|
379
|
+
l1BlockTime: opts.ethereumSlotDuration,
|
|
380
|
+
accounts: opts.anvilAccounts,
|
|
381
|
+
port: opts.anvilPort,
|
|
382
|
+
});
|
|
383
|
+
anvil = res.anvil;
|
|
384
|
+
config.l1RpcUrls = [res.rpcUrl];
|
|
385
|
+
}
|
|
378
386
|
|
|
379
|
-
|
|
387
|
+
// Enable logging metrics to a local file named after the test suite
|
|
388
|
+
if (isMetricsLoggingRequested()) {
|
|
389
|
+
const filename = path.join('log', getJobName() + '.jsonl');
|
|
390
|
+
logger.info(`Logging metrics to ${filename}`);
|
|
391
|
+
setupMetricsLogger(filename);
|
|
392
|
+
}
|
|
380
393
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
394
|
+
const dateProvider = new TestDateProvider();
|
|
395
|
+
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
|
|
384
396
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
397
|
+
if (opts.stateLoad) {
|
|
398
|
+
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
399
|
+
}
|
|
388
400
|
|
|
389
|
-
|
|
390
|
-
|
|
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
|
-
}
|
|
401
|
+
if (opts.l1StartTime) {
|
|
402
|
+
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
403
|
+
}
|
|
402
404
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
+
let publisherPrivKeyHex: `0x${string}` | undefined = undefined;
|
|
406
|
+
let publisherHdAccount: HDAccount | PrivateKeyAccount | undefined = undefined;
|
|
407
|
+
|
|
408
|
+
if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
|
|
409
|
+
publisherPrivKeyHex = opts.l1PublisherKey.getValue();
|
|
410
|
+
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
411
|
+
} else if (
|
|
412
|
+
config.publisherPrivateKeys &&
|
|
413
|
+
config.publisherPrivateKeys.length > 0 &&
|
|
414
|
+
config.publisherPrivateKeys[0].getValue() != NULL_KEY
|
|
415
|
+
) {
|
|
416
|
+
publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
|
|
417
|
+
publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
|
|
418
|
+
} else if (!MNEMONIC) {
|
|
419
|
+
throw new Error(`Mnemonic not provided and no publisher private key`);
|
|
420
|
+
} else {
|
|
421
|
+
publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
422
|
+
const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
|
|
423
|
+
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
424
|
+
publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
|
|
425
|
+
config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
|
|
426
|
+
}
|
|
405
427
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
428
|
+
if (config.coinbase === undefined) {
|
|
429
|
+
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
430
|
+
}
|
|
410
431
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|
-
);
|
|
432
|
+
if (AZTEC_NODE_URL) {
|
|
433
|
+
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
434
|
+
return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
|
|
435
|
+
}
|
|
425
436
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
));
|
|
437
|
+
const initialFundedAccounts =
|
|
438
|
+
opts.initialFundedAccounts ??
|
|
439
|
+
(await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
|
|
440
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
|
|
441
|
+
initialFundedAccounts.map(a => a.address),
|
|
442
|
+
opts.initialAccountFeeJuice,
|
|
443
|
+
opts.genesisPublicData,
|
|
444
|
+
);
|
|
435
445
|
|
|
436
|
-
|
|
446
|
+
const wasAutomining = await ethCheatCodes.isAutoMining();
|
|
447
|
+
const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
|
|
448
|
+
if (enableAutomine) {
|
|
449
|
+
await ethCheatCodes.setAutomine(true);
|
|
450
|
+
}
|
|
437
451
|
|
|
438
|
-
|
|
439
|
-
|
|
452
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount!, chain);
|
|
453
|
+
|
|
454
|
+
const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await deployAztecL1Contracts(
|
|
455
|
+
config.l1RpcUrls[0],
|
|
456
|
+
publisherPrivKeyHex!,
|
|
457
|
+
chain.id,
|
|
458
|
+
{
|
|
459
|
+
...getL1ContractsConfigEnvVars(),
|
|
460
|
+
...opts,
|
|
461
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
462
|
+
protocolContractsHash,
|
|
463
|
+
genesisArchiveRoot,
|
|
464
|
+
initialValidators: opts.initialValidators,
|
|
465
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
466
|
+
realVerifier: false,
|
|
467
|
+
},
|
|
468
|
+
);
|
|
440
469
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
abi: l1Artifacts.rewardDistributor.contractAbi,
|
|
444
|
-
client: deployL1ContractsValues.publicClient,
|
|
445
|
-
});
|
|
470
|
+
config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
471
|
+
config.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
446
472
|
|
|
447
|
-
|
|
448
|
-
|
|
473
|
+
if (enableAutomine) {
|
|
474
|
+
await ethCheatCodes.setAutomine(false);
|
|
475
|
+
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
476
|
+
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
477
|
+
}
|
|
449
478
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
479
|
+
if (opts.l2StartTime) {
|
|
480
|
+
// This should only be used in synching test or when you need to have a stable
|
|
481
|
+
// timestamp for the first l2 block.
|
|
482
|
+
await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
|
|
483
|
+
}
|
|
455
484
|
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
485
|
+
const watcher = new AnvilTestWatcher(
|
|
486
|
+
new EthCheatCodesWithState(config.l1RpcUrls, dateProvider),
|
|
487
|
+
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
488
|
+
deployL1ContractsValues.l1Client,
|
|
489
|
+
dateProvider,
|
|
490
|
+
);
|
|
491
|
+
if (!opts.disableAnvilTestWatcher) {
|
|
492
|
+
await watcher.start();
|
|
493
|
+
}
|
|
460
494
|
|
|
461
|
-
|
|
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
|
-
}
|
|
495
|
+
const telemetry = await getTelemetryClient(opts.telemetryConfig);
|
|
466
496
|
|
|
467
|
-
|
|
497
|
+
await setupSharedBlobStorage(config);
|
|
468
498
|
|
|
469
|
-
|
|
470
|
-
new EthCheatCodesWithState(config.l1RpcUrls),
|
|
471
|
-
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
472
|
-
deployL1ContractsValues.publicClient,
|
|
473
|
-
dateProvider,
|
|
474
|
-
);
|
|
499
|
+
logger.verbose('Creating and synching an aztec node', config);
|
|
475
500
|
|
|
476
|
-
|
|
501
|
+
const acvmConfig = await getACVMConfig(logger);
|
|
502
|
+
if (acvmConfig) {
|
|
503
|
+
config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
504
|
+
config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
505
|
+
}
|
|
477
506
|
|
|
478
|
-
|
|
507
|
+
const bbConfig = await getBBConfig(logger);
|
|
508
|
+
if (bbConfig) {
|
|
509
|
+
config.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
510
|
+
config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
511
|
+
}
|
|
479
512
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
483
|
-
config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
484
|
-
}
|
|
513
|
+
let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
514
|
+
let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
|
|
485
515
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
config.l1PublishRetryIntervalMS = 100;
|
|
516
|
+
if (opts.mockGossipSubNetwork) {
|
|
517
|
+
mockGossipSubNetwork = new MockGossipSubNetwork();
|
|
518
|
+
p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
|
|
519
|
+
}
|
|
492
520
|
|
|
493
|
-
|
|
521
|
+
// Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
|
|
522
|
+
// To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
|
|
523
|
+
// For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
|
|
524
|
+
// If no accounts need deployment, we await an empty block to confirm network progression. After either path
|
|
525
|
+
// completes, we restore the original minTxsPerBlock setting. The deployment and waiting for empty block is
|
|
526
|
+
// handled by the if-else branches on line 632.
|
|
527
|
+
// For more details on why the tx would be dropped see `validate_include_by_timestamp` function in
|
|
528
|
+
// `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
|
|
529
|
+
//
|
|
530
|
+
// Note: If the following seems too convoluted or if it starts making problems, we could drop the "progressing
|
|
531
|
+
// past genesis via an account contract deployment" optimization and just call flush() on the sequencer and wait
|
|
532
|
+
// for an empty block to be mined. This would simplify it all quite a bit but the setup would be slower for tests
|
|
533
|
+
// deploying accounts.
|
|
534
|
+
const originalMinTxsPerBlock = config.minTxsPerBlock;
|
|
535
|
+
if (originalMinTxsPerBlock === undefined) {
|
|
536
|
+
throw new Error('minTxsPerBlock is undefined in e2e test setup');
|
|
537
|
+
}
|
|
538
|
+
config.minTxsPerBlock = numberOfAccounts === 0 ? 0 : 1;
|
|
494
539
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
config,
|
|
498
|
-
{
|
|
499
|
-
dateProvider,
|
|
500
|
-
blobSinkClient,
|
|
501
|
-
},
|
|
502
|
-
{ prefilledPublicData },
|
|
503
|
-
);
|
|
504
|
-
const sequencer = aztecNode.getSequencer();
|
|
540
|
+
config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
|
|
541
|
+
config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
|
|
505
542
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
543
|
+
if (!config.disableValidator) {
|
|
544
|
+
if ((config.validatorPrivateKeys?.getValue().length ?? 0) === 0) {
|
|
545
|
+
config.validatorPrivateKeys = new SecretValue([generatePrivateKey()]);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
510
548
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
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')),
|
|
549
|
+
const aztecNode = await AztecNodeService.createAndSync(
|
|
550
|
+
config, // REFACTOR: createAndSync mutates this config
|
|
551
|
+
{ dateProvider, telemetry, p2pClientDeps, logger: createLogger('node:MAIN-aztec-node') },
|
|
552
|
+
{ prefilledPublicData },
|
|
521
553
|
);
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
logger.verbose('Creating a pxe...');
|
|
525
|
-
const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger);
|
|
554
|
+
const sequencerClient = aztecNode.getSequencer();
|
|
526
555
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
556
|
+
if (sequencerClient) {
|
|
557
|
+
const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
|
|
558
|
+
publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
|
|
559
|
+
}
|
|
531
560
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
561
|
+
let proverNode: ProverNode | undefined = undefined;
|
|
562
|
+
if (opts.startProverNode) {
|
|
563
|
+
logger.verbose('Creating and syncing a simulated prover node...');
|
|
564
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
565
|
+
const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
|
|
566
|
+
const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
567
|
+
const proverNodeConfig = { ...config.proverNodeConfig, dataDirectory: proverNodeDataDirectory };
|
|
568
|
+
proverNode = await createAndSyncProverNode(
|
|
569
|
+
proverNodePrivateKeyHex,
|
|
570
|
+
config,
|
|
571
|
+
proverNodeConfig,
|
|
572
|
+
aztecNode,
|
|
573
|
+
prefilledPublicData,
|
|
574
|
+
);
|
|
575
|
+
}
|
|
540
576
|
|
|
541
|
-
|
|
577
|
+
logger.verbose('Creating a pxe...');
|
|
578
|
+
const { wallet, teardown: pxeTeardown } = await setupPXEAndGetWallet(aztecNode!, pxeOpts, logger);
|
|
542
579
|
|
|
543
|
-
|
|
544
|
-
await pxeTeardown();
|
|
580
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, dateProvider);
|
|
545
581
|
|
|
546
|
-
if (
|
|
547
|
-
|
|
582
|
+
if (
|
|
583
|
+
(opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
|
|
584
|
+
(opts.initialValidators && opts.initialValidators.length > 0)
|
|
585
|
+
) {
|
|
586
|
+
// We need to advance such that the committee is set up.
|
|
587
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
588
|
+
EpochNumber.fromBigInt(
|
|
589
|
+
BigInt(await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochsForValidatorSet + 1),
|
|
590
|
+
),
|
|
591
|
+
);
|
|
592
|
+
await cheatCodes.rollup.setupEpoch();
|
|
593
|
+
await cheatCodes.rollup.debugRollup();
|
|
548
594
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
595
|
+
let accounts: AztecAddress[] = [];
|
|
596
|
+
// Below we continue with what we described in the long comment on line 571.
|
|
597
|
+
if (numberOfAccounts === 0) {
|
|
598
|
+
logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
|
|
599
|
+
while ((await aztecNode.getBlockNumber()) === 0) {
|
|
600
|
+
await sleep(2000);
|
|
601
|
+
}
|
|
602
|
+
} else {
|
|
603
|
+
logger.info(
|
|
604
|
+
`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`,
|
|
605
|
+
);
|
|
606
|
+
const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
607
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, aztecNode, accountsData);
|
|
608
|
+
accounts = accountManagers.map(accountManager => accountManager.address);
|
|
552
609
|
}
|
|
553
610
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
logger.verbose(`Cleaning up ACVM state`);
|
|
557
|
-
await acvmConfig.cleanup();
|
|
558
|
-
}
|
|
611
|
+
// Now we restore the original minTxsPerBlock setting.
|
|
612
|
+
sequencerClient!.getSequencer().updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
559
613
|
|
|
560
|
-
if (
|
|
561
|
-
//
|
|
562
|
-
|
|
563
|
-
|
|
614
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
615
|
+
// TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
|
|
616
|
+
throw new Error(
|
|
617
|
+
`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
|
|
618
|
+
);
|
|
564
619
|
}
|
|
565
620
|
|
|
566
|
-
|
|
567
|
-
await watcher.stop();
|
|
568
|
-
await blobSink?.stop();
|
|
569
|
-
|
|
570
|
-
if (directoryToCleanup) {
|
|
621
|
+
const teardown = async () => {
|
|
571
622
|
try {
|
|
572
|
-
|
|
573
|
-
|
|
623
|
+
await pxeTeardown();
|
|
624
|
+
|
|
625
|
+
await tryStop(aztecNode, logger);
|
|
626
|
+
await tryStop(proverNode, logger);
|
|
627
|
+
|
|
628
|
+
if (acvmConfig?.cleanup) {
|
|
629
|
+
await acvmConfig.cleanup();
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (bbConfig?.cleanup) {
|
|
633
|
+
await bbConfig.cleanup();
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
await tryStop(watcher, logger);
|
|
637
|
+
await tryStop(anvil, logger);
|
|
638
|
+
|
|
639
|
+
await tryRmDir(directoryToCleanup, logger);
|
|
574
640
|
} catch (err) {
|
|
575
|
-
logger.
|
|
641
|
+
logger.error(`Error during e2e test teardown`, err);
|
|
576
642
|
}
|
|
577
|
-
}
|
|
578
|
-
};
|
|
643
|
+
};
|
|
579
644
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
645
|
+
return {
|
|
646
|
+
aztecNode,
|
|
647
|
+
aztecNodeAdmin: aztecNode,
|
|
648
|
+
cheatCodes,
|
|
649
|
+
ethCheatCodes,
|
|
650
|
+
config,
|
|
651
|
+
dateProvider,
|
|
652
|
+
deployL1ContractsValues,
|
|
653
|
+
initialFundedAccounts,
|
|
654
|
+
logger,
|
|
655
|
+
mockGossipSubNetwork,
|
|
656
|
+
prefilledPublicData,
|
|
657
|
+
proverNode,
|
|
658
|
+
sequencer: sequencerClient,
|
|
659
|
+
teardown,
|
|
660
|
+
telemetryClient: telemetry,
|
|
661
|
+
wallet,
|
|
662
|
+
accounts,
|
|
663
|
+
watcher,
|
|
664
|
+
};
|
|
665
|
+
} catch (err) {
|
|
666
|
+
// TODO: Just hoisted anvil for now to ensure cleanup. Prob need to hoist the rest.
|
|
667
|
+
await anvil?.stop();
|
|
668
|
+
throw err;
|
|
669
|
+
}
|
|
598
670
|
}
|
|
599
671
|
|
|
600
672
|
/**
|
|
@@ -604,16 +676,14 @@ export async function setup(
|
|
|
604
676
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
605
677
|
*/
|
|
606
678
|
|
|
607
|
-
|
|
608
|
-
export async function ensureAccountsPubliclyDeployed(sender: Wallet, accountsToDeploy: Wallet[]) {
|
|
679
|
+
export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
|
|
609
680
|
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
610
|
-
// the
|
|
681
|
+
// the local network and the test accounts exist
|
|
611
682
|
const accountsAndAddresses = await Promise.all(
|
|
612
|
-
accountsToDeploy.map(async
|
|
613
|
-
const address = account.getAddress();
|
|
683
|
+
accountsToDeploy.map(async address => {
|
|
614
684
|
return {
|
|
615
685
|
address,
|
|
616
|
-
deployed: (await
|
|
686
|
+
deployed: (await wallet.getContractMetadata(address)).isContractPublished,
|
|
617
687
|
};
|
|
618
688
|
}),
|
|
619
689
|
);
|
|
@@ -621,33 +691,18 @@ export async function ensureAccountsPubliclyDeployed(sender: Wallet, accountsToD
|
|
|
621
691
|
await Promise.all(
|
|
622
692
|
accountsAndAddresses
|
|
623
693
|
.filter(({ deployed }) => !deployed)
|
|
624
|
-
.map(({ address }) =>
|
|
694
|
+
.map(({ address }) => wallet.getContractMetadata(address)),
|
|
625
695
|
)
|
|
626
696
|
).map(contractMetadata => contractMetadata.contractInstance);
|
|
627
697
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
628
|
-
if (!(await
|
|
629
|
-
await (await
|
|
698
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
699
|
+
await (await publishContractClass(wallet, SchnorrAccountContractArtifact))
|
|
700
|
+
.send({ from: accountsToDeploy[0] })
|
|
701
|
+
.wait();
|
|
630
702
|
}
|
|
631
|
-
const requests = await Promise.all(
|
|
632
|
-
|
|
633
|
-
);
|
|
634
|
-
const batch = new BatchCall(sender, [...requests]);
|
|
635
|
-
await batch.send().wait();
|
|
636
|
-
}
|
|
637
|
-
// docs:end:public_deploy_accounts
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* Sets the timestamp of the next block.
|
|
641
|
-
* @param rpcUrl - rpc url of the blockchain instance to connect to
|
|
642
|
-
* @param timestamp - the timestamp for the next block
|
|
643
|
-
*/
|
|
644
|
-
export async function setNextBlockTimestamp(rpcUrl: string, timestamp: number) {
|
|
645
|
-
const params = `[${timestamp}]`;
|
|
646
|
-
await fetch(rpcUrl, {
|
|
647
|
-
body: `{"jsonrpc":"2.0", "method": "evm_setNextBlockTimestamp", "params": ${params}, "id": 1}`,
|
|
648
|
-
method: 'POST',
|
|
649
|
-
headers: { 'Content-Type': 'application/json' },
|
|
650
|
-
});
|
|
703
|
+
const requests = await Promise.all(instances.map(async instance => await publishInstance(wallet, instance!)));
|
|
704
|
+
const batch = new BatchCall(wallet, requests);
|
|
705
|
+
await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
651
706
|
}
|
|
652
707
|
|
|
653
708
|
/** Returns the job name for the current test. */
|
|
@@ -672,11 +727,12 @@ export type BalancesFn = ReturnType<typeof getBalancesFn>;
|
|
|
672
727
|
export function getBalancesFn(
|
|
673
728
|
symbol: string,
|
|
674
729
|
method: ContractMethod,
|
|
730
|
+
from: AztecAddress,
|
|
675
731
|
logger: any,
|
|
676
732
|
): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
|
|
677
733
|
const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
|
|
678
734
|
const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
|
|
679
|
-
const b = await Promise.all(addresses.map(address => method(address).simulate()));
|
|
735
|
+
const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
|
|
680
736
|
const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
|
|
681
737
|
logger.verbose(debugString);
|
|
682
738
|
return b;
|
|
@@ -712,27 +768,50 @@ export async function expectMappingDelta<K, V extends number | bigint>(
|
|
|
712
768
|
}
|
|
713
769
|
|
|
714
770
|
/**
|
|
715
|
-
*
|
|
771
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
772
|
+
* but by conventions its address is computed with a salt of 0.
|
|
773
|
+
* @returns The address of the sponsored FPC contract
|
|
716
774
|
*/
|
|
717
|
-
export
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
775
|
+
export function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
|
|
776
|
+
return Promise.resolve(
|
|
777
|
+
getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
778
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
779
|
+
}),
|
|
780
|
+
);
|
|
781
|
+
}
|
|
722
782
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
getLogger().warn(`Fee Juice might have already been setup. Got error: ${inspect(error)}.`);
|
|
732
|
-
}
|
|
783
|
+
/**
|
|
784
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
785
|
+
* but by conventions its address is computed with a salt of 0.
|
|
786
|
+
* @returns The address of the sponsored FPC contract
|
|
787
|
+
*/
|
|
788
|
+
export async function getSponsoredFPCAddress() {
|
|
789
|
+
const sponsoredFPCInstance = await getSponsoredFPCInstance();
|
|
790
|
+
return sponsoredFPCInstance.address;
|
|
733
791
|
}
|
|
734
792
|
|
|
735
|
-
|
|
793
|
+
/**
|
|
794
|
+
* Deploy a sponsored FPC contract to a running instance.
|
|
795
|
+
*/
|
|
796
|
+
export async function setupSponsoredFPC(wallet: Wallet) {
|
|
797
|
+
const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
798
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
await wallet.registerContract(instance, SponsoredFPCContract.artifact);
|
|
802
|
+
getLogger().info(`SponsoredFPC: ${instance.address}`);
|
|
803
|
+
return instance;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Registers the SponsoredFPC in this PXE instance
|
|
808
|
+
* @param wallet - The wallet
|
|
809
|
+
*/
|
|
810
|
+
export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
|
|
811
|
+
await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNumber, timeoutSec = 60, intervalSec = 1) {
|
|
736
815
|
targetBlock ??= await node.getBlockNumber();
|
|
737
816
|
|
|
738
817
|
await retryUntil(
|
|
@@ -743,81 +822,83 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: number,
|
|
|
743
822
|
);
|
|
744
823
|
}
|
|
745
824
|
|
|
746
|
-
export
|
|
825
|
+
export function createAndSyncProverNode(
|
|
747
826
|
proverNodePrivateKey: `0x${string}`,
|
|
748
827
|
aztecNodeConfig: AztecNodeConfig,
|
|
749
|
-
|
|
750
|
-
|
|
828
|
+
proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
|
|
829
|
+
aztecNode: AztecNode | undefined,
|
|
751
830
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
831
|
+
proverNodeDeps: ProverNodeDeps = {},
|
|
752
832
|
) {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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
|
-
};
|
|
833
|
+
return withLogNameSuffix('prover-node', async () => {
|
|
834
|
+
// Disable stopping the aztec node as the prover coordination test will kill it otherwise
|
|
835
|
+
// This is only required when stopping the prover node for testing
|
|
836
|
+
const aztecNodeTxProvider = aztecNode && {
|
|
837
|
+
getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
|
|
838
|
+
getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
|
|
839
|
+
stop: () => Promise.resolve(),
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('blob-client:prover-node'));
|
|
843
|
+
|
|
844
|
+
// Creating temp store and archiver for simulated prover node
|
|
845
|
+
const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
|
|
846
|
+
const archiver = await createArchiver(
|
|
847
|
+
archiverConfig,
|
|
848
|
+
{ blobClient, dateProvider: proverNodeDeps.dateProvider },
|
|
849
|
+
{ blockUntilSync: true },
|
|
850
|
+
);
|
|
783
851
|
|
|
784
|
-
|
|
852
|
+
// Prover node config is for simulated proofs
|
|
853
|
+
const proverConfig: ProverNodeConfig = {
|
|
854
|
+
...aztecNodeConfig,
|
|
855
|
+
txCollectionNodeRpcUrls: [],
|
|
856
|
+
realProofs: false,
|
|
857
|
+
proverAgentCount: 2,
|
|
858
|
+
publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
|
|
859
|
+
proverNodeMaxPendingJobs: 10,
|
|
860
|
+
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
861
|
+
proverNodePollingIntervalMs: 200,
|
|
862
|
+
txGatheringIntervalMs: 1000,
|
|
863
|
+
txGatheringBatchSize: 10,
|
|
864
|
+
txGatheringMaxParallelRequestsPerNode: 10,
|
|
865
|
+
txGatheringTimeoutMs: 24_000,
|
|
866
|
+
proverNodeFailedEpochStore: undefined,
|
|
867
|
+
proverId: EthAddress.fromNumber(1),
|
|
868
|
+
proverNodeEpochProvingDelayMs: undefined,
|
|
869
|
+
...proverNodeConfig,
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
const l1TxUtils = createDelayedL1TxUtils(
|
|
873
|
+
aztecNodeConfig,
|
|
874
|
+
proverNodePrivateKey,
|
|
875
|
+
'prover-node',
|
|
876
|
+
proverNodeDeps.dateProvider,
|
|
877
|
+
);
|
|
785
878
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return proverNode;
|
|
879
|
+
const proverNode = await createProverNode(
|
|
880
|
+
proverConfig,
|
|
881
|
+
{ ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
|
|
882
|
+
{ prefilledPublicData },
|
|
883
|
+
);
|
|
884
|
+
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
|
|
885
|
+
if (!proverNodeConfig.dontStart) {
|
|
886
|
+
await proverNode.start();
|
|
887
|
+
}
|
|
888
|
+
return proverNode;
|
|
889
|
+
});
|
|
798
890
|
}
|
|
799
891
|
|
|
800
|
-
function createDelayedL1TxUtils(
|
|
801
|
-
|
|
892
|
+
function createDelayedL1TxUtils(
|
|
893
|
+
aztecNodeConfig: AztecNodeConfig,
|
|
894
|
+
privateKey: `0x${string}`,
|
|
895
|
+
logName: string,
|
|
896
|
+
dateProvider?: DateProvider,
|
|
897
|
+
) {
|
|
898
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
802
899
|
|
|
803
900
|
const log = createLogger(logName);
|
|
804
|
-
const l1TxUtils =
|
|
901
|
+
const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
|
|
805
902
|
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
806
903
|
return l1TxUtils;
|
|
807
904
|
}
|
|
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
|
-
}
|