@aztec/end-to-end 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +4 -3
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +26 -15
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +111 -90
- package/dest/bench/client_flows/config.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.js +10 -30
- package/dest/bench/utils.d.ts +3 -12
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +17 -37
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +8 -8
- 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 +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +13 -10
- 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 +35 -35
- package/dest/e2e_deploy_contract/deploy_test.d.ts +12 -6
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +20 -12
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +36 -27
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +14 -11
- package/dest/e2e_fees/fees_test.d.ts +13 -9
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +39 -40
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +9 -8
- package/dest/e2e_multi_validator/utils.d.ts +2 -2
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +4 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -4
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +11 -12
- 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 +238 -18
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +50 -25
- package/dest/e2e_p2p/shared.d.ts +16 -17
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +57 -56
- package/dest/e2e_token_contract/token_contract_test.d.ts +6 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +13 -11
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +57 -66
- package/dest/fixtures/fixtures.d.ts +2 -3
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +2 -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 +1 -1
- 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 +2 -2
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +2 -2
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +12 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +50 -24
- package/dest/fixtures/snapshot_manager.d.ts +16 -15
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +84 -88
- package/dest/fixtures/token_utils.d.ts +10 -5
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +17 -18
- package/dest/fixtures/utils.d.ts +44 -47
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +128 -185
- 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 +20 -23
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +14 -16
- package/dest/shared/gas_portal_test_harness.d.ts +10 -17
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +11 -8
- 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 +13 -9
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +44 -58
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +4 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +8 -5
- package/dest/simulators/token_simulator.d.ts +4 -2
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +22 -14
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +144 -86
- 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 +101 -16
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +414 -52
- package/package.json +43 -40
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +143 -115
- package/src/bench/client_flows/data_extractor.ts +9 -31
- package/src/bench/utils.ts +15 -39
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +46 -55
- package/src/e2e_deploy_contract/deploy_test.ts +18 -36
- package/src/e2e_epochs/epochs_test.ts +59 -42
- package/src/e2e_fees/bridging_race.notest.ts +16 -11
- package/src/e2e_fees/fees_test.ts +48 -52
- package/src/e2e_l1_publisher/write_json.ts +12 -9
- package/src/e2e_multi_validator/utils.ts +5 -11
- package/src/e2e_nested_contract/nested_contract_test.ts +15 -13
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +125 -89
- package/src/e2e_p2p/shared.ts +69 -60
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +65 -105
- package/src/fixtures/fixtures.ts +2 -5
- package/src/fixtures/get_acvm_config.ts +2 -2
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/setup_p2p_test.ts +79 -32
- package/src/fixtures/snapshot_manager.ts +120 -131
- package/src/fixtures/token_utils.ts +16 -24
- package/src/fixtures/utils.ts +175 -269
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +3 -11
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +23 -31
- package/src/shared/gas_portal_test_harness.ts +14 -21
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +80 -88
- package/src/simulators/lending_simulator.ts +9 -6
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +15 -3
- package/src/spartan/setup_test_wallets.ts +171 -127
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +543 -45
- 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/src/fixtures/setup_l1_contracts.ts +0 -26
|
@@ -1,66 +1,60 @@
|
|
|
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 {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
BatchCall,
|
|
8
|
-
type CompleteAddress,
|
|
9
|
-
type ContractFunctionInteraction,
|
|
10
|
-
DefaultWaitForProvenOpts,
|
|
11
|
-
EthAddress,
|
|
12
|
-
type Logger,
|
|
13
|
-
type PXE,
|
|
14
|
-
type Wallet,
|
|
15
|
-
getContractClassFromArtifact,
|
|
16
|
-
waitForProven,
|
|
17
|
-
} from '@aztec/aztec.js';
|
|
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';
|
|
18
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';
|
|
19
11
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
20
|
-
import {
|
|
12
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
13
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
14
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
21
15
|
import {
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
getL1ContractsConfigEnvVars,
|
|
27
|
-
} from '@aztec/ethereum';
|
|
16
|
+
type DeployAztecL1ContractsArgs,
|
|
17
|
+
type DeployAztecL1ContractsReturnType,
|
|
18
|
+
deployAztecL1Contracts,
|
|
19
|
+
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
28
20
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
29
21
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
30
22
|
import { SecretValue } from '@aztec/foundation/config';
|
|
31
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
23
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
32
24
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
33
25
|
import { createLogger } from '@aztec/foundation/log';
|
|
34
26
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
35
27
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
28
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
29
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
36
30
|
import type { ProverNode } from '@aztec/prover-node';
|
|
37
|
-
import {
|
|
31
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
38
32
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
39
33
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
40
34
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
35
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
41
36
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
42
37
|
|
|
43
38
|
import type { Anvil } from '@viem/anvil';
|
|
44
39
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
45
40
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
46
41
|
import fs from 'fs/promises';
|
|
47
|
-
import getPort from 'get-port';
|
|
48
42
|
import { tmpdir } from 'os';
|
|
49
43
|
import path, { join } from 'path';
|
|
50
44
|
import type { Hex } from 'viem';
|
|
51
45
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
52
46
|
import { foundry } from 'viem/chains';
|
|
53
47
|
|
|
54
|
-
import { MNEMONIC,
|
|
48
|
+
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
55
49
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
56
50
|
import { getBBConfig } from './get_bb_config.js';
|
|
57
|
-
import { setupL1Contracts } from './setup_l1_contracts.js';
|
|
58
51
|
import {
|
|
59
52
|
type SetupOptions,
|
|
60
53
|
createAndSyncProverNode,
|
|
61
54
|
getLogger,
|
|
62
55
|
getPrivateKeyFromIndex,
|
|
63
56
|
getSponsoredFPCAddress,
|
|
57
|
+
setupSharedBlobStorage,
|
|
64
58
|
} from './utils.js';
|
|
65
59
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
66
60
|
|
|
@@ -70,14 +64,13 @@ export type SubsystemsContext = {
|
|
|
70
64
|
bbConfig: any;
|
|
71
65
|
aztecNode: AztecNodeService;
|
|
72
66
|
aztecNodeConfig: AztecNodeConfig;
|
|
73
|
-
|
|
74
|
-
deployL1ContractsValues:
|
|
67
|
+
wallet: TestWallet;
|
|
68
|
+
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
75
69
|
proverNode?: ProverNode;
|
|
76
70
|
watcher: AnvilTestWatcher;
|
|
77
71
|
cheatCodes: CheatCodes;
|
|
78
72
|
sequencer: SequencerClient;
|
|
79
73
|
dateProvider: TestDateProvider;
|
|
80
|
-
blobSink: BlobSinkServer;
|
|
81
74
|
initialFundedAccounts: InitialAccountData[];
|
|
82
75
|
directoryToCleanup?: string;
|
|
83
76
|
};
|
|
@@ -93,7 +86,7 @@ export function createSnapshotManager(
|
|
|
93
86
|
testName: string,
|
|
94
87
|
dataPath?: string,
|
|
95
88
|
config: Partial<SetupOptions> = {},
|
|
96
|
-
deployL1ContractsArgs: Partial<
|
|
89
|
+
deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
|
|
97
90
|
initialValidators: [],
|
|
98
91
|
},
|
|
99
92
|
) {
|
|
@@ -122,7 +115,7 @@ class MockSnapshotManager implements ISnapshotManager {
|
|
|
122
115
|
constructor(
|
|
123
116
|
testName: string,
|
|
124
117
|
private config: Partial<AztecNodeConfig> = {},
|
|
125
|
-
private deployL1ContractsArgs: Partial<
|
|
118
|
+
private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {},
|
|
126
119
|
) {
|
|
127
120
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
128
121
|
this.logger.warn(`No data path given, will not persist any snapshots.`);
|
|
@@ -170,7 +163,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
170
163
|
testName: string,
|
|
171
164
|
private dataPath: string,
|
|
172
165
|
private config: Partial<SetupOptions> = {},
|
|
173
|
-
private deployL1ContractsArgs: Partial<
|
|
166
|
+
private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {},
|
|
174
167
|
) {
|
|
175
168
|
this.livePath = join(this.dataPath, 'live', testName);
|
|
176
169
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
@@ -206,7 +199,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
206
199
|
await restore(snapshotData, context);
|
|
207
200
|
|
|
208
201
|
// Save the snapshot data.
|
|
209
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
202
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
|
|
210
203
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
211
204
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
212
205
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -280,7 +273,6 @@ async function teardown(context: SubsystemsContext | undefined) {
|
|
|
280
273
|
await context.bbConfig?.cleanup();
|
|
281
274
|
await tryStop(context.anvil);
|
|
282
275
|
await tryStop(context.watcher);
|
|
283
|
-
await tryStop(context.blobSink);
|
|
284
276
|
await tryRmDir(context.directoryToCleanup, logger);
|
|
285
277
|
} catch (err) {
|
|
286
278
|
logger.error('Error during teardown', err);
|
|
@@ -296,14 +288,12 @@ async function setupFromFresh(
|
|
|
296
288
|
statePath: string | undefined,
|
|
297
289
|
logger: Logger,
|
|
298
290
|
{ numberOfInitialFundedAccounts = 10, ...opts }: SetupOptions = {},
|
|
299
|
-
deployL1ContractsArgs: Partial<
|
|
291
|
+
deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
|
|
300
292
|
initialValidators: [],
|
|
301
293
|
},
|
|
302
294
|
): Promise<SubsystemsContext> {
|
|
303
295
|
logger.verbose(`Initializing state...`);
|
|
304
296
|
|
|
305
|
-
const blobSinkPort = await getPort();
|
|
306
|
-
|
|
307
297
|
// Default to no slashing
|
|
308
298
|
opts.slasherFlavor ??= 'none';
|
|
309
299
|
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
@@ -312,7 +302,7 @@ async function setupFromFresh(
|
|
|
312
302
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
313
303
|
const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
|
|
314
304
|
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
315
|
-
aztecNodeConfig.
|
|
305
|
+
aztecNodeConfig.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
|
|
316
306
|
// Only enable proving if specifically requested.
|
|
317
307
|
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
318
308
|
// Only enforce the time table if requested
|
|
@@ -331,31 +321,36 @@ async function setupFromFresh(
|
|
|
331
321
|
} else {
|
|
332
322
|
aztecNodeConfig.dataDirectory = statePath;
|
|
333
323
|
}
|
|
334
|
-
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
335
324
|
|
|
336
|
-
|
|
337
|
-
logger.verbose('Starting anvil...');
|
|
338
|
-
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
339
|
-
const anvil = res.anvil;
|
|
340
|
-
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
325
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
341
326
|
|
|
342
|
-
// Deploy our L1 contracts.
|
|
343
|
-
logger.verbose('Deploying L1 contracts...');
|
|
344
327
|
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
345
328
|
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
346
329
|
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
330
|
+
const publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` satisfies `0x${string}`;
|
|
347
331
|
|
|
348
332
|
const l1Client = createExtendedL1Client([aztecNodeConfig.l1RpcUrls[0]], hdAccount, foundry);
|
|
349
333
|
|
|
350
334
|
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
351
335
|
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
352
336
|
|
|
353
|
-
aztecNodeConfig.publisherPrivateKeys = [new SecretValue
|
|
337
|
+
aztecNodeConfig.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
|
|
354
338
|
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
|
|
355
339
|
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
356
340
|
|
|
357
|
-
|
|
341
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
358
342
|
|
|
343
|
+
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
344
|
+
logger.verbose('Starting anvil...');
|
|
345
|
+
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
346
|
+
const anvil = res.anvil;
|
|
347
|
+
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
348
|
+
|
|
349
|
+
const dateProvider = new TestDateProvider();
|
|
350
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
351
|
+
|
|
352
|
+
// Deploy our L1 contracts.
|
|
353
|
+
logger.verbose('Deploying Aztec L1 contracts...');
|
|
359
354
|
if (opts.l1StartTime) {
|
|
360
355
|
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
361
356
|
}
|
|
@@ -367,24 +362,33 @@ async function setupFromFresh(
|
|
|
367
362
|
opts.initialAccountFeeJuice,
|
|
368
363
|
);
|
|
369
364
|
|
|
365
|
+
const vkTreeRoot = getVKTreeRoot();
|
|
370
366
|
await deployMulticall3(l1Client, logger);
|
|
371
367
|
|
|
372
|
-
|
|
368
|
+
// Define args, defaulted to our environment variables.
|
|
369
|
+
const args: DeployAztecL1ContractsArgs = {
|
|
373
370
|
...getL1ContractsConfigEnvVars(),
|
|
374
|
-
genesisArchiveRoot,
|
|
375
|
-
feeJuicePortalInitialBalance: fundingNeeded,
|
|
376
|
-
salt: opts.salt,
|
|
377
371
|
...deployL1ContractsArgs,
|
|
372
|
+
vkTreeRoot,
|
|
373
|
+
genesisArchiveRoot,
|
|
374
|
+
protocolContractsHash,
|
|
378
375
|
initialValidators: opts.initialValidators,
|
|
379
|
-
|
|
376
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
377
|
+
realVerifier: false,
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const deployL1ContractsValues = await deployAztecL1Contracts(
|
|
381
|
+
aztecNodeConfig.l1RpcUrls[0],
|
|
382
|
+
publisherPrivKeyHex,
|
|
383
|
+
foundry.id,
|
|
384
|
+
args,
|
|
385
|
+
);
|
|
386
|
+
|
|
380
387
|
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
381
388
|
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
382
|
-
aztecNodeConfig.l1PublishRetryIntervalMS = 100;
|
|
383
|
-
|
|
384
|
-
const dateProvider = new TestDateProvider();
|
|
385
389
|
|
|
386
390
|
const watcher = new AnvilTestWatcher(
|
|
387
|
-
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
391
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
|
|
388
392
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
389
393
|
deployL1ContractsValues.l1Client,
|
|
390
394
|
dateProvider,
|
|
@@ -403,21 +407,7 @@ async function setupFromFresh(
|
|
|
403
407
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
404
408
|
}
|
|
405
409
|
|
|
406
|
-
const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
407
|
-
|
|
408
|
-
// Setup blob sink service
|
|
409
|
-
const blobSink = await createBlobSinkServer(
|
|
410
|
-
{
|
|
411
|
-
l1ChainId: aztecNodeConfig.l1ChainId,
|
|
412
|
-
l1RpcUrls: aztecNodeConfig.l1RpcUrls,
|
|
413
|
-
l1Contracts: aztecNodeConfig.l1Contracts,
|
|
414
|
-
port: blobSinkPort,
|
|
415
|
-
dataDirectory: aztecNodeConfig.dataDirectory,
|
|
416
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
|
|
417
|
-
},
|
|
418
|
-
telemetry,
|
|
419
|
-
);
|
|
420
|
-
await blobSink.start();
|
|
410
|
+
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
421
411
|
|
|
422
412
|
logger.info('Creating and synching an aztec node...');
|
|
423
413
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
@@ -432,20 +422,23 @@ async function setupFromFresh(
|
|
|
432
422
|
proverNode = await createAndSyncProverNode(
|
|
433
423
|
`0x${proverNodePrivateKey!.toString('hex')}`,
|
|
434
424
|
aztecNodeConfig,
|
|
435
|
-
{
|
|
425
|
+
{
|
|
426
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
427
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
428
|
+
p2pEnabled: false,
|
|
429
|
+
},
|
|
436
430
|
aztecNode,
|
|
437
431
|
prefilledPublicData,
|
|
438
432
|
);
|
|
439
433
|
}
|
|
440
434
|
|
|
441
435
|
logger.verbose('Creating pxe...');
|
|
442
|
-
const pxeConfig =
|
|
436
|
+
const pxeConfig = getPXEConfig();
|
|
443
437
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
444
438
|
// Only enable proving if specifically requested.
|
|
445
439
|
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
440
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
441
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
449
442
|
|
|
450
443
|
if (statePath) {
|
|
451
444
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
@@ -456,7 +449,7 @@ async function setupFromFresh(
|
|
|
456
449
|
aztecNodeConfig,
|
|
457
450
|
anvil,
|
|
458
451
|
aztecNode,
|
|
459
|
-
|
|
452
|
+
wallet,
|
|
460
453
|
sequencer: aztecNode.getSequencer()!,
|
|
461
454
|
acvmConfig,
|
|
462
455
|
bbConfig,
|
|
@@ -465,7 +458,6 @@ async function setupFromFresh(
|
|
|
465
458
|
watcher,
|
|
466
459
|
cheatCodes,
|
|
467
460
|
dateProvider,
|
|
468
|
-
blobSink,
|
|
469
461
|
initialFundedAccounts,
|
|
470
462
|
directoryToCleanup,
|
|
471
463
|
};
|
|
@@ -480,18 +472,16 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
480
472
|
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
481
473
|
await fs.mkdir(directoryToCleanup, { recursive: true });
|
|
482
474
|
|
|
483
|
-
// Run the blob sink on a random port
|
|
484
|
-
const blobSinkPort = await getPort();
|
|
485
|
-
|
|
486
475
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
487
476
|
const aztecNodeConfig: AztecNodeConfig & SetupOptions = JSON.parse(
|
|
488
477
|
readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'),
|
|
489
478
|
reviver,
|
|
490
479
|
);
|
|
491
480
|
aztecNodeConfig.dataDirectory = statePath;
|
|
492
|
-
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
493
481
|
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
494
482
|
|
|
483
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
484
|
+
|
|
495
485
|
const initialFundedAccounts: InitialAccountData[] =
|
|
496
486
|
JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
497
487
|
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
|
|
@@ -501,7 +491,9 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
501
491
|
aztecNodeConfig.l1RpcUrls = [rpcUrl];
|
|
502
492
|
// Load anvil state.
|
|
503
493
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
504
|
-
|
|
494
|
+
|
|
495
|
+
const dateProvider = new TestDateProvider();
|
|
496
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
505
497
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
506
498
|
|
|
507
499
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
@@ -520,28 +512,15 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
520
512
|
logger.verbose('Creating ETH clients...');
|
|
521
513
|
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
522
514
|
|
|
523
|
-
const dateProvider = new TestDateProvider();
|
|
524
515
|
const watcher = new AnvilTestWatcher(
|
|
525
|
-
|
|
516
|
+
ethCheatCodes,
|
|
526
517
|
aztecNodeConfig.l1Contracts.rollupAddress,
|
|
527
518
|
l1Client,
|
|
528
519
|
dateProvider,
|
|
529
520
|
);
|
|
530
521
|
await watcher.start();
|
|
531
522
|
|
|
532
|
-
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
533
|
-
const blobSink = await createBlobSinkServer(
|
|
534
|
-
{
|
|
535
|
-
l1ChainId: aztecNodeConfig.l1ChainId,
|
|
536
|
-
l1RpcUrls: aztecNodeConfig.l1RpcUrls,
|
|
537
|
-
l1Contracts: aztecNodeConfig.l1Contracts,
|
|
538
|
-
port: blobSinkPort,
|
|
539
|
-
dataDirectory: statePath,
|
|
540
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
|
|
541
|
-
},
|
|
542
|
-
telemetry,
|
|
543
|
-
);
|
|
544
|
-
await blobSink.start();
|
|
523
|
+
const telemetry = await initTelemetryClient(getTelemetryConfig());
|
|
545
524
|
|
|
546
525
|
logger.verbose('Creating aztec node...');
|
|
547
526
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
@@ -558,24 +537,27 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
558
537
|
proverNode = await createAndSyncProverNode(
|
|
559
538
|
proverNodePrivateKeyHex,
|
|
560
539
|
aztecNodeConfig,
|
|
561
|
-
{
|
|
540
|
+
{
|
|
541
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
542
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
543
|
+
p2pEnabled: false,
|
|
544
|
+
},
|
|
562
545
|
aztecNode,
|
|
563
546
|
prefilledPublicData,
|
|
564
547
|
);
|
|
565
548
|
}
|
|
566
549
|
|
|
567
550
|
logger.verbose('Creating pxe...');
|
|
568
|
-
const pxeConfig =
|
|
551
|
+
const pxeConfig = getPXEConfig();
|
|
569
552
|
pxeConfig.dataDirectory = statePath;
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
553
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
554
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
573
555
|
|
|
574
556
|
return {
|
|
575
557
|
aztecNodeConfig,
|
|
576
558
|
anvil,
|
|
577
559
|
aztecNode,
|
|
578
|
-
|
|
560
|
+
wallet,
|
|
579
561
|
sequencer: aztecNode.getSequencer()!,
|
|
580
562
|
acvmConfig,
|
|
581
563
|
bbConfig,
|
|
@@ -588,7 +570,6 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
588
570
|
watcher,
|
|
589
571
|
cheatCodes,
|
|
590
572
|
dateProvider,
|
|
591
|
-
blobSink,
|
|
592
573
|
initialFundedAccounts,
|
|
593
574
|
directoryToCleanup,
|
|
594
575
|
};
|
|
@@ -599,20 +580,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
599
580
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
600
581
|
*/
|
|
601
582
|
export const deployAccounts =
|
|
602
|
-
(numberOfAccounts: number, logger: Logger
|
|
603
|
-
async ({
|
|
583
|
+
(numberOfAccounts: number, logger: Logger) =>
|
|
584
|
+
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
|
|
604
585
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
605
586
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
606
587
|
}
|
|
607
588
|
|
|
608
589
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
609
590
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
591
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
592
|
+
for (let i = 0; i < deployedAccounts.length; i++) {
|
|
593
|
+
const accountManager = await wallet.createSchnorrAccount(
|
|
594
|
+
deployedAccounts[i].secret,
|
|
595
|
+
deployedAccounts[i].salt,
|
|
596
|
+
deployedAccounts[i].signingKey,
|
|
597
|
+
);
|
|
598
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
599
|
+
await deployMethod
|
|
600
|
+
.send({
|
|
601
|
+
from: AztecAddress.ZERO,
|
|
602
|
+
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
603
|
+
})
|
|
604
|
+
.wait();
|
|
605
|
+
}
|
|
616
606
|
|
|
617
607
|
return { deployedAccounts };
|
|
618
608
|
};
|
|
@@ -623,35 +613,34 @@ export const deployAccounts =
|
|
|
623
613
|
* @param sender - Wallet to send the deployment tx.
|
|
624
614
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
625
615
|
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
626
|
-
* @param
|
|
616
|
+
* @param node - AztecNode used to wait for proven tx.
|
|
627
617
|
*/
|
|
628
618
|
export async function publicDeployAccounts(
|
|
629
|
-
|
|
630
|
-
accountsToDeploy:
|
|
619
|
+
wallet: Wallet,
|
|
620
|
+
accountsToDeploy: AztecAddress[],
|
|
631
621
|
waitUntilProven = false,
|
|
632
|
-
|
|
622
|
+
node?: AztecNode,
|
|
633
623
|
) {
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
).map(metadata => metadata.contractInstance);
|
|
624
|
+
const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
|
|
625
|
+
metadata => metadata.contractInstance,
|
|
626
|
+
);
|
|
638
627
|
|
|
639
628
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
640
|
-
const alreadyRegistered = (await
|
|
629
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
641
630
|
|
|
642
631
|
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
643
|
-
...(!alreadyRegistered ? [publishContractClass(
|
|
644
|
-
...instances.map(instance => publishInstance(
|
|
632
|
+
...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
|
|
633
|
+
...instances.map(instance => publishInstance(wallet, instance!)),
|
|
645
634
|
]);
|
|
646
635
|
|
|
647
|
-
const batch = new BatchCall(
|
|
636
|
+
const batch = new BatchCall(wallet, calls);
|
|
648
637
|
|
|
649
|
-
const txReceipt = await batch.send({ from:
|
|
638
|
+
const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
650
639
|
if (waitUntilProven) {
|
|
651
|
-
if (!
|
|
652
|
-
throw new Error('Need to provide
|
|
640
|
+
if (!node) {
|
|
641
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
653
642
|
} else {
|
|
654
|
-
await waitForProven(
|
|
643
|
+
await waitForProven(node, txReceipt);
|
|
655
644
|
}
|
|
656
645
|
}
|
|
657
646
|
}
|
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
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';
|
|
2
5
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export async function deployToken(
|
|
7
|
-
adminWallet: Wallet,
|
|
8
|
-
deployerAddress: AztecAddress,
|
|
9
|
-
initialAdminBalance: bigint,
|
|
10
|
-
logger: Logger,
|
|
11
|
-
) {
|
|
7
|
+
export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
|
|
12
8
|
logger.info(`Deploying Token contract...`);
|
|
13
|
-
const contract = await TokenContract.deploy(
|
|
14
|
-
.send({ from:
|
|
15
|
-
.
|
|
9
|
+
const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18)
|
|
10
|
+
.send({ from: admin })
|
|
11
|
+
.wait();
|
|
16
12
|
|
|
17
13
|
if (initialAdminBalance > 0n) {
|
|
18
|
-
|
|
19
|
-
await mintTokensToPrivate(contract, deployerAddress, adminWallet, deployerAddress, initialAdminBalance);
|
|
14
|
+
await mintTokensToPrivate(contract, admin, admin, initialAdminBalance);
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
logger.info('L2 contract deployed');
|
|
23
18
|
|
|
24
|
-
return contract;
|
|
19
|
+
return { contract, instance };
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
export async function mintTokensToPrivate(
|
|
28
23
|
token: TokenContract,
|
|
29
24
|
minter: AztecAddress,
|
|
30
|
-
minterWallet: Wallet,
|
|
31
25
|
recipient: AztecAddress,
|
|
32
26
|
amount: bigint,
|
|
33
27
|
) {
|
|
34
|
-
|
|
35
|
-
await tokenAsMinter.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
|
|
28
|
+
await token.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
|
|
36
29
|
}
|
|
37
|
-
// docs:end:token_utils
|
|
38
30
|
|
|
39
31
|
export async function expectTokenBalance(
|
|
40
32
|
wallet: Wallet,
|
|
@@ -44,26 +36,26 @@ export async function expectTokenBalance(
|
|
|
44
36
|
logger: Logger,
|
|
45
37
|
) {
|
|
46
38
|
// Then check the balance
|
|
47
|
-
const contractWithWallet =
|
|
39
|
+
const contractWithWallet = TokenContract.at(token.address, wallet);
|
|
48
40
|
const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
|
|
49
41
|
logger.info(`Account ${owner} balance: ${balance}`);
|
|
50
42
|
expect(balance).toBe(expectedBalance);
|
|
51
43
|
}
|
|
52
44
|
|
|
53
45
|
export async function mintNotes(
|
|
54
|
-
|
|
46
|
+
wallet: Wallet,
|
|
55
47
|
minter: AztecAddress,
|
|
56
48
|
recipient: AztecAddress,
|
|
57
49
|
asset: TokenContract,
|
|
58
50
|
noteAmounts: bigint[],
|
|
59
51
|
): Promise<bigint> {
|
|
60
|
-
// We can only mint
|
|
52
|
+
// We can only mint 5 notes at a time, since that's the maximum number of calls our entrypoints allow
|
|
61
53
|
// TODO(#13024): mint as many notes as possible in a single tx
|
|
62
|
-
const notesPerIteration =
|
|
54
|
+
const notesPerIteration = 5;
|
|
63
55
|
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
|
|
64
56
|
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
65
57
|
const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
|
|
66
|
-
await new BatchCall(
|
|
58
|
+
await new BatchCall(wallet, actions).send({ from: minter }).wait();
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
|