@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.1142ef1
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 +79 -0
- package/dest/bench/utils.d.ts +14 -40
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +37 -70
- 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 +29 -28
- 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 +79 -82
- 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 +107 -110
- 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 +55 -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 -113
- 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 +147 -138
- 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 +92 -54
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +452 -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/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +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 +106 -52
- 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 +2 -2
- package/dest/shared/index.d.ts.map +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 +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +170 -120
- 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 +27 -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 +151 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +598 -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 +35 -81
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +103 -122
- 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 +150 -142
- package/src/e2e_l1_publisher/write_json.ts +74 -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 +252 -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 +112 -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 +189 -160
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +556 -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 → grafana_client.ts} +2 -2
- package/src/shared/cross_chain_test_harness.ts +113 -87
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +194 -211
- 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 +258 -93
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +722 -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/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.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/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,41 @@
|
|
|
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 { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
10
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
11
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
12
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
8
13
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
9
14
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
10
|
-
import {
|
|
15
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
16
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
17
|
+
import { tryRmDir } from '@aztec/foundation/fs';
|
|
11
18
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
19
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
13
20
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
|
-
import {
|
|
21
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
22
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
23
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
24
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
15
25
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
26
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
16
27
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
17
28
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
18
29
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
19
30
|
import fs from 'fs/promises';
|
|
20
|
-
import getPort from 'get-port';
|
|
21
31
|
import { tmpdir } from 'os';
|
|
22
32
|
import path, { join } from 'path';
|
|
23
|
-
import { getContract } from 'viem';
|
|
24
33
|
import { mnemonicToAccount } from 'viem/accounts';
|
|
25
|
-
import {
|
|
34
|
+
import { foundry } from 'viem/chains';
|
|
35
|
+
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
26
36
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
27
37
|
import { getBBConfig } from './get_bb_config.js';
|
|
28
|
-
import {
|
|
29
|
-
import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex } from './utils.js';
|
|
38
|
+
import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex, getSponsoredFPCAddress, setupSharedBlobStorage } from './utils.js';
|
|
30
39
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
31
40
|
export function createSnapshotManager(testName, dataPath, config = {}, deployL1ContractsArgs = {
|
|
32
41
|
initialValidators: []
|
|
@@ -114,7 +123,7 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
114
123
|
// Execute the restoration function.
|
|
115
124
|
await restore(snapshotData, context);
|
|
116
125
|
// Save the snapshot data.
|
|
117
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
126
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
|
|
118
127
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
119
128
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
120
129
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -176,28 +185,18 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
176
185
|
if (!context) {
|
|
177
186
|
return;
|
|
178
187
|
}
|
|
188
|
+
const logger = getLogger();
|
|
179
189
|
try {
|
|
180
|
-
|
|
181
|
-
await context.proverNode
|
|
182
|
-
await context.aztecNode
|
|
190
|
+
logger.info('Tearing down subsystems');
|
|
191
|
+
await tryStop(context.proverNode);
|
|
192
|
+
await tryStop(context.aztecNode);
|
|
183
193
|
await context.acvmConfig?.cleanup();
|
|
184
194
|
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
|
-
}
|
|
195
|
+
await tryStop(context.anvil);
|
|
196
|
+
await tryStop(context.watcher);
|
|
197
|
+
await tryRmDir(context.directoryToCleanup, logger);
|
|
199
198
|
} catch (err) {
|
|
200
|
-
|
|
199
|
+
logger.error('Error during teardown', err);
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
/**
|
|
@@ -208,7 +207,9 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
208
207
|
initialValidators: []
|
|
209
208
|
}) {
|
|
210
209
|
logger.verbose(`Initializing state...`);
|
|
211
|
-
|
|
210
|
+
// Default to no slashing
|
|
211
|
+
opts.slasherFlavor ??= 'none';
|
|
212
|
+
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
212
213
|
// Fetch the AztecNode config.
|
|
213
214
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
214
215
|
const aztecNodeConfig = {
|
|
@@ -216,6 +217,15 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
216
217
|
...opts
|
|
217
218
|
};
|
|
218
219
|
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
220
|
+
aztecNodeConfig.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
|
|
221
|
+
// Only enable proving if specifically requested.
|
|
222
|
+
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
223
|
+
// Only enforce the time table if requested
|
|
224
|
+
aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
|
|
225
|
+
// Only set the target committee size if it is explicitly set
|
|
226
|
+
aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
|
|
227
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
228
|
+
deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
|
|
219
229
|
// Create a temp directory for all ephemeral state and cleanup afterwards
|
|
220
230
|
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
221
231
|
await fs.mkdir(directoryToCleanup, {
|
|
@@ -226,16 +236,26 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
226
236
|
} else {
|
|
227
237
|
aztecNodeConfig.dataDirectory = statePath;
|
|
228
238
|
}
|
|
229
|
-
aztecNodeConfig
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
port: blobSinkPort,
|
|
233
|
-
dataStoreConfig: {
|
|
234
|
-
dataDirectory: aztecNodeConfig.dataDirectory,
|
|
235
|
-
dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB
|
|
236
|
-
}
|
|
239
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
240
|
+
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
241
|
+
addressIndex: 0
|
|
237
242
|
});
|
|
238
|
-
|
|
243
|
+
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
244
|
+
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
245
|
+
const publisherPrivKeyHex = `0x${publisherPrivKey.toString('hex')}`;
|
|
246
|
+
const l1Client = createExtendedL1Client([
|
|
247
|
+
aztecNodeConfig.l1RpcUrls[0]
|
|
248
|
+
], hdAccount, foundry);
|
|
249
|
+
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
250
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
251
|
+
aztecNodeConfig.publisherPrivateKeys = [
|
|
252
|
+
new SecretValue(publisherPrivKeyHex)
|
|
253
|
+
];
|
|
254
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([
|
|
255
|
+
`0x${validatorPrivKey.toString('hex')}`
|
|
256
|
+
]);
|
|
257
|
+
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
258
|
+
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
239
259
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
240
260
|
logger.verbose('Starting anvil...');
|
|
241
261
|
const res = await startAnvil({
|
|
@@ -245,57 +265,35 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
245
265
|
aztecNodeConfig.l1RpcUrls = [
|
|
246
266
|
res.rpcUrl
|
|
247
267
|
];
|
|
268
|
+
const dateProvider = new TestDateProvider();
|
|
269
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
248
270
|
// 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);
|
|
271
|
+
logger.verbose('Deploying Aztec L1 contracts...');
|
|
260
272
|
if (opts.l1StartTime) {
|
|
261
|
-
await ethCheatCodes.warp(opts.l1StartTime
|
|
273
|
+
await ethCheatCodes.warp(opts.l1StartTime, {
|
|
274
|
+
resetBlockInterval: true
|
|
275
|
+
});
|
|
262
276
|
}
|
|
263
277
|
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
264
|
-
const
|
|
265
|
-
const
|
|
278
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
279
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address).concat(sponsoredFPCAddress), opts.initialAccountFeeJuice);
|
|
280
|
+
const vkTreeRoot = getVKTreeRoot();
|
|
281
|
+
await deployMulticall3(l1Client, logger);
|
|
282
|
+
// Define args, defaulted to our environment variables.
|
|
283
|
+
const args = {
|
|
266
284
|
...getL1ContractsConfigEnvVars(),
|
|
267
|
-
genesisArchiveRoot,
|
|
268
|
-
genesisBlockHash,
|
|
269
|
-
salt: opts.salt,
|
|
270
285
|
...deployL1ContractsArgs,
|
|
271
|
-
|
|
272
|
-
|
|
286
|
+
vkTreeRoot,
|
|
287
|
+
genesisArchiveRoot,
|
|
288
|
+
protocolContractsHash,
|
|
289
|
+
initialValidators: opts.initialValidators,
|
|
290
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
291
|
+
realVerifier: false
|
|
292
|
+
};
|
|
293
|
+
const deployL1ContractsValues = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], publisherPrivKeyHex, foundry.id, args);
|
|
273
294
|
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);
|
|
295
|
+
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
296
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
|
|
299
297
|
await watcher.start();
|
|
300
298
|
const acvmConfig = await getACVMConfig(logger);
|
|
301
299
|
if (acvmConfig) {
|
|
@@ -307,9 +305,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
307
305
|
aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
308
306
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
309
307
|
}
|
|
310
|
-
const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
311
|
-
logger.
|
|
312
|
-
const dateProvider = new TestDateProvider();
|
|
308
|
+
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
309
|
+
logger.info('Creating and synching an aztec node...');
|
|
313
310
|
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
314
311
|
telemetry,
|
|
315
312
|
dateProvider
|
|
@@ -318,14 +315,20 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
318
315
|
});
|
|
319
316
|
let proverNode = undefined;
|
|
320
317
|
if (opts.startProverNode) {
|
|
321
|
-
logger.verbose('Creating and syncing a simulated prover node...');
|
|
322
|
-
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig,
|
|
318
|
+
logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
|
|
319
|
+
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, {
|
|
320
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
321
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
322
|
+
p2pEnabled: false
|
|
323
|
+
}, aztecNode, prefilledPublicData);
|
|
323
324
|
}
|
|
324
325
|
logger.verbose('Creating pxe...');
|
|
325
|
-
const pxeConfig =
|
|
326
|
+
const pxeConfig = getPXEConfig();
|
|
326
327
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
// Only enable proving if specifically requested.
|
|
329
|
+
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
330
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
331
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
329
332
|
if (statePath) {
|
|
330
333
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
331
334
|
writeFileSync(`${statePath}/accounts.json`, JSON.stringify(initialFundedAccounts, resolver));
|
|
@@ -334,7 +337,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
334
337
|
aztecNodeConfig,
|
|
335
338
|
anvil,
|
|
336
339
|
aztecNode,
|
|
337
|
-
|
|
340
|
+
wallet,
|
|
341
|
+
sequencer: aztecNode.getSequencer(),
|
|
338
342
|
acvmConfig,
|
|
339
343
|
bbConfig,
|
|
340
344
|
deployL1ContractsValues,
|
|
@@ -342,7 +346,6 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
342
346
|
watcher,
|
|
343
347
|
cheatCodes,
|
|
344
348
|
dateProvider,
|
|
345
|
-
blobSink,
|
|
346
349
|
initialFundedAccounts,
|
|
347
350
|
directoryToCleanup
|
|
348
351
|
};
|
|
@@ -355,22 +358,13 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
355
358
|
await fs.mkdir(directoryToCleanup, {
|
|
356
359
|
recursive: true
|
|
357
360
|
});
|
|
358
|
-
// Run the blob sink on a random port
|
|
359
|
-
const blobSinkPort = await getPort();
|
|
360
361
|
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
361
362
|
const aztecNodeConfig = JSON.parse(readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'), reviver);
|
|
362
363
|
aztecNodeConfig.dataDirectory = statePath;
|
|
363
|
-
aztecNodeConfig.
|
|
364
|
+
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
365
|
+
await setupSharedBlobStorage(aztecNodeConfig);
|
|
364
366
|
const initialFundedAccounts = JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
365
367
|
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
368
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
375
369
|
const { anvil, rpcUrl } = await startAnvil();
|
|
376
370
|
aztecNodeConfig.l1RpcUrls = [
|
|
@@ -378,7 +372,8 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
378
372
|
];
|
|
379
373
|
// Load anvil state.
|
|
380
374
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
381
|
-
const
|
|
375
|
+
const dateProvider = new TestDateProvider();
|
|
376
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
382
377
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
383
378
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
384
379
|
const acvmConfig = await getACVMConfig(logger);
|
|
@@ -392,12 +387,11 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
392
387
|
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
393
388
|
}
|
|
394
389
|
logger.verbose('Creating ETH clients...');
|
|
395
|
-
const
|
|
396
|
-
const watcher = new AnvilTestWatcher(
|
|
390
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
391
|
+
const watcher = new AnvilTestWatcher(ethCheatCodes, aztecNodeConfig.l1Contracts.rollupAddress, l1Client, dateProvider);
|
|
397
392
|
await watcher.start();
|
|
393
|
+
const telemetry = await initTelemetryClient(getTelemetryConfig());
|
|
398
394
|
logger.verbose('Creating aztec node...');
|
|
399
|
-
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
400
|
-
const dateProvider = new TestDateProvider();
|
|
401
395
|
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
402
396
|
telemetry,
|
|
403
397
|
dateProvider
|
|
@@ -409,30 +403,34 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
409
403
|
logger.verbose('Creating and syncing a simulated prover node...');
|
|
410
404
|
const proverNodePrivateKey = getPrivateKeyFromIndex(2);
|
|
411
405
|
const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
|
|
412
|
-
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig,
|
|
406
|
+
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig, {
|
|
407
|
+
...aztecNodeConfig.proverNodeConfig,
|
|
408
|
+
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
409
|
+
p2pEnabled: false
|
|
410
|
+
}, aztecNode, prefilledPublicData);
|
|
413
411
|
}
|
|
414
412
|
logger.verbose('Creating pxe...');
|
|
415
|
-
const pxeConfig =
|
|
413
|
+
const pxeConfig = getPXEConfig();
|
|
416
414
|
pxeConfig.dataDirectory = statePath;
|
|
417
|
-
const
|
|
418
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls,
|
|
415
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
416
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
419
417
|
return {
|
|
420
418
|
aztecNodeConfig,
|
|
421
419
|
anvil,
|
|
422
420
|
aztecNode,
|
|
423
|
-
|
|
421
|
+
wallet,
|
|
422
|
+
sequencer: aztecNode.getSequencer(),
|
|
424
423
|
acvmConfig,
|
|
425
424
|
bbConfig,
|
|
426
425
|
proverNode,
|
|
427
426
|
deployL1ContractsValues: {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
427
|
+
l1Client,
|
|
428
|
+
l1ContractAddresses: aztecNodeConfig.l1Contracts,
|
|
429
|
+
rollupVersion: aztecNodeConfig.rollupVersion
|
|
431
430
|
},
|
|
432
431
|
watcher,
|
|
433
432
|
cheatCodes,
|
|
434
433
|
dateProvider,
|
|
435
|
-
blobSink,
|
|
436
434
|
initialFundedAccounts,
|
|
437
435
|
directoryToCleanup
|
|
438
436
|
};
|
|
@@ -440,15 +438,21 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
440
438
|
/**
|
|
441
439
|
* Snapshot 'apply' helper function to add accounts.
|
|
442
440
|
* 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
|
|
441
|
+
*/ export const deployAccounts = (numberOfAccounts, logger)=>async ({ wallet, initialFundedAccounts })=>{
|
|
444
442
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
445
443
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
446
444
|
}
|
|
447
445
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
448
446
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
447
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
448
|
+
for(let i = 0; i < deployedAccounts.length; i++){
|
|
449
|
+
const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
|
|
450
|
+
const deployMethod = await accountManager.getDeployMethod();
|
|
451
|
+
await deployMethod.send({
|
|
452
|
+
from: AztecAddress.ZERO,
|
|
453
|
+
skipClassPublication: i !== 0
|
|
454
|
+
}).wait();
|
|
455
|
+
}
|
|
452
456
|
return {
|
|
453
457
|
deployedAccounts
|
|
454
458
|
};
|
|
@@ -458,22 +462,27 @@ export function createSnapshotManager(testName, dataPath, config = {}, deployL1C
|
|
|
458
462
|
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
459
463
|
* @param sender - Wallet to send the deployment tx.
|
|
460
464
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
465
|
+
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
466
|
+
* @param node - AztecNode used to wait for proven tx.
|
|
467
|
+
*/ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
|
|
468
|
+
const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.contractInstance);
|
|
464
469
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
465
|
-
const alreadyRegistered = (await
|
|
466
|
-
const
|
|
470
|
+
const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
471
|
+
const calls = await Promise.all([
|
|
467
472
|
...!alreadyRegistered ? [
|
|
468
|
-
|
|
473
|
+
publishContractClass(wallet, SchnorrAccountContractArtifact)
|
|
469
474
|
] : [],
|
|
470
|
-
...instances.map((instance)=>
|
|
475
|
+
...instances.map((instance)=>publishInstance(wallet, instance))
|
|
471
476
|
]);
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
477
|
+
const batch = new BatchCall(wallet, calls);
|
|
478
|
+
const txReceipt = await batch.send({
|
|
479
|
+
from: accountsToDeploy[0]
|
|
480
|
+
}).wait();
|
|
481
|
+
if (waitUntilProven) {
|
|
482
|
+
if (!node) {
|
|
483
|
+
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
484
|
+
} else {
|
|
485
|
+
await waitForProven(node, txReceipt);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
479
488
|
}
|
|
@@ -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
|
+
}
|