@aztec/end-to-end 0.85.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +6 -7
- package/dest/bench/client_flows/data_extractor.js +12 -7
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- 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 +11 -11
- package/dest/e2e_epochs/epochs_test.d.ts +2 -2
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +1 -1
- package/dest/e2e_fees/fees_test.d.ts +4 -0
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +22 -10
- package/dest/e2e_p2p/p2p_network.d.ts +67 -72
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +20 -61
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -1
- package/dest/e2e_prover/e2e_prover_test.js +9 -9
- package/dest/fixtures/l1_to_l2_messaging.d.ts +2 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +3 -3
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +9 -11
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +24 -23
- package/dest/shared/capture_private_execution_steps.d.ts.map +1 -1
- package/dest/shared/capture_private_execution_steps.js +3 -17
- package/dest/shared/cross_chain_test_harness.d.ts +7 -11
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +14 -16
- package/dest/shared/gas_portal_test_harness.d.ts +6 -11
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +8 -10
- package/dest/shared/uniswap_l1_l2.d.ts +3 -5
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +18 -19
- package/dest/spartan/setup_test_wallets.js +3 -3
- package/package.json +34 -35
- package/src/bench/client_flows/client_flows_benchmark.ts +6 -8
- package/src/bench/client_flows/data_extractor.ts +10 -6
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +14 -18
- package/src/e2e_epochs/epochs_test.ts +4 -3
- package/src/e2e_fees/fees_test.ts +32 -10
- package/src/e2e_p2p/p2p_network.ts +28 -74
- package/src/e2e_prover/e2e_prover_test.ts +9 -14
- package/src/fixtures/l1_to_l2_messaging.ts +5 -14
- package/src/fixtures/setup_l1_contracts.ts +1 -2
- package/src/fixtures/snapshot_manager.ts +9 -11
- package/src/fixtures/utils.ts +24 -25
- package/src/shared/capture_private_execution_steps.ts +3 -19
- package/src/shared/cross_chain_test_harness.ts +14 -31
- package/src/shared/gas_portal_test_harness.ts +9 -14
- package/src/shared/uniswap_l1_l2.ts +25 -43
- package/src/spartan/setup_test_wallets.ts +3 -3
package/src/fixtures/utils.ts
CHANGED
|
@@ -29,14 +29,14 @@ import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee/testing';
|
|
|
29
29
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec.js/testing';
|
|
30
30
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
31
31
|
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
32
|
-
import { GENESIS_ARCHIVE_ROOT,
|
|
32
|
+
import { GENESIS_ARCHIVE_ROOT, SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
33
33
|
import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
|
|
34
34
|
import {
|
|
35
35
|
type DeployL1ContractsArgs,
|
|
36
36
|
type DeployL1ContractsReturnType,
|
|
37
37
|
ForwarderContract,
|
|
38
38
|
NULL_KEY,
|
|
39
|
-
|
|
39
|
+
createExtendedL1Client,
|
|
40
40
|
deployL1Contracts,
|
|
41
41
|
getL1ContractsConfigEnvVars,
|
|
42
42
|
isAnvilTestChain,
|
|
@@ -125,7 +125,6 @@ export const setupL1Contracts = async (
|
|
|
125
125
|
vkTreeRoot: getVKTreeRoot(),
|
|
126
126
|
protocolContractTreeRoot,
|
|
127
127
|
genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
128
|
-
genesisBlockHash: args.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
|
|
129
128
|
salt: args.salt,
|
|
130
129
|
initialValidators: args.initialValidators,
|
|
131
130
|
...getL1ContractsConfigEnvVars(),
|
|
@@ -224,12 +223,11 @@ async function setupWithRemoteEnvironment(
|
|
|
224
223
|
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
|
|
225
224
|
const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses;
|
|
226
225
|
|
|
227
|
-
const
|
|
226
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
228
227
|
|
|
229
228
|
const deployL1ContractsValues: DeployL1ContractsReturnType = {
|
|
230
229
|
l1ContractAddresses: l1Contracts,
|
|
231
|
-
|
|
232
|
-
publicClient,
|
|
230
|
+
l1Client,
|
|
233
231
|
};
|
|
234
232
|
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
|
|
235
233
|
const teardown = () => Promise.resolve();
|
|
@@ -425,7 +423,7 @@ export async function setup(
|
|
|
425
423
|
const initialFundedAccounts =
|
|
426
424
|
opts.initialFundedAccounts ??
|
|
427
425
|
(await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
|
|
428
|
-
const {
|
|
426
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
|
|
429
427
|
initialFundedAccounts.map(a => a.address),
|
|
430
428
|
opts.initialAccountFeeJuice,
|
|
431
429
|
opts.genesisPublicData,
|
|
@@ -437,7 +435,7 @@ export async function setup(
|
|
|
437
435
|
config.l1RpcUrls,
|
|
438
436
|
publisherHdAccount!,
|
|
439
437
|
logger,
|
|
440
|
-
{ ...opts, genesisArchiveRoot,
|
|
438
|
+
{ ...opts, genesisArchiveRoot, feeJuicePortalInitialBalance: fundingNeeded },
|
|
441
439
|
chain,
|
|
442
440
|
));
|
|
443
441
|
|
|
@@ -449,7 +447,7 @@ export async function setup(
|
|
|
449
447
|
const rewardDistributor = getContract({
|
|
450
448
|
address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
|
|
451
449
|
abi: l1Artifacts.rewardDistributor.contractAbi,
|
|
452
|
-
client: deployL1ContractsValues.
|
|
450
|
+
client: deployL1ContractsValues.l1Client,
|
|
453
451
|
});
|
|
454
452
|
|
|
455
453
|
const blockReward = await rewardDistributor.read.BLOCK_REWARD();
|
|
@@ -458,11 +456,11 @@ export async function setup(
|
|
|
458
456
|
const feeJuice = getContract({
|
|
459
457
|
address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
460
458
|
abi: l1Artifacts.feeAsset.contractAbi,
|
|
461
|
-
client: deployL1ContractsValues.
|
|
459
|
+
client: deployL1ContractsValues.l1Client,
|
|
462
460
|
});
|
|
463
461
|
|
|
464
462
|
const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
|
|
465
|
-
await deployL1ContractsValues.
|
|
463
|
+
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
|
|
466
464
|
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
467
465
|
}
|
|
468
466
|
|
|
@@ -477,7 +475,7 @@ export async function setup(
|
|
|
477
475
|
const watcher = new AnvilTestWatcher(
|
|
478
476
|
new EthCheatCodesWithState(config.l1RpcUrls),
|
|
479
477
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
480
|
-
deployL1ContractsValues.
|
|
478
|
+
deployL1ContractsValues.l1Client,
|
|
481
479
|
dateProvider,
|
|
482
480
|
);
|
|
483
481
|
|
|
@@ -516,7 +514,7 @@ export async function setup(
|
|
|
516
514
|
}
|
|
517
515
|
config.l1PublishRetryIntervalMS = 100;
|
|
518
516
|
|
|
519
|
-
const blobSinkClient = createBlobSinkClient(config);
|
|
517
|
+
const blobSinkClient = createBlobSinkClient(config, { logger: createLogger('node:blob-sink:client') });
|
|
520
518
|
const aztecNode = await AztecNodeService.createAndSync(
|
|
521
519
|
config,
|
|
522
520
|
{ dateProvider, blobSinkClient, telemetry },
|
|
@@ -791,7 +789,9 @@ export async function createAndSyncProverNode(
|
|
|
791
789
|
stop: () => Promise.resolve(),
|
|
792
790
|
};
|
|
793
791
|
|
|
794
|
-
const blobSinkClient = createBlobSinkClient(aztecNodeConfig
|
|
792
|
+
const blobSinkClient = createBlobSinkClient(aztecNodeConfig, {
|
|
793
|
+
logger: createLogger('prover-node:blob-sink:client'),
|
|
794
|
+
});
|
|
795
795
|
// Creating temp store and archiver for simulated prover node
|
|
796
796
|
const archiverConfig = { ...aztecNodeConfig, dataDirectory };
|
|
797
797
|
const archiver = await createArchiver(archiverConfig, blobSinkClient, {
|
|
@@ -801,7 +801,7 @@ export async function createAndSyncProverNode(
|
|
|
801
801
|
// Prover node config is for simulated proofs
|
|
802
802
|
const proverConfig: ProverNodeConfig = {
|
|
803
803
|
...aztecNodeConfig,
|
|
804
|
-
|
|
804
|
+
proverCoordinationNodeUrls: [],
|
|
805
805
|
dataDirectory: undefined,
|
|
806
806
|
realProofs: false,
|
|
807
807
|
proverAgentCount: 2,
|
|
@@ -809,9 +809,9 @@ export async function createAndSyncProverNode(
|
|
|
809
809
|
proverNodeMaxPendingJobs: 10,
|
|
810
810
|
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
811
811
|
proverNodePollingIntervalMs: 200,
|
|
812
|
-
txGatheringTimeoutMs: 60000,
|
|
813
812
|
txGatheringIntervalMs: 1000,
|
|
814
|
-
|
|
813
|
+
txGatheringBatchSize: 10,
|
|
814
|
+
txGatheringMaxParallelRequestsPerNode: 10,
|
|
815
815
|
};
|
|
816
816
|
|
|
817
817
|
const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node');
|
|
@@ -825,16 +825,16 @@ export async function createAndSyncProverNode(
|
|
|
825
825
|
},
|
|
826
826
|
{ prefilledPublicData },
|
|
827
827
|
);
|
|
828
|
-
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.
|
|
829
|
-
proverNode.start();
|
|
828
|
+
getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
|
|
829
|
+
await proverNode.start();
|
|
830
830
|
return proverNode;
|
|
831
831
|
}
|
|
832
832
|
|
|
833
833
|
function createDelayedL1TxUtils(aztecNodeConfig: AztecNodeConfig, privateKey: `0x${string}`, logName: string) {
|
|
834
|
-
const
|
|
834
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
835
835
|
|
|
836
836
|
const log = createLogger(logName);
|
|
837
|
-
const l1TxUtils = new DelayedTxUtils(
|
|
837
|
+
const l1TxUtils = new DelayedTxUtils(l1Client, log, aztecNodeConfig);
|
|
838
838
|
l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
|
|
839
839
|
return l1TxUtils;
|
|
840
840
|
}
|
|
@@ -844,11 +844,10 @@ export async function createForwarderContract(
|
|
|
844
844
|
privateKey: `0x${string}`,
|
|
845
845
|
rollupAddress: Hex,
|
|
846
846
|
) {
|
|
847
|
-
const
|
|
847
|
+
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
|
|
848
848
|
const forwarderContract = await ForwarderContract.create(
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
publicClient,
|
|
849
|
+
l1Client.account.address,
|
|
850
|
+
l1Client,
|
|
852
851
|
createLogger('forwarder'),
|
|
853
852
|
rollupAddress,
|
|
854
853
|
);
|
|
@@ -9,30 +9,13 @@ import type {
|
|
|
9
9
|
ProfileMethodOptions,
|
|
10
10
|
} from '@aztec/aztec.js/contracts';
|
|
11
11
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
|
-
import {
|
|
13
|
-
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
12
|
+
import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
14
13
|
|
|
15
|
-
import { encode } from '@msgpack/msgpack';
|
|
16
14
|
import { promises as fs } from 'fs';
|
|
17
15
|
import path from 'path';
|
|
18
16
|
|
|
19
17
|
const logger = createLogger('e2e:capture-private-execution-steps');
|
|
20
18
|
|
|
21
|
-
// TODO(#7371): This is duplicated.
|
|
22
|
-
// Longer term we won't use this hacked together msgpack format
|
|
23
|
-
// Leaving duplicated as this eventually bb will provide a serialization
|
|
24
|
-
// helper for passing to a generic msgpack RPC endpoint.
|
|
25
|
-
async function _createClientIvcProofFiles(directory: string, executionSteps: PrivateExecutionStep[]) {
|
|
26
|
-
const acirPath = path.join(directory, 'acir.msgpack');
|
|
27
|
-
const witnessPath = path.join(directory, 'witnesses.msgpack');
|
|
28
|
-
await fs.writeFile(acirPath, encode(executionSteps.map(map => map.bytecode)));
|
|
29
|
-
await fs.writeFile(witnessPath, encode(executionSteps.map(map => serializeWitness(map.witness))));
|
|
30
|
-
return {
|
|
31
|
-
acirPath,
|
|
32
|
-
witnessPath,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
19
|
export async function capturePrivateExecutionStepsIfEnvSet(
|
|
37
20
|
label: string,
|
|
38
21
|
interaction: ContractFunctionInteraction | DeployMethod,
|
|
@@ -56,7 +39,8 @@ export async function capturePrivateExecutionStepsIfEnvSet(
|
|
|
56
39
|
logger.info(`Writing private execution steps to ${resultsDirectory}`);
|
|
57
40
|
await fs.mkdir(resultsDirectory, { recursive: true });
|
|
58
41
|
// Write the client IVC files read by the prover.
|
|
59
|
-
|
|
42
|
+
const ivcInputsPath = path.join(resultsDirectory, 'ivc-inputs.msgpack');
|
|
43
|
+
await fs.writeFile(ivcInputsPath, serializePrivateExecutionSteps(result.executionSteps));
|
|
60
44
|
if (profileMode === 'full') {
|
|
61
45
|
// If we have gate counts, write the steps in human-readable format.
|
|
62
46
|
await fs.writeFile(
|
|
@@ -18,12 +18,7 @@ import {
|
|
|
18
18
|
type Wallet,
|
|
19
19
|
retryUntil,
|
|
20
20
|
} from '@aztec/aztec.js';
|
|
21
|
-
import {
|
|
22
|
-
type L1ContractAddresses,
|
|
23
|
-
type ViemPublicClient,
|
|
24
|
-
type ViemWalletClient,
|
|
25
|
-
deployL1Contract,
|
|
26
|
-
} from '@aztec/ethereum';
|
|
21
|
+
import { type ExtendedViemWalletClient, type L1ContractAddresses, deployL1Contract } from '@aztec/ethereum';
|
|
27
22
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
28
23
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
29
24
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
@@ -45,8 +40,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
|
45
40
|
*/
|
|
46
41
|
export async function deployAndInitializeTokenAndBridgeContracts(
|
|
47
42
|
wallet: Wallet,
|
|
48
|
-
|
|
49
|
-
publicClient: ViemPublicClient,
|
|
43
|
+
l1Client: ExtendedViemWalletClient,
|
|
50
44
|
rollupRegistryAddress: EthAddress,
|
|
51
45
|
owner: AztecAddress,
|
|
52
46
|
underlyingERC20Address: EthAddress,
|
|
@@ -73,16 +67,11 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
73
67
|
underlyingERC20: any;
|
|
74
68
|
}> {
|
|
75
69
|
// deploy the token portal
|
|
76
|
-
const { address: tokenPortalAddress } = await deployL1Contract(
|
|
77
|
-
walletClient,
|
|
78
|
-
publicClient,
|
|
79
|
-
TokenPortalAbi,
|
|
80
|
-
TokenPortalBytecode,
|
|
81
|
-
);
|
|
70
|
+
const { address: tokenPortalAddress } = await deployL1Contract(l1Client, TokenPortalAbi, TokenPortalBytecode);
|
|
82
71
|
const tokenPortal = getContract({
|
|
83
72
|
address: tokenPortalAddress.toString(),
|
|
84
73
|
abi: TokenPortalAbi,
|
|
85
|
-
client:
|
|
74
|
+
client: l1Client,
|
|
86
75
|
});
|
|
87
76
|
|
|
88
77
|
// deploy l2 token
|
|
@@ -114,7 +103,7 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
114
103
|
const underlyingERC20 = getContract({
|
|
115
104
|
address: underlyingERC20Address.toString(),
|
|
116
105
|
abi: TestERC20Abi,
|
|
117
|
-
client:
|
|
106
|
+
client: l1Client,
|
|
118
107
|
});
|
|
119
108
|
|
|
120
109
|
return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
|
|
@@ -140,21 +129,19 @@ export class CrossChainTestHarness {
|
|
|
140
129
|
static async new(
|
|
141
130
|
aztecNode: AztecNode,
|
|
142
131
|
pxeService: PXE,
|
|
143
|
-
|
|
144
|
-
walletClient: ViemWalletClient,
|
|
132
|
+
l1Client: ExtendedViemWalletClient,
|
|
145
133
|
wallet: AccountWallet,
|
|
146
134
|
logger: Logger,
|
|
147
135
|
underlyingERC20Address: EthAddress,
|
|
148
136
|
): Promise<CrossChainTestHarness> {
|
|
149
|
-
const ethAccount = EthAddress.fromString((await
|
|
137
|
+
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
150
138
|
const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
|
|
151
139
|
|
|
152
140
|
// Deploy and initialize all required contracts
|
|
153
141
|
logger.info('Deploying and initializing token, portal and its bridge...');
|
|
154
142
|
const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(
|
|
155
143
|
wallet,
|
|
156
|
-
|
|
157
|
-
publicClient,
|
|
144
|
+
l1Client,
|
|
158
145
|
l1ContractAddresses.registryAddress,
|
|
159
146
|
wallet.getAddress(),
|
|
160
147
|
underlyingERC20Address,
|
|
@@ -170,8 +157,7 @@ export class CrossChainTestHarness {
|
|
|
170
157
|
ethAccount,
|
|
171
158
|
tokenPortalAddress,
|
|
172
159
|
underlyingERC20.address,
|
|
173
|
-
|
|
174
|
-
walletClient,
|
|
160
|
+
l1Client,
|
|
175
161
|
l1ContractAddresses,
|
|
176
162
|
wallet,
|
|
177
163
|
);
|
|
@@ -202,10 +188,8 @@ export class CrossChainTestHarness {
|
|
|
202
188
|
public tokenPortalAddress: EthAddress,
|
|
203
189
|
/** Underlying token for portal tests. */
|
|
204
190
|
public underlyingERC20Address: EthAddress,
|
|
205
|
-
/** Viem
|
|
206
|
-
public
|
|
207
|
-
/** Viem Wallet Client instance. */
|
|
208
|
-
public walletClient: ViemWalletClient,
|
|
191
|
+
/** Viem Extended client instance. */
|
|
192
|
+
public l1Client: ExtendedViemWalletClient,
|
|
209
193
|
|
|
210
194
|
/** Deployment addresses for all L1 contracts */
|
|
211
195
|
public readonly l1ContractAddresses: L1ContractAddresses,
|
|
@@ -218,8 +202,7 @@ export class CrossChainTestHarness {
|
|
|
218
202
|
this.underlyingERC20Address,
|
|
219
203
|
this.l1ContractAddresses.feeAssetHandlerAddress,
|
|
220
204
|
this.l1ContractAddresses.outboxAddress,
|
|
221
|
-
this.
|
|
222
|
-
this.walletClient,
|
|
205
|
+
this.l1Client,
|
|
223
206
|
this.logger,
|
|
224
207
|
);
|
|
225
208
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
@@ -230,11 +213,11 @@ export class CrossChainTestHarness {
|
|
|
230
213
|
const contract = getContract({
|
|
231
214
|
abi: TestERC20Abi,
|
|
232
215
|
address: this.l1TokenManager.tokenAddress.toString(),
|
|
233
|
-
client: this.
|
|
216
|
+
client: this.l1Client,
|
|
234
217
|
});
|
|
235
218
|
const balanceBefore = await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString());
|
|
236
219
|
const hash = await contract.write.mint([this.ethAccount.toString(), amount]);
|
|
237
|
-
await this.
|
|
220
|
+
await this.l1Client.waitForTransactionReceipt({ hash });
|
|
238
221
|
expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(balanceBefore + amount);
|
|
239
222
|
}
|
|
240
223
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type Wallet,
|
|
12
12
|
retryUntil,
|
|
13
13
|
} from '@aztec/aztec.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum';
|
|
15
15
|
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
16
16
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
17
17
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -31,8 +31,7 @@ export interface FeeJuicePortalTestingHarnessFactoryConfig {
|
|
|
31
31
|
aztecNode: AztecNode;
|
|
32
32
|
aztecNodeAdmin?: AztecNodeAdmin;
|
|
33
33
|
pxeService: PXE;
|
|
34
|
-
|
|
35
|
-
walletClient: ViemWalletClient;
|
|
34
|
+
l1Client: ExtendedViemWalletClient;
|
|
36
35
|
wallet: Wallet;
|
|
37
36
|
logger: Logger;
|
|
38
37
|
mockL1?: boolean;
|
|
@@ -42,9 +41,9 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
42
41
|
private constructor(private config: FeeJuicePortalTestingHarnessFactoryConfig) {}
|
|
43
42
|
|
|
44
43
|
private async createReal() {
|
|
45
|
-
const { aztecNode, aztecNodeAdmin, pxeService,
|
|
44
|
+
const { aztecNode, aztecNodeAdmin, pxeService, l1Client, wallet, logger } = this.config;
|
|
46
45
|
|
|
47
|
-
const ethAccount = EthAddress.fromString((await
|
|
46
|
+
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
48
47
|
const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
|
|
49
48
|
|
|
50
49
|
const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
|
|
@@ -66,8 +65,7 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
66
65
|
feeJuicePortalAddress,
|
|
67
66
|
feeJuiceAddress,
|
|
68
67
|
l1ContractAddresses.feeAssetHandlerAddress!,
|
|
69
|
-
|
|
70
|
-
walletClient,
|
|
68
|
+
l1Client,
|
|
71
69
|
);
|
|
72
70
|
}
|
|
73
71
|
|
|
@@ -107,17 +105,14 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
107
105
|
public l1FeeJuiceAddress: EthAddress,
|
|
108
106
|
/** Fee asset handler address. */
|
|
109
107
|
public feeAssetHandlerAddress: EthAddress,
|
|
110
|
-
/** Viem
|
|
111
|
-
public
|
|
112
|
-
/** Viem Wallet Client instance. */
|
|
113
|
-
public walletClient: ViemWalletClient,
|
|
108
|
+
/** Viem Extended client instance. */
|
|
109
|
+
public l1Client: ExtendedViemWalletClient,
|
|
114
110
|
) {
|
|
115
111
|
this.feeJuicePortalManager = new L1FeeJuicePortalManager(
|
|
116
112
|
this.feeJuicePortalAddress,
|
|
117
113
|
this.l1FeeJuiceAddress,
|
|
118
114
|
this.feeAssetHandlerAddress,
|
|
119
|
-
this.
|
|
120
|
-
this.walletClient,
|
|
115
|
+
this.l1Client,
|
|
121
116
|
this.logger,
|
|
122
117
|
);
|
|
123
118
|
|
|
@@ -130,7 +125,7 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
130
125
|
const feeAssetL1 = getContract({
|
|
131
126
|
address: this.l1FeeJuiceAddress.toString(),
|
|
132
127
|
abi: TestERC20Abi,
|
|
133
|
-
client: this.
|
|
128
|
+
client: this.l1Client,
|
|
134
129
|
});
|
|
135
130
|
|
|
136
131
|
await feeAssetL1.write.mint([to.toString(), amount]);
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
import { CheatCodes } from '@aztec/aztec.js/testing';
|
|
13
13
|
import {
|
|
14
14
|
type DeployL1ContractsReturnType,
|
|
15
|
+
type ExtendedViemWalletClient,
|
|
15
16
|
RollupContract,
|
|
16
|
-
type ViemPublicClient,
|
|
17
|
-
type ViemWalletClient,
|
|
18
17
|
deployL1Contract,
|
|
19
18
|
extractEvent,
|
|
20
19
|
} from '@aztec/ethereum';
|
|
@@ -46,10 +45,8 @@ export type UniswapSetupContext = {
|
|
|
46
45
|
pxe: PXE;
|
|
47
46
|
/** Logger instance named as the current test. */
|
|
48
47
|
logger: Logger;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
/** Viem Wallet Client instance. */
|
|
52
|
-
walletClient: ViemWalletClient;
|
|
48
|
+
/** The L1 wallet client, extended with public actions. */
|
|
49
|
+
l1Client: ExtendedViemWalletClient;
|
|
53
50
|
/** The owner wallet. */
|
|
54
51
|
ownerWallet: AccountWallet;
|
|
55
52
|
/** The sponsor wallet. */
|
|
@@ -77,8 +74,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
77
74
|
let pxe: PXE;
|
|
78
75
|
let logger: Logger;
|
|
79
76
|
|
|
80
|
-
let
|
|
81
|
-
let publicClient: ViemPublicClient;
|
|
77
|
+
let l1Client: ExtendedViemWalletClient;
|
|
82
78
|
|
|
83
79
|
let ownerWallet: AccountWallet;
|
|
84
80
|
let ownerAddress: AztecAddress;
|
|
@@ -92,7 +88,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
92
88
|
|
|
93
89
|
let deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
94
90
|
let rollup: RollupContract;
|
|
95
|
-
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi,
|
|
91
|
+
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
|
|
96
92
|
let uniswapPortalAddress: EthAddress;
|
|
97
93
|
let uniswapL2Contract: UniswapContract;
|
|
98
94
|
|
|
@@ -103,30 +99,21 @@ export const uniswapL1L2TestSuite = (
|
|
|
103
99
|
let cheatCodes: CheatCodes;
|
|
104
100
|
let version: number;
|
|
105
101
|
beforeAll(async () => {
|
|
106
|
-
({
|
|
107
|
-
|
|
108
|
-
pxe,
|
|
109
|
-
logger,
|
|
110
|
-
publicClient,
|
|
111
|
-
walletClient,
|
|
112
|
-
ownerWallet,
|
|
113
|
-
sponsorWallet,
|
|
114
|
-
deployL1ContractsValues,
|
|
115
|
-
cheatCodes,
|
|
116
|
-
} = await setup());
|
|
102
|
+
({ aztecNode, pxe, logger, l1Client, ownerWallet, sponsorWallet, deployL1ContractsValues, cheatCodes } =
|
|
103
|
+
await setup());
|
|
117
104
|
|
|
118
|
-
if (Number(await
|
|
105
|
+
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
119
106
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
120
107
|
}
|
|
121
108
|
|
|
122
109
|
rollup = new RollupContract(
|
|
123
|
-
deployL1ContractsValues.
|
|
110
|
+
deployL1ContractsValues.l1Client,
|
|
124
111
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
125
112
|
);
|
|
126
113
|
version = Number(await rollup.getVersion());
|
|
127
114
|
ownerAddress = ownerWallet.getAddress();
|
|
128
115
|
// sponsorAddress = sponsorWallet.getAddress();
|
|
129
|
-
ownerEthAddress = EthAddress.fromString((await
|
|
116
|
+
ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
130
117
|
|
|
131
118
|
await ensureAccountsPubliclyDeployed(ownerWallet, [ownerWallet, sponsorWallet]);
|
|
132
119
|
|
|
@@ -134,8 +121,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
134
121
|
daiCrossChainHarness = await CrossChainTestHarness.new(
|
|
135
122
|
aztecNode,
|
|
136
123
|
pxe,
|
|
137
|
-
|
|
138
|
-
walletClient,
|
|
124
|
+
deployL1ContractsValues.l1Client,
|
|
139
125
|
ownerWallet,
|
|
140
126
|
logger,
|
|
141
127
|
DAI_ADDRESS,
|
|
@@ -145,25 +131,21 @@ export const uniswapL1L2TestSuite = (
|
|
|
145
131
|
wethCrossChainHarness = await CrossChainTestHarness.new(
|
|
146
132
|
aztecNode,
|
|
147
133
|
pxe,
|
|
148
|
-
|
|
149
|
-
walletClient,
|
|
134
|
+
l1Client,
|
|
150
135
|
ownerWallet,
|
|
151
136
|
logger,
|
|
152
137
|
WETH9_ADDRESS,
|
|
153
138
|
);
|
|
154
139
|
|
|
155
140
|
logger.info('Deploy Uniswap portal on L1 and L2...');
|
|
156
|
-
uniswapPortalAddress = await deployL1Contract(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
UniswapPortalAbi,
|
|
160
|
-
UniswapPortalBytecode,
|
|
161
|
-
).then(({ address }) => address);
|
|
141
|
+
uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(
|
|
142
|
+
({ address }) => address,
|
|
143
|
+
);
|
|
162
144
|
|
|
163
145
|
uniswapPortal = getContract({
|
|
164
146
|
address: uniswapPortalAddress.toString(),
|
|
165
147
|
abi: UniswapPortalAbi,
|
|
166
|
-
client:
|
|
148
|
+
client: l1Client,
|
|
167
149
|
});
|
|
168
150
|
// deploy l2 uniswap contract and attach to portal
|
|
169
151
|
uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send().deployed();
|
|
@@ -177,8 +159,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
177
159
|
|
|
178
160
|
// Give me some WETH so I can deposit to L2 and do the swap...
|
|
179
161
|
logger.info('Getting some weth');
|
|
180
|
-
const hash = await
|
|
181
|
-
await
|
|
162
|
+
const hash = await l1Client.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
|
|
163
|
+
await l1Client.waitForTransactionReceipt({ hash });
|
|
182
164
|
|
|
183
165
|
const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
184
166
|
expect(wethBalance).toBe(parseEther('1000'));
|
|
@@ -263,7 +245,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
263
245
|
uniswapL2Contract.address,
|
|
264
246
|
new Fr(version), // aztec version
|
|
265
247
|
EthAddress.fromString(uniswapPortal.address).toBuffer32(),
|
|
266
|
-
new Fr(
|
|
248
|
+
new Fr(l1Client.chain.id), // chain id
|
|
267
249
|
swapPrivateContent,
|
|
268
250
|
]);
|
|
269
251
|
|
|
@@ -278,7 +260,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
278
260
|
wethCrossChainHarness.l2Bridge.address,
|
|
279
261
|
new Fr(version), // aztec version
|
|
280
262
|
wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
|
|
281
|
-
new Fr(
|
|
263
|
+
new Fr(l1Client.chain.id), // chain id
|
|
282
264
|
withdrawContent,
|
|
283
265
|
]);
|
|
284
266
|
|
|
@@ -333,7 +315,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
333
315
|
] as const;
|
|
334
316
|
|
|
335
317
|
// this should also insert a message into the inbox.
|
|
336
|
-
const txReceipt = await daiCrossChainHarness.
|
|
318
|
+
const txReceipt = await daiCrossChainHarness.l1Client.waitForTransactionReceipt({
|
|
337
319
|
hash: await uniswapPortal.write.swapPrivate(swapArgs),
|
|
338
320
|
});
|
|
339
321
|
|
|
@@ -851,7 +833,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
851
833
|
uniswapL2Contract.address,
|
|
852
834
|
new Fr(version), // aztec version
|
|
853
835
|
EthAddress.fromString(uniswapPortal.address).toBuffer32(),
|
|
854
|
-
new Fr(
|
|
836
|
+
new Fr(l1Client.chain.id), // chain id
|
|
855
837
|
swapPrivateContent,
|
|
856
838
|
]);
|
|
857
839
|
|
|
@@ -866,7 +848,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
866
848
|
wethCrossChainHarness.l2Bridge.address,
|
|
867
849
|
new Fr(version), // aztec version
|
|
868
850
|
wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
|
|
869
|
-
new Fr(
|
|
851
|
+
new Fr(l1Client.chain.id), // chain id
|
|
870
852
|
withdrawContent,
|
|
871
853
|
]);
|
|
872
854
|
|
|
@@ -981,7 +963,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
981
963
|
uniswapL2Contract.address,
|
|
982
964
|
new Fr(version), // aztec version
|
|
983
965
|
EthAddress.fromString(uniswapPortal.address).toBuffer32(),
|
|
984
|
-
new Fr(
|
|
966
|
+
new Fr(l1Client.chain.id), // chain id
|
|
985
967
|
swapPublicContent,
|
|
986
968
|
]);
|
|
987
969
|
|
|
@@ -996,7 +978,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
996
978
|
wethCrossChainHarness.l2Bridge.address,
|
|
997
979
|
new Fr(version), // aztec version
|
|
998
980
|
wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
|
|
999
|
-
new Fr(
|
|
981
|
+
new Fr(l1Client.chain.id), // chain id
|
|
1000
982
|
withdrawContent,
|
|
1001
983
|
]);
|
|
1002
984
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
createCompatibleClient,
|
|
13
13
|
retryUntil,
|
|
14
14
|
} from '@aztec/aztec.js';
|
|
15
|
-
import { createEthereumChain,
|
|
15
|
+
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
16
16
|
import type { Logger } from '@aztec/foundation/log';
|
|
17
17
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
18
18
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
@@ -105,10 +105,10 @@ async function bridgeL1FeeJuice(
|
|
|
105
105
|
) {
|
|
106
106
|
const { l1ChainId } = await pxe.getNodeInfo();
|
|
107
107
|
const chain = createEthereumChain(l1RpcUrls, l1ChainId);
|
|
108
|
-
const
|
|
108
|
+
const l1Client = createExtendedL1Client(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
|
|
109
109
|
|
|
110
110
|
// docs:start:bridge_fee_juice
|
|
111
|
-
const portal = await L1FeeJuicePortalManager.new(pxe,
|
|
111
|
+
const portal = await L1FeeJuicePortalManager.new(pxe, l1Client, log);
|
|
112
112
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
113
113
|
// docs:end:bridge_fee_juice
|
|
114
114
|
|