@aztec/end-to-end 2.1.0-rc.9 → 3.0.0-devnet.2
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 +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +16 -12
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
- package/dest/bench/utils.d.ts +2 -11
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +10 -34
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -8
- 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 +31 -33
- package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +3 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +10 -9
- package/dest/e2e_fees/bridging_race.notest.js +12 -9
- package/dest/e2e_fees/fees_test.d.ts +5 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +23 -31
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -5
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +2 -2
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +5 -2
- package/dest/e2e_p2p/p2p_network.d.ts +16 -4
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +32 -10
- package/dest/e2e_p2p/shared.d.ts +11 -13
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +49 -45
- package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +8 -6
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +40 -50
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +2 -2
- package/dest/fixtures/setup_p2p_test.d.ts +0 -7
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.d.ts +10 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +44 -34
- package/dest/fixtures/token_utils.d.ts +6 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +11 -15
- package/dest/fixtures/utils.d.ts +23 -27
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +76 -101
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/web3signer.d.ts.map +1 -1
- package/dest/fixtures/web3signer.js +16 -5
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +16 -10
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -15
- package/dest/shared/gas_portal_test_harness.d.ts +9 -6
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +10 -7
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- 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 +9 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +29 -45
- package/dest/simulators/lending_simulator.d.ts +2 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +3 -2
- package/dest/simulators/token_simulator.d.ts +3 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +19 -13
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -85
- package/dest/spartan/utils.d.ts +44 -0
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +212 -20
- package/package.json +38 -37
- package/src/bench/client_flows/benchmark.ts +6 -6
- package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
- package/src/bench/client_flows/data_extractor.ts +1 -1
- package/src/bench/utils.ts +9 -37
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
- package/src/e2e_deploy_contract/deploy_test.ts +17 -35
- package/src/e2e_epochs/epochs_test.ts +12 -14
- package/src/e2e_fees/bridging_race.notest.ts +14 -9
- package/src/e2e_fees/fees_test.ts +26 -38
- package/src/e2e_l1_publisher/write_json.ts +8 -6
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
- package/src/e2e_p2p/inactivity_slash_test.ts +7 -3
- package/src/e2e_p2p/p2p_network.ts +105 -67
- package/src/e2e_p2p/shared.ts +50 -55
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +51 -88
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +0 -8
- package/src/fixtures/snapshot_manager.ts +61 -61
- package/src/fixtures/token_utils.ts +13 -21
- package/src/fixtures/utils.ts +87 -138
- package/src/fixtures/web3signer.ts +22 -5
- package/src/guides/up_quick_start.sh +2 -10
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +18 -29
- package/src/shared/gas_portal_test_harness.ts +12 -19
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +61 -67
- package/src/simulators/lending_simulator.ts +3 -2
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +8 -3
- package/src/spartan/setup_test_wallets.ts +133 -126
- package/src/spartan/utils.ts +268 -18
package/src/fixtures/utils.ts
CHANGED
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
3
|
-
type InitialAccountData,
|
|
4
|
-
deployFundedSchnorrAccounts,
|
|
5
|
-
generateSchnorrAccounts,
|
|
6
|
-
getDeployedTestAccounts,
|
|
7
|
-
getDeployedTestAccountsWallets,
|
|
8
|
-
} from '@aztec/accounts/testing';
|
|
2
|
+
import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
9
3
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
10
4
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
type AccountWalletWithSecretKey,
|
|
14
|
-
type AztecAddress,
|
|
15
|
-
type AztecNode,
|
|
16
|
-
BatchCall,
|
|
17
|
-
type ContractMethod,
|
|
18
|
-
type Logger,
|
|
19
|
-
type PXE,
|
|
20
|
-
type Wallet,
|
|
21
|
-
createAztecNodeClient,
|
|
22
|
-
createLogger,
|
|
23
|
-
createPXEClient,
|
|
24
|
-
makeFetch,
|
|
25
|
-
sleep,
|
|
26
|
-
waitForPXE,
|
|
27
|
-
} from '@aztec/aztec.js';
|
|
5
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
6
|
+
import { BatchCall, type ContractMethod } from '@aztec/aztec.js/contracts';
|
|
28
7
|
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
9
|
+
import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
|
|
10
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
29
11
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
30
12
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
31
13
|
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
@@ -57,24 +39,18 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
57
39
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
58
40
|
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
59
41
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
42
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
60
43
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
61
44
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
62
45
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
63
46
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
64
47
|
import type { P2PClientDeps } from '@aztec/p2p';
|
|
65
48
|
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
66
|
-
import {
|
|
49
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
67
50
|
import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
68
|
-
import {
|
|
69
|
-
type PXEService,
|
|
70
|
-
type PXEServiceConfig,
|
|
71
|
-
createPXEServiceWithSimulator,
|
|
72
|
-
getPXEServiceConfig,
|
|
73
|
-
} from '@aztec/pxe/server';
|
|
51
|
+
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
|
|
74
52
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
75
53
|
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
76
|
-
import { MemoryCircuitRecorder, SimulatorRecorderWrapper, WASMSimulator } from '@aztec/simulator/client';
|
|
77
|
-
import { FileCircuitRecorder } from '@aztec/simulator/testing';
|
|
78
54
|
import {
|
|
79
55
|
type ContractInstanceWithAddress,
|
|
80
56
|
getContractClassFromArtifact,
|
|
@@ -91,6 +67,7 @@ import {
|
|
|
91
67
|
initTelemetryClient,
|
|
92
68
|
} from '@aztec/telemetry-client';
|
|
93
69
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
70
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
94
71
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
95
72
|
|
|
96
73
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -110,8 +87,8 @@ import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
|
110
87
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
111
88
|
export { startAnvil };
|
|
112
89
|
|
|
113
|
-
const {
|
|
114
|
-
const getAztecUrl = () =>
|
|
90
|
+
const { AZTEC_NODE_URL = '' } = process.env;
|
|
91
|
+
const getAztecUrl = () => AZTEC_NODE_URL;
|
|
115
92
|
|
|
116
93
|
let telemetry: TelemetryClient | undefined = undefined;
|
|
117
94
|
function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
|
|
@@ -142,7 +119,7 @@ export const setupL1Contracts = async (
|
|
|
142
119
|
) => {
|
|
143
120
|
const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
|
|
144
121
|
vkTreeRoot: getVKTreeRoot(),
|
|
145
|
-
|
|
122
|
+
protocolContractsHash,
|
|
146
123
|
genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
147
124
|
salt: args.salt,
|
|
148
125
|
initialValidators: args.initialValidators,
|
|
@@ -155,23 +132,23 @@ export const setupL1Contracts = async (
|
|
|
155
132
|
};
|
|
156
133
|
|
|
157
134
|
/**
|
|
158
|
-
* Sets up Private eXecution Environment (PXE).
|
|
135
|
+
* Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
|
|
159
136
|
* @param aztecNode - An instance of Aztec Node.
|
|
160
|
-
* @param opts - Partial configuration for the PXE
|
|
137
|
+
* @param opts - Partial configuration for the PXE.
|
|
161
138
|
* @param logger - The logger to be used.
|
|
162
139
|
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
163
|
-
* @returns
|
|
140
|
+
* @returns A test wallet, logger and teardown function.
|
|
164
141
|
*/
|
|
165
|
-
export async function
|
|
142
|
+
export async function setupPXEAndGetWallet(
|
|
166
143
|
aztecNode: AztecNode,
|
|
167
|
-
opts: Partial<
|
|
144
|
+
opts: Partial<PXEConfig> = {},
|
|
168
145
|
logger = getLogger(),
|
|
169
146
|
useLogSuffix = false,
|
|
170
147
|
): Promise<{
|
|
171
148
|
/**
|
|
172
|
-
* The
|
|
149
|
+
* The wallet instance.
|
|
173
150
|
*/
|
|
174
|
-
|
|
151
|
+
wallet: TestWallet;
|
|
175
152
|
/**
|
|
176
153
|
* Logger instance named as the current test.
|
|
177
154
|
*/
|
|
@@ -181,29 +158,24 @@ export async function setupPXEService(
|
|
|
181
158
|
*/
|
|
182
159
|
teardown: () => Promise<void>;
|
|
183
160
|
}> {
|
|
184
|
-
const
|
|
161
|
+
const PXEConfig = { ...getPXEConfig(), ...opts };
|
|
185
162
|
// For tests we only want proving enabled if specifically requested
|
|
186
|
-
|
|
163
|
+
PXEConfig.proverEnabled = !!opts.proverEnabled;
|
|
187
164
|
|
|
188
165
|
// If no data directory provided, create a temp directory and clean up afterwards
|
|
189
|
-
const configuredDataDirectory =
|
|
166
|
+
const configuredDataDirectory = PXEConfig.dataDirectory;
|
|
190
167
|
if (!configuredDataDirectory) {
|
|
191
|
-
|
|
168
|
+
PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
192
169
|
}
|
|
193
170
|
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
: new MemoryCircuitRecorder();
|
|
198
|
-
const simulatorWithRecorder = new SimulatorRecorderWrapper(simulator, recorder);
|
|
199
|
-
const pxe = await createPXEServiceWithSimulator(aztecNode, simulatorWithRecorder, pxeServiceConfig, {
|
|
171
|
+
const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
|
|
172
|
+
|
|
173
|
+
const wallet = await TestWallet.create(aztecNode, PXEConfig, {
|
|
200
174
|
useLogSuffix,
|
|
201
175
|
});
|
|
202
176
|
|
|
203
|
-
const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(pxeServiceConfig.dataDirectory!);
|
|
204
|
-
|
|
205
177
|
return {
|
|
206
|
-
|
|
178
|
+
wallet,
|
|
207
179
|
logger,
|
|
208
180
|
teardown,
|
|
209
181
|
};
|
|
@@ -228,12 +200,10 @@ async function setupWithRemoteEnvironment(
|
|
|
228
200
|
const aztecNodeUrl = getAztecUrl();
|
|
229
201
|
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
230
202
|
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
|
|
236
|
-
const { l1ContractAddresses, rollupVersion } = await pxeClient.getNodeInfo();
|
|
203
|
+
await waitForNode(aztecNode, logger);
|
|
204
|
+
logger.verbose('JSON RPC client connected to Aztec Node');
|
|
205
|
+
logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
|
|
206
|
+
const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
237
207
|
|
|
238
208
|
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
239
209
|
|
|
@@ -242,31 +212,36 @@ async function setupWithRemoteEnvironment(
|
|
|
242
212
|
l1Client,
|
|
243
213
|
rollupVersion,
|
|
244
214
|
};
|
|
245
|
-
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls);
|
|
246
|
-
const
|
|
215
|
+
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
|
|
216
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
217
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
|
|
247
218
|
const teardown = () => Promise.resolve();
|
|
248
219
|
|
|
249
|
-
logger.verbose('
|
|
250
|
-
const initialFundedAccounts = await
|
|
251
|
-
const wallets = await getDeployedTestAccountsWallets(pxeClient);
|
|
220
|
+
logger.verbose('Populating wallet from already registered accounts...');
|
|
221
|
+
const initialFundedAccounts = await getInitialTestAccountsData();
|
|
252
222
|
|
|
253
|
-
if (
|
|
254
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${
|
|
223
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
224
|
+
throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
|
|
255
225
|
// Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
|
|
256
226
|
}
|
|
257
227
|
|
|
228
|
+
const testAccounts = await Promise.all(
|
|
229
|
+
initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
|
|
230
|
+
const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
|
|
231
|
+
return accountManager.address;
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
|
|
258
235
|
return {
|
|
259
236
|
aztecNode,
|
|
260
237
|
aztecNodeAdmin: undefined,
|
|
261
238
|
sequencer: undefined,
|
|
262
239
|
proverNode: undefined,
|
|
263
|
-
pxe: pxeClient,
|
|
264
240
|
deployL1ContractsValues,
|
|
265
241
|
config,
|
|
266
242
|
initialFundedAccounts,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
accounts: wallets.slice(0, numberOfAccounts).map(w => w.getAddress()),
|
|
243
|
+
wallet,
|
|
244
|
+
accounts: testAccounts,
|
|
270
245
|
logger,
|
|
271
246
|
cheatCodes,
|
|
272
247
|
ethCheatCodes,
|
|
@@ -338,19 +313,15 @@ export type EndToEndContext = {
|
|
|
338
313
|
proverNode: ProverNode | undefined;
|
|
339
314
|
/** A client to the sequencer service (undefined if connected to remote environment) */
|
|
340
315
|
sequencer: SequencerClient | undefined;
|
|
341
|
-
/** The Private eXecution Environment (PXE). */
|
|
342
|
-
pxe: PXE;
|
|
343
316
|
/** Return values from deployL1Contracts function. */
|
|
344
317
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
345
318
|
/** The Aztec Node configuration. */
|
|
346
319
|
config: AztecNodeConfig;
|
|
347
320
|
/** The data for the initial funded accounts. */
|
|
348
321
|
initialFundedAccounts: InitialAccountData[];
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
/** The
|
|
352
|
-
wallet: AccountWalletWithSecretKey;
|
|
353
|
-
/** The accounts to be used. */
|
|
322
|
+
/** The wallet to be used. */
|
|
323
|
+
wallet: TestWallet;
|
|
324
|
+
/** The wallets to be used. */
|
|
354
325
|
accounts: AztecAddress[];
|
|
355
326
|
/** Logger instance named as the current test. */
|
|
356
327
|
logger: Logger;
|
|
@@ -383,7 +354,7 @@ export type EndToEndContext = {
|
|
|
383
354
|
export async function setup(
|
|
384
355
|
numberOfAccounts = 1,
|
|
385
356
|
opts: SetupOptions = {},
|
|
386
|
-
pxeOpts: Partial<
|
|
357
|
+
pxeOpts: Partial<PXEConfig> = {},
|
|
387
358
|
chain: Chain = foundry,
|
|
388
359
|
): Promise<EndToEndContext> {
|
|
389
360
|
let anvil: Anvil | undefined;
|
|
@@ -414,9 +385,9 @@ export async function setup(
|
|
|
414
385
|
if (!isAnvilTestChain(chain.id)) {
|
|
415
386
|
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
416
387
|
}
|
|
417
|
-
if (
|
|
388
|
+
if (AZTEC_NODE_URL) {
|
|
418
389
|
throw new Error(
|
|
419
|
-
`
|
|
390
|
+
`AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
|
|
420
391
|
);
|
|
421
392
|
}
|
|
422
393
|
|
|
@@ -436,7 +407,8 @@ export async function setup(
|
|
|
436
407
|
setupMetricsLogger(filename);
|
|
437
408
|
}
|
|
438
409
|
|
|
439
|
-
const
|
|
410
|
+
const dateProvider = new TestDateProvider();
|
|
411
|
+
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
|
|
440
412
|
|
|
441
413
|
if (opts.stateLoad) {
|
|
442
414
|
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
@@ -468,7 +440,7 @@ export async function setup(
|
|
|
468
440
|
|
|
469
441
|
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
470
442
|
|
|
471
|
-
if (
|
|
443
|
+
if (AZTEC_NODE_URL) {
|
|
472
444
|
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
473
445
|
return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
|
|
474
446
|
}
|
|
@@ -537,6 +509,7 @@ export async function setup(
|
|
|
537
509
|
if (enableAutomine) {
|
|
538
510
|
await ethCheatCodes.setAutomine(false);
|
|
539
511
|
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
512
|
+
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
540
513
|
}
|
|
541
514
|
|
|
542
515
|
if (opts.l2StartTime) {
|
|
@@ -545,11 +518,8 @@ export async function setup(
|
|
|
545
518
|
await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
|
|
546
519
|
}
|
|
547
520
|
|
|
548
|
-
const dateProvider = new TestDateProvider();
|
|
549
|
-
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
550
|
-
|
|
551
521
|
const watcher = new AnvilTestWatcher(
|
|
552
|
-
new EthCheatCodesWithState(config.l1RpcUrls),
|
|
522
|
+
new EthCheatCodesWithState(config.l1RpcUrls, dateProvider),
|
|
553
523
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
554
524
|
deployL1ContractsValues.l1Client,
|
|
555
525
|
dateProvider,
|
|
@@ -569,7 +539,7 @@ export async function setup(
|
|
|
569
539
|
l1Contracts: config.l1Contracts,
|
|
570
540
|
port: blobSinkPort,
|
|
571
541
|
dataDirectory: config.dataDirectory,
|
|
572
|
-
|
|
542
|
+
dataStoreMapSizeKb: config.dataStoreMapSizeKb,
|
|
573
543
|
},
|
|
574
544
|
telemetry,
|
|
575
545
|
);
|
|
@@ -657,40 +627,38 @@ export async function setup(
|
|
|
657
627
|
}
|
|
658
628
|
|
|
659
629
|
logger.verbose('Creating a pxe...');
|
|
660
|
-
const {
|
|
630
|
+
const { wallet, teardown: pxeTeardown } = await setupPXEAndGetWallet(aztecNode!, pxeOpts, logger);
|
|
661
631
|
|
|
662
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls,
|
|
632
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, dateProvider);
|
|
663
633
|
|
|
664
634
|
if (
|
|
665
635
|
(opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
|
|
666
636
|
(opts.initialValidators && opts.initialValidators.length > 0)
|
|
667
637
|
) {
|
|
668
638
|
// We need to advance such that the committee is set up.
|
|
669
|
-
await cheatCodes.rollup.advanceToEpoch((await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochs + 1)
|
|
670
|
-
updateDateProvider: dateProvider,
|
|
671
|
-
});
|
|
639
|
+
await cheatCodes.rollup.advanceToEpoch((await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochs + 1));
|
|
672
640
|
await cheatCodes.rollup.setupEpoch();
|
|
673
641
|
await cheatCodes.rollup.debugRollup();
|
|
674
642
|
}
|
|
675
|
-
|
|
643
|
+
let accounts: AztecAddress[] = [];
|
|
676
644
|
// Below we continue with what we described in the long comment on line 571.
|
|
677
|
-
let accountManagers: AccountManager[] = [];
|
|
678
645
|
if (numberOfAccounts === 0) {
|
|
679
646
|
logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
|
|
680
|
-
while ((await
|
|
647
|
+
while ((await aztecNode.getBlockNumber()) === 0) {
|
|
681
648
|
await sleep(2000);
|
|
682
649
|
}
|
|
683
650
|
} else {
|
|
684
651
|
logger.info(
|
|
685
652
|
`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`,
|
|
686
653
|
);
|
|
687
|
-
|
|
654
|
+
const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
655
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, aztecNode, accountsData);
|
|
656
|
+
accounts = accountManagers.map(accountManager => accountManager.address);
|
|
688
657
|
}
|
|
689
658
|
|
|
690
659
|
// Now we restore the original minTxsPerBlock setting.
|
|
691
660
|
sequencerClient!.getSequencer().updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
692
661
|
|
|
693
|
-
const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
|
|
694
662
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
695
663
|
// TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
|
|
696
664
|
throw new Error(
|
|
@@ -737,13 +705,11 @@ export async function setup(
|
|
|
737
705
|
mockGossipSubNetwork,
|
|
738
706
|
prefilledPublicData,
|
|
739
707
|
proverNode,
|
|
740
|
-
pxe,
|
|
741
708
|
sequencer: sequencerClient,
|
|
742
709
|
teardown,
|
|
743
710
|
telemetryClient: telemetry,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
accounts: wallets.map(w => w.getAddress()),
|
|
711
|
+
wallet,
|
|
712
|
+
accounts,
|
|
747
713
|
watcher,
|
|
748
714
|
};
|
|
749
715
|
} catch (err) {
|
|
@@ -760,16 +726,14 @@ export async function setup(
|
|
|
760
726
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
761
727
|
*/
|
|
762
728
|
|
|
763
|
-
|
|
764
|
-
export async function ensureAccountContractsPublished(sender: Wallet, accountsToDeploy: Wallet[]) {
|
|
729
|
+
export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
|
|
765
730
|
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
766
731
|
// the sandbox and the test accounts exist
|
|
767
732
|
const accountsAndAddresses = await Promise.all(
|
|
768
|
-
accountsToDeploy.map(async
|
|
769
|
-
const address = account.getAddress();
|
|
733
|
+
accountsToDeploy.map(async address => {
|
|
770
734
|
return {
|
|
771
735
|
address,
|
|
772
|
-
deployed: (await
|
|
736
|
+
deployed: (await wallet.getContractMetadata(address)).isContractPublished,
|
|
773
737
|
};
|
|
774
738
|
}),
|
|
775
739
|
);
|
|
@@ -777,33 +741,18 @@ export async function ensureAccountContractsPublished(sender: Wallet, accountsTo
|
|
|
777
741
|
await Promise.all(
|
|
778
742
|
accountsAndAddresses
|
|
779
743
|
.filter(({ deployed }) => !deployed)
|
|
780
|
-
.map(({ address }) =>
|
|
744
|
+
.map(({ address }) => wallet.getContractMetadata(address)),
|
|
781
745
|
)
|
|
782
746
|
).map(contractMetadata => contractMetadata.contractInstance);
|
|
783
747
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
784
|
-
if (!(await
|
|
785
|
-
await (await publishContractClass(
|
|
786
|
-
.send({ from: accountsToDeploy[0]
|
|
748
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
749
|
+
await (await publishContractClass(wallet, SchnorrAccountContractArtifact))
|
|
750
|
+
.send({ from: accountsToDeploy[0] })
|
|
787
751
|
.wait();
|
|
788
752
|
}
|
|
789
|
-
const requests = await Promise.all(instances.map(async instance => await publishInstance(
|
|
790
|
-
const batch = new BatchCall(
|
|
791
|
-
await batch.send({ from: accountsToDeploy[0]
|
|
792
|
-
}
|
|
793
|
-
// docs:end:public_deploy_accounts
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* Sets the timestamp of the next block.
|
|
797
|
-
* @param rpcUrl - rpc url of the blockchain instance to connect to
|
|
798
|
-
* @param timestamp - the timestamp for the next block
|
|
799
|
-
*/
|
|
800
|
-
export async function setNextBlockTimestamp(rpcUrl: string, timestamp: number) {
|
|
801
|
-
const params = `[${timestamp}]`;
|
|
802
|
-
await fetch(rpcUrl, {
|
|
803
|
-
body: `{"jsonrpc":"2.0", "method": "evm_setNextBlockTimestamp", "params": ${params}, "id": 1}`,
|
|
804
|
-
method: 'POST',
|
|
805
|
-
headers: { 'Content-Type': 'application/json' },
|
|
806
|
-
});
|
|
753
|
+
const requests = await Promise.all(instances.map(async instance => await publishInstance(wallet, instance!)));
|
|
754
|
+
const batch = new BatchCall(wallet, requests);
|
|
755
|
+
await batch.send({ from: accountsToDeploy[0] }).wait();
|
|
807
756
|
}
|
|
808
757
|
|
|
809
758
|
/** Returns the job name for the current test. */
|
|
@@ -869,7 +818,7 @@ export async function expectMappingDelta<K, V extends number | bigint>(
|
|
|
869
818
|
}
|
|
870
819
|
|
|
871
820
|
/**
|
|
872
|
-
* Computes the address of the "canonical"
|
|
821
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
873
822
|
* but by conventions its address is computed with a salt of 0.
|
|
874
823
|
* @returns The address of the sponsored FPC contract
|
|
875
824
|
*/
|
|
@@ -882,7 +831,7 @@ export function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress>
|
|
|
882
831
|
}
|
|
883
832
|
|
|
884
833
|
/**
|
|
885
|
-
* Computes the address of the "canonical"
|
|
834
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
886
835
|
* but by conventions its address is computed with a salt of 0.
|
|
887
836
|
* @returns The address of the sponsored FPC contract
|
|
888
837
|
*/
|
|
@@ -894,22 +843,22 @@ export async function getSponsoredFPCAddress() {
|
|
|
894
843
|
/**
|
|
895
844
|
* Deploy a sponsored FPC contract to a running instance.
|
|
896
845
|
*/
|
|
897
|
-
export async function setupSponsoredFPC(
|
|
846
|
+
export async function setupSponsoredFPC(wallet: Wallet) {
|
|
898
847
|
const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
899
848
|
salt: new Fr(SPONSORED_FPC_SALT),
|
|
900
849
|
});
|
|
901
850
|
|
|
902
|
-
await
|
|
851
|
+
await wallet.registerContract({ instance, artifact: SponsoredFPCContract.artifact });
|
|
903
852
|
getLogger().info(`SponsoredFPC: ${instance.address}`);
|
|
904
853
|
return instance;
|
|
905
854
|
}
|
|
906
855
|
|
|
907
856
|
/**
|
|
908
857
|
* Registers the SponsoredFPC in this PXE instance
|
|
909
|
-
* @param
|
|
858
|
+
* @param wallet - The wallet
|
|
910
859
|
*/
|
|
911
|
-
export async function registerSponsoredFPC(
|
|
912
|
-
await
|
|
860
|
+
export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
|
|
861
|
+
await wallet.registerContract({ instance: await getSponsoredFPCInstance(), artifact: SponsoredFPCContract.artifact });
|
|
913
862
|
}
|
|
914
863
|
|
|
915
864
|
export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { sleep } from '@aztec/aztec.js';
|
|
2
1
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
|
+
import { RemoteSigner } from '@aztec/node-keystore';
|
|
3
5
|
|
|
4
6
|
import { mkdirSync } from 'node:fs';
|
|
5
7
|
import { writeFile } from 'node:fs/promises';
|
|
@@ -21,11 +23,26 @@ privateKey: ${pk}`,
|
|
|
21
23
|
await writeFile(path, yaml, { flag: 'wx' });
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
export async function refreshWeb3Signer(url: string) {
|
|
26
|
+
export async function refreshWeb3Signer(url: string, ...expectedAddresses: string[]) {
|
|
25
27
|
await fetch(new URL('reload', url), { method: 'POST' });
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
if (expectedAddresses.length > 0) {
|
|
30
|
+
await retryUntil(
|
|
31
|
+
async () => {
|
|
32
|
+
try {
|
|
33
|
+
await RemoteSigner.validateAccess(url, expectedAddresses);
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
'web3signer refresh',
|
|
40
|
+
10,
|
|
41
|
+
0.5,
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
await sleep(1000);
|
|
45
|
+
}
|
|
29
46
|
}
|
|
30
47
|
|
|
31
48
|
export function getWeb3SignerTestKeystoreDir(): string {
|
|
@@ -19,36 +19,28 @@ aztec-wallet() {
|
|
|
19
19
|
aztec-wallet import-test-accounts
|
|
20
20
|
|
|
21
21
|
# docs:start:declare-accounts
|
|
22
|
-
aztec-wallet create-account -a alice
|
|
23
|
-
aztec-wallet create-account -a bob
|
|
22
|
+
aztec-wallet create-account -a alice -f test0
|
|
23
|
+
aztec-wallet create-account -a bob -f test0
|
|
24
24
|
# docs:end:declare-accounts
|
|
25
25
|
|
|
26
|
-
# docs:start:deploy
|
|
27
26
|
DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
|
|
28
27
|
TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
|
|
29
28
|
echo "Deployed contract at $TOKEN_ADDRESS"
|
|
30
|
-
# docs:end:deploy
|
|
31
29
|
|
|
32
|
-
# docs:start:mint-private
|
|
33
30
|
MINT_AMOUNT=69
|
|
34
31
|
aztec-wallet send mint_to_private -ca last --args accounts:alice $MINT_AMOUNT -f test0
|
|
35
|
-
# docs:end:mint-private
|
|
36
32
|
|
|
37
|
-
# docs:start:get-balance
|
|
38
33
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|
|
39
34
|
if ! echo $ALICE_BALANCE | grep -q $MINT_AMOUNT; then
|
|
40
35
|
echo "Incorrect Alice balance after transaction (expected $MINT_AMOUNT but got $ALICE_BALANCE)"
|
|
41
36
|
exit 1
|
|
42
37
|
fi
|
|
43
|
-
# docs:end:get-balance
|
|
44
38
|
|
|
45
|
-
# docs:start:transfer
|
|
46
39
|
TRANSFER_AMOUNT=42
|
|
47
40
|
|
|
48
41
|
aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
|
|
49
42
|
|
|
50
43
|
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
|
|
51
|
-
# docs:end:transfer
|
|
52
44
|
|
|
53
45
|
# Test end result
|
|
54
46
|
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
|