@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
|
@@ -1,33 +1,36 @@
|
|
|
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 { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
4
13
|
import {
|
|
5
|
-
|
|
6
|
-
type AztecAddress,
|
|
7
|
-
BatchCall,
|
|
8
|
-
type Capsule,
|
|
9
|
-
CheatCodes,
|
|
10
|
-
type CompleteAddress,
|
|
11
|
-
type ContractFunctionInteraction,
|
|
14
|
+
type DeployL1ContractsArgs,
|
|
12
15
|
type DeployL1ContractsReturnType,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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';
|
|
16
|
+
createExtendedL1Client,
|
|
17
|
+
deployMulticall3,
|
|
18
|
+
getL1ContractsConfigEnvVars,
|
|
19
|
+
} from '@aztec/ethereum';
|
|
22
20
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
23
21
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
22
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
24
23
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
24
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
25
25
|
import { createLogger } from '@aztec/foundation/log';
|
|
26
26
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
27
27
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
28
28
|
import type { ProverNode } from '@aztec/prover-node';
|
|
29
|
-
import {
|
|
29
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
30
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
31
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
30
32
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
33
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
31
34
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
32
35
|
|
|
33
36
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -37,14 +40,21 @@ import fs from 'fs/promises';
|
|
|
37
40
|
import getPort from 'get-port';
|
|
38
41
|
import { tmpdir } from 'os';
|
|
39
42
|
import path, { join } from 'path';
|
|
40
|
-
import {
|
|
43
|
+
import type { Hex } from 'viem';
|
|
41
44
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
45
|
+
import { foundry } from 'viem/chains';
|
|
42
46
|
|
|
43
|
-
import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
47
|
+
import { MNEMONIC, TEST_MAX_TX_POOL_SIZE, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
44
48
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
45
49
|
import { getBBConfig } from './get_bb_config.js';
|
|
46
50
|
import { setupL1Contracts } from './setup_l1_contracts.js';
|
|
47
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
type SetupOptions,
|
|
53
|
+
createAndSyncProverNode,
|
|
54
|
+
getLogger,
|
|
55
|
+
getPrivateKeyFromIndex,
|
|
56
|
+
getSponsoredFPCAddress,
|
|
57
|
+
} from './utils.js';
|
|
48
58
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
49
59
|
|
|
50
60
|
export type SubsystemsContext = {
|
|
@@ -53,11 +63,12 @@ export type SubsystemsContext = {
|
|
|
53
63
|
bbConfig: any;
|
|
54
64
|
aztecNode: AztecNodeService;
|
|
55
65
|
aztecNodeConfig: AztecNodeConfig;
|
|
56
|
-
|
|
66
|
+
wallet: TestWallet;
|
|
57
67
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
58
68
|
proverNode?: ProverNode;
|
|
59
69
|
watcher: AnvilTestWatcher;
|
|
60
70
|
cheatCodes: CheatCodes;
|
|
71
|
+
sequencer: SequencerClient;
|
|
61
72
|
dateProvider: TestDateProvider;
|
|
62
73
|
blobSink: BlobSinkServer;
|
|
63
74
|
initialFundedAccounts: InitialAccountData[];
|
|
@@ -188,7 +199,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
188
199
|
await restore(snapshotData, context);
|
|
189
200
|
|
|
190
201
|
// Save the snapshot data.
|
|
191
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
202
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
|
|
192
203
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
193
204
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
194
205
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -253,24 +264,19 @@ async function teardown(context: SubsystemsContext | undefined) {
|
|
|
253
264
|
if (!context) {
|
|
254
265
|
return;
|
|
255
266
|
}
|
|
267
|
+
const logger = getLogger();
|
|
256
268
|
try {
|
|
257
|
-
|
|
258
|
-
await context.proverNode
|
|
259
|
-
await context.aztecNode
|
|
269
|
+
logger.info('Tearing down subsystems');
|
|
270
|
+
await tryStop(context.proverNode);
|
|
271
|
+
await tryStop(context.aztecNode);
|
|
260
272
|
await context.acvmConfig?.cleanup();
|
|
261
273
|
await context.bbConfig?.cleanup();
|
|
262
|
-
await context.anvil
|
|
263
|
-
await context.watcher
|
|
264
|
-
await context.blobSink
|
|
265
|
-
|
|
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
|
-
}
|
|
274
|
+
await tryStop(context.anvil);
|
|
275
|
+
await tryStop(context.watcher);
|
|
276
|
+
await tryStop(context.blobSink);
|
|
277
|
+
await tryRmDir(context.directoryToCleanup, logger);
|
|
272
278
|
} catch (err) {
|
|
273
|
-
|
|
279
|
+
logger.error('Error during teardown', err);
|
|
274
280
|
}
|
|
275
281
|
}
|
|
276
282
|
|
|
@@ -291,10 +297,24 @@ async function setupFromFresh(
|
|
|
291
297
|
|
|
292
298
|
const blobSinkPort = await getPort();
|
|
293
299
|
|
|
300
|
+
// Default to no slashing
|
|
301
|
+
opts.slasherFlavor ??= 'none';
|
|
302
|
+
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
303
|
+
|
|
294
304
|
// Fetch the AztecNode config.
|
|
295
305
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
296
306
|
const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
|
|
297
307
|
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
308
|
+
aztecNodeConfig.maxTxPoolSize = opts.maxTxPoolSize ?? TEST_MAX_TX_POOL_SIZE;
|
|
309
|
+
// Only enable proving if specifically requested.
|
|
310
|
+
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
311
|
+
// Only enforce the time table if requested
|
|
312
|
+
aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
|
|
313
|
+
// Only set the target committee size if it is explicitly set
|
|
314
|
+
aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
|
|
315
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
316
|
+
|
|
317
|
+
deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
|
|
298
318
|
|
|
299
319
|
// Create a temp directory for all ephemeral state and cleanup afterwards
|
|
300
320
|
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
@@ -304,17 +324,22 @@ async function setupFromFresh(
|
|
|
304
324
|
} else {
|
|
305
325
|
aztecNodeConfig.dataDirectory = statePath;
|
|
306
326
|
}
|
|
307
|
-
aztecNodeConfig.blobSinkUrl = `http://
|
|
327
|
+
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
308
328
|
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
329
|
+
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
330
|
+
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
331
|
+
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
332
|
+
|
|
333
|
+
const l1Client = createExtendedL1Client([aztecNodeConfig.l1RpcUrls[0]], hdAccount, foundry);
|
|
334
|
+
|
|
335
|
+
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
336
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
337
|
+
|
|
338
|
+
aztecNodeConfig.publisherPrivateKeys = [new SecretValue<`0x${string}`>(`0x${publisherPrivKey!.toString('hex')}`)];
|
|
339
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
|
|
340
|
+
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
341
|
+
|
|
342
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
318
343
|
|
|
319
344
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
320
345
|
logger.verbose('Starting anvil...');
|
|
@@ -322,68 +347,40 @@ async function setupFromFresh(
|
|
|
322
347
|
const anvil = res.anvil;
|
|
323
348
|
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
324
349
|
|
|
350
|
+
const dateProvider = new TestDateProvider();
|
|
351
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
352
|
+
|
|
325
353
|
// Deploy our L1 contracts.
|
|
326
354
|
logger.verbose('Deploying L1 contracts...');
|
|
327
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, { accountIndex: 0 });
|
|
328
|
-
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
329
|
-
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
330
|
-
|
|
331
|
-
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
332
|
-
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
333
|
-
|
|
334
|
-
aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
|
|
335
|
-
aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey!.toString('hex')}`;
|
|
336
|
-
|
|
337
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
338
|
-
|
|
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
|
|
|
366
|
+
await deployMulticall3(l1Client, logger);
|
|
367
|
+
|
|
349
368
|
const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrls[0], hdAccount, logger, {
|
|
350
369
|
...getL1ContractsConfigEnvVars(),
|
|
351
370
|
genesisArchiveRoot,
|
|
352
|
-
|
|
371
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
353
372
|
salt: opts.salt,
|
|
354
373
|
...deployL1ContractsArgs,
|
|
355
374
|
initialValidators: opts.initialValidators,
|
|
356
375
|
});
|
|
357
376
|
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
358
|
-
aztecNodeConfig.
|
|
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);
|
|
371
|
-
|
|
372
|
-
const feeJuice = getContract({
|
|
373
|
-
address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
374
|
-
abi: l1Artifacts.feeAsset.contractAbi,
|
|
375
|
-
client: deployL1ContractsValues.walletClient,
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
|
|
379
|
-
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
|
|
380
|
-
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
381
|
-
}
|
|
377
|
+
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
382
378
|
|
|
383
379
|
const watcher = new AnvilTestWatcher(
|
|
384
|
-
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
380
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
|
|
385
381
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
386
|
-
deployL1ContractsValues.
|
|
382
|
+
deployL1ContractsValues.l1Client,
|
|
383
|
+
dateProvider,
|
|
387
384
|
);
|
|
388
385
|
await watcher.start();
|
|
389
386
|
|
|
@@ -401,8 +398,21 @@ async function setupFromFresh(
|
|
|
401
398
|
|
|
402
399
|
const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
403
400
|
|
|
404
|
-
|
|
405
|
-
const
|
|
401
|
+
// Setup blob sink service
|
|
402
|
+
const blobSink = await createBlobSinkServer(
|
|
403
|
+
{
|
|
404
|
+
l1ChainId: aztecNodeConfig.l1ChainId,
|
|
405
|
+
l1RpcUrls: aztecNodeConfig.l1RpcUrls,
|
|
406
|
+
l1Contracts: aztecNodeConfig.l1Contracts,
|
|
407
|
+
port: blobSinkPort,
|
|
408
|
+
dataDirectory: aztecNodeConfig.dataDirectory,
|
|
409
|
+
dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
|
|
410
|
+
},
|
|
411
|
+
telemetry,
|
|
412
|
+
);
|
|
413
|
+
await blobSink.start();
|
|
414
|
+
|
|
415
|
+
logger.info('Creating and synching an aztec node...');
|
|
406
416
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
407
417
|
aztecNodeConfig,
|
|
408
418
|
{ telemetry, dateProvider },
|
|
@@ -411,22 +421,27 @@ async function setupFromFresh(
|
|
|
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,
|
|
@@ -470,26 +486,20 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
470
486
|
);
|
|
471
487
|
aztecNodeConfig.dataDirectory = statePath;
|
|
472
488
|
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
489
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
473
490
|
|
|
474
491
|
const initialFundedAccounts: InitialAccountData[] =
|
|
475
492
|
JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
476
493
|
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
|
|
477
494
|
|
|
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
495
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
488
496
|
const { anvil, rpcUrl } = await startAnvil();
|
|
489
497
|
aztecNodeConfig.l1RpcUrls = [rpcUrl];
|
|
490
498
|
// Load anvil state.
|
|
491
499
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
492
|
-
|
|
500
|
+
|
|
501
|
+
const dateProvider = new TestDateProvider();
|
|
502
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
493
503
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
494
504
|
|
|
495
505
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
@@ -506,18 +516,31 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
506
516
|
}
|
|
507
517
|
|
|
508
518
|
logger.verbose('Creating ETH clients...');
|
|
509
|
-
const
|
|
519
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
510
520
|
|
|
511
521
|
const watcher = new AnvilTestWatcher(
|
|
512
|
-
|
|
522
|
+
ethCheatCodes,
|
|
513
523
|
aztecNodeConfig.l1Contracts.rollupAddress,
|
|
514
|
-
|
|
524
|
+
l1Client,
|
|
525
|
+
dateProvider,
|
|
515
526
|
);
|
|
516
527
|
await watcher.start();
|
|
517
528
|
|
|
518
|
-
logger.verbose('Creating aztec node...');
|
|
519
529
|
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
520
|
-
const
|
|
530
|
+
const blobSink = await createBlobSinkServer(
|
|
531
|
+
{
|
|
532
|
+
l1ChainId: aztecNodeConfig.l1ChainId,
|
|
533
|
+
l1RpcUrls: aztecNodeConfig.l1RpcUrls,
|
|
534
|
+
l1Contracts: aztecNodeConfig.l1Contracts,
|
|
535
|
+
port: blobSinkPort,
|
|
536
|
+
dataDirectory: statePath,
|
|
537
|
+
dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
|
|
538
|
+
},
|
|
539
|
+
telemetry,
|
|
540
|
+
);
|
|
541
|
+
await blobSink.start();
|
|
542
|
+
|
|
543
|
+
logger.verbose('Creating aztec node...');
|
|
521
544
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
522
545
|
aztecNodeConfig,
|
|
523
546
|
{ telemetry, dateProvider },
|
|
@@ -532,31 +555,35 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
532
555
|
proverNode = await createAndSyncProverNode(
|
|
533
556
|
proverNodePrivateKeyHex,
|
|
534
557
|
aztecNodeConfig,
|
|
558
|
+
{
|
|
559
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
560
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
561
|
+
p2pEnabled: false,
|
|
562
|
+
},
|
|
535
563
|
aztecNode,
|
|
536
|
-
path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
537
564
|
prefilledPublicData,
|
|
538
565
|
);
|
|
539
566
|
}
|
|
540
567
|
|
|
541
568
|
logger.verbose('Creating pxe...');
|
|
542
|
-
const pxeConfig =
|
|
569
|
+
const pxeConfig = getPXEConfig();
|
|
543
570
|
pxeConfig.dataDirectory = statePath;
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
571
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
572
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
547
573
|
|
|
548
574
|
return {
|
|
549
575
|
aztecNodeConfig,
|
|
550
576
|
anvil,
|
|
551
577
|
aztecNode,
|
|
552
|
-
|
|
578
|
+
wallet,
|
|
579
|
+
sequencer: aztecNode.getSequencer()!,
|
|
553
580
|
acvmConfig,
|
|
554
581
|
bbConfig,
|
|
555
582
|
proverNode,
|
|
556
583
|
deployL1ContractsValues: {
|
|
557
|
-
|
|
558
|
-
publicClient,
|
|
584
|
+
l1Client,
|
|
559
585
|
l1ContractAddresses: aztecNodeConfig.l1Contracts,
|
|
586
|
+
rollupVersion: aztecNodeConfig.rollupVersion,
|
|
560
587
|
},
|
|
561
588
|
watcher,
|
|
562
589
|
cheatCodes,
|
|
@@ -572,15 +599,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
572
599
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
573
600
|
*/
|
|
574
601
|
export const deployAccounts =
|
|
575
|
-
(numberOfAccounts: number, logger: Logger
|
|
576
|
-
async ({
|
|
602
|
+
(numberOfAccounts: number, logger: Logger) =>
|
|
603
|
+
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
|
|
577
604
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
578
605
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
579
606
|
}
|
|
580
607
|
|
|
581
608
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
582
609
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
583
|
-
|
|
610
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
611
|
+
for (let i = 0; i < deployedAccounts.length; i++) {
|
|
612
|
+
const accountManager = await wallet.createSchnorrAccount(
|
|
613
|
+
deployedAccounts[i].secret,
|
|
614
|
+
deployedAccounts[i].salt,
|
|
615
|
+
deployedAccounts[i].signingKey,
|
|
616
|
+
);
|
|
617
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
618
|
+
await deployMethod
|
|
619
|
+
.send({
|
|
620
|
+
from: AztecAddress.ZERO,
|
|
621
|
+
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
622
|
+
})
|
|
623
|
+
.wait();
|
|
624
|
+
}
|
|
584
625
|
|
|
585
626
|
return { deployedAccounts };
|
|
586
627
|
};
|
|
@@ -590,28 +631,35 @@ export const deployAccounts =
|
|
|
590
631
|
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
591
632
|
* @param sender - Wallet to send the deployment tx.
|
|
592
633
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
634
|
+
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
635
|
+
* @param node - AztecNode used to wait for proven tx.
|
|
593
636
|
*/
|
|
594
637
|
export async function publicDeployAccounts(
|
|
595
|
-
|
|
596
|
-
accountsToDeploy:
|
|
638
|
+
wallet: Wallet,
|
|
639
|
+
accountsToDeploy: AztecAddress[],
|
|
597
640
|
waitUntilProven = false,
|
|
641
|
+
node?: AztecNode,
|
|
598
642
|
) {
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
).map(metadata => metadata.contractInstance);
|
|
643
|
+
const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
|
|
644
|
+
metadata => metadata.contractInstance,
|
|
645
|
+
);
|
|
603
646
|
|
|
604
647
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
605
|
-
const alreadyRegistered = (await
|
|
648
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
606
649
|
|
|
607
|
-
const
|
|
608
|
-
...(!alreadyRegistered ? [
|
|
609
|
-
...instances.map(instance =>
|
|
650
|
+
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
651
|
+
...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
|
|
652
|
+
...instances.map(instance => publishInstance(wallet, instance!)),
|
|
610
653
|
]);
|
|
611
|
-
const calls: FunctionCall[] = await Promise.all(fns.map(fn => fn.request()));
|
|
612
|
-
const capsules: Capsule[] = fns.map(fn => fn.getCapsules()).flat();
|
|
613
654
|
|
|
614
|
-
const batch = new BatchCall(
|
|
615
|
-
|
|
616
|
-
await batch.send(
|
|
655
|
+
const batch = new BatchCall(wallet, calls);
|
|
656
|
+
|
|
657
|
+
const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
658
|
+
if (waitUntilProven) {
|
|
659
|
+
if (!node) {
|
|
660
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
661
|
+
} else {
|
|
662
|
+
await waitForProven(node, txReceipt);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
617
665
|
}
|
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
5
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
6
|
|
|
5
|
-
export async function deployToken(
|
|
7
|
+
export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
|
|
6
8
|
logger.info(`Deploying Token contract...`);
|
|
7
|
-
const contract = await TokenContract.deploy(
|
|
8
|
-
.send()
|
|
9
|
-
.
|
|
9
|
+
const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18)
|
|
10
|
+
.send({ from: admin })
|
|
11
|
+
.wait();
|
|
10
12
|
|
|
11
13
|
if (initialAdminBalance > 0n) {
|
|
12
|
-
|
|
13
|
-
await mintTokensToPrivate(contract, adminWallet, adminWallet.getAddress(), initialAdminBalance);
|
|
14
|
+
await mintTokensToPrivate(contract, admin, admin, initialAdminBalance);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
logger.info('L2 contract deployed');
|
|
17
18
|
|
|
18
|
-
return contract;
|
|
19
|
+
return { contract, instance };
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export async function mintTokensToPrivate(
|
|
22
23
|
token: TokenContract,
|
|
23
|
-
|
|
24
|
+
minter: AztecAddress,
|
|
24
25
|
recipient: AztecAddress,
|
|
25
26
|
amount: bigint,
|
|
26
27
|
) {
|
|
27
|
-
|
|
28
|
-
const from = minterWallet.getAddress(); // we are setting from to minter here because we need a sender to calculate the tag
|
|
29
|
-
await tokenAsMinter.methods.mint_to_private(from, recipient, amount).send().wait();
|
|
28
|
+
await token.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
|
|
30
29
|
}
|
|
31
|
-
// docs:end:token_utils
|
|
32
30
|
|
|
33
31
|
export async function expectTokenBalance(
|
|
34
32
|
wallet: Wallet,
|
|
@@ -38,8 +36,27 @@ export async function expectTokenBalance(
|
|
|
38
36
|
logger: Logger,
|
|
39
37
|
) {
|
|
40
38
|
// Then check the balance
|
|
41
|
-
const contractWithWallet =
|
|
39
|
+
const contractWithWallet = TokenContract.at(token.address, wallet);
|
|
42
40
|
const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
43
41
|
logger.info(`Account ${owner} balance: ${balance}`);
|
|
44
42
|
expect(balance).toBe(expectedBalance);
|
|
45
43
|
}
|
|
44
|
+
|
|
45
|
+
export async function mintNotes(
|
|
46
|
+
wallet: Wallet,
|
|
47
|
+
minter: AztecAddress,
|
|
48
|
+
recipient: AztecAddress,
|
|
49
|
+
asset: TokenContract,
|
|
50
|
+
noteAmounts: bigint[],
|
|
51
|
+
): Promise<bigint> {
|
|
52
|
+
// We can only mint 5 notes at a time, since that's the maximum number of calls our entrypoints allow
|
|
53
|
+
// TODO(#13024): mint as many notes as possible in a single tx
|
|
54
|
+
const notesPerIteration = 5;
|
|
55
|
+
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
|
|
56
|
+
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
57
|
+
const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
|
|
58
|
+
await new BatchCall(wallet, actions).send({ from: minter }).wait();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
|
|
62
|
+
}
|