@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/dest/fixtures/utils.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
2
|
+
import { generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
3
|
import { createArchiver } from '@aztec/archiver';
|
|
4
4
|
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
-
import { BatchCall
|
|
5
|
+
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
6
6
|
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
7
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
8
|
+
import { createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
|
|
7
9
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
8
10
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
9
11
|
import { createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
@@ -17,19 +19,19 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
17
19
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
18
20
|
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
19
21
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
20
|
-
import {
|
|
22
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
23
|
+
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
21
24
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
22
25
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
23
26
|
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
24
|
-
import {
|
|
27
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
25
28
|
import { createProverNode } from '@aztec/prover-node';
|
|
26
|
-
import {
|
|
27
|
-
import { MemoryCircuitRecorder, SimulatorRecorderWrapper, WASMSimulator } from '@aztec/simulator/client';
|
|
28
|
-
import { FileCircuitRecorder } from '@aztec/simulator/testing';
|
|
29
|
+
import { getPXEConfig } from '@aztec/pxe/server';
|
|
29
30
|
import { getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
30
31
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
31
32
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
32
33
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
34
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
33
35
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
34
36
|
import fs from 'fs/promises';
|
|
35
37
|
import getPort from 'get-port';
|
|
@@ -44,8 +46,8 @@ import { getBBConfig } from './get_bb_config.js';
|
|
|
44
46
|
import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
45
47
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
46
48
|
export { startAnvil };
|
|
47
|
-
const {
|
|
48
|
-
const getAztecUrl = ()=>
|
|
49
|
+
const { AZTEC_NODE_URL = '' } = process.env;
|
|
50
|
+
const getAztecUrl = ()=>AZTEC_NODE_URL;
|
|
49
51
|
let telemetry = undefined;
|
|
50
52
|
function getTelemetryClient(partialConfig = {}) {
|
|
51
53
|
if (!telemetry) {
|
|
@@ -72,7 +74,7 @@ export const getPrivateKeyFromIndex = (index)=>{
|
|
|
72
74
|
export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, chain = foundry)=>{
|
|
73
75
|
const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
|
|
74
76
|
vkTreeRoot: getVKTreeRoot(),
|
|
75
|
-
|
|
77
|
+
protocolContractsHash,
|
|
76
78
|
genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
77
79
|
salt: args.salt,
|
|
78
80
|
initialValidators: args.initialValidators,
|
|
@@ -83,33 +85,30 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
83
85
|
return l1Data;
|
|
84
86
|
};
|
|
85
87
|
/**
|
|
86
|
-
* Sets up Private eXecution Environment (PXE).
|
|
88
|
+
* Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
|
|
87
89
|
* @param aztecNode - An instance of Aztec Node.
|
|
88
|
-
* @param opts - Partial configuration for the PXE
|
|
90
|
+
* @param opts - Partial configuration for the PXE.
|
|
89
91
|
* @param logger - The logger to be used.
|
|
90
92
|
* @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
|
|
91
|
-
* @returns
|
|
92
|
-
*/ export async function
|
|
93
|
-
const
|
|
94
|
-
...
|
|
93
|
+
* @returns A test wallet, logger and teardown function.
|
|
94
|
+
*/ export async function setupPXEAndGetWallet(aztecNode, opts = {}, logger = getLogger(), useLogSuffix = false) {
|
|
95
|
+
const PXEConfig = {
|
|
96
|
+
...getPXEConfig(),
|
|
95
97
|
...opts
|
|
96
98
|
};
|
|
97
99
|
// For tests we only want proving enabled if specifically requested
|
|
98
|
-
|
|
100
|
+
PXEConfig.proverEnabled = !!opts.proverEnabled;
|
|
99
101
|
// If no data directory provided, create a temp directory and clean up afterwards
|
|
100
|
-
const configuredDataDirectory =
|
|
102
|
+
const configuredDataDirectory = PXEConfig.dataDirectory;
|
|
101
103
|
if (!configuredDataDirectory) {
|
|
102
|
-
|
|
104
|
+
PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
103
105
|
}
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const simulatorWithRecorder = new SimulatorRecorderWrapper(simulator, recorder);
|
|
107
|
-
const pxe = await createPXEServiceWithSimulator(aztecNode, simulatorWithRecorder, pxeServiceConfig, {
|
|
106
|
+
const teardown = configuredDataDirectory ? ()=>Promise.resolve() : ()=>tryRmDir(PXEConfig.dataDirectory);
|
|
107
|
+
const wallet = await TestWallet.create(aztecNode, PXEConfig, {
|
|
108
108
|
useLogSuffix
|
|
109
109
|
});
|
|
110
|
-
const teardown = configuredDataDirectory ? ()=>Promise.resolve() : ()=>tryRmDir(pxeServiceConfig.dataDirectory);
|
|
111
110
|
return {
|
|
112
|
-
|
|
111
|
+
wallet,
|
|
113
112
|
logger,
|
|
114
113
|
teardown
|
|
115
114
|
};
|
|
@@ -127,44 +126,40 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
127
126
|
const aztecNodeUrl = getAztecUrl();
|
|
128
127
|
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
129
128
|
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
3
|
|
135
|
-
], true));
|
|
136
|
-
await waitForPXE(pxeClient, logger);
|
|
137
|
-
logger.verbose('JSON RPC client connected to PXE');
|
|
138
|
-
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
|
|
139
|
-
const { l1ContractAddresses, rollupVersion } = await pxeClient.getNodeInfo();
|
|
129
|
+
await waitForNode(aztecNode, logger);
|
|
130
|
+
logger.verbose('JSON RPC client connected to Aztec Node');
|
|
131
|
+
logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
|
|
132
|
+
const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
140
133
|
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
141
134
|
const deployL1ContractsValues = {
|
|
142
135
|
l1ContractAddresses,
|
|
143
136
|
l1Client,
|
|
144
137
|
rollupVersion
|
|
145
138
|
};
|
|
146
|
-
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls);
|
|
147
|
-
const
|
|
139
|
+
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
|
|
140
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
141
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
|
|
148
142
|
const teardown = ()=>Promise.resolve();
|
|
149
|
-
logger.verbose('
|
|
150
|
-
const initialFundedAccounts = await
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
|
|
143
|
+
logger.verbose('Populating wallet from already registered accounts...');
|
|
144
|
+
const initialFundedAccounts = await getInitialTestAccountsData();
|
|
145
|
+
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
146
|
+
throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
|
|
154
147
|
// Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
|
|
155
148
|
}
|
|
149
|
+
const testAccounts = await Promise.all(initialFundedAccounts.slice(0, numberOfAccounts).map(async (account)=>{
|
|
150
|
+
const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
|
|
151
|
+
return accountManager.address;
|
|
152
|
+
}));
|
|
156
153
|
return {
|
|
157
154
|
aztecNode,
|
|
158
155
|
aztecNodeAdmin: undefined,
|
|
159
156
|
sequencer: undefined,
|
|
160
157
|
proverNode: undefined,
|
|
161
|
-
pxe: pxeClient,
|
|
162
158
|
deployL1ContractsValues,
|
|
163
159
|
config,
|
|
164
160
|
initialFundedAccounts,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
accounts: wallets.slice(0, numberOfAccounts).map((w)=>w.getAddress()),
|
|
161
|
+
wallet,
|
|
162
|
+
accounts: testAccounts,
|
|
168
163
|
logger,
|
|
169
164
|
cheatCodes,
|
|
170
165
|
ethCheatCodes,
|
|
@@ -211,8 +206,8 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
211
206
|
if (!isAnvilTestChain(chain.id)) {
|
|
212
207
|
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
213
208
|
}
|
|
214
|
-
if (
|
|
215
|
-
throw new Error(`
|
|
209
|
+
if (AZTEC_NODE_URL) {
|
|
210
|
+
throw new Error(`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`);
|
|
216
211
|
}
|
|
217
212
|
const res = await startAnvil({
|
|
218
213
|
l1BlockTime: opts.ethereumSlotDuration,
|
|
@@ -230,7 +225,8 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
230
225
|
logger.info(`Logging metrics to ${filename}`);
|
|
231
226
|
setupMetricsLogger(filename);
|
|
232
227
|
}
|
|
233
|
-
const
|
|
228
|
+
const dateProvider = new TestDateProvider();
|
|
229
|
+
const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
|
|
234
230
|
if (opts.stateLoad) {
|
|
235
231
|
await ethCheatCodes.loadChainState(opts.stateLoad);
|
|
236
232
|
}
|
|
@@ -258,7 +254,7 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
258
254
|
];
|
|
259
255
|
}
|
|
260
256
|
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
261
|
-
if (
|
|
257
|
+
if (AZTEC_NODE_URL) {
|
|
262
258
|
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
263
259
|
return await setupWithRemoteEnvironment(publisherHdAccount, config, logger, numberOfAccounts);
|
|
264
260
|
}
|
|
@@ -301,6 +297,7 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
301
297
|
if (enableAutomine) {
|
|
302
298
|
await ethCheatCodes.setAutomine(false);
|
|
303
299
|
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
300
|
+
dateProvider.setTime(await ethCheatCodes.timestamp() * 1000);
|
|
304
301
|
}
|
|
305
302
|
if (opts.l2StartTime) {
|
|
306
303
|
// This should only be used in synching test or when you need to have a stable
|
|
@@ -309,9 +306,7 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
309
306
|
resetBlockInterval: true
|
|
310
307
|
});
|
|
311
308
|
}
|
|
312
|
-
const
|
|
313
|
-
dateProvider.setTime(await ethCheatCodes.timestamp() * 1000);
|
|
314
|
-
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
|
|
309
|
+
const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
|
|
315
310
|
if (!opts.disableAnvilTestWatcher) {
|
|
316
311
|
await watcher.start();
|
|
317
312
|
}
|
|
@@ -324,7 +319,7 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
324
319
|
l1Contracts: config.l1Contracts,
|
|
325
320
|
port: blobSinkPort,
|
|
326
321
|
dataDirectory: config.dataDirectory,
|
|
327
|
-
|
|
322
|
+
dataStoreMapSizeKb: config.dataStoreMapSizeKb
|
|
328
323
|
}, telemetry);
|
|
329
324
|
await blobSink.start();
|
|
330
325
|
config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
|
|
@@ -404,32 +399,31 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
404
399
|
proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, config, proverNodeConfig, aztecNode, prefilledPublicData);
|
|
405
400
|
}
|
|
406
401
|
logger.verbose('Creating a pxe...');
|
|
407
|
-
const {
|
|
408
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls,
|
|
402
|
+
const { wallet, teardown: pxeTeardown } = await setupPXEAndGetWallet(aztecNode, pxeOpts, logger);
|
|
403
|
+
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, dateProvider);
|
|
409
404
|
if (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0 || opts.initialValidators && opts.initialValidators.length > 0) {
|
|
410
405
|
// We need to advance such that the committee is set up.
|
|
411
|
-
await cheatCodes.rollup.advanceToEpoch(await cheatCodes.rollup.getEpoch() + BigInt(config.lagInEpochs + 1)
|
|
412
|
-
updateDateProvider: dateProvider
|
|
413
|
-
});
|
|
406
|
+
await cheatCodes.rollup.advanceToEpoch(await cheatCodes.rollup.getEpoch() + BigInt(config.lagInEpochs + 1));
|
|
414
407
|
await cheatCodes.rollup.setupEpoch();
|
|
415
408
|
await cheatCodes.rollup.debugRollup();
|
|
416
409
|
}
|
|
410
|
+
let accounts = [];
|
|
417
411
|
// Below we continue with what we described in the long comment on line 571.
|
|
418
|
-
let accountManagers = [];
|
|
419
412
|
if (numberOfAccounts === 0) {
|
|
420
413
|
logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
|
|
421
|
-
while(await
|
|
414
|
+
while(await aztecNode.getBlockNumber() === 0){
|
|
422
415
|
await sleep(2000);
|
|
423
416
|
}
|
|
424
417
|
} else {
|
|
425
418
|
logger.info(`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`);
|
|
426
|
-
|
|
419
|
+
const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
420
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, aztecNode, accountsData);
|
|
421
|
+
accounts = accountManagers.map((accountManager)=>accountManager.address);
|
|
427
422
|
}
|
|
428
423
|
// Now we restore the original minTxsPerBlock setting.
|
|
429
424
|
sequencerClient.getSequencer().updateConfig({
|
|
430
425
|
minTxsPerBlock: originalMinTxsPerBlock
|
|
431
426
|
});
|
|
432
|
-
const wallets = await Promise.all(accountManagers.map((account)=>account.getWallet()));
|
|
433
427
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
434
428
|
// TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
|
|
435
429
|
throw new Error(`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`);
|
|
@@ -467,13 +461,11 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
467
461
|
mockGossipSubNetwork,
|
|
468
462
|
prefilledPublicData,
|
|
469
463
|
proverNode,
|
|
470
|
-
pxe,
|
|
471
464
|
sequencer: sequencerClient,
|
|
472
465
|
teardown,
|
|
473
466
|
telemetryClient: telemetry,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
accounts: wallets.map((w)=>w.getAddress()),
|
|
467
|
+
wallet,
|
|
468
|
+
accounts,
|
|
477
469
|
watcher
|
|
478
470
|
};
|
|
479
471
|
} catch (err) {
|
|
@@ -487,45 +479,28 @@ export const setupL1Contracts = async (l1RpcUrls, account, logger, args = {}, ch
|
|
|
487
479
|
* Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
|
|
488
480
|
* @param sender - Wallet to send the deployment tx.
|
|
489
481
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
490
|
-
*/
|
|
491
|
-
export async function ensureAccountContractsPublished(sender, accountsToDeploy) {
|
|
482
|
+
*/ export async function ensureAccountContractsPublished(wallet, accountsToDeploy) {
|
|
492
483
|
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
493
484
|
// the sandbox and the test accounts exist
|
|
494
|
-
const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (
|
|
495
|
-
const address = account.getAddress();
|
|
485
|
+
const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (address)=>{
|
|
496
486
|
return {
|
|
497
487
|
address,
|
|
498
|
-
deployed: (await
|
|
488
|
+
deployed: (await wallet.getContractMetadata(address)).isContractPublished
|
|
499
489
|
};
|
|
500
490
|
}));
|
|
501
|
-
const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>
|
|
491
|
+
const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>wallet.getContractMetadata(address)))).map((contractMetadata)=>contractMetadata.contractInstance);
|
|
502
492
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
503
|
-
if (!(await
|
|
504
|
-
await (await publishContractClass(
|
|
505
|
-
from: accountsToDeploy[0]
|
|
493
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
|
|
494
|
+
await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({
|
|
495
|
+
from: accountsToDeploy[0]
|
|
506
496
|
}).wait();
|
|
507
497
|
}
|
|
508
|
-
const requests = await Promise.all(instances.map(async (instance)=>await publishInstance(
|
|
509
|
-
const batch = new BatchCall(
|
|
498
|
+
const requests = await Promise.all(instances.map(async (instance)=>await publishInstance(wallet, instance)));
|
|
499
|
+
const batch = new BatchCall(wallet, requests);
|
|
510
500
|
await batch.send({
|
|
511
|
-
from: accountsToDeploy[0]
|
|
501
|
+
from: accountsToDeploy[0]
|
|
512
502
|
}).wait();
|
|
513
503
|
}
|
|
514
|
-
// docs:end:public_deploy_accounts
|
|
515
|
-
/**
|
|
516
|
-
* Sets the timestamp of the next block.
|
|
517
|
-
* @param rpcUrl - rpc url of the blockchain instance to connect to
|
|
518
|
-
* @param timestamp - the timestamp for the next block
|
|
519
|
-
*/ export async function setNextBlockTimestamp(rpcUrl, timestamp) {
|
|
520
|
-
const params = `[${timestamp}]`;
|
|
521
|
-
await fetch(rpcUrl, {
|
|
522
|
-
body: `{"jsonrpc":"2.0", "method": "evm_setNextBlockTimestamp", "params": ${params}, "id": 1}`,
|
|
523
|
-
method: 'POST',
|
|
524
|
-
headers: {
|
|
525
|
-
'Content-Type': 'application/json'
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
504
|
/** Returns the job name for the current test. */ function getJobName() {
|
|
530
505
|
return process.env.JOB_NAME ?? expect.getState().currentTestName?.split(' ')[0].replaceAll('/', '_') ?? 'unknown';
|
|
531
506
|
}
|
|
@@ -564,7 +539,7 @@ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiff
|
|
|
564
539
|
expect(diffs).toEqual(expectedDiffs);
|
|
565
540
|
}
|
|
566
541
|
/**
|
|
567
|
-
* Computes the address of the "canonical"
|
|
542
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
568
543
|
* but by conventions its address is computed with a salt of 0.
|
|
569
544
|
* @returns The address of the sponsored FPC contract
|
|
570
545
|
*/ export function getSponsoredFPCInstance() {
|
|
@@ -573,7 +548,7 @@ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiff
|
|
|
573
548
|
}));
|
|
574
549
|
}
|
|
575
550
|
/**
|
|
576
|
-
* Computes the address of the "canonical"
|
|
551
|
+
* Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
|
|
577
552
|
* but by conventions its address is computed with a salt of 0.
|
|
578
553
|
* @returns The address of the sponsored FPC contract
|
|
579
554
|
*/ export async function getSponsoredFPCAddress() {
|
|
@@ -582,11 +557,11 @@ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiff
|
|
|
582
557
|
}
|
|
583
558
|
/**
|
|
584
559
|
* Deploy a sponsored FPC contract to a running instance.
|
|
585
|
-
*/ export async function setupSponsoredFPC(
|
|
560
|
+
*/ export async function setupSponsoredFPC(wallet) {
|
|
586
561
|
const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
587
562
|
salt: new Fr(SPONSORED_FPC_SALT)
|
|
588
563
|
});
|
|
589
|
-
await
|
|
564
|
+
await wallet.registerContract({
|
|
590
565
|
instance,
|
|
591
566
|
artifact: SponsoredFPCContract.artifact
|
|
592
567
|
});
|
|
@@ -595,9 +570,9 @@ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiff
|
|
|
595
570
|
}
|
|
596
571
|
/**
|
|
597
572
|
* Registers the SponsoredFPC in this PXE instance
|
|
598
|
-
* @param
|
|
599
|
-
*/ export async function registerSponsoredFPC(
|
|
600
|
-
await
|
|
573
|
+
* @param wallet - The wallet
|
|
574
|
+
*/ export async function registerSponsoredFPC(wallet) {
|
|
575
|
+
await wallet.registerContract({
|
|
601
576
|
instance: await getSponsoredFPCInstance(),
|
|
602
577
|
artifact: SponsoredFPCContract.artifact
|
|
603
578
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]): Promise<void>;
|
|
2
|
-
export declare function refreshWeb3Signer(url: string): Promise<void>;
|
|
2
|
+
export declare function refreshWeb3Signer(url: string, ...expectedAddresses: string[]): Promise<void>;
|
|
3
3
|
export declare function getWeb3SignerTestKeystoreDir(): string;
|
|
4
4
|
export declare function getWeb3SignerUrl(): string;
|
|
5
5
|
//# sourceMappingURL=web3signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web3signer.d.ts","sourceRoot":"","sources":["../../src/fixtures/web3signer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web3signer.d.ts","sourceRoot":"","sources":["../../src/fixtures/web3signer.ts"],"names":[],"mappings":"AASA,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,iBAcnF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE,MAAM,EAAE,iBAoBlF;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAOrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC"}
|
|
@@ -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
|
import { mkdirSync } from 'node:fs';
|
|
4
6
|
import { writeFile } from 'node:fs/promises';
|
|
5
7
|
import { join } from 'node:path';
|
|
@@ -15,13 +17,22 @@ privateKey: ${pk}`).join('\n---\n');
|
|
|
15
17
|
flag: 'wx'
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
|
-
export async function refreshWeb3Signer(url) {
|
|
20
|
+
export async function refreshWeb3Signer(url, ...expectedAddresses) {
|
|
19
21
|
await fetch(new URL('reload', url), {
|
|
20
22
|
method: 'POST'
|
|
21
23
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (expectedAddresses.length > 0) {
|
|
25
|
+
await retryUntil(async ()=>{
|
|
26
|
+
try {
|
|
27
|
+
await RemoteSigner.validateAccess(url, expectedAddresses);
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}, 'web3signer refresh', 10, 0.5);
|
|
33
|
+
} else {
|
|
34
|
+
await sleep(1000);
|
|
35
|
+
}
|
|
25
36
|
}
|
|
26
37
|
export function getWeb3SignerTestKeystoreDir() {
|
|
27
38
|
if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert_checker.d.ts","sourceRoot":"","sources":["../../src/quality_of_service/alert_checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"alert_checker.d.ts","sourceRoot":"","sources":["../../src/quality_of_service/alert_checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAKlD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAQD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,kBAAkB,CAAM;IAKpE;;;OAGG;IACH,OAAO,CAAC,gBAAgB;YAMV,YAAY;YAqCZ,WAAW;IAqBzB;;;OAGG;IACU,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhE;;;OAGG;IACU,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIxE;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IACnC,IAAI,SAAyB;CACvC"}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
4
|
+
import { type L2AmountClaim, type L2AmountClaimWithRecipient } from '@aztec/aztec.js/ethereum';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
7
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
8
|
+
import type { SiblingPath } from '@aztec/aztec.js/trees';
|
|
9
|
+
import type { TxReceipt } from '@aztec/aztec.js/tx';
|
|
10
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
11
|
import { type ExtendedViemWalletClient, type L1ContractAddresses } from '@aztec/ethereum';
|
|
12
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
13
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
14
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
5
15
|
import { type Hex } from 'viem';
|
|
@@ -52,8 +62,6 @@ export type CrossChainContext = {
|
|
|
52
62
|
export declare class CrossChainTestHarness {
|
|
53
63
|
/** Aztec node instance. */
|
|
54
64
|
aztecNode: AztecNode;
|
|
55
|
-
/** Private eXecution Environment (PXE). */
|
|
56
|
-
pxeService: PXE;
|
|
57
65
|
/** Logger. */
|
|
58
66
|
logger: Logger;
|
|
59
67
|
/** L2 Token contract. */
|
|
@@ -70,18 +78,16 @@ export declare class CrossChainTestHarness {
|
|
|
70
78
|
l1Client: ExtendedViemWalletClient;
|
|
71
79
|
/** Deployment addresses for all L1 contracts */
|
|
72
80
|
readonly l1ContractAddresses: L1ContractAddresses;
|
|
73
|
-
/** Wallet
|
|
74
|
-
readonly
|
|
81
|
+
/** Wallet to simulate and send txs from. */
|
|
82
|
+
readonly wallet: Wallet;
|
|
75
83
|
/** Owner of the l2 token and bridge */
|
|
76
84
|
readonly ownerAddress: AztecAddress;
|
|
77
|
-
static new(aztecNode: AztecNode,
|
|
85
|
+
static new(aztecNode: AztecNode, l1Client: ExtendedViemWalletClient, wallet: Wallet, ownerAddress: AztecAddress, logger: Logger, underlyingERC20Address: EthAddress): Promise<CrossChainTestHarness>;
|
|
78
86
|
private readonly l1TokenManager;
|
|
79
87
|
private readonly l1TokenPortalManager;
|
|
80
88
|
constructor(
|
|
81
89
|
/** Aztec node instance. */
|
|
82
90
|
aztecNode: AztecNode,
|
|
83
|
-
/** Private eXecution Environment (PXE). */
|
|
84
|
-
pxeService: PXE,
|
|
85
91
|
/** Logger. */
|
|
86
92
|
logger: Logger,
|
|
87
93
|
/** L2 Token contract. */
|
|
@@ -98,8 +104,8 @@ export declare class CrossChainTestHarness {
|
|
|
98
104
|
l1Client: ExtendedViemWalletClient,
|
|
99
105
|
/** Deployment addresses for all L1 contracts */
|
|
100
106
|
l1ContractAddresses: L1ContractAddresses,
|
|
101
|
-
/** Wallet
|
|
102
|
-
|
|
107
|
+
/** Wallet to simulate and send txs from. */
|
|
108
|
+
wallet: Wallet,
|
|
103
109
|
/** Owner of the l2 token and bridge */
|
|
104
110
|
ownerAddress: AztecAddress);
|
|
105
111
|
mintTokensOnL1(amount: bigint): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross_chain_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/cross_chain_test_harness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cross_chain_test_harness.d.ts","sourceRoot":"","sources":["../../src/shared/cross_chain_test_harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,mBAAmB,EAAoB,MAAM,iBAAiB,CAAC;AAE5G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAI7C;;;;;;;;;GASG;AACH,wBAAsB,0CAA0C,CAC9D,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,wBAAwB,EAClC,qBAAqB,EAAE,UAAU,EACjC,KAAK,EAAE,YAAY,EACnB,sBAAsB,EAAE,UAAU,GACjC,OAAO,CAAC;IACT;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,mBAAmB,CAAC;IAC5B;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC;IAC/B;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;IACjB;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC,CA8CD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,qBAAa,qBAAqB;IA0C9B,2BAA2B;IACpB,SAAS,EAAE,SAAS;IAC3B,cAAc;IACP,MAAM,EAAE,MAAM;IAErB,yBAAyB;IAClB,OAAO,EAAE,aAAa;IAC7B,gCAAgC;IACzB,QAAQ,EAAE,mBAAmB;IAEpC,oCAAoC;IAC7B,UAAU,EAAE,UAAU;IAE7B,sBAAsB;IACf,kBAAkB,EAAE,UAAU;IACrC,yCAAyC;IAClC,sBAAsB,EAAE,UAAU;IACzC,qCAAqC;IAC9B,QAAQ,EAAE,wBAAwB;IAEzC,gDAAgD;aAChC,mBAAmB,EAAE,mBAAmB;IAExD,4CAA4C;aAC5B,MAAM,EAAE,MAAM;IAE9B,uCAAuC;aACvB,YAAY,EAAE,YAAY;WApE/B,GAAG,CACd,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,wBAAwB,EAClC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,sBAAsB,EAAE,UAAU,GACjC,OAAO,CAAC,qBAAqB,CAAC;IA8BjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;;IAG1D,2BAA2B;IACpB,SAAS,EAAE,SAAS;IAC3B,cAAc;IACP,MAAM,EAAE,MAAM;IAErB,yBAAyB;IAClB,OAAO,EAAE,aAAa;IAC7B,gCAAgC;IACzB,QAAQ,EAAE,mBAAmB;IAEpC,oCAAoC;IAC7B,UAAU,EAAE,UAAU;IAE7B,sBAAsB;IACf,kBAAkB,EAAE,UAAU;IACrC,yCAAyC;IAClC,sBAAsB,EAAE,UAAU;IACzC,qCAAqC;IAC9B,QAAQ,EAAE,wBAAwB;IAEzC,gDAAgD;IAChC,mBAAmB,EAAE,mBAAmB;IAExD,4CAA4C;IAC5B,MAAM,EAAE,MAAM;IAE9B,uCAAuC;IACvB,YAAY,EAAE,YAAY;IAatC,cAAc,CAAC,MAAM,EAAE,MAAM;IAYnC,cAAc,CAAC,OAAO,EAAE,UAAU;IAIlC,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,UAAQ;IAI3D,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,UAAQ;IAItD,oBAAoB,CAAC,MAAM,EAAE,MAAM;IAKnC,qBAAqB,CAAC,MAAM,EAAE,MAAM;IAIpC,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY;IAQ1E,qCAAqC,CACzC,KAAK,EAAE,IAAI,CAAC,0BAA0B,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,GAAG,WAAW,CAAC;IAUrG,oCAAoC,CACxC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAU1E,4BAA4B,CAChC,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,EAAE,YAAU,EAC1B,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IASzB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,GAAE,EAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAS7G,qBAAqB,CAAC,KAAK,EAAE,YAAY;IAIzC,wBAAwB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM;IAMrE,oBAAoB,CAAC,KAAK,EAAE,YAAY;IAIxC,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM;IAKpE,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,GAAE,UAA4B,GAAG,OAAO,CAAC,EAAE,CAAC;IASzG,2BAA2B,CACzB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;IAW5B,qBAAqB,CAAC,YAAY,EAAE,MAAM;IAQ1C,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,KAAU;IAQjE;;;;;;OAMG;IACG,qBAAqB,CAAC,OAAO,EAAE,EAAE,GAAG,GAAG;IAS7C,mBAAmB,IAAI,iBAAiB;CAYzC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { L1TokenPortalManager } from '@aztec/aztec.js/ethereum';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
4
|
import { deployL1Contract } from '@aztec/ethereum';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
6
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
5
7
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
8
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
7
9
|
import { getContract } from 'viem';
|
|
8
10
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
9
|
-
// docs:start:deployAndInitializeTokenAndBridgeContracts
|
|
10
11
|
/**
|
|
11
12
|
* Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
|
|
12
13
|
* @param wallet - the wallet instance
|
|
@@ -75,7 +76,6 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
75
76
|
* shared between cross chain tests.
|
|
76
77
|
*/ export class CrossChainTestHarness {
|
|
77
78
|
aztecNode;
|
|
78
|
-
pxeService;
|
|
79
79
|
logger;
|
|
80
80
|
l2Token;
|
|
81
81
|
l2Bridge;
|
|
@@ -84,22 +84,21 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
84
84
|
underlyingERC20Address;
|
|
85
85
|
l1Client;
|
|
86
86
|
l1ContractAddresses;
|
|
87
|
-
|
|
87
|
+
wallet;
|
|
88
88
|
ownerAddress;
|
|
89
|
-
static async new(aztecNode,
|
|
89
|
+
static async new(aztecNode, l1Client, wallet, ownerAddress, logger, underlyingERC20Address) {
|
|
90
90
|
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
91
|
-
const l1ContractAddresses = (await
|
|
91
|
+
const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
|
|
92
92
|
// Deploy and initialize all required contracts
|
|
93
93
|
logger.info('Deploying and initializing token, portal and its bridge...');
|
|
94
|
-
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, l1ContractAddresses.registryAddress,
|
|
94
|
+
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(wallet, l1Client, l1ContractAddresses.registryAddress, ownerAddress, underlyingERC20Address);
|
|
95
95
|
logger.info('Deployed and initialized token, portal and its bridge.');
|
|
96
|
-
return new CrossChainTestHarness(aztecNode,
|
|
96
|
+
return new CrossChainTestHarness(aztecNode, logger, token, bridge, ethAccount, tokenPortalAddress, underlyingERC20.address, l1Client, l1ContractAddresses, wallet, ownerAddress);
|
|
97
97
|
}
|
|
98
98
|
l1TokenManager;
|
|
99
99
|
l1TokenPortalManager;
|
|
100
|
-
constructor(/** Aztec node instance. */ aztecNode, /**
|
|
100
|
+
constructor(/** Aztec node instance. */ aztecNode, /** Logger. */ logger, /** L2 Token contract. */ l2Token, /** L2 Token bridge contract. */ l2Bridge, /** Eth account to interact with. */ ethAccount, /** Portal address. */ tokenPortalAddress, /** Underlying token for portal tests. */ underlyingERC20Address, /** Viem Extended client instance. */ l1Client, /** Deployment addresses for all L1 contracts */ l1ContractAddresses, /** Wallet to simulate and send txs from. */ wallet, /** Owner of the l2 token and bridge */ ownerAddress){
|
|
101
101
|
this.aztecNode = aztecNode;
|
|
102
|
-
this.pxeService = pxeService;
|
|
103
102
|
this.logger = logger;
|
|
104
103
|
this.l2Token = l2Token;
|
|
105
104
|
this.l2Bridge = l2Bridge;
|
|
@@ -108,11 +107,10 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
108
107
|
this.underlyingERC20Address = underlyingERC20Address;
|
|
109
108
|
this.l1Client = l1Client;
|
|
110
109
|
this.l1ContractAddresses = l1ContractAddresses;
|
|
111
|
-
this.
|
|
110
|
+
this.wallet = wallet;
|
|
112
111
|
this.ownerAddress = ownerAddress;
|
|
113
112
|
this.l1TokenPortalManager = new L1TokenPortalManager(this.tokenPortalAddress, this.underlyingERC20Address, this.l1ContractAddresses.feeAssetHandlerAddress, this.l1ContractAddresses.outboxAddress, this.l1Client, this.logger);
|
|
114
113
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
115
|
-
this.ownerAddress = this.ownerWallet.getAddress();
|
|
116
114
|
}
|
|
117
115
|
async mintTokensOnL1(amount) {
|
|
118
116
|
const contract = getContract({
|
|
@@ -146,7 +144,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
146
144
|
}).wait();
|
|
147
145
|
}
|
|
148
146
|
async mintTokensPrivateOnL2(amount) {
|
|
149
|
-
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.
|
|
147
|
+
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
|
|
150
148
|
}
|
|
151
149
|
async sendL2PublicTransfer(transferAmount, receiverAddress) {
|
|
152
150
|
// send a transfer tx to force through rollup with the message included
|
|
@@ -245,4 +243,4 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
245
243
|
outbox: this.l1ContractAddresses.outboxAddress
|
|
246
244
|
};
|
|
247
245
|
}
|
|
248
|
-
}
|
|
246
|
+
}
|