@aztec/end-to-end 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.21
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/README.md +2 -0
- package/dest/bench/utils.d.ts +70 -0
- package/dest/bench/utils.d.ts.map +1 -0
- package/dest/bench/utils.js +24 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +46 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +17 -17
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +47 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +27 -16
- package/dest/e2e_deploy_contract/deploy_test.d.ts +28 -0
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -0
- package/dest/e2e_deploy_contract/deploy_test.js +4 -7
- package/dest/e2e_epochs/epochs_test.d.ts +51 -0
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -0
- package/dest/e2e_epochs/epochs_test.js +155 -0
- package/dest/e2e_fees/fees_test.d.ts +73 -0
- package/dest/e2e_fees/fees_test.d.ts.map +1 -0
- package/dest/e2e_fees/fees_test.js +75 -32
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +26 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -0
- package/dest/e2e_nested_contract/nested_contract_test.js +14 -12
- package/dest/e2e_p2p/p2p_network.d.ts +61 -0
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -0
- package/dest/e2e_p2p/p2p_network.js +54 -30
- package/dest/e2e_p2p/shared.d.ts +10 -0
- package/dest/e2e_p2p/shared.d.ts.map +1 -0
- package/dest/e2e_p2p/shared.js +7 -8
- package/dest/e2e_prover/e2e_prover_test.d.ts +56 -0
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -0
- package/dest/e2e_prover/e2e_prover_test.js +20 -24
- package/dest/e2e_token_contract/token_contract_test.d.ts +29 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -0
- package/dest/e2e_token_contract/token_contract_test.js +4 -7
- package/dest/fixtures/fixtures.d.ts +17 -0
- package/dest/fixtures/fixtures.d.ts.map +1 -0
- package/dest/fixtures/fixtures.js +2 -2
- package/dest/fixtures/get_acvm_config.d.ts +8 -0
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -0
- package/dest/fixtures/get_acvm_config.js +10 -5
- package/dest/fixtures/get_bb_config.d.ts +6 -0
- package/dest/fixtures/get_bb_config.d.ts.map +1 -0
- package/dest/fixtures/get_bb_config.js +9 -4
- package/dest/fixtures/index.d.ts +6 -0
- package/dest/fixtures/index.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts +13 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.js +1 -1
- package/dest/fixtures/logging.d.ts +8 -0
- package/dest/fixtures/logging.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.d.ts +6 -0
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.js +6 -4
- package/dest/fixtures/setup_p2p_test.d.ts +22 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -0
- package/dest/fixtures/setup_p2p_test.js +5 -3
- package/dest/fixtures/snapshot_manager.d.ts +87 -0
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -0
- package/dest/fixtures/snapshot_manager.js +67 -74
- package/dest/fixtures/token_utils.d.ts +6 -0
- package/dest/fixtures/token_utils.d.ts.map +1 -0
- package/dest/fixtures/token_utils.js +1 -1
- package/dest/fixtures/utils.d.ts +155 -0
- package/dest/fixtures/utils.d.ts.map +1 -0
- package/dest/fixtures/utils.js +97 -71
- package/dest/fixtures/with_telemetry_utils.d.ts +3 -0
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.d.ts +41 -0
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.js +4 -1
- package/dest/sample-dapp/index.js +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +124 -0
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -0
- package/dest/shared/cross_chain_test_harness.js +6 -17
- package/dest/shared/gas_portal_test_harness.d.ts +80 -0
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -0
- package/dest/shared/gas_portal_test_harness.js +11 -4
- package/dest/shared/index.d.ts +2 -0
- package/dest/shared/index.d.ts.map +1 -0
- package/dest/shared/index.js +0 -1
- package/dest/shared/jest_setup.d.ts +2 -0
- package/dest/shared/jest_setup.d.ts.map +1 -0
- package/dest/shared/submit-transactions.d.ts +4 -0
- package/dest/shared/submit-transactions.d.ts.map +1 -0
- package/dest/shared/submit-transactions.js +9 -17
- package/dest/shared/uniswap_l1_l2.d.ts +25 -0
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -0
- package/dest/shared/uniswap_l1_l2.js +5 -10
- package/dest/simulators/index.d.ts +3 -0
- package/dest/simulators/index.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.d.ts +69 -0
- package/dest/simulators/lending_simulator.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.js +1 -3
- package/dest/simulators/token_simulator.d.ts +29 -0
- package/dest/simulators/token_simulator.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.d.ts +20 -0
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.js +72 -38
- package/dest/spartan/utils.d.ts +415 -0
- package/dest/spartan/utils.d.ts.map +1 -0
- package/dest/spartan/utils.js +169 -43
- package/package.json +35 -40
- package/src/bench/utils.ts +30 -13
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +40 -30
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +34 -18
- package/src/e2e_deploy_contract/deploy_test.ts +6 -11
- package/src/e2e_epochs/epochs_test.ts +217 -0
- package/src/e2e_fees/fees_test.ts +84 -38
- package/src/e2e_nested_contract/nested_contract_test.ts +14 -16
- package/src/e2e_p2p/p2p_network.ts +67 -47
- package/src/e2e_p2p/shared.ts +16 -10
- package/src/e2e_prover/e2e_prover_test.ts +56 -37
- package/src/e2e_token_contract/token_contract_test.ts +10 -11
- package/src/fixtures/fixtures.ts +2 -2
- package/src/fixtures/get_acvm_config.ts +7 -3
- package/src/fixtures/get_bb_config.ts +6 -2
- package/src/fixtures/l1_to_l2_messaging.ts +6 -13
- package/src/fixtures/setup_l1_contracts.ts +8 -7
- package/src/fixtures/setup_p2p_test.ts +8 -6
- package/src/fixtures/snapshot_manager.ts +72 -79
- package/src/fixtures/token_utils.ts +2 -2
- package/src/fixtures/utils.ts +135 -97
- package/src/guides/up_quick_start.sh +10 -5
- package/src/quality_of_service/alert_checker.ts +6 -2
- package/src/sample-dapp/index.mjs +1 -1
- package/src/shared/cross_chain_test_harness.ts +17 -35
- package/src/shared/gas_portal_test_harness.ts +21 -11
- package/src/shared/index.ts +0 -1
- package/src/shared/submit-transactions.ts +16 -20
- package/src/shared/uniswap_l1_l2.ts +35 -26
- package/src/simulators/lending_simulator.ts +5 -6
- package/src/simulators/token_simulator.ts +1 -1
- package/src/spartan/setup_test_wallets.ts +111 -37
- package/src/spartan/utils.ts +161 -54
- package/dest/shared/browser.js +0 -163
- package/src/shared/browser.ts +0 -272
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Test fixtures and utilities to set up and run a test using multiple validators
|
|
3
3
|
*/
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
5
|
-
import {
|
|
6
|
-
import { type AztecAddress } from '@aztec/circuits.js';
|
|
5
|
+
import type { SentTx } from '@aztec/aztec.js';
|
|
7
6
|
import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
8
|
+
import type { PXEService } from '@aztec/pxe';
|
|
9
|
+
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
10
|
|
|
11
11
|
import getPort from 'get-port';
|
|
12
12
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
@@ -24,7 +24,6 @@ export interface NodeContext {
|
|
|
24
24
|
node: AztecNodeService;
|
|
25
25
|
pxeService: PXEService;
|
|
26
26
|
txs: SentTx[];
|
|
27
|
-
account: AztecAddress;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[] {
|
|
@@ -42,6 +41,7 @@ export async function createNodes(
|
|
|
42
41
|
bootstrapNodeEnr: string,
|
|
43
42
|
numNodes: number,
|
|
44
43
|
bootNodePort: number,
|
|
44
|
+
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
45
45
|
dataDirectory?: string,
|
|
46
46
|
metricsPort?: number,
|
|
47
47
|
): Promise<AztecNodeService[]> {
|
|
@@ -62,6 +62,7 @@ export async function createNodes(
|
|
|
62
62
|
port,
|
|
63
63
|
bootstrapNodeEnr,
|
|
64
64
|
i,
|
|
65
|
+
prefilledPublicData,
|
|
65
66
|
dataDir,
|
|
66
67
|
metricsPort,
|
|
67
68
|
loggerIdStorage,
|
|
@@ -80,6 +81,7 @@ export async function createNode(
|
|
|
80
81
|
tcpPort: number,
|
|
81
82
|
bootstrapNode: string | undefined,
|
|
82
83
|
accountIndex: number,
|
|
84
|
+
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
83
85
|
dataDirectory?: string,
|
|
84
86
|
metricsPort?: number,
|
|
85
87
|
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
@@ -87,7 +89,7 @@ export async function createNode(
|
|
|
87
89
|
const createNode = async () => {
|
|
88
90
|
const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, accountIndex, dataDirectory);
|
|
89
91
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
90
|
-
return await AztecNodeService.createAndSync(validatorConfig, { telemetry, dateProvider });
|
|
92
|
+
return await AztecNodeService.createAndSync(validatorConfig, { telemetry, dateProvider }, { prefilledPublicData });
|
|
91
93
|
};
|
|
92
94
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
93
95
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact
|
|
1
|
+
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { type InitialAccountData, deployFundedSchnorrAccounts, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
4
|
import {
|
|
4
5
|
AnvilTestWatcher,
|
|
5
6
|
type AztecAddress,
|
|
6
7
|
BatchCall,
|
|
8
|
+
type Capsule,
|
|
7
9
|
CheatCodes,
|
|
8
10
|
type CompleteAddress,
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
+
type ContractFunctionInteraction,
|
|
12
|
+
type DeployL1ContractsReturnType,
|
|
11
13
|
type FunctionCall,
|
|
12
|
-
GrumpkinScalar,
|
|
13
14
|
type Logger,
|
|
14
15
|
type PXE,
|
|
15
16
|
type Wallet,
|
|
@@ -24,11 +25,12 @@ import { randomBytes } from '@aztec/foundation/crypto';
|
|
|
24
25
|
import { createLogger } from '@aztec/foundation/log';
|
|
25
26
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
26
27
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
27
|
-
import {
|
|
28
|
+
import type { ProverNode } from '@aztec/prover-node';
|
|
28
29
|
import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
|
|
29
30
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
31
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
30
32
|
|
|
31
|
-
import {
|
|
33
|
+
import type { Anvil } from '@viem/anvil';
|
|
32
34
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
33
35
|
import { copySync, removeSync } from 'fs-extra/esm';
|
|
34
36
|
import fs from 'fs/promises';
|
|
@@ -52,12 +54,13 @@ export type SubsystemsContext = {
|
|
|
52
54
|
aztecNode: AztecNodeService;
|
|
53
55
|
aztecNodeConfig: AztecNodeConfig;
|
|
54
56
|
pxe: PXEService;
|
|
55
|
-
deployL1ContractsValues:
|
|
57
|
+
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
56
58
|
proverNode?: ProverNode;
|
|
57
59
|
watcher: AnvilTestWatcher;
|
|
58
60
|
cheatCodes: CheatCodes;
|
|
59
61
|
dateProvider: TestDateProvider;
|
|
60
62
|
blobSink: BlobSinkServer;
|
|
63
|
+
initialFundedAccounts: InitialAccountData[];
|
|
61
64
|
directoryToCleanup?: string;
|
|
62
65
|
};
|
|
63
66
|
|
|
@@ -73,7 +76,6 @@ export function createSnapshotManager(
|
|
|
73
76
|
dataPath?: string,
|
|
74
77
|
config: Partial<SetupOptions> = {},
|
|
75
78
|
deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
|
|
76
|
-
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
|
|
77
79
|
initialValidators: [],
|
|
78
80
|
},
|
|
79
81
|
) {
|
|
@@ -102,7 +104,7 @@ class MockSnapshotManager implements ISnapshotManager {
|
|
|
102
104
|
constructor(
|
|
103
105
|
testName: string,
|
|
104
106
|
private config: Partial<AztecNodeConfig> = {},
|
|
105
|
-
private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
|
|
107
|
+
private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {},
|
|
106
108
|
) {
|
|
107
109
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
108
110
|
this.logger.warn(`No data path given, will not persist any snapshots.`);
|
|
@@ -150,7 +152,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
150
152
|
testName: string,
|
|
151
153
|
private dataPath: string,
|
|
152
154
|
private config: Partial<SetupOptions> = {},
|
|
153
|
-
private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
|
|
155
|
+
private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {},
|
|
154
156
|
) {
|
|
155
157
|
this.livePath = join(this.dataPath, 'live', testName);
|
|
156
158
|
this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
|
|
@@ -186,7 +188,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
186
188
|
await restore(snapshotData, context);
|
|
187
189
|
|
|
188
190
|
// Save the snapshot data.
|
|
189
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.
|
|
191
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
190
192
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
191
193
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
192
194
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -261,7 +263,11 @@ async function teardown(context: SubsystemsContext | undefined) {
|
|
|
261
263
|
await context.watcher.stop();
|
|
262
264
|
await context.blobSink.stop();
|
|
263
265
|
if (context.directoryToCleanup) {
|
|
264
|
-
|
|
266
|
+
try {
|
|
267
|
+
await fs.rm(context.directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
|
|
268
|
+
} catch (err) {
|
|
269
|
+
getLogger().warn(`Failed to delete tmp directory ${context.directoryToCleanup}: ${err}`);
|
|
270
|
+
}
|
|
265
271
|
}
|
|
266
272
|
} catch (err) {
|
|
267
273
|
getLogger().error('Error during teardown', err);
|
|
@@ -276,9 +282,8 @@ async function teardown(context: SubsystemsContext | undefined) {
|
|
|
276
282
|
async function setupFromFresh(
|
|
277
283
|
statePath: string | undefined,
|
|
278
284
|
logger: Logger,
|
|
279
|
-
opts: SetupOptions = {},
|
|
285
|
+
{ numberOfInitialFundedAccounts = 10, ...opts }: SetupOptions = {},
|
|
280
286
|
deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
|
|
281
|
-
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
|
|
282
287
|
initialValidators: [],
|
|
283
288
|
},
|
|
284
289
|
): Promise<SubsystemsContext> {
|
|
@@ -313,9 +318,9 @@ async function setupFromFresh(
|
|
|
313
318
|
|
|
314
319
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
315
320
|
logger.verbose('Starting anvil...');
|
|
316
|
-
const res = await startAnvil(opts.ethereumSlotDuration);
|
|
321
|
+
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
317
322
|
const anvil = res.anvil;
|
|
318
|
-
aztecNodeConfig.
|
|
323
|
+
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
319
324
|
|
|
320
325
|
// Deploy our L1 contracts.
|
|
321
326
|
logger.verbose('Deploying L1 contracts...');
|
|
@@ -329,14 +334,22 @@ async function setupFromFresh(
|
|
|
329
334
|
aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
|
|
330
335
|
aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey!.toString('hex')}`;
|
|
331
336
|
|
|
332
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.
|
|
337
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
333
338
|
|
|
334
339
|
if (opts.l1StartTime) {
|
|
335
340
|
await ethCheatCodes.warp(opts.l1StartTime);
|
|
336
341
|
}
|
|
337
342
|
|
|
338
|
-
const
|
|
343
|
+
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
344
|
+
const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(
|
|
345
|
+
initialFundedAccounts.map(a => a.address),
|
|
346
|
+
opts.initialAccountFeeJuice,
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrls[0], hdAccount, logger, {
|
|
339
350
|
...getL1ContractsConfigEnvVars(),
|
|
351
|
+
genesisArchiveRoot,
|
|
352
|
+
genesisBlockHash,
|
|
340
353
|
salt: opts.salt,
|
|
341
354
|
...deployL1ContractsArgs,
|
|
342
355
|
initialValidators: opts.initialValidators,
|
|
@@ -368,7 +381,7 @@ async function setupFromFresh(
|
|
|
368
381
|
}
|
|
369
382
|
|
|
370
383
|
const watcher = new AnvilTestWatcher(
|
|
371
|
-
new EthCheatCodesWithState(aztecNodeConfig.
|
|
384
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
372
385
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
373
386
|
deployL1ContractsValues.publicClient,
|
|
374
387
|
);
|
|
@@ -390,7 +403,11 @@ async function setupFromFresh(
|
|
|
390
403
|
|
|
391
404
|
logger.verbose('Creating and synching an aztec node...');
|
|
392
405
|
const dateProvider = new TestDateProvider();
|
|
393
|
-
const aztecNode = await AztecNodeService.createAndSync(
|
|
406
|
+
const aztecNode = await AztecNodeService.createAndSync(
|
|
407
|
+
aztecNodeConfig,
|
|
408
|
+
{ telemetry, dateProvider },
|
|
409
|
+
{ prefilledPublicData },
|
|
410
|
+
);
|
|
394
411
|
|
|
395
412
|
let proverNode: ProverNode | undefined = undefined;
|
|
396
413
|
if (opts.startProverNode) {
|
|
@@ -400,6 +417,7 @@ async function setupFromFresh(
|
|
|
400
417
|
aztecNodeConfig,
|
|
401
418
|
aztecNode,
|
|
402
419
|
path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
420
|
+
prefilledPublicData,
|
|
403
421
|
);
|
|
404
422
|
}
|
|
405
423
|
|
|
@@ -408,10 +426,11 @@ async function setupFromFresh(
|
|
|
408
426
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
409
427
|
const pxe = await createPXEService(aztecNode, pxeConfig);
|
|
410
428
|
|
|
411
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.
|
|
429
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
412
430
|
|
|
413
431
|
if (statePath) {
|
|
414
432
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
433
|
+
writeFileSync(`${statePath}/accounts.json`, JSON.stringify(initialFundedAccounts, resolver));
|
|
415
434
|
}
|
|
416
435
|
|
|
417
436
|
return {
|
|
@@ -427,6 +446,7 @@ async function setupFromFresh(
|
|
|
427
446
|
cheatCodes,
|
|
428
447
|
dateProvider,
|
|
429
448
|
blobSink,
|
|
449
|
+
initialFundedAccounts,
|
|
430
450
|
directoryToCleanup,
|
|
431
451
|
};
|
|
432
452
|
}
|
|
@@ -451,6 +471,10 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
451
471
|
aztecNodeConfig.dataDirectory = statePath;
|
|
452
472
|
aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
|
|
453
473
|
|
|
474
|
+
const initialFundedAccounts: InitialAccountData[] =
|
|
475
|
+
JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
|
|
476
|
+
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
|
|
477
|
+
|
|
454
478
|
const blobSink = await createBlobSinkServer({
|
|
455
479
|
port: blobSinkPort,
|
|
456
480
|
dataStoreConfig: {
|
|
@@ -462,10 +486,10 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
462
486
|
|
|
463
487
|
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
464
488
|
const { anvil, rpcUrl } = await startAnvil();
|
|
465
|
-
aztecNodeConfig.
|
|
489
|
+
aztecNodeConfig.l1RpcUrls = [rpcUrl];
|
|
466
490
|
// Load anvil state.
|
|
467
491
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
468
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.
|
|
492
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
469
493
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
470
494
|
|
|
471
495
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
@@ -482,10 +506,10 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
482
506
|
}
|
|
483
507
|
|
|
484
508
|
logger.verbose('Creating ETH clients...');
|
|
485
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.
|
|
509
|
+
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
486
510
|
|
|
487
511
|
const watcher = new AnvilTestWatcher(
|
|
488
|
-
new EthCheatCodesWithState(aztecNodeConfig.
|
|
512
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
489
513
|
aztecNodeConfig.l1Contracts.rollupAddress,
|
|
490
514
|
publicClient,
|
|
491
515
|
);
|
|
@@ -494,7 +518,11 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
494
518
|
logger.verbose('Creating aztec node...');
|
|
495
519
|
const telemetry = initTelemetryClient(getTelemetryConfig());
|
|
496
520
|
const dateProvider = new TestDateProvider();
|
|
497
|
-
const aztecNode = await AztecNodeService.createAndSync(
|
|
521
|
+
const aztecNode = await AztecNodeService.createAndSync(
|
|
522
|
+
aztecNodeConfig,
|
|
523
|
+
{ telemetry, dateProvider },
|
|
524
|
+
{ prefilledPublicData },
|
|
525
|
+
);
|
|
498
526
|
|
|
499
527
|
let proverNode: ProverNode | undefined = undefined;
|
|
500
528
|
if (aztecNodeConfig.startProverNode) {
|
|
@@ -506,6 +534,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
506
534
|
aztecNodeConfig,
|
|
507
535
|
aztecNode,
|
|
508
536
|
path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
537
|
+
prefilledPublicData,
|
|
509
538
|
);
|
|
510
539
|
}
|
|
511
540
|
|
|
@@ -514,7 +543,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
514
543
|
pxeConfig.dataDirectory = statePath;
|
|
515
544
|
const pxe = await createPXEService(aztecNode, pxeConfig);
|
|
516
545
|
|
|
517
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.
|
|
546
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
518
547
|
|
|
519
548
|
return {
|
|
520
549
|
aztecNodeConfig,
|
|
@@ -533,6 +562,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
533
562
|
cheatCodes,
|
|
534
563
|
dateProvider,
|
|
535
564
|
blobSink,
|
|
565
|
+
initialFundedAccounts,
|
|
536
566
|
directoryToCleanup,
|
|
537
567
|
};
|
|
538
568
|
}
|
|
@@ -541,53 +571,18 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
541
571
|
* Snapshot 'apply' helper function to add accounts.
|
|
542
572
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
543
573
|
*/
|
|
544
|
-
export const
|
|
574
|
+
export const deployAccounts =
|
|
545
575
|
(numberOfAccounts: number, logger: Logger, waitUntilProven = false) =>
|
|
546
|
-
async ({ pxe }: { pxe: PXE }) => {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
Fr.random(),
|
|
550
|
-
GrumpkinScalar.random(),
|
|
551
|
-
]);
|
|
552
|
-
|
|
553
|
-
logger.verbose('Simulating account deployment...');
|
|
554
|
-
const provenTxs = await Promise.all(
|
|
555
|
-
accountKeys.map(async ([secretKey, signPk], index) => {
|
|
556
|
-
const account = await getSchnorrAccount(pxe, secretKey, signPk, 1);
|
|
557
|
-
|
|
558
|
-
// only register the contract class once
|
|
559
|
-
let skipClassRegistration = true;
|
|
560
|
-
if (index === 0) {
|
|
561
|
-
// for the first account, check if the contract class is already registered, otherwise we should register now
|
|
562
|
-
if (
|
|
563
|
-
!(await pxe.getContractClassMetadata(account.getInstance().contractClassId))
|
|
564
|
-
.isContractClassPubliclyRegistered
|
|
565
|
-
) {
|
|
566
|
-
skipClassRegistration = false;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
const deployMethod = await account.getDeployMethod();
|
|
571
|
-
const provenTx = await deployMethod.prove({
|
|
572
|
-
contractAddressSalt: new Fr(account.salt),
|
|
573
|
-
skipClassRegistration,
|
|
574
|
-
skipPublicDeployment: true,
|
|
575
|
-
universalDeploy: true,
|
|
576
|
-
});
|
|
577
|
-
return provenTx;
|
|
578
|
-
}),
|
|
579
|
-
);
|
|
580
|
-
|
|
581
|
-
logger.verbose('Account deployment tx hashes:');
|
|
582
|
-
for (const provenTx of provenTxs) {
|
|
583
|
-
logger.verbose((await provenTx.getTxHash()).toString());
|
|
576
|
+
async ({ pxe, initialFundedAccounts }: { pxe: PXE; initialFundedAccounts: InitialAccountData[] }) => {
|
|
577
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
578
|
+
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
584
579
|
}
|
|
585
580
|
|
|
586
|
-
logger.verbose('Deploying accounts...');
|
|
587
|
-
const
|
|
588
|
-
await
|
|
581
|
+
logger.verbose('Deploying accounts funded with fee juice...');
|
|
582
|
+
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
583
|
+
await deployFundedSchnorrAccounts(pxe, deployedAccounts, { proven: waitUntilProven });
|
|
589
584
|
|
|
590
|
-
return {
|
|
585
|
+
return { deployedAccounts };
|
|
591
586
|
};
|
|
592
587
|
|
|
593
588
|
/**
|
|
@@ -609,16 +604,14 @@ export async function publicDeployAccounts(
|
|
|
609
604
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
610
605
|
const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
611
606
|
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
instances.map(async instance => (await deployInstance(sender, instance!)).request()),
|
|
619
|
-
);
|
|
620
|
-
calls.push(...requests);
|
|
607
|
+
const fns: ContractFunctionInteraction[] = await Promise.all([
|
|
608
|
+
...(!alreadyRegistered ? [registerContractClass(sender, SchnorrAccountContractArtifact)] : []),
|
|
609
|
+
...instances.map(instance => deployInstance(sender, instance!)),
|
|
610
|
+
]);
|
|
611
|
+
const calls: FunctionCall[] = await Promise.all(fns.map(fn => fn.request()));
|
|
612
|
+
const capsules: Capsule[] = fns.map(fn => fn.getCapsules()).flat();
|
|
621
613
|
|
|
622
614
|
const batch = new BatchCall(sender, calls);
|
|
615
|
+
batch.addCapsules(capsules);
|
|
623
616
|
await batch.send().wait({ proven: waitUntilProven });
|
|
624
617
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// docs:start:token_utils
|
|
2
|
-
import {
|
|
2
|
+
import type { AztecAddress, Logger, Wallet } from '@aztec/aztec.js';
|
|
3
3
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
4
|
|
|
5
5
|
export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigint, logger: Logger) {
|
|
@@ -25,7 +25,7 @@ export async function mintTokensToPrivate(
|
|
|
25
25
|
amount: bigint,
|
|
26
26
|
) {
|
|
27
27
|
const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
|
|
28
|
-
const from = minterWallet.getAddress(); // we are setting from to minter here because
|
|
28
|
+
const from = minterWallet.getAddress(); // we are setting from to minter here because we need a sender to calculate the tag
|
|
29
29
|
await tokenAsMinter.methods.mint_to_private(from, recipient, amount).send().wait();
|
|
30
30
|
}
|
|
31
31
|
// docs:end:token_utils
|