@aztec/end-to-end 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.21
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/README.md +2 -0
- package/dest/bench/utils.d.ts +70 -0
- package/dest/bench/utils.d.ts.map +1 -0
- package/dest/bench/utils.js +24 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +46 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +17 -17
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +47 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +27 -16
- package/dest/e2e_deploy_contract/deploy_test.d.ts +28 -0
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -0
- package/dest/e2e_deploy_contract/deploy_test.js +4 -7
- package/dest/e2e_epochs/epochs_test.d.ts +51 -0
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -0
- package/dest/e2e_epochs/epochs_test.js +155 -0
- package/dest/e2e_fees/fees_test.d.ts +73 -0
- package/dest/e2e_fees/fees_test.d.ts.map +1 -0
- package/dest/e2e_fees/fees_test.js +75 -32
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +26 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -0
- package/dest/e2e_nested_contract/nested_contract_test.js +14 -12
- package/dest/e2e_p2p/p2p_network.d.ts +61 -0
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -0
- package/dest/e2e_p2p/p2p_network.js +54 -30
- package/dest/e2e_p2p/shared.d.ts +10 -0
- package/dest/e2e_p2p/shared.d.ts.map +1 -0
- package/dest/e2e_p2p/shared.js +7 -8
- package/dest/e2e_prover/e2e_prover_test.d.ts +56 -0
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -0
- package/dest/e2e_prover/e2e_prover_test.js +20 -24
- package/dest/e2e_token_contract/token_contract_test.d.ts +29 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -0
- package/dest/e2e_token_contract/token_contract_test.js +4 -7
- package/dest/fixtures/fixtures.d.ts +17 -0
- package/dest/fixtures/fixtures.d.ts.map +1 -0
- package/dest/fixtures/fixtures.js +2 -2
- package/dest/fixtures/get_acvm_config.d.ts +8 -0
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -0
- package/dest/fixtures/get_acvm_config.js +10 -5
- package/dest/fixtures/get_bb_config.d.ts +6 -0
- package/dest/fixtures/get_bb_config.d.ts.map +1 -0
- package/dest/fixtures/get_bb_config.js +9 -4
- package/dest/fixtures/index.d.ts +6 -0
- package/dest/fixtures/index.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts +13 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.js +1 -1
- package/dest/fixtures/logging.d.ts +8 -0
- package/dest/fixtures/logging.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.d.ts +6 -0
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.js +6 -4
- package/dest/fixtures/setup_p2p_test.d.ts +22 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -0
- package/dest/fixtures/setup_p2p_test.js +5 -3
- package/dest/fixtures/snapshot_manager.d.ts +87 -0
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -0
- package/dest/fixtures/snapshot_manager.js +67 -74
- package/dest/fixtures/token_utils.d.ts +6 -0
- package/dest/fixtures/token_utils.d.ts.map +1 -0
- package/dest/fixtures/token_utils.js +1 -1
- package/dest/fixtures/utils.d.ts +155 -0
- package/dest/fixtures/utils.d.ts.map +1 -0
- package/dest/fixtures/utils.js +97 -71
- package/dest/fixtures/with_telemetry_utils.d.ts +3 -0
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.d.ts +41 -0
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.js +4 -1
- package/dest/sample-dapp/index.js +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +124 -0
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -0
- package/dest/shared/cross_chain_test_harness.js +6 -17
- package/dest/shared/gas_portal_test_harness.d.ts +80 -0
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -0
- package/dest/shared/gas_portal_test_harness.js +11 -4
- package/dest/shared/index.d.ts +2 -0
- package/dest/shared/index.d.ts.map +1 -0
- package/dest/shared/index.js +0 -1
- package/dest/shared/jest_setup.d.ts +2 -0
- package/dest/shared/jest_setup.d.ts.map +1 -0
- package/dest/shared/submit-transactions.d.ts +4 -0
- package/dest/shared/submit-transactions.d.ts.map +1 -0
- package/dest/shared/submit-transactions.js +9 -17
- package/dest/shared/uniswap_l1_l2.d.ts +25 -0
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -0
- package/dest/shared/uniswap_l1_l2.js +5 -10
- package/dest/simulators/index.d.ts +3 -0
- package/dest/simulators/index.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.d.ts +69 -0
- package/dest/simulators/lending_simulator.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.js +1 -3
- package/dest/simulators/token_simulator.d.ts +29 -0
- package/dest/simulators/token_simulator.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.d.ts +20 -0
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.js +72 -38
- package/dest/spartan/utils.d.ts +415 -0
- package/dest/spartan/utils.d.ts.map +1 -0
- package/dest/spartan/utils.js +169 -43
- package/package.json +35 -40
- package/src/bench/utils.ts +30 -13
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +40 -30
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +34 -18
- package/src/e2e_deploy_contract/deploy_test.ts +6 -11
- package/src/e2e_epochs/epochs_test.ts +217 -0
- package/src/e2e_fees/fees_test.ts +84 -38
- package/src/e2e_nested_contract/nested_contract_test.ts +14 -16
- package/src/e2e_p2p/p2p_network.ts +67 -47
- package/src/e2e_p2p/shared.ts +16 -10
- package/src/e2e_prover/e2e_prover_test.ts +56 -37
- package/src/e2e_token_contract/token_contract_test.ts +10 -11
- package/src/fixtures/fixtures.ts +2 -2
- package/src/fixtures/get_acvm_config.ts +7 -3
- package/src/fixtures/get_bb_config.ts +6 -2
- package/src/fixtures/l1_to_l2_messaging.ts +6 -13
- package/src/fixtures/setup_l1_contracts.ts +8 -7
- package/src/fixtures/setup_p2p_test.ts +8 -6
- package/src/fixtures/snapshot_manager.ts +72 -79
- package/src/fixtures/token_utils.ts +2 -2
- package/src/fixtures/utils.ts +135 -97
- package/src/guides/up_quick_start.sh +10 -5
- package/src/quality_of_service/alert_checker.ts +6 -2
- package/src/sample-dapp/index.mjs +1 -1
- package/src/shared/cross_chain_test_harness.ts +17 -35
- package/src/shared/gas_portal_test_harness.ts +21 -11
- package/src/shared/index.ts +0 -1
- package/src/shared/submit-transactions.ts +16 -20
- package/src/shared/uniswap_l1_l2.ts +35 -26
- package/src/simulators/lending_simulator.ts +5 -6
- package/src/simulators/token_simulator.ts +1 -1
- package/src/spartan/setup_test_wallets.ts +111 -37
- package/src/spartan/utils.ts +161 -54
- package/dest/shared/browser.js +0 -163
- package/src/shared/browser.ts +0 -272
|
@@ -2,18 +2,19 @@ import {
|
|
|
2
2
|
type AztecAddress,
|
|
3
3
|
type AztecNode,
|
|
4
4
|
EthAddress,
|
|
5
|
+
Fr,
|
|
5
6
|
L1FeeJuicePortalManager,
|
|
6
7
|
type L1TokenManager,
|
|
7
8
|
type L2AmountClaim,
|
|
8
9
|
type Logger,
|
|
9
10
|
type PXE,
|
|
10
11
|
type Wallet,
|
|
12
|
+
retryUntil,
|
|
11
13
|
} from '@aztec/aztec.js';
|
|
14
|
+
import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
|
|
12
15
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
13
16
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
14
17
|
|
|
15
|
-
import { type Account, type Chain, type HttpTransport, type PublicClient, type WalletClient } from 'viem';
|
|
16
|
-
|
|
17
18
|
export interface IGasBridgingTestHarness {
|
|
18
19
|
getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
|
|
19
20
|
prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
|
|
@@ -25,8 +26,8 @@ export interface IGasBridgingTestHarness {
|
|
|
25
26
|
export interface FeeJuicePortalTestingHarnessFactoryConfig {
|
|
26
27
|
aztecNode: AztecNode;
|
|
27
28
|
pxeService: PXE;
|
|
28
|
-
publicClient:
|
|
29
|
-
walletClient:
|
|
29
|
+
publicClient: ViemPublicClient;
|
|
30
|
+
walletClient: ViemWalletClient;
|
|
30
31
|
wallet: Wallet;
|
|
31
32
|
logger: Logger;
|
|
32
33
|
mockL1?: boolean;
|
|
@@ -74,8 +75,8 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
74
75
|
* shared between cross chain tests.
|
|
75
76
|
*/
|
|
76
77
|
export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
public readonly l1TokenManager: L1TokenManager;
|
|
79
|
+
public readonly feeJuicePortalManager: L1FeeJuicePortalManager;
|
|
79
80
|
|
|
80
81
|
constructor(
|
|
81
82
|
/** Aztec node */
|
|
@@ -96,9 +97,9 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
96
97
|
/** Underlying token for portal tests. */
|
|
97
98
|
public l1FeeJuiceAddress: EthAddress,
|
|
98
99
|
/** Viem Public client instance. */
|
|
99
|
-
public publicClient:
|
|
100
|
+
public publicClient: ViemPublicClient,
|
|
100
101
|
/** Viem Wallet Client instance. */
|
|
101
|
-
public walletClient:
|
|
102
|
+
public walletClient: ViemWalletClient,
|
|
102
103
|
) {
|
|
103
104
|
this.feeJuicePortalManager = new L1FeeJuicePortalManager(
|
|
104
105
|
this.feeJuicePortalAddress,
|
|
@@ -143,9 +144,12 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
143
144
|
async prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress) {
|
|
144
145
|
const claim = await this.sendTokensToPortalPublic(bridgeAmount, owner, true);
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
await
|
|
148
|
-
|
|
147
|
+
const isSynced = async () => await this.aztecNode.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
|
|
148
|
+
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 1);
|
|
149
|
+
|
|
150
|
+
// Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
151
|
+
await this.advanceL2Block();
|
|
152
|
+
await this.advanceL2Block();
|
|
149
153
|
|
|
150
154
|
return claim;
|
|
151
155
|
}
|
|
@@ -158,5 +162,11 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
|
|
|
158
162
|
await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
|
|
159
163
|
await this.expectPublicBalanceOnL2(owner, bridgeAmount);
|
|
160
164
|
}
|
|
165
|
+
|
|
166
|
+
private async advanceL2Block() {
|
|
167
|
+
const initialBlockNumber = await this.aztecNode.getBlockNumber();
|
|
168
|
+
await this.aztecNode.flushTxs();
|
|
169
|
+
await retryUntil(async () => (await this.aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
|
|
170
|
+
}
|
|
161
171
|
}
|
|
162
172
|
// docs:end:cross_chain_test_harness
|
package/src/shared/index.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type Logger, TxStatus } from '@aztec/aztec.js';
|
|
3
|
-
import {
|
|
2
|
+
import { Fr, GrumpkinScalar, type Logger, type SentTx, TxStatus, type Wallet } from '@aztec/aztec.js';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import type { PXEService } from '@aztec/pxe';
|
|
4
5
|
|
|
5
6
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
6
|
-
export const submitTxsTo = async (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
provenTxs.push(tx);
|
|
18
|
-
}
|
|
19
|
-
const sentTxs = await Promise.all(
|
|
20
|
-
provenTxs.map(async provenTx => {
|
|
21
|
-
const tx = provenTx.send();
|
|
7
|
+
export const submitTxsTo = async (
|
|
8
|
+
pxe: PXEService,
|
|
9
|
+
numTxs: number,
|
|
10
|
+
wallet: Wallet,
|
|
11
|
+
logger: Logger,
|
|
12
|
+
): Promise<SentTx[]> => {
|
|
13
|
+
const txs: SentTx[] = [];
|
|
14
|
+
await Promise.all(
|
|
15
|
+
times(numTxs, async () => {
|
|
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}`);
|
|
@@ -30,8 +26,8 @@ export const submitTxsTo = async (pxe: PXEService, numTxs: number, logger: Logge
|
|
|
30
26
|
}),
|
|
31
27
|
);
|
|
32
28
|
logger.info(`Receipt received for ${txHash}`);
|
|
33
|
-
|
|
29
|
+
txs.push(tx);
|
|
34
30
|
}),
|
|
35
31
|
);
|
|
36
|
-
return
|
|
32
|
+
return txs;
|
|
37
33
|
};
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
type AccountWallet,
|
|
3
3
|
AztecAddress,
|
|
4
4
|
type AztecNode,
|
|
5
|
+
type CheatCodes,
|
|
5
6
|
EthAddress,
|
|
6
7
|
Fr,
|
|
7
8
|
type Logger,
|
|
@@ -9,24 +10,19 @@ import {
|
|
|
9
10
|
computeAuthWitMessageHash,
|
|
10
11
|
generateClaimSecret,
|
|
11
12
|
} from '@aztec/aztec.js';
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type DeployL1ContractsReturnType,
|
|
15
|
+
type ViemPublicClient,
|
|
16
|
+
type ViemWalletClient,
|
|
17
|
+
deployL1Contract,
|
|
18
|
+
extractEvent,
|
|
19
|
+
} from '@aztec/ethereum';
|
|
13
20
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
14
21
|
import { InboxAbi, RollupAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
15
22
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
16
23
|
|
|
17
24
|
import { jest } from '@jest/globals';
|
|
18
|
-
import {
|
|
19
|
-
type Account,
|
|
20
|
-
type Chain,
|
|
21
|
-
type GetContractReturnType,
|
|
22
|
-
type HttpTransport,
|
|
23
|
-
type PublicClient,
|
|
24
|
-
type WalletClient,
|
|
25
|
-
getContract,
|
|
26
|
-
parseEther,
|
|
27
|
-
toFunctionSelector,
|
|
28
|
-
} from 'viem';
|
|
29
|
-
import type * as chains from 'viem/chains';
|
|
25
|
+
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
30
26
|
|
|
31
27
|
import { ensureAccountsPubliclyDeployed } from '../fixtures/utils.js';
|
|
32
28
|
import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
@@ -50,15 +46,17 @@ export type UniswapSetupContext = {
|
|
|
50
46
|
/** Logger instance named as the current test. */
|
|
51
47
|
logger: Logger;
|
|
52
48
|
/** Viem Public client instance. */
|
|
53
|
-
publicClient:
|
|
49
|
+
publicClient: ViemPublicClient;
|
|
54
50
|
/** Viem Wallet Client instance. */
|
|
55
|
-
walletClient:
|
|
51
|
+
walletClient: ViemWalletClient;
|
|
56
52
|
/** The owner wallet. */
|
|
57
53
|
ownerWallet: AccountWallet;
|
|
58
54
|
/** The sponsor wallet. */
|
|
59
55
|
sponsorWallet: AccountWallet;
|
|
60
56
|
/** */
|
|
61
|
-
deployL1ContractsValues:
|
|
57
|
+
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
58
|
+
/** Cheat codes instance. */
|
|
59
|
+
cheatCodes: CheatCodes;
|
|
62
60
|
};
|
|
63
61
|
// docs:end:uniswap_l1_l2_test_setup_const
|
|
64
62
|
|
|
@@ -78,8 +76,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
78
76
|
let pxe: PXE;
|
|
79
77
|
let logger: Logger;
|
|
80
78
|
|
|
81
|
-
let walletClient:
|
|
82
|
-
let publicClient:
|
|
79
|
+
let walletClient: ViemWalletClient;
|
|
80
|
+
let publicClient: ViemPublicClient;
|
|
83
81
|
|
|
84
82
|
let ownerWallet: AccountWallet;
|
|
85
83
|
let ownerAddress: AztecAddress;
|
|
@@ -91,9 +89,9 @@ export const uniswapL1L2TestSuite = (
|
|
|
91
89
|
let daiCrossChainHarness: CrossChainTestHarness;
|
|
92
90
|
let wethCrossChainHarness: CrossChainTestHarness;
|
|
93
91
|
|
|
94
|
-
let deployL1ContractsValues:
|
|
95
|
-
let rollup: GetContractReturnType<typeof RollupAbi,
|
|
96
|
-
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi,
|
|
92
|
+
let deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
93
|
+
let rollup: GetContractReturnType<typeof RollupAbi, ViemWalletClient>;
|
|
94
|
+
let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ViemWalletClient>;
|
|
97
95
|
let uniswapPortalAddress: EthAddress;
|
|
98
96
|
let uniswapL2Contract: UniswapContract;
|
|
99
97
|
|
|
@@ -101,9 +99,20 @@ export const uniswapL1L2TestSuite = (
|
|
|
101
99
|
const uniswapFeeTier = 3000n;
|
|
102
100
|
const minimumOutputAmount = 0n;
|
|
103
101
|
|
|
102
|
+
let cheatCodes: CheatCodes;
|
|
103
|
+
|
|
104
104
|
beforeAll(async () => {
|
|
105
|
-
({
|
|
106
|
-
|
|
105
|
+
({
|
|
106
|
+
aztecNode,
|
|
107
|
+
pxe,
|
|
108
|
+
logger,
|
|
109
|
+
publicClient,
|
|
110
|
+
walletClient,
|
|
111
|
+
ownerWallet,
|
|
112
|
+
sponsorWallet,
|
|
113
|
+
deployL1ContractsValues,
|
|
114
|
+
cheatCodes,
|
|
115
|
+
} = await setup());
|
|
107
116
|
|
|
108
117
|
if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
|
|
109
118
|
throw new Error('This test must be run on a fork of mainnet with the expected fork block');
|
|
@@ -279,7 +288,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
279
288
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
280
289
|
|
|
281
290
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
282
|
-
await rollup.
|
|
291
|
+
await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
|
|
283
292
|
|
|
284
293
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
285
294
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
@@ -890,7 +899,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
890
899
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
891
900
|
|
|
892
901
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
893
|
-
await rollup.
|
|
902
|
+
await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
|
|
894
903
|
|
|
895
904
|
// On L1 call swap_public!
|
|
896
905
|
logger.info('call swap_public on L1');
|
|
@@ -1020,7 +1029,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1020
1029
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
1021
1030
|
|
|
1022
1031
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
1023
|
-
await rollup.
|
|
1032
|
+
await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
|
|
1024
1033
|
|
|
1025
1034
|
// Call swap_private on L1
|
|
1026
1035
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { AztecAddress, type CheatCodes, Fr } from '@aztec/aztec.js';
|
|
3
3
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
4
4
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import type { RollupAbi } from '@aztec/l1-artifacts';
|
|
6
|
+
import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import type { Account, GetContractReturnType, HttpTransport, WalletClient } from 'viem';
|
|
9
9
|
import type * as chains from 'viem/chains';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import type { TokenSimulator } from './token_simulator.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Contains utilities to compute the "key" for private holdings in the public state.
|
|
@@ -115,8 +115,7 @@ export class LendingSimulator {
|
|
|
115
115
|
if (dateProvider) {
|
|
116
116
|
dateProvider.setTime(this.time * 1000);
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
await this.rollup.write.setAssumeProvenThroughBlockNumber([(await this.rollup.read.getPendingBlockNumber()) + 1n]);
|
|
118
|
+
await this.cc.rollup.markAsProven(await this.rollup.read.getPendingBlockNumber());
|
|
120
119
|
this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
|
|
121
120
|
}
|
|
122
121
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable jsdoc/require-jsdoc */
|
|
2
2
|
import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
4
|
|
|
5
5
|
import chunk from 'lodash.chunk';
|
|
6
6
|
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getSchnorrAccount, getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { generateSchnorrAccounts, getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
|
|
3
|
+
import {
|
|
4
|
+
type AccountWalletWithSecretKey,
|
|
5
|
+
type AztecAddress,
|
|
6
|
+
type AztecNode,
|
|
7
|
+
FeeJuicePaymentMethodWithClaim,
|
|
8
|
+
Fr,
|
|
9
|
+
L1FeeJuicePortalManager,
|
|
10
|
+
type PXE,
|
|
11
|
+
createAztecNodeClient,
|
|
12
|
+
createCompatibleClient,
|
|
13
|
+
retryUntil,
|
|
14
|
+
} from '@aztec/aztec.js';
|
|
15
|
+
import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
|
|
16
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
17
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
18
|
|
|
6
|
-
import { addAccounts } from '../fixtures/snapshot_manager.js';
|
|
7
|
-
|
|
8
19
|
export interface TestWallets {
|
|
9
20
|
pxe: PXE;
|
|
10
21
|
wallets: AccountWalletWithSecretKey[];
|
|
@@ -14,69 +25,132 @@ export interface TestWallets {
|
|
|
14
25
|
tokenAddress: AztecAddress;
|
|
15
26
|
}
|
|
16
27
|
|
|
28
|
+
const TOKEN_NAME = 'USDC';
|
|
29
|
+
const TOKEN_SYMBOL = 'USD';
|
|
30
|
+
const TOKEN_DECIMALS = 18n;
|
|
31
|
+
|
|
17
32
|
export async function setupTestWalletsWithTokens(
|
|
18
33
|
pxeUrl: string,
|
|
19
34
|
mintAmount: bigint,
|
|
20
35
|
logger: Logger,
|
|
21
36
|
): Promise<TestWallets> {
|
|
22
|
-
const TOKEN_NAME = 'USDC';
|
|
23
|
-
const TOKEN_SYMBOL = 'USD';
|
|
24
|
-
const TOKEN_DECIMALS = 18n;
|
|
25
|
-
|
|
26
37
|
const WALLET_COUNT = 1; // TODO fix this to allow for 16 wallets again
|
|
27
38
|
|
|
28
|
-
let recipientWallet: AccountWalletWithSecretKey;
|
|
29
|
-
|
|
30
39
|
const pxe = await createCompatibleClient(pxeUrl, logger);
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
const { accountKeys } = await addAccounts(1, logger, false)({ pxe });
|
|
34
|
-
const accountManagers = await Promise.all(accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)));
|
|
41
|
+
const [recipientWallet, ...wallets] = (await getDeployedTestAccountsWallets(pxe)).slice(0, WALLET_COUNT + 1);
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
const tokenAdmin = wallets[0];
|
|
44
|
+
const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, logger);
|
|
45
|
+
const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
|
|
46
|
+
|
|
47
|
+
return { pxe, wallets, tokenAdminWallet, tokenName: TOKEN_NAME, tokenAddress, recipientWallet };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function deployTestWalletWithTokens(
|
|
51
|
+
pxeUrl: string,
|
|
52
|
+
nodeUrl: string,
|
|
53
|
+
l1RpcUrl: string,
|
|
54
|
+
mnemonicOrPrivateKey: string,
|
|
55
|
+
mintAmount: bigint,
|
|
56
|
+
logger: Logger,
|
|
57
|
+
numberOfFundedWallets = 1,
|
|
58
|
+
initialFeeJuice = 10n ** 22n,
|
|
59
|
+
): Promise<TestWallets> {
|
|
60
|
+
const pxe = await createCompatibleClient(pxeUrl, logger);
|
|
61
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
62
|
+
|
|
63
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
64
|
+
const recipientWallet = await getSchnorrWalletWithSecretKey(
|
|
65
|
+
pxe,
|
|
66
|
+
recipient.secret,
|
|
67
|
+
recipient.signingKey,
|
|
68
|
+
recipient.salt,
|
|
69
|
+
);
|
|
70
|
+
const fundedAccounts = await Promise.all(funded.map(a => getSchnorrAccount(pxe, a.secret, a.signingKey, a.salt)));
|
|
71
|
+
|
|
72
|
+
const claims = await Promise.all(
|
|
73
|
+
fundedAccounts.map(a =>
|
|
74
|
+
bridgeL1FeeJuice(l1RpcUrl, mnemonicOrPrivateKey, pxe, a.getAddress(), initialFeeJuice, logger),
|
|
75
|
+
),
|
|
76
|
+
);
|
|
42
77
|
|
|
43
|
-
|
|
44
|
-
|
|
78
|
+
// Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
|
|
79
|
+
await advanceL2Block(node);
|
|
80
|
+
await advanceL2Block(node);
|
|
45
81
|
|
|
46
82
|
const wallets = await Promise.all(
|
|
47
|
-
|
|
48
|
-
const completeAddress = await a.getCompleteAddress();
|
|
49
|
-
const partialAddress = completeAddress.partialAddress;
|
|
50
|
-
await pxe.registerAccount(accountKeys[i][0], partialAddress);
|
|
83
|
+
fundedAccounts.map(async (a, i) => {
|
|
51
84
|
const wallet = await a.getWallet();
|
|
52
|
-
|
|
85
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(wallet, claims[i]);
|
|
86
|
+
await a.deploy({ fee: { paymentMethod } }).wait();
|
|
87
|
+
logger.info(`Account deployed at ${a.getAddress()}`);
|
|
53
88
|
return wallet;
|
|
54
89
|
}),
|
|
55
90
|
);
|
|
56
91
|
|
|
92
|
+
const tokenAdmin = wallets[0];
|
|
93
|
+
const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, logger);
|
|
94
|
+
const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
|
|
95
|
+
|
|
96
|
+
return { pxe, wallets, tokenAdminWallet, tokenName: TOKEN_NAME, tokenAddress, recipientWallet };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function bridgeL1FeeJuice(
|
|
100
|
+
l1RpcUrl: string,
|
|
101
|
+
mnemonicOrPrivateKey: string,
|
|
102
|
+
pxe: PXE,
|
|
103
|
+
recipient: AztecAddress,
|
|
104
|
+
amount: bigint,
|
|
105
|
+
log: Logger,
|
|
106
|
+
) {
|
|
107
|
+
const { l1ChainId } = await pxe.getNodeInfo();
|
|
108
|
+
const chain = createEthereumChain([l1RpcUrl], l1ChainId);
|
|
109
|
+
const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
|
|
110
|
+
|
|
111
|
+
const portal = await L1FeeJuicePortalManager.new(pxe, publicClient, walletClient, log);
|
|
112
|
+
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
113
|
+
|
|
114
|
+
const isSynced = async () => await pxe.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
|
|
115
|
+
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
116
|
+
|
|
117
|
+
log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
|
|
118
|
+
return claim;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function advanceL2Block(node: AztecNode) {
|
|
122
|
+
const initialBlockNumber = await node.getBlockNumber();
|
|
123
|
+
await node!.flushTxs();
|
|
124
|
+
await retryUntil(async () => (await node.getBlockNumber()) >= initialBlockNumber + 1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function deployTokenAndMint(
|
|
128
|
+
wallets: AccountWalletWithSecretKey[],
|
|
129
|
+
admin: AztecAddress,
|
|
130
|
+
mintAmount: bigint,
|
|
131
|
+
logger: Logger,
|
|
132
|
+
) {
|
|
57
133
|
logger.verbose(`Deploying TokenContract...`);
|
|
58
|
-
const tokenContract = await TokenContract.deploy(
|
|
59
|
-
wallets[0],
|
|
60
|
-
wallets[0].getAddress(),
|
|
61
|
-
TOKEN_NAME,
|
|
62
|
-
TOKEN_SYMBOL,
|
|
63
|
-
TOKEN_DECIMALS,
|
|
64
|
-
)
|
|
134
|
+
const tokenContract = await TokenContract.deploy(wallets[0], admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS)
|
|
65
135
|
.send()
|
|
66
136
|
.deployed({ timeout: 600 });
|
|
67
137
|
|
|
68
138
|
const tokenAddress = tokenContract.address;
|
|
69
|
-
const tokenAdminWallet = await TokenContract.at(tokenAddress, wallets[0]);
|
|
70
139
|
|
|
71
140
|
logger.verbose(`Minting ${mintAmount} public assets to the ${wallets.length} wallets...`);
|
|
72
141
|
|
|
73
142
|
await Promise.all(
|
|
74
|
-
wallets.map(w =>
|
|
143
|
+
wallets.map(async w =>
|
|
144
|
+
(await TokenContract.at(tokenAddress, w)).methods
|
|
145
|
+
.mint_to_public(w.getAddress(), mintAmount)
|
|
146
|
+
.send()
|
|
147
|
+
.wait({ timeout: 600 }),
|
|
148
|
+
),
|
|
75
149
|
);
|
|
76
150
|
|
|
77
151
|
logger.verbose(`Minting complete.`);
|
|
78
152
|
|
|
79
|
-
return
|
|
153
|
+
return tokenAddress;
|
|
80
154
|
}
|
|
81
155
|
|
|
82
156
|
export async function performTransfers({
|