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