@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
|
@@ -1,50 +1,62 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type InitialAccountData,
|
|
2
|
+
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
5
|
+
import { getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
|
|
6
|
+
import { BatchCall, type ContractFunctionInteraction, waitForProven } from '@aztec/aztec.js/contracts';
|
|
7
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
9
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
10
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
11
|
+
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
12
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
13
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
14
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
15
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
4
16
|
import {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
CheatCodes,
|
|
10
|
-
type CompleteAddress,
|
|
11
|
-
type ContractFunctionInteraction,
|
|
12
|
-
type DeployL1ContractsReturnType,
|
|
13
|
-
type FunctionCall,
|
|
14
|
-
type Logger,
|
|
15
|
-
type PXE,
|
|
16
|
-
type Wallet,
|
|
17
|
-
getContractClassFromArtifact,
|
|
18
|
-
} from '@aztec/aztec.js';
|
|
19
|
-
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
|
|
20
|
-
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
21
|
-
import { type DeployL1ContractsArgs, createL1Clients, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum';
|
|
17
|
+
type DeployAztecL1ContractsArgs,
|
|
18
|
+
type DeployAztecL1ContractsReturnType,
|
|
19
|
+
deployAztecL1Contracts,
|
|
20
|
+
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
22
21
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
23
22
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
24
|
-
import {
|
|
23
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
24
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
25
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
25
26
|
import { createLogger } from '@aztec/foundation/log';
|
|
26
27
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
27
28
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
29
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
30
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
28
31
|
import type { ProverNode } from '@aztec/prover-node';
|
|
29
|
-
import {
|
|
32
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
33
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
34
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
30
35
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
36
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
31
37
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
32
38
|
|
|
33
39
|
import type { Anvil } from '@viem/anvil';
|
|
34
40
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
35
41
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
36
42
|
import fs from 'fs/promises';
|
|
37
|
-
import getPort from 'get-port';
|
|
38
43
|
import { tmpdir } from 'os';
|
|
39
44
|
import path, { join } from 'path';
|
|
40
|
-
import {
|
|
45
|
+
import type { Hex } from 'viem';
|
|
41
46
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
47
|
+
import { foundry } from 'viem/chains';
|
|
42
48
|
|
|
43
|
-
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
49
|
+
import { MNEMONIC, TEST_MAX_TX_POOL_SIZE, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
44
50
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
45
51
|
import { getBBConfig } from './get_bb_config.js';
|
|
46
|
-
import {
|
|
47
|
-
|
|
52
|
+
import {
|
|
53
|
+
type SetupOptions,
|
|
54
|
+
createAndSyncProverNode,
|
|
55
|
+
getLogger,
|
|
56
|
+
getPrivateKeyFromIndex,
|
|
57
|
+
getSponsoredFPCAddress,
|
|
58
|
+
setupSharedBlobStorage,
|
|
59
|
+
} from './utils.js';
|
|
48
60
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
49
61
|
|
|
50
62
|
export type SubsystemsContext = {
|
|
@@ -53,13 +65,13 @@ export type SubsystemsContext = {
|
|
|
53
65
|
bbConfig: any;
|
|
54
66
|
aztecNode: AztecNodeService;
|
|
55
67
|
aztecNodeConfig: AztecNodeConfig;
|
|
56
|
-
|
|
57
|
-
deployL1ContractsValues:
|
|
68
|
+
wallet: TestWallet;
|
|
69
|
+
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
58
70
|
proverNode?: ProverNode;
|
|
59
71
|
watcher: AnvilTestWatcher;
|
|
60
72
|
cheatCodes: CheatCodes;
|
|
73
|
+
sequencer: SequencerClient;
|
|
61
74
|
dateProvider: TestDateProvider;
|
|
62
|
-
blobSink: BlobSinkServer;
|
|
63
75
|
initialFundedAccounts: InitialAccountData[];
|
|
64
76
|
directoryToCleanup?: string;
|
|
65
77
|
};
|
|
@@ -75,7 +87,7 @@ export function createSnapshotManager(
|
|
|
75
87
|
testName: string,
|
|
76
88
|
dataPath?: string,
|
|
77
89
|
config: Partial<SetupOptions> = {},
|
|
78
|
-
deployL1ContractsArgs: Partial<
|
|
90
|
+
deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
|
|
79
91
|
initialValidators: [],
|
|
80
92
|
},
|
|
81
93
|
) {
|
|
@@ -104,7 +116,7 @@ class MockSnapshotManager implements ISnapshotManager {
|
|
|
104
116
|
constructor(
|
|
105
117
|
testName: string,
|
|
106
118
|
private config: Partial<AztecNodeConfig> = {},
|
|
107
|
-
private deployL1ContractsArgs: Partial<
|
|
119
|
+
private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {},
|
|
108
120
|
) {
|
|
109
121
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
110
122
|
this.logger.warn(`No data path given, will not persist any snapshots.`);
|
|
@@ -152,7 +164,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
152
164
|
testName: string,
|
|
153
165
|
private dataPath: string,
|
|
154
166
|
private config: Partial<SetupOptions> = {},
|
|
155
|
-
private deployL1ContractsArgs: Partial<
|
|
167
|
+
private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {},
|
|
156
168
|
) {
|
|
157
169
|
this.livePath = join(this.dataPath, 'live', testName);
|
|
158
170
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
@@ -188,7 +200,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
188
200
|
await restore(snapshotData, context);
|
|
189
201
|
|
|
190
202
|
// Save the snapshot data.
|
|
191
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
203
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
|
|
192
204
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
193
205
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
194
206
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -253,24 +265,18 @@ async function teardown(context: SubsystemsContext | undefined) {
|
|
|
253
265
|
if (!context) {
|
|
254
266
|
return;
|
|
255
267
|
}
|
|
268
|
+
const logger = getLogger();
|
|
256
269
|
try {
|
|
257
|
-
|
|
258
|
-
await context.proverNode
|
|
259
|
-
await context.aztecNode
|
|
270
|
+
logger.info('Tearing down subsystems');
|
|
271
|
+
await tryStop(context.proverNode);
|
|
272
|
+
await tryStop(context.aztecNode);
|
|
260
273
|
await context.acvmConfig?.cleanup();
|
|
261
274
|
await context.bbConfig?.cleanup();
|
|
262
|
-
await context.anvil
|
|
263
|
-
await context.watcher
|
|
264
|
-
await context.
|
|
265
|
-
if (context.directoryToCleanup) {
|
|
266
|
-
try {
|
|
267
|
-
await fs.rm(context.directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
|
|
268
|
-
} catch (err) {
|
|
269
|
-
getLogger().warn(`Failed to delete tmp directory ${context.directoryToCleanup}: ${err}`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
275
|
+
await tryStop(context.anvil);
|
|
276
|
+
await tryStop(context.watcher);
|
|
277
|
+
await tryRmDir(context.directoryToCleanup, logger);
|
|
272
278
|
} catch (err) {
|
|
273
|
-
|
|
279
|
+
logger.error('Error during teardown', err);
|
|
274
280
|
}
|
|
275
281
|
}
|
|
276
282
|
|
|
@@ -283,18 +289,30 @@ async function setupFromFresh(
|
|
|
283
289
|
statePath: string | undefined,
|
|
284
290
|
logger: Logger,
|
|
285
291
|
{ numberOfInitialFundedAccounts = 10, ...opts }: SetupOptions = {},
|
|
286
|
-
deployL1ContractsArgs: Partial<
|
|
292
|
+
deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
|
|
287
293
|
initialValidators: [],
|
|
288
294
|
},
|
|
289
295
|
): Promise<SubsystemsContext> {
|
|
290
296
|
logger.verbose(`Initializing state...`);
|
|
291
297
|
|
|
292
|
-
|
|
298
|
+
// Default to no slashing
|
|
299
|
+
opts.slasherFlavor ??= 'none';
|
|
300
|
+
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
293
301
|
|
|
294
302
|
// Fetch the AztecNode config.
|
|
295
303
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
296
304
|
const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
|
|
297
305
|
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
306
|
+
aztecNodeConfig.maxTxPoolSize = opts.maxTxPoolSize ?? TEST_MAX_TX_POOL_SIZE;
|
|
307
|
+
// Only enable proving if specifically requested.
|
|
308
|
+
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
309
|
+
// Only enforce the time table if requested
|
|
310
|
+
aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
|
|
311
|
+
// Only set the target committee size if it is explicitly set
|
|
312
|
+
aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
|
|
313
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
314
|
+
|
|
315
|
+
deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
|
|
298
316
|
|
|
299
317
|
// Create a temp directory for all ephemeral state and cleanup afterwards
|
|
300
318
|
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
@@ -304,86 +322,77 @@ async function setupFromFresh(
|
|
|
304
322
|
} else {
|
|
305
323
|
aztecNodeConfig.dataDirectory = statePath;
|
|
306
324
|
}
|
|
307
|
-
aztecNodeConfig.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
308
|
-
|
|
309
|
-
// Setup blob sink service
|
|
310
|
-
const blobSink = await createBlobSinkServer({
|
|
311
|
-
port: blobSinkPort,
|
|
312
|
-
dataStoreConfig: {
|
|
313
|
-
dataDirectory: aztecNodeConfig.dataDirectory,
|
|
314
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
|
|
315
|
-
},
|
|
316
|
-
});
|
|
317
|
-
await blobSink.start();
|
|
318
325
|
|
|
319
|
-
|
|
320
|
-
logger.verbose('Starting anvil...');
|
|
321
|
-
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
322
|
-
const anvil = res.anvil;
|
|
323
|
-
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
326
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
324
327
|
|
|
325
|
-
|
|
326
|
-
logger.verbose('Deploying L1 contracts...');
|
|
327
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, { accountIndex: 0 });
|
|
328
|
+
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
328
329
|
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
329
330
|
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
331
|
+
const publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` satisfies `0x${string}`;
|
|
332
|
+
|
|
333
|
+
const l1Client = createExtendedL1Client([aztecNodeConfig.l1RpcUrls[0]], hdAccount, foundry);
|
|
330
334
|
|
|
331
335
|
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
332
336
|
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
333
337
|
|
|
334
|
-
aztecNodeConfig.
|
|
335
|
-
aztecNodeConfig.
|
|
338
|
+
aztecNodeConfig.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
|
|
339
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
|
|
340
|
+
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
336
341
|
|
|
337
|
-
|
|
342
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
338
343
|
|
|
344
|
+
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
345
|
+
logger.verbose('Starting anvil...');
|
|
346
|
+
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
347
|
+
const anvil = res.anvil;
|
|
348
|
+
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
349
|
+
|
|
350
|
+
const dateProvider = new TestDateProvider();
|
|
351
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
352
|
+
|
|
353
|
+
// Deploy our L1 contracts.
|
|
354
|
+
logger.verbose('Deploying Aztec L1 contracts...');
|
|
339
355
|
if (opts.l1StartTime) {
|
|
340
|
-
await ethCheatCodes.warp(opts.l1StartTime);
|
|
356
|
+
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
341
357
|
}
|
|
342
358
|
|
|
343
359
|
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
344
|
-
const
|
|
345
|
-
|
|
360
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
361
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
|
|
362
|
+
initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
|
|
346
363
|
opts.initialAccountFeeJuice,
|
|
347
364
|
);
|
|
348
365
|
|
|
349
|
-
const
|
|
366
|
+
const vkTreeRoot = getVKTreeRoot();
|
|
367
|
+
await deployMulticall3(l1Client, logger);
|
|
368
|
+
|
|
369
|
+
// Define args, defaulted to our environment variables.
|
|
370
|
+
const args: DeployAztecL1ContractsArgs = {
|
|
350
371
|
...getL1ContractsConfigEnvVars(),
|
|
351
|
-
genesisArchiveRoot,
|
|
352
|
-
genesisBlockHash,
|
|
353
|
-
salt: opts.salt,
|
|
354
372
|
...deployL1ContractsArgs,
|
|
373
|
+
vkTreeRoot,
|
|
374
|
+
genesisArchiveRoot,
|
|
375
|
+
protocolContractsHash,
|
|
355
376
|
initialValidators: opts.initialValidators,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (opts.fundRewardDistributor) {
|
|
361
|
-
// Mints block rewards for 10000 blocks to the rewardDistributor contract
|
|
362
|
-
|
|
363
|
-
const rewardDistributor = getContract({
|
|
364
|
-
address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
365
|
-
abi: l1Artifacts.rewardDistributor.contractAbi,
|
|
366
|
-
client: deployL1ContractsValues.publicClient,
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
const blockReward = await rewardDistributor.read.BLOCK_REWARD();
|
|
370
|
-
const mintAmount = 10_000n * (blockReward as bigint);
|
|
377
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
378
|
+
realVerifier: false,
|
|
379
|
+
};
|
|
371
380
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
381
|
+
const deployL1ContractsValues = await deployAztecL1Contracts(
|
|
382
|
+
aztecNodeConfig.l1RpcUrls[0],
|
|
383
|
+
publisherPrivKeyHex,
|
|
384
|
+
foundry.id,
|
|
385
|
+
args,
|
|
386
|
+
);
|
|
377
387
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
381
|
-
}
|
|
388
|
+
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
389
|
+
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
382
390
|
|
|
383
391
|
const watcher = new AnvilTestWatcher(
|
|
384
|
-
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
392
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
|
|
385
393
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
386
|
-
deployL1ContractsValues.
|
|
394
|
+
deployL1ContractsValues.l1Client,
|
|
395
|
+
dateProvider,
|
|
387
396
|
);
|
|
388
397
|
await watcher.start();
|
|
389
398
|
|
|
@@ -399,34 +408,40 @@ async function setupFromFresh(
|
|
|
399
408
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
400
409
|
}
|
|
401
410
|
|
|
402
|
-
const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
411
|
+
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
403
412
|
|
|
404
|
-
|
|
405
|
-
|
|
413
|
+
const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('node:blob-client:client'));
|
|
414
|
+
|
|
415
|
+
logger.info('Creating and synching an aztec node...');
|
|
406
416
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
407
417
|
aztecNodeConfig,
|
|
408
|
-
{ telemetry, dateProvider },
|
|
418
|
+
{ telemetry, dateProvider, blobClient },
|
|
409
419
|
{ prefilledPublicData },
|
|
410
420
|
);
|
|
411
421
|
|
|
412
422
|
let proverNode: ProverNode | undefined = undefined;
|
|
413
423
|
if (opts.startProverNode) {
|
|
414
|
-
logger.verbose('Creating and syncing a simulated prover node...');
|
|
424
|
+
logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
|
|
415
425
|
proverNode = await createAndSyncProverNode(
|
|
416
426
|
`0x${proverNodePrivateKey!.toString('hex')}`,
|
|
417
427
|
aztecNodeConfig,
|
|
428
|
+
{
|
|
429
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
430
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
431
|
+
p2pEnabled: false,
|
|
432
|
+
},
|
|
418
433
|
aztecNode,
|
|
419
|
-
path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
420
434
|
prefilledPublicData,
|
|
421
435
|
);
|
|
422
436
|
}
|
|
423
437
|
|
|
424
438
|
logger.verbose('Creating pxe...');
|
|
425
|
-
const pxeConfig =
|
|
439
|
+
const pxeConfig = getPXEConfig();
|
|
426
440
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const
|
|
441
|
+
// Only enable proving if specifically requested.
|
|
442
|
+
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
443
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
444
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
430
445
|
|
|
431
446
|
if (statePath) {
|
|
432
447
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
@@ -437,7 +452,8 @@ async function setupFromFresh(
|
|
|
437
452
|
aztecNodeConfig,
|
|
438
453
|
anvil,
|
|
439
454
|
aztecNode,
|
|
440
|
-
|
|
455
|
+
wallet,
|
|
456
|
+
sequencer: aztecNode.getSequencer()!,
|
|
441
457
|
acvmConfig,
|
|
442
458
|
bbConfig,
|
|
443
459
|
deployL1ContractsValues,
|
|
@@ -445,7 +461,6 @@ async function setupFromFresh(
|
|
|
445
461
|
watcher,
|
|
446
462
|
cheatCodes,
|
|
447
463
|
dateProvider,
|
|
448
|
-
blobSink,
|
|
449
464
|
initialFundedAccounts,
|
|
450
465
|
directoryToCleanup,
|
|
451
466
|
};
|
|
@@ -460,36 +475,28 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
460
475
|
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
461
476
|
await fs.mkdir(directoryToCleanup, { recursive: true });
|
|
462
477
|
|
|
463
|
-
// Run the blob sink on a random port
|
|
464
|
-
const blobSinkPort = await getPort();
|
|
465
|
-
|
|
466
478
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
467
479
|
const aztecNodeConfig: AztecNodeConfig & SetupOptions = JSON.parse(
|
|
468
480
|
readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'),
|
|
469
481
|
reviver,
|
|
470
482
|
);
|
|
471
483
|
aztecNodeConfig.dataDirectory = statePath;
|
|
472
|
-
aztecNodeConfig.
|
|
484
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
485
|
+
|
|
486
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
473
487
|
|
|
474
488
|
const initialFundedAccounts: InitialAccountData[] =
|
|
475
489
|
JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
476
490
|
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
|
|
477
491
|
|
|
478
|
-
const blobSink = await createBlobSinkServer({
|
|
479
|
-
port: blobSinkPort,
|
|
480
|
-
dataStoreConfig: {
|
|
481
|
-
dataDirectory: statePath,
|
|
482
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
|
|
483
|
-
},
|
|
484
|
-
});
|
|
485
|
-
await blobSink.start();
|
|
486
|
-
|
|
487
492
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
488
493
|
const { anvil, rpcUrl } = await startAnvil();
|
|
489
494
|
aztecNodeConfig.l1RpcUrls = [rpcUrl];
|
|
490
495
|
// Load anvil state.
|
|
491
496
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
492
|
-
|
|
497
|
+
|
|
498
|
+
const dateProvider = new TestDateProvider();
|
|
499
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
493
500
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
494
501
|
|
|
495
502
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
@@ -506,21 +513,24 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
506
513
|
}
|
|
507
514
|
|
|
508
515
|
logger.verbose('Creating ETH clients...');
|
|
509
|
-
const
|
|
516
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
510
517
|
|
|
511
518
|
const watcher = new AnvilTestWatcher(
|
|
512
|
-
|
|
519
|
+
ethCheatCodes,
|
|
513
520
|
aztecNodeConfig.l1Contracts.rollupAddress,
|
|
514
|
-
|
|
521
|
+
l1Client,
|
|
522
|
+
dateProvider,
|
|
515
523
|
);
|
|
516
524
|
await watcher.start();
|
|
517
525
|
|
|
526
|
+
const telemetry = await initTelemetryClient(getTelemetryConfig());
|
|
527
|
+
|
|
528
|
+
const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('node:blob-client:client'));
|
|
529
|
+
|
|
518
530
|
logger.verbose('Creating aztec node...');
|
|
519
|
-
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
520
|
-
const dateProvider = new TestDateProvider();
|
|
521
531
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
522
532
|
aztecNodeConfig,
|
|
523
|
-
{ telemetry, dateProvider },
|
|
533
|
+
{ telemetry, dateProvider, blobClient },
|
|
524
534
|
{ prefilledPublicData },
|
|
525
535
|
);
|
|
526
536
|
|
|
@@ -532,36 +542,39 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
532
542
|
proverNode = await createAndSyncProverNode(
|
|
533
543
|
proverNodePrivateKeyHex,
|
|
534
544
|
aztecNodeConfig,
|
|
545
|
+
{
|
|
546
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
547
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
548
|
+
p2pEnabled: false,
|
|
549
|
+
},
|
|
535
550
|
aztecNode,
|
|
536
|
-
path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
537
551
|
prefilledPublicData,
|
|
538
552
|
);
|
|
539
553
|
}
|
|
540
554
|
|
|
541
555
|
logger.verbose('Creating pxe...');
|
|
542
|
-
const pxeConfig =
|
|
556
|
+
const pxeConfig = getPXEConfig();
|
|
543
557
|
pxeConfig.dataDirectory = statePath;
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
558
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
559
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
547
560
|
|
|
548
561
|
return {
|
|
549
562
|
aztecNodeConfig,
|
|
550
563
|
anvil,
|
|
551
564
|
aztecNode,
|
|
552
|
-
|
|
565
|
+
wallet,
|
|
566
|
+
sequencer: aztecNode.getSequencer()!,
|
|
553
567
|
acvmConfig,
|
|
554
568
|
bbConfig,
|
|
555
569
|
proverNode,
|
|
556
570
|
deployL1ContractsValues: {
|
|
557
|
-
|
|
558
|
-
publicClient,
|
|
571
|
+
l1Client,
|
|
559
572
|
l1ContractAddresses: aztecNodeConfig.l1Contracts,
|
|
573
|
+
rollupVersion: aztecNodeConfig.rollupVersion,
|
|
560
574
|
},
|
|
561
575
|
watcher,
|
|
562
576
|
cheatCodes,
|
|
563
577
|
dateProvider,
|
|
564
|
-
blobSink,
|
|
565
578
|
initialFundedAccounts,
|
|
566
579
|
directoryToCleanup,
|
|
567
580
|
};
|
|
@@ -572,15 +585,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
572
585
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
573
586
|
*/
|
|
574
587
|
export const deployAccounts =
|
|
575
|
-
(numberOfAccounts: number, logger: Logger
|
|
576
|
-
async ({
|
|
588
|
+
(numberOfAccounts: number, logger: Logger) =>
|
|
589
|
+
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
|
|
577
590
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
578
591
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
579
592
|
}
|
|
580
593
|
|
|
581
594
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
582
595
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
583
|
-
|
|
596
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
597
|
+
for (let i = 0; i < deployedAccounts.length; i++) {
|
|
598
|
+
const accountManager = await wallet.createSchnorrAccount(
|
|
599
|
+
deployedAccounts[i].secret,
|
|
600
|
+
deployedAccounts[i].salt,
|
|
601
|
+
deployedAccounts[i].signingKey,
|
|
602
|
+
);
|
|
603
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
604
|
+
await deployMethod
|
|
605
|
+
.send({
|
|
606
|
+
from: AztecAddress.ZERO,
|
|
607
|
+
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
608
|
+
})
|
|
609
|
+
.wait();
|
|
610
|
+
}
|
|
584
611
|
|
|
585
612
|
return { deployedAccounts };
|
|
586
613
|
};
|
|
@@ -590,28 +617,35 @@ export const deployAccounts =
|
|
|
590
617
|
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
591
618
|
* @param sender - Wallet to send the deployment tx.
|
|
592
619
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
620
|
+
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
621
|
+
* @param node - AztecNode used to wait for proven tx.
|
|
593
622
|
*/
|
|
594
623
|
export async function publicDeployAccounts(
|
|
595
|
-
|
|
596
|
-
accountsToDeploy:
|
|
624
|
+
wallet: Wallet,
|
|
625
|
+
accountsToDeploy: AztecAddress[],
|
|
597
626
|
waitUntilProven = false,
|
|
627
|
+
node?: AztecNode,
|
|
598
628
|
) {
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
).map(metadata => metadata.contractInstance);
|
|
629
|
+
const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
|
|
630
|
+
metadata => metadata.contractInstance,
|
|
631
|
+
);
|
|
603
632
|
|
|
604
633
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
605
|
-
const alreadyRegistered = (await
|
|
634
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
606
635
|
|
|
607
|
-
const
|
|
608
|
-
...(!alreadyRegistered ? [
|
|
609
|
-
...instances.map(instance =>
|
|
636
|
+
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
637
|
+
...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
|
|
638
|
+
...instances.map(instance => publishInstance(wallet, instance!)),
|
|
610
639
|
]);
|
|
611
|
-
const calls: FunctionCall[] = await Promise.all(fns.map(fn => fn.request()));
|
|
612
|
-
const capsules: Capsule[] = fns.map(fn => fn.getCapsules()).flat();
|
|
613
640
|
|
|
614
|
-
const batch = new BatchCall(
|
|
615
|
-
|
|
616
|
-
await batch.send(
|
|
641
|
+
const batch = new BatchCall(wallet, calls);
|
|
642
|
+
|
|
643
|
+
const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
644
|
+
if (waitUntilProven) {
|
|
645
|
+
if (!node) {
|
|
646
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
647
|
+
} else {
|
|
648
|
+
await waitForProven(node, txReceipt);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
617
651
|
}
|