@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,32 +1,42 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
2
|
+
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
3
|
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
5
|
+
import { getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
|
|
6
|
+
import { BatchCall, waitForProven } from '@aztec/aztec.js/contracts';
|
|
7
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
+
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
9
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
10
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
11
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
13
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
8
14
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
9
15
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
10
|
-
import {
|
|
16
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
17
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
18
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
11
19
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
20
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
13
21
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
|
-
import {
|
|
22
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
23
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
24
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
25
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
15
26
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
27
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
16
28
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
17
29
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
18
30
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
19
31
|
import fs from 'fs/promises';
|
|
20
|
-
import getPort from 'get-port';
|
|
21
32
|
import { tmpdir } from 'os';
|
|
22
33
|
import path, { join } from 'path';
|
|
23
|
-
import { getContract } from 'viem';
|
|
24
34
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
25
|
-
import {
|
|
35
|
+
import { foundry } from 'viem/chains';
|
|
36
|
+
import { MNEMONIC, TEST_MAX_TX_POOL_SIZE, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
26
37
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
27
38
|
import { getBBConfig } from './get_bb_config.js';
|
|
28
|
-
import {
|
|
29
|
-
import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex } from './utils.js';
|
|
39
|
+
import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex, getSponsoredFPCAddress, setupSharedBlobStorage } from './utils.js';
|
|
30
40
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
31
41
|
export function createSnapshotManager(testName, dataPath, config = {}, deployL1ContractsArgs = {
|
|
32
42
|
initialValidators: []
|
|
@@ -114,7 +124,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
114
124
|
// Execute the restoration function.
|
|
115
125
|
await restore(snapshotData, context);
|
|
116
126
|
// Save the snapshot data.
|
|
117
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
127
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
|
|
118
128
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
119
129
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
120
130
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -176,28 +186,18 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
176
186
|
if (!context) {
|
|
177
187
|
return;
|
|
178
188
|
}
|
|
189
|
+
const logger = getLogger();
|
|
179
190
|
try {
|
|
180
|
-
|
|
181
|
-
await context.proverNode
|
|
182
|
-
await context.aztecNode
|
|
191
|
+
logger.info('Tearing down subsystems');
|
|
192
|
+
await tryStop(context.proverNode);
|
|
193
|
+
await tryStop(context.aztecNode);
|
|
183
194
|
await context.acvmConfig?.cleanup();
|
|
184
195
|
await context.bbConfig?.cleanup();
|
|
185
|
-
await context.anvil
|
|
186
|
-
await context.watcher
|
|
187
|
-
await context.
|
|
188
|
-
if (context.directoryToCleanup) {
|
|
189
|
-
try {
|
|
190
|
-
await fs.rm(context.directoryToCleanup, {
|
|
191
|
-
recursive: true,
|
|
192
|
-
force: true,
|
|
193
|
-
maxRetries: 3
|
|
194
|
-
});
|
|
195
|
-
} catch (err) {
|
|
196
|
-
getLogger().warn(`Failed to delete tmp directory ${context.directoryToCleanup}: ${err}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
196
|
+
await tryStop(context.anvil);
|
|
197
|
+
await tryStop(context.watcher);
|
|
198
|
+
await tryRmDir(context.directoryToCleanup, logger);
|
|
199
199
|
} catch (err) {
|
|
200
|
-
|
|
200
|
+
logger.error('Error during teardown', err);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
@@ -208,7 +208,9 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
208
208
|
initialValidators: []
|
|
209
209
|
}) {
|
|
210
210
|
logger.verbose(`Initializing state...`);
|
|
211
|
-
|
|
211
|
+
// Default to no slashing
|
|
212
|
+
opts.slasherFlavor ??= 'none';
|
|
213
|
+
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
212
214
|
// Fetch the AztecNode config.
|
|
213
215
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
214
216
|
const aztecNodeConfig = {
|
|
@@ -216,6 +218,15 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
216
218
|
...opts
|
|
217
219
|
};
|
|
218
220
|
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
221
|
+
aztecNodeConfig.maxTxPoolSize = opts.maxTxPoolSize ?? TEST_MAX_TX_POOL_SIZE;
|
|
222
|
+
// Only enable proving if specifically requested.
|
|
223
|
+
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
224
|
+
// Only enforce the time table if requested
|
|
225
|
+
aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
|
|
226
|
+
// Only set the target committee size if it is explicitly set
|
|
227
|
+
aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
|
|
228
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
229
|
+
deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
|
|
219
230
|
// Create a temp directory for all ephemeral state and cleanup afterwards
|
|
220
231
|
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
221
232
|
await fs.mkdir(directoryToCleanup, {
|
|
@@ -226,16 +237,26 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
226
237
|
} else {
|
|
227
238
|
aztecNodeConfig.dataDirectory = statePath;
|
|
228
239
|
}
|
|
229
|
-
aztecNodeConfig
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
port: blobSinkPort,
|
|
233
|
-
dataStoreConfig: {
|
|
234
|
-
dataDirectory: aztecNodeConfig.dataDirectory,
|
|
235
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB
|
|
236
|
-
}
|
|
240
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
241
|
+
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
242
|
+
addressIndex: 0
|
|
237
243
|
});
|
|
238
|
-
|
|
244
|
+
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
245
|
+
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
246
|
+
const publisherPrivKeyHex = `0x${publisherPrivKey.toString('hex')}`;
|
|
247
|
+
const l1Client = createExtendedL1Client([
|
|
248
|
+
aztecNodeConfig.l1RpcUrls[0]
|
|
249
|
+
], hdAccount, foundry);
|
|
250
|
+
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
251
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
252
|
+
aztecNodeConfig.publisherPrivateKeys = [
|
|
253
|
+
new SecretValue(publisherPrivKeyHex)
|
|
254
|
+
];
|
|
255
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([
|
|
256
|
+
`0x${validatorPrivKey.toString('hex')}`
|
|
257
|
+
]);
|
|
258
|
+
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
259
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
239
260
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
240
261
|
logger.verbose('Starting anvil...');
|
|
241
262
|
const res = await startAnvil({
|
|
@@ -245,57 +266,35 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
245
266
|
aztecNodeConfig.l1RpcUrls = [
|
|
246
267
|
res.rpcUrl
|
|
247
268
|
];
|
|
269
|
+
const dateProvider = new TestDateProvider();
|
|
270
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
248
271
|
// Deploy our L1 contracts.
|
|
249
|
-
logger.verbose('Deploying L1 contracts...');
|
|
250
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
251
|
-
accountIndex: 0
|
|
252
|
-
});
|
|
253
|
-
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
254
|
-
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
255
|
-
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
256
|
-
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
257
|
-
aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey.toString('hex')}`;
|
|
258
|
-
aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey.toString('hex')}`;
|
|
259
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
272
|
+
logger.verbose('Deploying Aztec L1 contracts...');
|
|
260
273
|
if (opts.l1StartTime) {
|
|
261
|
-
await ethCheatCodes.warp(opts.l1StartTime
|
|
274
|
+
await ethCheatCodes.warp(opts.l1StartTime, {
|
|
275
|
+
resetBlockInterval: true
|
|
276
|
+
});
|
|
262
277
|
}
|
|
263
278
|
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
264
|
-
const
|
|
265
|
-
const
|
|
279
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
280
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address).concat(sponsoredFPCAddress), opts.initialAccountFeeJuice);
|
|
281
|
+
const vkTreeRoot = getVKTreeRoot();
|
|
282
|
+
await deployMulticall3(l1Client, logger);
|
|
283
|
+
// Define args, defaulted to our environment variables.
|
|
284
|
+
const args = {
|
|
266
285
|
...getL1ContractsConfigEnvVars(),
|
|
267
|
-
genesisArchiveRoot,
|
|
268
|
-
genesisBlockHash,
|
|
269
|
-
salt: opts.salt,
|
|
270
286
|
...deployL1ContractsArgs,
|
|
271
|
-
|
|
272
|
-
|
|
287
|
+
vkTreeRoot,
|
|
288
|
+
genesisArchiveRoot,
|
|
289
|
+
protocolContractsHash,
|
|
290
|
+
initialValidators: opts.initialValidators,
|
|
291
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
292
|
+
realVerifier: false
|
|
293
|
+
};
|
|
294
|
+
const deployL1ContractsValues = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], publisherPrivKeyHex, foundry.id, args);
|
|
273
295
|
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
274
|
-
aztecNodeConfig.
|
|
275
|
-
|
|
276
|
-
// Mints block rewards for 10000 blocks to the rewardDistributor contract
|
|
277
|
-
const rewardDistributor = getContract({
|
|
278
|
-
address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
279
|
-
abi: l1Artifacts.rewardDistributor.contractAbi,
|
|
280
|
-
client: deployL1ContractsValues.publicClient
|
|
281
|
-
});
|
|
282
|
-
const blockReward = await rewardDistributor.read.BLOCK_REWARD();
|
|
283
|
-
const mintAmount = 10_000n * blockReward;
|
|
284
|
-
const feeJuice = getContract({
|
|
285
|
-
address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
286
|
-
abi: l1Artifacts.feeAsset.contractAbi,
|
|
287
|
-
client: deployL1ContractsValues.walletClient
|
|
288
|
-
});
|
|
289
|
-
const rewardDistributorMintTxHash = await feeJuice.write.mint([
|
|
290
|
-
rewardDistributor.address,
|
|
291
|
-
mintAmount
|
|
292
|
-
], {});
|
|
293
|
-
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
|
|
294
|
-
hash: rewardDistributorMintTxHash
|
|
295
|
-
});
|
|
296
|
-
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
297
|
-
}
|
|
298
|
-
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.publicClient);
|
|
296
|
+
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
297
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
|
|
299
298
|
await watcher.start();
|
|
300
299
|
const acvmConfig = await getACVMConfig(logger);
|
|
301
300
|
if (acvmConfig) {
|
|
@@ -307,25 +306,32 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
307
306
|
aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
308
307
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
309
308
|
}
|
|
310
|
-
const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
310
|
+
const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('node:blob-client:client'));
|
|
311
|
+
logger.info('Creating and synching an aztec node...');
|
|
313
312
|
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
314
313
|
telemetry,
|
|
315
|
-
dateProvider
|
|
314
|
+
dateProvider,
|
|
315
|
+
blobClient
|
|
316
316
|
}, {
|
|
317
317
|
prefilledPublicData
|
|
318
318
|
});
|
|
319
319
|
let proverNode = undefined;
|
|
320
320
|
if (opts.startProverNode) {
|
|
321
|
-
logger.verbose('Creating and syncing a simulated prover node...');
|
|
322
|
-
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig,
|
|
321
|
+
logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
|
|
322
|
+
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, {
|
|
323
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
324
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
325
|
+
p2pEnabled: false
|
|
326
|
+
}, aztecNode, prefilledPublicData);
|
|
323
327
|
}
|
|
324
328
|
logger.verbose('Creating pxe...');
|
|
325
|
-
const pxeConfig =
|
|
329
|
+
const pxeConfig = getPXEConfig();
|
|
326
330
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
327
|
-
|
|
328
|
-
|
|
331
|
+
// Only enable proving if specifically requested.
|
|
332
|
+
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
333
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
334
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
329
335
|
if (statePath) {
|
|
330
336
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
331
337
|
writeFileSync(`${statePath}/accounts.json`, JSON.stringify(initialFundedAccounts, resolver));
|
|
@@ -334,7 +340,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
334
340
|
aztecNodeConfig,
|
|
335
341
|
anvil,
|
|
336
342
|
aztecNode,
|
|
337
|
-
|
|
343
|
+
wallet,
|
|
344
|
+
sequencer: aztecNode.getSequencer(),
|
|
338
345
|
acvmConfig,
|
|
339
346
|
bbConfig,
|
|
340
347
|
deployL1ContractsValues,
|
|
@@ -342,7 +349,6 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
342
349
|
watcher,
|
|
343
350
|
cheatCodes,
|
|
344
351
|
dateProvider,
|
|
345
|
-
blobSink,
|
|
346
352
|
initialFundedAccounts,
|
|
347
353
|
directoryToCleanup
|
|
348
354
|
};
|
|
@@ -355,22 +361,13 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
355
361
|
await fs.mkdir(directoryToCleanup, {
|
|
356
362
|
recursive: true
|
|
357
363
|
});
|
|
358
|
-
// Run the blob sink on a random port
|
|
359
|
-
const blobSinkPort = await getPort();
|
|
360
364
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
361
365
|
const aztecNodeConfig = JSON.parse(readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'), reviver);
|
|
362
366
|
aztecNodeConfig.dataDirectory = statePath;
|
|
363
|
-
aztecNodeConfig.
|
|
367
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
368
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
364
369
|
const initialFundedAccounts = JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
365
370
|
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address));
|
|
366
|
-
const blobSink = await createBlobSinkServer({
|
|
367
|
-
port: blobSinkPort,
|
|
368
|
-
dataStoreConfig: {
|
|
369
|
-
dataDirectory: statePath,
|
|
370
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
await blobSink.start();
|
|
374
371
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
375
372
|
const { anvil, rpcUrl } = await startAnvil();
|
|
376
373
|
aztecNodeConfig.l1RpcUrls = [
|
|
@@ -378,7 +375,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
378
375
|
];
|
|
379
376
|
// Load anvil state.
|
|
380
377
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
381
|
-
const
|
|
378
|
+
const dateProvider = new TestDateProvider();
|
|
379
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
382
380
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
383
381
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
384
382
|
const acvmConfig = await getACVMConfig(logger);
|
|
@@ -392,15 +390,16 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
392
390
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
393
391
|
}
|
|
394
392
|
logger.verbose('Creating ETH clients...');
|
|
395
|
-
const
|
|
396
|
-
const watcher = new AnvilTestWatcher(
|
|
393
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
394
|
+
const watcher = new AnvilTestWatcher(ethCheatCodes, aztecNodeConfig.l1Contracts.rollupAddress, l1Client, dateProvider);
|
|
397
395
|
await watcher.start();
|
|
396
|
+
const telemetry = await initTelemetryClient(getTelemetryConfig());
|
|
397
|
+
const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('node:blob-client:client'));
|
|
398
398
|
logger.verbose('Creating aztec node...');
|
|
399
|
-
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
400
|
-
const dateProvider = new TestDateProvider();
|
|
401
399
|
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
402
400
|
telemetry,
|
|
403
|
-
dateProvider
|
|
401
|
+
dateProvider,
|
|
402
|
+
blobClient
|
|
404
403
|
}, {
|
|
405
404
|
prefilledPublicData
|
|
406
405
|
});
|
|
@@ -409,30 +408,34 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
409
408
|
logger.verbose('Creating and syncing a simulated prover node...');
|
|
410
409
|
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
411
410
|
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
|
|
412
|
-
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig,
|
|
411
|
+
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig, {
|
|
412
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
413
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
414
|
+
p2pEnabled: false
|
|
415
|
+
}, aztecNode, prefilledPublicData);
|
|
413
416
|
}
|
|
414
417
|
logger.verbose('Creating pxe...');
|
|
415
|
-
const pxeConfig =
|
|
418
|
+
const pxeConfig = getPXEConfig();
|
|
416
419
|
pxeConfig.dataDirectory = statePath;
|
|
417
|
-
const
|
|
418
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls,
|
|
420
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
421
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
419
422
|
return {
|
|
420
423
|
aztecNodeConfig,
|
|
421
424
|
anvil,
|
|
422
425
|
aztecNode,
|
|
423
|
-
|
|
426
|
+
wallet,
|
|
427
|
+
sequencer: aztecNode.getSequencer(),
|
|
424
428
|
acvmConfig,
|
|
425
429
|
bbConfig,
|
|
426
430
|
proverNode,
|
|
427
431
|
deployL1ContractsValues: {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
l1Client,
|
|
433
|
+
l1ContractAddresses: aztecNodeConfig.l1Contracts,
|
|
434
|
+
rollupVersion: aztecNodeConfig.rollupVersion
|
|
431
435
|
},
|
|
432
436
|
watcher,
|
|
433
437
|
cheatCodes,
|
|
434
438
|
dateProvider,
|
|
435
|
-
blobSink,
|
|
436
439
|
initialFundedAccounts,
|
|
437
440
|
directoryToCleanup
|
|
438
441
|
};
|
|
@@ -440,15 +443,21 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
440
443
|
/**
|
|
441
444
|
* Snapshot 'apply' helper function to add accounts.
|
|
442
445
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
443
|
-
*/ export const deployAccounts = (numberOfAccounts, logger
|
|
446
|
+
*/ export const deployAccounts = (numberOfAccounts, logger)=>async ({ wallet, initialFundedAccounts })=>{
|
|
444
447
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
445
448
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
446
449
|
}
|
|
447
450
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
448
451
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
453
|
+
for(let i = 0; i < deployedAccounts.length; i++){
|
|
454
|
+
const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
|
|
455
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
456
|
+
await deployMethod.send({
|
|
457
|
+
from: AztecAddress.ZERO,
|
|
458
|
+
skipClassPublication: i !== 0
|
|
459
|
+
}).wait();
|
|
460
|
+
}
|
|
452
461
|
return {
|
|
453
462
|
deployedAccounts
|
|
454
463
|
};
|
|
@@ -458,22 +467,27 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
458
467
|
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
459
468
|
* @param sender - Wallet to send the deployment tx.
|
|
460
469
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
470
|
+
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
471
|
+
* @param node - AztecNode used to wait for proven tx.
|
|
472
|
+
*/ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
|
|
473
|
+
const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.contractInstance);
|
|
464
474
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
465
|
-
const alreadyRegistered = (await
|
|
466
|
-
const
|
|
475
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
476
|
+
const calls = await Promise.all([
|
|
467
477
|
...!alreadyRegistered ? [
|
|
468
|
-
|
|
478
|
+
publishContractClass(wallet, SchnorrAccountContractArtifact)
|
|
469
479
|
] : [],
|
|
470
|
-
...instances.map((instance)=>
|
|
480
|
+
...instances.map((instance)=>publishInstance(wallet, instance))
|
|
471
481
|
]);
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
482
|
+
const batch = new BatchCall(wallet, calls);
|
|
483
|
+
const txReceipt = await batch.send({
|
|
484
|
+
from: accountsToDeploy[0]
|
|
485
|
+
}).wait();
|
|
486
|
+
if (waitUntilProven) {
|
|
487
|
+
if (!node) {
|
|
488
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
489
|
+
} else {
|
|
490
|
+
await waitForProven(node, txReceipt);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
479
493
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type { AztecAddress
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
|
-
export declare function deployToken(
|
|
4
|
-
|
|
5
|
+
export declare function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger): Promise<{
|
|
6
|
+
contract: TokenContract;
|
|
7
|
+
instance: import("@aztec/aztec.js/contracts").ContractInstanceWithAddress;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function mintTokensToPrivate(token: TokenContract, minter: AztecAddress, recipient: AztecAddress, amount: bigint): Promise<void>;
|
|
5
10
|
export declare function expectTokenBalance(wallet: Wallet, token: TokenContract, owner: AztecAddress, expectedBalance: bigint, logger: Logger): Promise<void>;
|
|
6
|
-
|
|
11
|
+
export declare function mintNotes(wallet: Wallet, minter: AztecAddress, recipient: AztecAddress, asset: TokenContract, noteAmounts: bigint[]): Promise<bigint>;
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9rZW5fdXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maXh0dXJlcy90b2tlbl91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUNyRCxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFL0Qsd0JBQXNCLFdBQVcsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxZQUFZLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxNQUFNOzs7R0Fhakg7QUFFRCx3QkFBc0IsbUJBQW1CLENBQ3ZDLEtBQUssRUFBRSxhQUFhLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLFNBQVMsRUFBRSxZQUFZLEVBQ3ZCLE1BQU0sRUFBRSxNQUFNLGlCQUdmO0FBRUQsd0JBQXNCLGtCQUFrQixDQUN0QyxNQUFNLEVBQUUsTUFBTSxFQUNkLEtBQUssRUFBRSxhQUFhLEVBQ3BCLEtBQUssRUFBRSxZQUFZLEVBQ25CLGVBQWUsRUFBRSxNQUFNLEVBQ3ZCLE1BQU0sRUFBRSxNQUFNLGlCQU9mO0FBRUQsd0JBQXNCLFNBQVMsQ0FDN0IsTUFBTSxFQUFFLE1BQU0sRUFDZCxNQUFNLEVBQUUsWUFBWSxFQUNwQixTQUFTLEVBQUUsWUFBWSxFQUN2QixLQUFLLEVBQUUsYUFBYSxFQUNwQixXQUFXLEVBQUUsTUFBTSxFQUFFLEdBQ3BCLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FXakIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/token_utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token_utils.d.ts","sourceRoot":"","sources":["../../src/fixtures/token_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;GAajH;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,MAAM,iBAGf;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,iBAOf;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,MAAM,CAAC,CAWjB"}
|
|
@@ -1,27 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
|
-
export async function deployToken(
|
|
3
|
+
export async function deployToken(wallet, admin, initialAdminBalance, logger) {
|
|
4
4
|
logger.info(`Deploying Token contract...`);
|
|
5
|
-
const contract = await TokenContract.deploy(
|
|
5
|
+
const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
|
|
6
|
+
from: admin
|
|
7
|
+
}).wait();
|
|
6
8
|
if (initialAdminBalance > 0n) {
|
|
7
|
-
|
|
8
|
-
await mintTokensToPrivate(contract, adminWallet, adminWallet.getAddress(), initialAdminBalance);
|
|
9
|
+
await mintTokensToPrivate(contract, admin, admin, initialAdminBalance);
|
|
9
10
|
}
|
|
10
11
|
logger.info('L2 contract deployed');
|
|
11
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
contract,
|
|
14
|
+
instance
|
|
15
|
+
};
|
|
12
16
|
}
|
|
13
|
-
export async function mintTokensToPrivate(token,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
export async function mintTokensToPrivate(token, minter, recipient, amount) {
|
|
18
|
+
await token.methods.mint_to_private(recipient, amount).send({
|
|
19
|
+
from: minter
|
|
20
|
+
}).wait();
|
|
17
21
|
}
|
|
18
|
-
// docs:end:token_utils
|
|
19
22
|
export async function expectTokenBalance(wallet, token, owner, expectedBalance, logger) {
|
|
20
23
|
// Then check the balance
|
|
21
|
-
const contractWithWallet =
|
|
24
|
+
const contractWithWallet = TokenContract.at(token.address, wallet);
|
|
22
25
|
const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({
|
|
23
26
|
from: owner
|
|
24
27
|
});
|
|
25
28
|
logger.info(`Account ${owner} balance: ${balance}`);
|
|
26
29
|
expect(balance).toBe(expectedBalance);
|
|
27
30
|
}
|
|
31
|
+
export async function mintNotes(wallet, minter, recipient, asset, noteAmounts) {
|
|
32
|
+
// We can only mint 5 notes at a time, since that's the maximum number of calls our entrypoints allow
|
|
33
|
+
// TODO(#13024): mint as many notes as possible in a single tx
|
|
34
|
+
const notesPerIteration = 5;
|
|
35
|
+
for(let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration){
|
|
36
|
+
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
37
|
+
const actions = toMint.map((amt)=>asset.methods.mint_to_private(recipient, amt));
|
|
38
|
+
await new BatchCall(wallet, actions).send({
|
|
39
|
+
from: minter
|
|
40
|
+
}).wait();
|
|
41
|
+
}
|
|
42
|
+
return noteAmounts.reduce((prev, curr)=>prev + curr, 0n);
|
|
43
|
+
}
|