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