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