@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
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
1
|
+
// docs:start:cross_chain_test_harness
|
|
4
2
|
import {
|
|
3
|
+
type AccountWallet,
|
|
4
|
+
AuthWitness,
|
|
5
|
+
type AztecAddress,
|
|
6
|
+
type AztecNode,
|
|
7
|
+
EthAddress,
|
|
8
|
+
type FieldsOf,
|
|
9
|
+
Fr,
|
|
5
10
|
type L1TokenManager,
|
|
6
11
|
L1TokenPortalManager,
|
|
7
12
|
type L2AmountClaim,
|
|
8
13
|
type L2AmountClaimWithRecipient,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
type Logger,
|
|
15
|
+
type PXE,
|
|
16
|
+
type SiblingPath,
|
|
17
|
+
type TxReceipt,
|
|
18
|
+
type Wallet,
|
|
19
|
+
retryUntil,
|
|
20
|
+
} from '@aztec/aztec.js';
|
|
16
21
|
import { type ExtendedViemWalletClient, type L1ContractAddresses, deployL1Contract } from '@aztec/ethereum';
|
|
17
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
18
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
19
22
|
import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
|
|
20
23
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
21
24
|
import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
|
|
@@ -24,6 +27,7 @@ import { type Hex, getContract } from 'viem';
|
|
|
24
27
|
|
|
25
28
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
26
29
|
|
|
30
|
+
// docs:start:deployAndInitializeTokenAndBridgeContracts
|
|
27
31
|
/**
|
|
28
32
|
* Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
|
|
29
33
|
* @param wallet - the wallet instance
|
|
@@ -108,6 +112,7 @@ export async function deployAndInitializeTokenAndBridgeContracts(
|
|
|
108
112
|
|
|
109
113
|
return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
|
|
110
114
|
}
|
|
115
|
+
// docs:end:deployAndInitializeTokenAndBridgeContracts
|
|
111
116
|
|
|
112
117
|
export type CrossChainContext = {
|
|
113
118
|
l2Token: AztecAddress;
|
|
@@ -127,14 +132,15 @@ export type CrossChainContext = {
|
|
|
127
132
|
export class CrossChainTestHarness {
|
|
128
133
|
static async new(
|
|
129
134
|
aztecNode: AztecNode,
|
|
135
|
+
pxeService: PXE,
|
|
130
136
|
l1Client: ExtendedViemWalletClient,
|
|
131
|
-
wallet:
|
|
137
|
+
wallet: AccountWallet,
|
|
132
138
|
ownerAddress: AztecAddress,
|
|
133
139
|
logger: Logger,
|
|
134
140
|
underlyingERC20Address: EthAddress,
|
|
135
141
|
): Promise<CrossChainTestHarness> {
|
|
136
142
|
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
137
|
-
const l1ContractAddresses = (await
|
|
143
|
+
const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
|
|
138
144
|
|
|
139
145
|
// Deploy and initialize all required contracts
|
|
140
146
|
logger.info('Deploying and initializing token, portal and its bridge...');
|
|
@@ -142,13 +148,14 @@ export class CrossChainTestHarness {
|
|
|
142
148
|
wallet,
|
|
143
149
|
l1Client,
|
|
144
150
|
l1ContractAddresses.registryAddress,
|
|
145
|
-
|
|
151
|
+
wallet.getAddress(),
|
|
146
152
|
underlyingERC20Address,
|
|
147
153
|
);
|
|
148
154
|
logger.info('Deployed and initialized token, portal and its bridge.');
|
|
149
155
|
|
|
150
156
|
return new CrossChainTestHarness(
|
|
151
157
|
aztecNode,
|
|
158
|
+
pxeService,
|
|
152
159
|
logger,
|
|
153
160
|
token,
|
|
154
161
|
bridge,
|
|
@@ -168,6 +175,8 @@ export class CrossChainTestHarness {
|
|
|
168
175
|
constructor(
|
|
169
176
|
/** Aztec node instance. */
|
|
170
177
|
public aztecNode: AztecNode,
|
|
178
|
+
/** Private eXecution Environment (PXE). */
|
|
179
|
+
public pxeService: PXE,
|
|
171
180
|
/** Logger. */
|
|
172
181
|
public logger: Logger,
|
|
173
182
|
|
|
@@ -189,8 +198,8 @@ export class CrossChainTestHarness {
|
|
|
189
198
|
/** Deployment addresses for all L1 contracts */
|
|
190
199
|
public readonly l1ContractAddresses: L1ContractAddresses,
|
|
191
200
|
|
|
192
|
-
/** Wallet
|
|
193
|
-
public readonly
|
|
201
|
+
/** Wallet of the owner. */
|
|
202
|
+
public readonly ownerWallet: AccountWallet,
|
|
194
203
|
|
|
195
204
|
/** Owner of the l2 token and bridge */
|
|
196
205
|
public readonly ownerAddress: AztecAddress,
|
|
@@ -204,6 +213,7 @@ export class CrossChainTestHarness {
|
|
|
204
213
|
this.logger,
|
|
205
214
|
);
|
|
206
215
|
this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
|
|
216
|
+
this.ownerAddress = this.ownerWallet.getAddress();
|
|
207
217
|
}
|
|
208
218
|
|
|
209
219
|
async mintTokensOnL1(amount: bigint) {
|
|
@@ -236,7 +246,7 @@ export class CrossChainTestHarness {
|
|
|
236
246
|
}
|
|
237
247
|
|
|
238
248
|
async mintTokensPrivateOnL2(amount: bigint) {
|
|
239
|
-
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
|
|
249
|
+
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerWallet, this.ownerAddress, amount);
|
|
240
250
|
}
|
|
241
251
|
|
|
242
252
|
async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
|
|
@@ -379,3 +389,4 @@ export class CrossChainTestHarness {
|
|
|
379
389
|
};
|
|
380
390
|
}
|
|
381
391
|
}
|
|
392
|
+
// docs:end:cross_chain_test_harness
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
type AztecAddress,
|
|
3
|
+
type AztecNode,
|
|
4
|
+
EthAddress,
|
|
5
|
+
Fr,
|
|
6
|
+
L1FeeJuicePortalManager,
|
|
7
|
+
type L1TokenManager,
|
|
8
|
+
type L2AmountClaim,
|
|
9
|
+
type Logger,
|
|
10
|
+
type PXE,
|
|
11
|
+
type Wallet,
|
|
12
|
+
retryUntil,
|
|
13
|
+
} from '@aztec/aztec.js';
|
|
7
14
|
import type { ExtendedViemWalletClient } from '@aztec/ethereum';
|
|
8
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
9
15
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
10
16
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
11
17
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
@@ -21,6 +27,7 @@ export interface IGasBridgingTestHarness {
|
|
|
21
27
|
export interface FeeJuicePortalTestingHarnessFactoryConfig {
|
|
22
28
|
aztecNode: AztecNode;
|
|
23
29
|
aztecNodeAdmin?: AztecNodeAdmin;
|
|
30
|
+
pxeService: PXE;
|
|
24
31
|
l1Client: ExtendedViemWalletClient;
|
|
25
32
|
wallet: Wallet;
|
|
26
33
|
logger: Logger;
|
|
@@ -31,10 +38,10 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
31
38
|
private constructor(private config: FeeJuicePortalTestingHarnessFactoryConfig) {}
|
|
32
39
|
|
|
33
40
|
private async createReal() {
|
|
34
|
-
const { aztecNode, aztecNodeAdmin, l1Client, wallet, logger } = this.config;
|
|
41
|
+
const { aztecNode, aztecNodeAdmin, pxeService, l1Client, wallet, logger } = this.config;
|
|
35
42
|
|
|
36
43
|
const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
37
|
-
const l1ContractAddresses = (await
|
|
44
|
+
const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
|
|
38
45
|
|
|
39
46
|
const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
|
|
40
47
|
const feeJuicePortalAddress = l1ContractAddresses.feeJuicePortalAddress;
|
|
@@ -48,7 +55,7 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
48
55
|
return new GasBridgingTestHarness(
|
|
49
56
|
aztecNode,
|
|
50
57
|
aztecNodeAdmin,
|
|
51
|
-
|
|
58
|
+
pxeService,
|
|
52
59
|
logger,
|
|
53
60
|
gasL2,
|
|
54
61
|
ethAccount,
|
|
@@ -78,8 +85,8 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
78
85
|
public aztecNode: AztecNode,
|
|
79
86
|
/** Aztec node admin interface */
|
|
80
87
|
public aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
81
|
-
/**
|
|
82
|
-
public
|
|
88
|
+
/** Private eXecution Environment (PXE). */
|
|
89
|
+
public pxeService: PXE,
|
|
83
90
|
/** Logger. */
|
|
84
91
|
public logger: Logger,
|
|
85
92
|
|
package/src/shared/jest_setup.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields';
|
|
4
|
-
import type { Logger } from '@aztec/aztec.js/log';
|
|
5
|
-
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { Fr, GrumpkinScalar, type Logger, type SentTx, TxStatus, type Wallet } from '@aztec/aztec.js';
|
|
6
3
|
import { times } from '@aztec/foundation/collection';
|
|
7
|
-
import type {
|
|
4
|
+
import type { PXEService } from '@aztec/pxe/server';
|
|
8
5
|
|
|
9
|
-
// submits a set of transactions to the provided
|
|
6
|
+
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
10
7
|
export const submitTxsTo = async (
|
|
11
|
-
|
|
12
|
-
submitter: AztecAddress,
|
|
8
|
+
pxe: PXEService,
|
|
13
9
|
numTxs: number,
|
|
10
|
+
wallet: Wallet,
|
|
14
11
|
logger: Logger,
|
|
15
12
|
): Promise<SentTx[]> => {
|
|
16
13
|
const txs: SentTx[] = [];
|
|
17
14
|
await Promise.all(
|
|
18
15
|
times(numTxs, async () => {
|
|
19
|
-
const accountManager = await
|
|
20
|
-
const
|
|
21
|
-
const tx = deployMethod.send({ from: submitter });
|
|
16
|
+
const accountManager = await getSchnorrAccount(pxe, Fr.random(), GrumpkinScalar.random(), Fr.random());
|
|
17
|
+
const tx = accountManager.deploy({ deployWallet: wallet });
|
|
22
18
|
const txHash = await tx.getTxHash();
|
|
23
19
|
|
|
24
20
|
logger.info(`Tx sent with hash ${txHash}`);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
type AccountWallet,
|
|
3
|
+
AztecAddress,
|
|
4
|
+
type AztecNode,
|
|
5
|
+
EthAddress,
|
|
6
|
+
Fr,
|
|
7
|
+
type Logger,
|
|
8
|
+
type PXE,
|
|
9
|
+
computeAuthWitMessageHash,
|
|
10
|
+
generateClaimSecret,
|
|
11
|
+
} from '@aztec/aztec.js';
|
|
7
12
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
8
13
|
import {
|
|
9
14
|
type DeployL1ContractsReturnType,
|
|
@@ -17,7 +22,6 @@ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-art
|
|
|
17
22
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
18
23
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
19
24
|
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
20
|
-
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
21
25
|
|
|
22
26
|
import { jest } from '@jest/globals';
|
|
23
27
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
@@ -32,33 +36,36 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
|
32
36
|
// anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
|
|
33
37
|
// For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
|
|
34
38
|
|
|
39
|
+
// docs:start:uniswap_l1_l2_test_setup_const
|
|
35
40
|
const TIMEOUT = 360_000;
|
|
36
41
|
|
|
37
42
|
/** Objects to be returned by the uniswap setup function */
|
|
38
43
|
export type UniswapSetupContext = {
|
|
39
44
|
/** Aztec Node instance */
|
|
40
45
|
aztecNode: AztecNode;
|
|
46
|
+
/** The Private eXecution Environment (PXE). */
|
|
47
|
+
pxe: PXE;
|
|
41
48
|
/** Logger instance named as the current test. */
|
|
42
49
|
logger: Logger;
|
|
43
50
|
/** The L1 wallet client, extended with public actions. */
|
|
44
51
|
l1Client: ExtendedViemWalletClient;
|
|
45
|
-
/** The wallet. */
|
|
46
|
-
|
|
47
|
-
/** The owner address. */
|
|
48
|
-
ownerAddress: AztecAddress;
|
|
52
|
+
/** The owner wallet. */
|
|
53
|
+
ownerWallet: AccountWallet;
|
|
49
54
|
/** The sponsor wallet. */
|
|
50
|
-
|
|
55
|
+
sponsorWallet: AccountWallet;
|
|
51
56
|
/** */
|
|
52
57
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
53
58
|
/** Cheat codes instance. */
|
|
54
59
|
cheatCodes: CheatCodes;
|
|
55
60
|
};
|
|
61
|
+
// docs:end:uniswap_l1_l2_test_setup_const
|
|
56
62
|
|
|
57
63
|
export const uniswapL1L2TestSuite = (
|
|
58
64
|
setup: () => Promise<UniswapSetupContext>,
|
|
59
65
|
cleanup: () => Promise<void>,
|
|
60
66
|
expectedForkBlockNumber = 17514288,
|
|
61
67
|
) => {
|
|
68
|
+
// docs:start:uniswap_l1_l2_test_beforeAll
|
|
62
69
|
describe('uniswap_trade_on_l1_from_l2', () => {
|
|
63
70
|
jest.setTimeout(TIMEOUT);
|
|
64
71
|
|
|
@@ -66,14 +73,16 @@ export const uniswapL1L2TestSuite = (
|
|
|
66
73
|
const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
|
|
67
74
|
|
|
68
75
|
let aztecNode: AztecNode;
|
|
76
|
+
let pxe: PXE;
|
|
69
77
|
let logger: Logger;
|
|
70
78
|
|
|
71
79
|
let l1Client: ExtendedViemWalletClient;
|
|
72
80
|
|
|
73
|
-
let
|
|
81
|
+
let ownerWallet: AccountWallet;
|
|
74
82
|
let ownerAddress: AztecAddress;
|
|
75
83
|
let ownerEthAddress: EthAddress;
|
|
76
84
|
// does transactions on behalf of owner on Aztec:
|
|
85
|
+
let sponsorWallet: AccountWallet;
|
|
77
86
|
let sponsorAddress: AztecAddress;
|
|
78
87
|
|
|
79
88
|
let daiCrossChainHarness: CrossChainTestHarness;
|
|
@@ -92,7 +101,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
92
101
|
let cheatCodes: CheatCodes;
|
|
93
102
|
let version: number;
|
|
94
103
|
beforeAll(async () => {
|
|
95
|
-
({ aztecNode, logger, l1Client,
|
|
104
|
+
({ aztecNode, pxe, logger, l1Client, ownerWallet, sponsorWallet, deployL1ContractsValues, cheatCodes } =
|
|
96
105
|
await setup());
|
|
97
106
|
|
|
98
107
|
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
@@ -104,15 +113,18 @@ export const uniswapL1L2TestSuite = (
|
|
|
104
113
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
105
114
|
);
|
|
106
115
|
version = Number(await rollup.getVersion());
|
|
116
|
+
ownerAddress = ownerWallet.getAddress();
|
|
117
|
+
sponsorAddress = sponsorWallet.getAddress();
|
|
107
118
|
ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
108
119
|
|
|
109
|
-
await ensureAccountContractsPublished(
|
|
120
|
+
await ensureAccountContractsPublished(ownerWallet, [ownerWallet, sponsorWallet]);
|
|
110
121
|
|
|
111
122
|
logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
|
|
112
123
|
daiCrossChainHarness = await CrossChainTestHarness.new(
|
|
113
124
|
aztecNode,
|
|
125
|
+
pxe,
|
|
114
126
|
deployL1ContractsValues.l1Client,
|
|
115
|
-
|
|
127
|
+
ownerWallet,
|
|
116
128
|
ownerAddress,
|
|
117
129
|
logger,
|
|
118
130
|
DAI_ADDRESS,
|
|
@@ -121,8 +133,9 @@ export const uniswapL1L2TestSuite = (
|
|
|
121
133
|
logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
|
|
122
134
|
wethCrossChainHarness = await CrossChainTestHarness.new(
|
|
123
135
|
aztecNode,
|
|
136
|
+
pxe,
|
|
124
137
|
l1Client,
|
|
125
|
-
|
|
138
|
+
ownerWallet,
|
|
126
139
|
ownerAddress,
|
|
127
140
|
logger,
|
|
128
141
|
WETH9_ADDRESS,
|
|
@@ -139,11 +152,11 @@ export const uniswapL1L2TestSuite = (
|
|
|
139
152
|
client: l1Client,
|
|
140
153
|
});
|
|
141
154
|
// deploy l2 uniswap contract and attach to portal
|
|
142
|
-
uniswapL2Contract = await UniswapContract.deploy(
|
|
155
|
+
uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress)
|
|
143
156
|
.send({ from: ownerAddress })
|
|
144
157
|
.deployed();
|
|
145
158
|
|
|
146
|
-
const registryAddress = (await
|
|
159
|
+
const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
147
160
|
|
|
148
161
|
await uniswapPortal.write.initialize(
|
|
149
162
|
[registryAddress.toString(), uniswapL2Contract.address.toString()],
|
|
@@ -158,6 +171,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
158
171
|
const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
159
172
|
expect(wethBalance).toBe(parseEther('1000'));
|
|
160
173
|
});
|
|
174
|
+
// docs:end:uniswap_l1_l2_test_beforeAll
|
|
161
175
|
|
|
162
176
|
afterAll(async () => {
|
|
163
177
|
await cleanup();
|
|
@@ -192,7 +206,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
192
206
|
// 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
193
207
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
194
208
|
const nonceForWETHTransferToPublicApproval = new Fr(1n);
|
|
195
|
-
const transferToPublicAuhtwit = await
|
|
209
|
+
const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
|
|
196
210
|
caller: uniswapL2Contract.address,
|
|
197
211
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
198
212
|
ownerAddress,
|
|
@@ -601,16 +615,14 @@ export const uniswapL1L2TestSuite = (
|
|
|
601
615
|
const expectedMessageHash = await computeAuthWitMessageHash(
|
|
602
616
|
{
|
|
603
617
|
caller: uniswapL2Contract.address,
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
)
|
|
611
|
-
.getFunctionCall(),
|
|
618
|
+
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
619
|
+
ownerAddress,
|
|
620
|
+
uniswapL2Contract.address,
|
|
621
|
+
wethAmountToBridge,
|
|
622
|
+
nonceForWETHTransferToPublicApproval,
|
|
623
|
+
),
|
|
612
624
|
},
|
|
613
|
-
|
|
625
|
+
{ chainId: ownerWallet.getChainId(), version: ownerWallet.getVersion() },
|
|
614
626
|
);
|
|
615
627
|
|
|
616
628
|
await expect(
|
|
@@ -638,7 +650,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
638
650
|
// 2. owner gives uniswap approval to transfer the funds to public:
|
|
639
651
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
640
652
|
const nonceForWETHTransferToPublicApproval = new Fr(3n);
|
|
641
|
-
const transferToPublicAuthwith = await
|
|
653
|
+
const transferToPublicAuthwith = await ownerWallet.createAuthWit({
|
|
642
654
|
caller: uniswapL2Contract.address,
|
|
643
655
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
644
656
|
ownerAddress,
|
|
@@ -663,8 +675,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
663
675
|
Fr.random(),
|
|
664
676
|
ownerEthAddress,
|
|
665
677
|
)
|
|
666
|
-
.
|
|
667
|
-
.wait(),
|
|
678
|
+
.prove({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
|
|
668
679
|
).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
669
680
|
});
|
|
670
681
|
|
|
@@ -676,8 +687,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
676
687
|
|
|
677
688
|
// 2. Give approval to uniswap to transfer funds to itself
|
|
678
689
|
const nonceForWETHTransferApproval = new Fr(2n);
|
|
679
|
-
const validateActionInteraction = await
|
|
680
|
-
ownerAddress,
|
|
690
|
+
const validateActionInteraction = await ownerWallet.setPublicAuthWit(
|
|
681
691
|
{
|
|
682
692
|
caller: uniswapL2Contract.address,
|
|
683
693
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -689,7 +699,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
689
699
|
},
|
|
690
700
|
true,
|
|
691
701
|
);
|
|
692
|
-
await validateActionInteraction.send().wait();
|
|
702
|
+
await validateActionInteraction.send({ from: ownerAddress }).wait();
|
|
693
703
|
|
|
694
704
|
// No approval to call `swap` but should work even without it:
|
|
695
705
|
const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
@@ -721,25 +731,23 @@ export const uniswapL1L2TestSuite = (
|
|
|
721
731
|
const nonceForWETHTransferApproval = new Fr(3n);
|
|
722
732
|
const nonceForSwap = new Fr(3n);
|
|
723
733
|
const secretHashForDepositingSwappedDai = new Fr(4n);
|
|
724
|
-
const action = uniswapL2Contract
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
);
|
|
742
|
-
await validateActionInteraction.send().wait();
|
|
734
|
+
const action = uniswapL2Contract
|
|
735
|
+
.withWallet(sponsorWallet)
|
|
736
|
+
.methods.swap_public(
|
|
737
|
+
ownerAddress,
|
|
738
|
+
wethCrossChainHarness.l2Bridge.address,
|
|
739
|
+
wethAmountToBridge,
|
|
740
|
+
daiCrossChainHarness.l2Bridge.address,
|
|
741
|
+
nonceForWETHTransferApproval,
|
|
742
|
+
uniswapFeeTier,
|
|
743
|
+
minimumOutputAmount,
|
|
744
|
+
ownerAddress,
|
|
745
|
+
secretHashForDepositingSwappedDai,
|
|
746
|
+
ownerEthAddress,
|
|
747
|
+
nonceForSwap,
|
|
748
|
+
);
|
|
749
|
+
const validateActionInteraction = await ownerWallet.setPublicAuthWit({ caller: approvedUser, action }, true);
|
|
750
|
+
await validateActionInteraction.send({ from: ownerAddress }).wait();
|
|
743
751
|
|
|
744
752
|
await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
|
|
745
753
|
});
|
|
@@ -748,8 +756,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
748
756
|
// swap should fail since no transfer approval to uniswap:
|
|
749
757
|
const nonceForWETHTransferApproval = new Fr(4n);
|
|
750
758
|
|
|
751
|
-
const validateActionInteraction = await
|
|
752
|
-
ownerAddress,
|
|
759
|
+
const validateActionInteraction = await ownerWallet.setPublicAuthWit(
|
|
753
760
|
{
|
|
754
761
|
caller: uniswapL2Contract.address,
|
|
755
762
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -761,7 +768,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
761
768
|
},
|
|
762
769
|
true,
|
|
763
770
|
);
|
|
764
|
-
await validateActionInteraction.send().wait();
|
|
771
|
+
await validateActionInteraction.send({ from: ownerAddress }).wait();
|
|
765
772
|
|
|
766
773
|
await expect(
|
|
767
774
|
uniswapL2Contract.methods
|
|
@@ -791,7 +798,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
791
798
|
// Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
792
799
|
logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
|
|
793
800
|
const nonceForWETHTransferToPublicApproval = new Fr(4n);
|
|
794
|
-
const transferToPublicAuhtwit = await
|
|
801
|
+
const transferToPublicAuhtwit = await ownerWallet.createAuthWit({
|
|
795
802
|
caller: uniswapL2Contract.address,
|
|
796
803
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
797
804
|
ownerAddress,
|
|
@@ -919,8 +926,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
919
926
|
|
|
920
927
|
// Owner gives uniswap approval to transfer funds on its behalf
|
|
921
928
|
const nonceForWETHTransferApproval = new Fr(5n);
|
|
922
|
-
const validateActionInteraction = await
|
|
923
|
-
ownerAddress,
|
|
929
|
+
const validateActionInteraction = await ownerWallet.setPublicAuthWit(
|
|
924
930
|
{
|
|
925
931
|
caller: uniswapL2Contract.address,
|
|
926
932
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -932,7 +938,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
932
938
|
},
|
|
933
939
|
true,
|
|
934
940
|
);
|
|
935
|
-
await validateActionInteraction.send().wait();
|
|
941
|
+
await validateActionInteraction.send({ from: ownerAddress }).wait();
|
|
936
942
|
|
|
937
943
|
// Call swap_public on L2
|
|
938
944
|
const secretHashForDepositingSwappedDai = Fr.random();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Convenience struct to hold an account's address and secret that can easily be passed around.
|
|
2
|
-
import { AztecAddress } from '@aztec/aztec.js
|
|
3
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
+
import { AztecAddress, Fr } from '@aztec/aztec.js';
|
|
4
3
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
5
4
|
import type { RollupContract } from '@aztec/ethereum';
|
|
6
5
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
@@ -191,7 +190,7 @@ export class LendingSimulator {
|
|
|
191
190
|
expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
|
|
192
191
|
|
|
193
192
|
for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
|
|
194
|
-
const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from:
|
|
193
|
+
const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: key });
|
|
195
194
|
expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
|
|
196
195
|
expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
|
|
197
196
|
expect(privatePos['debt']).toEqual(
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
3
|
-
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
-
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
1
|
+
import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
|
|
5
2
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
3
|
|
|
7
4
|
import chunk from 'lodash.chunk';
|
|
@@ -107,7 +104,7 @@ export class TokenSimulator {
|
|
|
107
104
|
|
|
108
105
|
const results = (
|
|
109
106
|
await Promise.all(
|
|
110
|
-
chunk(calls,
|
|
107
|
+
chunk(calls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
|
|
111
108
|
)
|
|
112
109
|
).flat();
|
|
113
110
|
expect(results[0]).toEqual(this.totalSupply);
|
package/src/spartan/DEVELOP.md
CHANGED
|
@@ -60,15 +60,10 @@ The export is important there. The `AZTEC_DOCKER_IMAGE` env var is used as both:
|
|
|
60
60
|
- the container that runs the rollup contract deployment
|
|
61
61
|
- the containers for the aztec infrastructure (validators, provers, etc)
|
|
62
62
|
|
|
63
|
-
# Deploy Metrics
|
|
64
|
-
```bash
|
|
65
|
-
./spartan/bootstrap.sh metrics-kind
|
|
66
|
-
```
|
|
67
|
-
|
|
68
63
|
# Deploy stuff
|
|
69
64
|
|
|
70
65
|
```bash
|
|
71
|
-
./spartan/bootstrap.sh network_deploy scenario.local
|
|
66
|
+
./spartan/bootstrap.sh network_deploy scenario.local.env
|
|
72
67
|
```
|
|
73
68
|
|
|
74
69
|
That will take 1-3 minutes. But at the end you should have everything you need.
|
|
@@ -108,10 +103,10 @@ With the cluster running, you can now easily run tests.
|
|
|
108
103
|
|
|
109
104
|
```bash
|
|
110
105
|
# run one
|
|
111
|
-
./spartan/bootstrap.sh single_test scenario.local spartan/smoke.test.ts
|
|
106
|
+
./spartan/bootstrap.sh single_test scenario.local.env spartan/smoke.test.ts
|
|
112
107
|
|
|
113
108
|
# run all (serially)
|
|
114
|
-
./spartan/bootstrap.sh network_tests scenario.local
|
|
109
|
+
./spartan/bootstrap.sh network_tests scenario.local.env
|
|
115
110
|
```
|
|
116
111
|
|
|
117
112
|
Right now, I recommend running the smoke test first, always, as it waits for the committee to exist.
|