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