@aztec/end-to-end 4.0.0-nightly.20260114 → 4.0.0-nightly.20260115
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/client_flows_benchmark.d.ts +3 -4
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +13 -8
- package/dest/bench/utils.d.ts +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -3
- 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 +7 -4
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +3 -4
- 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 +10 -5
- package/dest/e2e_deploy_contract/deploy_test.d.ts +3 -3
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +7 -4
- package/dest/e2e_epochs/epochs_test.js +1 -1
- package/dest/e2e_fees/fees_test.d.ts +4 -4
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +14 -11
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +6 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts +4 -5
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +11 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts +3 -3
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +6 -4
- package/dest/fixtures/e2e_prover_test.d.ts +3 -3
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +9 -7
- package/dest/fixtures/setup.d.ts +216 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +683 -0
- package/dest/fixtures/utils.d.ts +5 -191
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -615
- package/dest/shared/cross_chain_test_harness.d.ts +12 -1
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.d.ts +11 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.d.ts +5 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/package.json +39 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +16 -11
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +9 -12
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +15 -10
- package/src/e2e_deploy_contract/deploy_test.ts +8 -5
- package/src/e2e_epochs/epochs_test.ts +1 -1
- package/src/e2e_fees/fees_test.ts +21 -18
- package/src/e2e_nested_contract/nested_contract_test.ts +9 -6
- package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
- package/src/e2e_p2p/p2p_network.ts +24 -10
- package/src/e2e_token_contract/token_contract_test.ts +6 -10
- package/src/fixtures/e2e_prover_test.ts +17 -13
- package/src/fixtures/setup.ts +1009 -0
- package/src/fixtures/utils.ts +27 -901
- package/dest/fixtures/snapshot_manager.d.ts +0 -59
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -245
- package/src/fixtures/snapshot_manager.ts +0 -333
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
-
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
-
import type { Logger } from '@aztec/aztec.js/log';
|
|
5
|
-
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
6
|
-
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
7
|
-
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
8
|
-
import { type DeployAztecL1ContractsArgs, type DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
9
|
-
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type { ProverNode } from '@aztec/prover-node';
|
|
11
|
-
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
12
|
-
import { TestWallet } from '@aztec/test-wallet/server';
|
|
13
|
-
import type { Anvil } from '@viem/anvil';
|
|
14
|
-
import { type SetupOptions } from './utils.js';
|
|
15
|
-
export type SubsystemsContext = {
|
|
16
|
-
anvil: Anvil;
|
|
17
|
-
acvmConfig: any;
|
|
18
|
-
bbConfig: any;
|
|
19
|
-
aztecNode: AztecNodeService;
|
|
20
|
-
aztecNodeConfig: AztecNodeConfig;
|
|
21
|
-
wallet: TestWallet;
|
|
22
|
-
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
23
|
-
proverNode?: ProverNode;
|
|
24
|
-
watcher: AnvilTestWatcher;
|
|
25
|
-
cheatCodes: CheatCodes;
|
|
26
|
-
sequencer: SequencerClient;
|
|
27
|
-
dateProvider: TestDateProvider;
|
|
28
|
-
initialFundedAccounts: InitialAccountData[];
|
|
29
|
-
directoryToCleanup?: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Destroys the current subsystem context.
|
|
33
|
-
*/
|
|
34
|
-
export declare function teardown(context: SubsystemsContext | undefined): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Initializes a fresh set of subsystems.
|
|
37
|
-
* State is stored in temporary in-memory locations.
|
|
38
|
-
*/
|
|
39
|
-
export declare function setupFromFresh(logger: Logger, { numberOfInitialFundedAccounts, ...opts }?: SetupOptions, deployL1ContractsArgs?: Partial<DeployAztecL1ContractsArgs>): Promise<SubsystemsContext>;
|
|
40
|
-
/**
|
|
41
|
-
* Helper function to deploy accounts.
|
|
42
|
-
* Returns deployed account data that can be used by tests.
|
|
43
|
-
*/
|
|
44
|
-
export declare const deployAccounts: (numberOfAccounts: number, logger: Logger) => ({ wallet, initialFundedAccounts }: {
|
|
45
|
-
wallet: TestWallet;
|
|
46
|
-
initialFundedAccounts: InitialAccountData[];
|
|
47
|
-
}) => Promise<{
|
|
48
|
-
deployedAccounts: InitialAccountData[];
|
|
49
|
-
}>;
|
|
50
|
-
/**
|
|
51
|
-
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
52
|
-
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
53
|
-
* @param sender - Wallet to send the deployment tx.
|
|
54
|
-
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
55
|
-
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
56
|
-
* @param node - AztecNode used to wait for proven tx.
|
|
57
|
-
*/
|
|
58
|
-
export declare function publicDeployAccounts(wallet: Wallet, accountsToDeploy: AztecAddress[], waitUntilProven?: boolean, node?: AztecNode): Promise<void>;
|
|
59
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic25hcHNob3RfbWFuYWdlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZpeHR1cmVzL3NuYXBzaG90X21hbmFnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssa0JBQWtCLEVBQTJCLE1BQU0seUJBQXlCLENBQUM7QUFDM0YsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLGdCQUFnQixFQ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B,EAAE,kBAAkB,EAAE,CAAC;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,iBAiBpE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,EAAE,6BAAkC,EAAE,GAAG,IAAI,EAAE,GAAE,YAAiB,EAClE,qBAAqB,GAAE,OAAO,CAAC,0BAA0B,CAExD,GACA,OAAO,CAAC,iBAAiB,CAAC,CAiK5B;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;EA0BxB,CAAC;AAEJ;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,YAAY,EAAE,EAChC,eAAe,UAAQ,EACvB,IAAI,CAAC,EAAE,SAAS,iBAwBjB"}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
|
-
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
-
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
5
|
-
import { BatchCall, waitForProven } from '@aztec/aztec.js/contracts';
|
|
6
|
-
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
7
|
-
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
8
|
-
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
9
|
-
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
10
|
-
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
11
|
-
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
12
|
-
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
13
|
-
import { SecretValue } from '@aztec/foundation/config';
|
|
14
|
-
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
15
|
-
import { tryRmDir } from '@aztec/foundation/fs';
|
|
16
|
-
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
17
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
18
|
-
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
19
|
-
import { getPXEConfig } from '@aztec/pxe/server';
|
|
20
|
-
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
21
|
-
import { TestWallet } from '@aztec/test-wallet/server';
|
|
22
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
23
|
-
import fs from 'fs/promises';
|
|
24
|
-
import { tmpdir } from 'os';
|
|
25
|
-
import path from 'path';
|
|
26
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
27
|
-
import { foundry } from 'viem/chains';
|
|
28
|
-
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
29
|
-
import { getACVMConfig } from './get_acvm_config.js';
|
|
30
|
-
import { getBBConfig } from './get_bb_config.js';
|
|
31
|
-
import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex, getSponsoredFPCAddress, setupSharedBlobStorage } from './utils.js';
|
|
32
|
-
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
33
|
-
/**
|
|
34
|
-
* Destroys the current subsystem context.
|
|
35
|
-
*/ export async function teardown(context) {
|
|
36
|
-
if (!context) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const logger = getLogger();
|
|
40
|
-
try {
|
|
41
|
-
logger.info('Tearing down subsystems');
|
|
42
|
-
await tryStop(context.proverNode);
|
|
43
|
-
await tryStop(context.aztecNode);
|
|
44
|
-
await context.acvmConfig?.cleanup();
|
|
45
|
-
await context.bbConfig?.cleanup();
|
|
46
|
-
await tryStop(context.anvil);
|
|
47
|
-
await tryStop(context.watcher);
|
|
48
|
-
await tryRmDir(context.directoryToCleanup, logger);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
logger.error('Error during teardown', err);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Initializes a fresh set of subsystems.
|
|
55
|
-
* State is stored in temporary in-memory locations.
|
|
56
|
-
*/ export async function setupFromFresh(logger, { numberOfInitialFundedAccounts = 10, ...opts } = {}, deployL1ContractsArgs = {
|
|
57
|
-
initialValidators: []
|
|
58
|
-
}) {
|
|
59
|
-
logger.verbose(`Initializing state...`);
|
|
60
|
-
// Default to no slashing
|
|
61
|
-
opts.slasherFlavor ??= 'none';
|
|
62
|
-
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
63
|
-
// Fetch the AztecNode config.
|
|
64
|
-
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
65
|
-
const aztecNodeConfig = {
|
|
66
|
-
...getConfigEnvVars(),
|
|
67
|
-
...opts
|
|
68
|
-
};
|
|
69
|
-
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
70
|
-
aztecNodeConfig.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
|
|
71
|
-
// Only enable proving if specifically requested.
|
|
72
|
-
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
73
|
-
// Only enforce the time table if requested
|
|
74
|
-
aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
|
|
75
|
-
// Only set the target committee size if it is explicitly set
|
|
76
|
-
aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
|
|
77
|
-
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
78
|
-
deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
|
|
79
|
-
// Create a temp directory for all ephemeral state and cleanup afterwards
|
|
80
|
-
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
81
|
-
await fs.mkdir(directoryToCleanup, {
|
|
82
|
-
recursive: true
|
|
83
|
-
});
|
|
84
|
-
aztecNodeConfig.dataDirectory = directoryToCleanup;
|
|
85
|
-
await setupSharedBlobStorage(aztecNodeConfig);
|
|
86
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, {
|
|
87
|
-
addressIndex: 0
|
|
88
|
-
});
|
|
89
|
-
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
90
|
-
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
91
|
-
const publisherPrivKeyHex = `0x${publisherPrivKey.toString('hex')}`;
|
|
92
|
-
const l1Client = createExtendedL1Client([
|
|
93
|
-
aztecNodeConfig.l1RpcUrls[0]
|
|
94
|
-
], hdAccount, foundry);
|
|
95
|
-
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
96
|
-
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
97
|
-
aztecNodeConfig.publisherPrivateKeys = [
|
|
98
|
-
new SecretValue(publisherPrivKeyHex)
|
|
99
|
-
];
|
|
100
|
-
aztecNodeConfig.validatorPrivateKeys = new SecretValue([
|
|
101
|
-
`0x${validatorPrivKey.toString('hex')}`
|
|
102
|
-
]);
|
|
103
|
-
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
104
|
-
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
105
|
-
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
106
|
-
logger.verbose('Starting anvil...');
|
|
107
|
-
const res = await startAnvil({
|
|
108
|
-
l1BlockTime: opts.ethereumSlotDuration
|
|
109
|
-
});
|
|
110
|
-
const anvil = res.anvil;
|
|
111
|
-
aztecNodeConfig.l1RpcUrls = [
|
|
112
|
-
res.rpcUrl
|
|
113
|
-
];
|
|
114
|
-
const dateProvider = new TestDateProvider();
|
|
115
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
116
|
-
// Deploy our L1 contracts.
|
|
117
|
-
logger.verbose('Deploying Aztec L1 contracts...');
|
|
118
|
-
if (opts.l1StartTime) {
|
|
119
|
-
await ethCheatCodes.warp(opts.l1StartTime, {
|
|
120
|
-
resetBlockInterval: true
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
124
|
-
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
125
|
-
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address).concat(sponsoredFPCAddress), opts.initialAccountFeeJuice);
|
|
126
|
-
const vkTreeRoot = getVKTreeRoot();
|
|
127
|
-
await deployMulticall3(l1Client, logger);
|
|
128
|
-
// Define args, defaulted to our environment variables.
|
|
129
|
-
const args = {
|
|
130
|
-
...getL1ContractsConfigEnvVars(),
|
|
131
|
-
...deployL1ContractsArgs,
|
|
132
|
-
vkTreeRoot,
|
|
133
|
-
genesisArchiveRoot,
|
|
134
|
-
protocolContractsHash,
|
|
135
|
-
initialValidators: opts.initialValidators,
|
|
136
|
-
feeJuicePortalInitialBalance: fundingNeeded,
|
|
137
|
-
realVerifier: false
|
|
138
|
-
};
|
|
139
|
-
const deployL1ContractsValues = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], publisherPrivKeyHex, foundry.id, args);
|
|
140
|
-
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
141
|
-
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
142
|
-
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
|
|
143
|
-
await watcher.start();
|
|
144
|
-
const acvmConfig = await getACVMConfig(logger);
|
|
145
|
-
if (acvmConfig) {
|
|
146
|
-
aztecNodeConfig.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
147
|
-
aztecNodeConfig.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
148
|
-
}
|
|
149
|
-
const bbConfig = await getBBConfig(logger);
|
|
150
|
-
if (bbConfig) {
|
|
151
|
-
aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
152
|
-
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
153
|
-
}
|
|
154
|
-
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
155
|
-
logger.info('Creating and synching an aztec node...');
|
|
156
|
-
const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
157
|
-
telemetry,
|
|
158
|
-
dateProvider
|
|
159
|
-
}, {
|
|
160
|
-
prefilledPublicData
|
|
161
|
-
});
|
|
162
|
-
let proverNode = undefined;
|
|
163
|
-
if (opts.startProverNode) {
|
|
164
|
-
logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
|
|
165
|
-
proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, {
|
|
166
|
-
...aztecNodeConfig.proverNodeConfig,
|
|
167
|
-
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
168
|
-
p2pEnabled: false
|
|
169
|
-
}, aztecNode, prefilledPublicData);
|
|
170
|
-
}
|
|
171
|
-
logger.verbose('Creating pxe...');
|
|
172
|
-
const pxeConfig = getPXEConfig();
|
|
173
|
-
pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
174
|
-
// Only enable proving if specifically requested.
|
|
175
|
-
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
176
|
-
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
177
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
178
|
-
return {
|
|
179
|
-
aztecNodeConfig,
|
|
180
|
-
anvil,
|
|
181
|
-
aztecNode,
|
|
182
|
-
wallet,
|
|
183
|
-
sequencer: aztecNode.getSequencer(),
|
|
184
|
-
acvmConfig,
|
|
185
|
-
bbConfig,
|
|
186
|
-
deployL1ContractsValues,
|
|
187
|
-
proverNode,
|
|
188
|
-
watcher,
|
|
189
|
-
cheatCodes,
|
|
190
|
-
dateProvider,
|
|
191
|
-
initialFundedAccounts,
|
|
192
|
-
directoryToCleanup
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Helper function to deploy accounts.
|
|
197
|
-
* Returns deployed account data that can be used by tests.
|
|
198
|
-
*/ export const deployAccounts = (numberOfAccounts, logger)=>async ({ wallet, initialFundedAccounts })=>{
|
|
199
|
-
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
200
|
-
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
201
|
-
}
|
|
202
|
-
logger.verbose('Deploying accounts funded with fee juice...');
|
|
203
|
-
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
204
|
-
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
205
|
-
for(let i = 0; i < deployedAccounts.length; i++){
|
|
206
|
-
const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
|
|
207
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
208
|
-
await deployMethod.send({
|
|
209
|
-
from: AztecAddress.ZERO,
|
|
210
|
-
skipClassPublication: i !== 0
|
|
211
|
-
}).wait();
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
deployedAccounts
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
219
|
-
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
220
|
-
* @param sender - Wallet to send the deployment tx.
|
|
221
|
-
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
222
|
-
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
223
|
-
* @param node - AztecNode used to wait for proven tx.
|
|
224
|
-
*/ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
|
|
225
|
-
const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.instance);
|
|
226
|
-
const { instance } = await wallet.getContractMetadata(accountsToDeploy[0]);
|
|
227
|
-
const { isContractClassPubliclyRegistered } = await wallet.getContractClassMetadata(instance.currentContractClassId);
|
|
228
|
-
const calls = await Promise.all([
|
|
229
|
-
...!isContractClassPubliclyRegistered ? [
|
|
230
|
-
publishContractClass(wallet, SchnorrAccountContractArtifact)
|
|
231
|
-
] : [],
|
|
232
|
-
...instances.map((instance)=>publishInstance(wallet, instance))
|
|
233
|
-
]);
|
|
234
|
-
const batch = new BatchCall(wallet, calls);
|
|
235
|
-
const txReceipt = await batch.send({
|
|
236
|
-
from: accountsToDeploy[0]
|
|
237
|
-
}).wait();
|
|
238
|
-
if (waitUntilProven) {
|
|
239
|
-
if (!node) {
|
|
240
|
-
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
241
|
-
} else {
|
|
242
|
-
await waitForProven(node, txReceipt);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
|
-
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
-
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
5
|
-
import { BatchCall, type ContractFunctionInteraction, waitForProven } from '@aztec/aztec.js/contracts';
|
|
6
|
-
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
7
|
-
import type { Logger } from '@aztec/aztec.js/log';
|
|
8
|
-
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
9
|
-
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
10
|
-
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
11
|
-
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
|
-
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
13
|
-
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
14
|
-
import {
|
|
15
|
-
type DeployAztecL1ContractsArgs,
|
|
16
|
-
type DeployAztecL1ContractsReturnType,
|
|
17
|
-
deployAztecL1Contracts,
|
|
18
|
-
} from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
19
|
-
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
20
|
-
import { SecretValue } from '@aztec/foundation/config';
|
|
21
|
-
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
22
|
-
import { tryRmDir } from '@aztec/foundation/fs';
|
|
23
|
-
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
24
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
25
|
-
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
26
|
-
import type { ProverNode } from '@aztec/prover-node';
|
|
27
|
-
import { getPXEConfig } from '@aztec/pxe/server';
|
|
28
|
-
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
29
|
-
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
30
|
-
import { TestWallet } from '@aztec/test-wallet/server';
|
|
31
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
32
|
-
|
|
33
|
-
import type { Anvil } from '@viem/anvil';
|
|
34
|
-
import fs from 'fs/promises';
|
|
35
|
-
import { tmpdir } from 'os';
|
|
36
|
-
import path from 'path';
|
|
37
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
38
|
-
import { foundry } from 'viem/chains';
|
|
39
|
-
|
|
40
|
-
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
41
|
-
import { getACVMConfig } from './get_acvm_config.js';
|
|
42
|
-
import { getBBConfig } from './get_bb_config.js';
|
|
43
|
-
import {
|
|
44
|
-
type SetupOptions,
|
|
45
|
-
createAndSyncProverNode,
|
|
46
|
-
getLogger,
|
|
47
|
-
getPrivateKeyFromIndex,
|
|
48
|
-
getSponsoredFPCAddress,
|
|
49
|
-
setupSharedBlobStorage,
|
|
50
|
-
} from './utils.js';
|
|
51
|
-
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
52
|
-
|
|
53
|
-
export type SubsystemsContext = {
|
|
54
|
-
anvil: Anvil;
|
|
55
|
-
acvmConfig: any;
|
|
56
|
-
bbConfig: any;
|
|
57
|
-
aztecNode: AztecNodeService;
|
|
58
|
-
aztecNodeConfig: AztecNodeConfig;
|
|
59
|
-
wallet: TestWallet;
|
|
60
|
-
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
61
|
-
proverNode?: ProverNode;
|
|
62
|
-
watcher: AnvilTestWatcher;
|
|
63
|
-
cheatCodes: CheatCodes;
|
|
64
|
-
sequencer: SequencerClient;
|
|
65
|
-
dateProvider: TestDateProvider;
|
|
66
|
-
initialFundedAccounts: InitialAccountData[];
|
|
67
|
-
directoryToCleanup?: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Destroys the current subsystem context.
|
|
72
|
-
*/
|
|
73
|
-
export async function teardown(context: SubsystemsContext | undefined) {
|
|
74
|
-
if (!context) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const logger = getLogger();
|
|
78
|
-
try {
|
|
79
|
-
logger.info('Tearing down subsystems');
|
|
80
|
-
await tryStop(context.proverNode);
|
|
81
|
-
await tryStop(context.aztecNode);
|
|
82
|
-
await context.acvmConfig?.cleanup();
|
|
83
|
-
await context.bbConfig?.cleanup();
|
|
84
|
-
await tryStop(context.anvil);
|
|
85
|
-
await tryStop(context.watcher);
|
|
86
|
-
await tryRmDir(context.directoryToCleanup, logger);
|
|
87
|
-
} catch (err) {
|
|
88
|
-
logger.error('Error during teardown', err);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Initializes a fresh set of subsystems.
|
|
94
|
-
* State is stored in temporary in-memory locations.
|
|
95
|
-
*/
|
|
96
|
-
export async function setupFromFresh(
|
|
97
|
-
logger: Logger,
|
|
98
|
-
{ numberOfInitialFundedAccounts = 10, ...opts }: SetupOptions = {},
|
|
99
|
-
deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
|
|
100
|
-
initialValidators: [],
|
|
101
|
-
},
|
|
102
|
-
): Promise<SubsystemsContext> {
|
|
103
|
-
logger.verbose(`Initializing state...`);
|
|
104
|
-
|
|
105
|
-
// Default to no slashing
|
|
106
|
-
opts.slasherFlavor ??= 'none';
|
|
107
|
-
deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
|
|
108
|
-
|
|
109
|
-
// Fetch the AztecNode config.
|
|
110
|
-
// TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
|
|
111
|
-
const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
|
|
112
|
-
aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
|
|
113
|
-
aztecNodeConfig.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
|
|
114
|
-
// Only enable proving if specifically requested.
|
|
115
|
-
aztecNodeConfig.realProofs = !!opts.realProofs;
|
|
116
|
-
// Only enforce the time table if requested
|
|
117
|
-
aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
|
|
118
|
-
// Only set the target committee size if it is explicitly set
|
|
119
|
-
aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
|
|
120
|
-
aztecNodeConfig.listenAddress = '127.0.0.1';
|
|
121
|
-
|
|
122
|
-
deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
|
|
123
|
-
|
|
124
|
-
// Create a temp directory for all ephemeral state and cleanup afterwards
|
|
125
|
-
const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
126
|
-
await fs.mkdir(directoryToCleanup, { recursive: true });
|
|
127
|
-
aztecNodeConfig.dataDirectory = directoryToCleanup;
|
|
128
|
-
|
|
129
|
-
await setupSharedBlobStorage(aztecNodeConfig);
|
|
130
|
-
|
|
131
|
-
const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
|
|
132
|
-
const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
|
|
133
|
-
const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
|
|
134
|
-
const publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` satisfies `0x${string}`;
|
|
135
|
-
|
|
136
|
-
const l1Client = createExtendedL1Client([aztecNodeConfig.l1RpcUrls[0]], hdAccount, foundry);
|
|
137
|
-
|
|
138
|
-
const validatorPrivKey = getPrivateKeyFromIndex(0);
|
|
139
|
-
const proverNodePrivateKey = getPrivateKeyFromIndex(0);
|
|
140
|
-
|
|
141
|
-
aztecNodeConfig.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
|
|
142
|
-
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
|
|
143
|
-
aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
|
|
144
|
-
|
|
145
|
-
logger.info(`Setting up environment with config`, aztecNodeConfig);
|
|
146
|
-
|
|
147
|
-
// Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
148
|
-
logger.verbose('Starting anvil...');
|
|
149
|
-
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
150
|
-
const anvil = res.anvil;
|
|
151
|
-
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
152
|
-
|
|
153
|
-
const dateProvider = new TestDateProvider();
|
|
154
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
155
|
-
|
|
156
|
-
// Deploy our L1 contracts.
|
|
157
|
-
logger.verbose('Deploying Aztec L1 contracts...');
|
|
158
|
-
if (opts.l1StartTime) {
|
|
159
|
-
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
163
|
-
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
164
|
-
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
|
|
165
|
-
initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
|
|
166
|
-
opts.initialAccountFeeJuice,
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
const vkTreeRoot = getVKTreeRoot();
|
|
170
|
-
await deployMulticall3(l1Client, logger);
|
|
171
|
-
|
|
172
|
-
// Define args, defaulted to our environment variables.
|
|
173
|
-
const args: DeployAztecL1ContractsArgs = {
|
|
174
|
-
...getL1ContractsConfigEnvVars(),
|
|
175
|
-
...deployL1ContractsArgs,
|
|
176
|
-
vkTreeRoot,
|
|
177
|
-
genesisArchiveRoot,
|
|
178
|
-
protocolContractsHash,
|
|
179
|
-
initialValidators: opts.initialValidators,
|
|
180
|
-
feeJuicePortalInitialBalance: fundingNeeded,
|
|
181
|
-
realVerifier: false,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const deployL1ContractsValues = await deployAztecL1Contracts(
|
|
185
|
-
aztecNodeConfig.l1RpcUrls[0],
|
|
186
|
-
publisherPrivKeyHex,
|
|
187
|
-
foundry.id,
|
|
188
|
-
args,
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
192
|
-
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
193
|
-
|
|
194
|
-
const watcher = new AnvilTestWatcher(
|
|
195
|
-
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
|
|
196
|
-
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
197
|
-
deployL1ContractsValues.l1Client,
|
|
198
|
-
dateProvider,
|
|
199
|
-
);
|
|
200
|
-
await watcher.start();
|
|
201
|
-
|
|
202
|
-
const acvmConfig = await getACVMConfig(logger);
|
|
203
|
-
if (acvmConfig) {
|
|
204
|
-
aztecNodeConfig.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
|
|
205
|
-
aztecNodeConfig.acvmBinaryPath = acvmConfig.acvmBinaryPath;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const bbConfig = await getBBConfig(logger);
|
|
209
|
-
if (bbConfig) {
|
|
210
|
-
aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
|
|
211
|
-
aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
|
|
215
|
-
|
|
216
|
-
logger.info('Creating and synching an aztec node...');
|
|
217
|
-
const aztecNode = await AztecNodeService.createAndSync(
|
|
218
|
-
aztecNodeConfig,
|
|
219
|
-
{ telemetry, dateProvider },
|
|
220
|
-
{ prefilledPublicData },
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
let proverNode: ProverNode | undefined = undefined;
|
|
224
|
-
if (opts.startProverNode) {
|
|
225
|
-
logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
|
|
226
|
-
proverNode = await createAndSyncProverNode(
|
|
227
|
-
`0x${proverNodePrivateKey!.toString('hex')}`,
|
|
228
|
-
aztecNodeConfig,
|
|
229
|
-
{
|
|
230
|
-
...aztecNodeConfig.proverNodeConfig,
|
|
231
|
-
dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
|
|
232
|
-
p2pEnabled: false,
|
|
233
|
-
},
|
|
234
|
-
aztecNode,
|
|
235
|
-
prefilledPublicData,
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
logger.verbose('Creating pxe...');
|
|
240
|
-
const pxeConfig = getPXEConfig();
|
|
241
|
-
pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
242
|
-
// Only enable proving if specifically requested.
|
|
243
|
-
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
244
|
-
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
245
|
-
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
aztecNodeConfig,
|
|
249
|
-
anvil,
|
|
250
|
-
aztecNode,
|
|
251
|
-
wallet,
|
|
252
|
-
sequencer: aztecNode.getSequencer()!,
|
|
253
|
-
acvmConfig,
|
|
254
|
-
bbConfig,
|
|
255
|
-
deployL1ContractsValues,
|
|
256
|
-
proverNode,
|
|
257
|
-
watcher,
|
|
258
|
-
cheatCodes,
|
|
259
|
-
dateProvider,
|
|
260
|
-
initialFundedAccounts,
|
|
261
|
-
directoryToCleanup,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Helper function to deploy accounts.
|
|
267
|
-
* Returns deployed account data that can be used by tests.
|
|
268
|
-
*/
|
|
269
|
-
export const deployAccounts =
|
|
270
|
-
(numberOfAccounts: number, logger: Logger) =>
|
|
271
|
-
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
|
|
272
|
-
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
273
|
-
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
logger.verbose('Deploying accounts funded with fee juice...');
|
|
277
|
-
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
278
|
-
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
279
|
-
for (let i = 0; i < deployedAccounts.length; i++) {
|
|
280
|
-
const accountManager = await wallet.createSchnorrAccount(
|
|
281
|
-
deployedAccounts[i].secret,
|
|
282
|
-
deployedAccounts[i].salt,
|
|
283
|
-
deployedAccounts[i].signingKey,
|
|
284
|
-
);
|
|
285
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
286
|
-
await deployMethod
|
|
287
|
-
.send({
|
|
288
|
-
from: AztecAddress.ZERO,
|
|
289
|
-
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
290
|
-
})
|
|
291
|
-
.wait();
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return { deployedAccounts };
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Registers the contract class used for test accounts and publicly deploys the instances requested.
|
|
299
|
-
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
300
|
-
* @param sender - Wallet to send the deployment tx.
|
|
301
|
-
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
302
|
-
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
303
|
-
* @param node - AztecNode used to wait for proven tx.
|
|
304
|
-
*/
|
|
305
|
-
export async function publicDeployAccounts(
|
|
306
|
-
wallet: Wallet,
|
|
307
|
-
accountsToDeploy: AztecAddress[],
|
|
308
|
-
waitUntilProven = false,
|
|
309
|
-
node?: AztecNode,
|
|
310
|
-
) {
|
|
311
|
-
const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
|
|
312
|
-
metadata => metadata.instance,
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
const { instance } = await wallet.getContractMetadata(accountsToDeploy[0]);
|
|
316
|
-
const { isContractClassPubliclyRegistered } = await wallet.getContractClassMetadata(instance!.currentContractClassId);
|
|
317
|
-
|
|
318
|
-
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
319
|
-
...(!isContractClassPubliclyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
|
|
320
|
-
...instances.map(instance => publishInstance(wallet, instance!)),
|
|
321
|
-
]);
|
|
322
|
-
|
|
323
|
-
const batch = new BatchCall(wallet, calls);
|
|
324
|
-
|
|
325
|
-
const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
326
|
-
if (waitUntilProven) {
|
|
327
|
-
if (!node) {
|
|
328
|
-
throw new Error('Need to provide an AztecNode to wait for proven.');
|
|
329
|
-
} else {
|
|
330
|
-
await waitForProven(node, txReceipt);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|