@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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 +4 -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 +25 -14
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +111 -90
- package/dest/bench/client_flows/config.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.d.ts +1 -1
- package/dest/bench/client_flows/data_extractor.js +8 -30
- package/dest/bench/utils.d.ts +4 -13
- 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 +8 -8
- 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 +12 -9
- 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 +35 -35
- package/dest/e2e_deploy_contract/deploy_test.d.ts +12 -6
- 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 +19 -12
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +30 -22
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +14 -11
- package/dest/e2e_fees/fees_test.d.ts +10 -8
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +35 -38
- package/dest/e2e_l1_publisher/write_json.d.ts +4 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +9 -8
- package/dest/e2e_multi_validator/utils.d.ts +2 -2
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +4 -10
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -4
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +11 -12
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +238 -17
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +46 -19
- package/dest/e2e_p2p/shared.d.ts +16 -17
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +56 -55
- package/dest/e2e_token_contract/token_contract_test.d.ts +6 -5
- 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 +12 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +53 -58
- package/dest/fixtures/fixtures.d.ts +1 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +1 -1
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +1 -1
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +2 -2
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +3 -3
- package/dest/fixtures/setup_p2p_test.d.ts +12 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +50 -24
- package/dest/fixtures/snapshot_manager.d.ts +13 -10
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +66 -51
- package/dest/fixtures/token_utils.d.ts +10 -5
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +17 -18
- package/dest/fixtures/utils.d.ts +479 -35
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +106 -125
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +20 -23
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +14 -16
- package/dest/shared/gas_portal_test_harness.d.ts +10 -17
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +11 -8
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- 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 +12 -8
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +44 -58
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +4 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +8 -5
- package/dest/simulators/token_simulator.d.ts +4 -2
- 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 +22 -14
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +144 -86
- package/dest/spartan/tx_metrics.d.ts +39 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +95 -0
- package/dest/spartan/utils.d.ts +92 -17
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +386 -63
- package/package.json +43 -40
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +141 -114
- package/src/bench/client_flows/data_extractor.ts +9 -31
- 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 +38 -51
- package/src/e2e_deploy_contract/deploy_test.ts +18 -36
- package/src/e2e_epochs/epochs_test.ts +41 -35
- package/src/e2e_fees/bridging_race.notest.ts +16 -11
- package/src/e2e_fees/fees_test.ts +42 -47
- package/src/e2e_l1_publisher/write_json.ts +12 -9
- package/src/e2e_multi_validator/utils.ts +5 -11
- package/src/e2e_nested_contract/nested_contract_test.ts +15 -13
- package/src/e2e_p2p/inactivity_slash_test.ts +184 -0
- package/src/e2e_p2p/p2p_network.ts +124 -82
- package/src/e2e_p2p/shared.ts +66 -58
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +60 -97
- package/src/fixtures/fixtures.ts +1 -2
- package/src/fixtures/get_acvm_config.ts +2 -2
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/l1_to_l2_messaging.ts +4 -2
- package/src/fixtures/setup_l1_contracts.ts +5 -4
- package/src/fixtures/setup_p2p_test.ts +79 -32
- package/src/fixtures/snapshot_manager.ts +87 -82
- package/src/fixtures/token_utils.ts +16 -24
- package/src/fixtures/utils.ts +142 -172
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +3 -11
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +23 -31
- package/src/shared/gas_portal_test_harness.ts +14 -21
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +77 -86
- package/src/simulators/lending_simulator.ts +9 -6
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +15 -3
- package/src/spartan/setup_test_wallets.ts +171 -127
- package/src/spartan/tx_metrics.ts +130 -0
- package/src/spartan/utils.ts +463 -64
|
@@ -1,27 +1,20 @@
|
|
|
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
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
extractEvent,
|
|
19
|
-
} from '@aztec/ethereum';
|
|
20
|
-
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
8
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
9
|
+
import { type DeployL1ContractsReturnType, deployL1Contract } from '@aztec/ethereum/deploy-l1-contracts';
|
|
10
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
11
|
+
import { extractEvent } from '@aztec/ethereum/utils';
|
|
12
|
+
import { sha256ToField } from '@aztec/foundation/crypto/sha256';
|
|
21
13
|
import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
|
|
22
14
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
23
15
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
24
16
|
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
17
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
25
18
|
|
|
26
19
|
import { jest } from '@jest/globals';
|
|
27
20
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
@@ -36,36 +29,33 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
|
|
|
36
29
|
// anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
|
|
37
30
|
// For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
|
|
38
31
|
|
|
39
|
-
// docs:start:uniswap_l1_l2_test_setup_const
|
|
40
32
|
const TIMEOUT = 360_000;
|
|
41
33
|
|
|
42
34
|
/** Objects to be returned by the uniswap setup function */
|
|
43
35
|
export type UniswapSetupContext = {
|
|
44
36
|
/** Aztec Node instance */
|
|
45
37
|
aztecNode: AztecNode;
|
|
46
|
-
/** The Private eXecution Environment (PXE). */
|
|
47
|
-
pxe: PXE;
|
|
48
38
|
/** Logger instance named as the current test. */
|
|
49
39
|
logger: Logger;
|
|
50
40
|
/** The L1 wallet client, extended with public actions. */
|
|
51
41
|
l1Client: ExtendedViemWalletClient;
|
|
52
|
-
/** The
|
|
53
|
-
|
|
42
|
+
/** The wallet. */
|
|
43
|
+
wallet: TestWallet;
|
|
44
|
+
/** The owner address. */
|
|
45
|
+
ownerAddress: AztecAddress;
|
|
54
46
|
/** The sponsor wallet. */
|
|
55
|
-
|
|
47
|
+
sponsorAddress: AztecAddress;
|
|
56
48
|
/** */
|
|
57
49
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
58
50
|
/** Cheat codes instance. */
|
|
59
51
|
cheatCodes: CheatCodes;
|
|
60
52
|
};
|
|
61
|
-
// docs:end:uniswap_l1_l2_test_setup_const
|
|
62
53
|
|
|
63
54
|
export const uniswapL1L2TestSuite = (
|
|
64
55
|
setup: () => Promise<UniswapSetupContext>,
|
|
65
56
|
cleanup: () => Promise<void>,
|
|
66
57
|
expectedForkBlockNumber = 17514288,
|
|
67
58
|
) => {
|
|
68
|
-
// docs:start:uniswap_l1_l2_test_beforeAll
|
|
69
59
|
describe('uniswap_trade_on_l1_from_l2', () => {
|
|
70
60
|
jest.setTimeout(TIMEOUT);
|
|
71
61
|
|
|
@@ -73,16 +63,14 @@ export const uniswapL1L2TestSuite = (
|
|
|
73
63
|
const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
|
|
74
64
|
|
|
75
65
|
let aztecNode: AztecNode;
|
|
76
|
-
let pxe: PXE;
|
|
77
66
|
let logger: Logger;
|
|
78
67
|
|
|
79
68
|
let l1Client: ExtendedViemWalletClient;
|
|
80
69
|
|
|
81
|
-
let
|
|
70
|
+
let wallet: TestWallet;
|
|
82
71
|
let ownerAddress: AztecAddress;
|
|
83
72
|
let ownerEthAddress: EthAddress;
|
|
84
73
|
// does transactions on behalf of owner on Aztec:
|
|
85
|
-
let sponsorWallet: AccountWallet;
|
|
86
74
|
let sponsorAddress: AztecAddress;
|
|
87
75
|
|
|
88
76
|
let daiCrossChainHarness: CrossChainTestHarness;
|
|
@@ -101,7 +89,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
101
89
|
let cheatCodes: CheatCodes;
|
|
102
90
|
let version: number;
|
|
103
91
|
beforeAll(async () => {
|
|
104
|
-
({ aztecNode,
|
|
92
|
+
({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } =
|
|
105
93
|
await setup());
|
|
106
94
|
|
|
107
95
|
if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
|
|
@@ -113,18 +101,15 @@ export const uniswapL1L2TestSuite = (
|
|
|
113
101
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
114
102
|
);
|
|
115
103
|
version = Number(await rollup.getVersion());
|
|
116
|
-
ownerAddress = ownerWallet.getAddress();
|
|
117
|
-
sponsorAddress = sponsorWallet.getAddress();
|
|
118
104
|
ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
|
|
119
105
|
|
|
120
|
-
await ensureAccountContractsPublished(
|
|
106
|
+
await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
|
|
121
107
|
|
|
122
108
|
logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
|
|
123
109
|
daiCrossChainHarness = await CrossChainTestHarness.new(
|
|
124
110
|
aztecNode,
|
|
125
|
-
pxe,
|
|
126
111
|
deployL1ContractsValues.l1Client,
|
|
127
|
-
|
|
112
|
+
wallet,
|
|
128
113
|
ownerAddress,
|
|
129
114
|
logger,
|
|
130
115
|
DAI_ADDRESS,
|
|
@@ -133,9 +118,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
133
118
|
logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
|
|
134
119
|
wethCrossChainHarness = await CrossChainTestHarness.new(
|
|
135
120
|
aztecNode,
|
|
136
|
-
pxe,
|
|
137
121
|
l1Client,
|
|
138
|
-
|
|
122
|
+
wallet,
|
|
139
123
|
ownerAddress,
|
|
140
124
|
logger,
|
|
141
125
|
WETH9_ADDRESS,
|
|
@@ -152,11 +136,11 @@ export const uniswapL1L2TestSuite = (
|
|
|
152
136
|
client: l1Client,
|
|
153
137
|
});
|
|
154
138
|
// deploy l2 uniswap contract and attach to portal
|
|
155
|
-
uniswapL2Contract = await UniswapContract.deploy(
|
|
139
|
+
uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress)
|
|
156
140
|
.send({ from: ownerAddress })
|
|
157
141
|
.deployed();
|
|
158
142
|
|
|
159
|
-
const registryAddress = (await
|
|
143
|
+
const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
|
|
160
144
|
|
|
161
145
|
await uniswapPortal.write.initialize(
|
|
162
146
|
[registryAddress.toString(), uniswapL2Contract.address.toString()],
|
|
@@ -171,7 +155,6 @@ export const uniswapL1L2TestSuite = (
|
|
|
171
155
|
const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
|
|
172
156
|
expect(wethBalance).toBe(parseEther('1000'));
|
|
173
157
|
});
|
|
174
|
-
// docs:end:uniswap_l1_l2_test_beforeAll
|
|
175
158
|
|
|
176
159
|
afterAll(async () => {
|
|
177
160
|
await cleanup();
|
|
@@ -206,7 +189,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
206
189
|
// 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
207
190
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
208
191
|
const nonceForWETHTransferToPublicApproval = new Fr(1n);
|
|
209
|
-
const transferToPublicAuhtwit = await
|
|
192
|
+
const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
|
|
210
193
|
caller: uniswapL2Contract.address,
|
|
211
194
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
212
195
|
ownerAddress,
|
|
@@ -276,7 +259,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
276
259
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
277
260
|
|
|
278
261
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
279
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
262
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
280
263
|
|
|
281
264
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
282
265
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
@@ -301,7 +284,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
301
284
|
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
302
285
|
|
|
303
286
|
const withdrawMessageMetadata = {
|
|
304
|
-
|
|
287
|
+
_checkpointNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
|
|
305
288
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
306
289
|
_path: withdrawSiblingPath
|
|
307
290
|
.toBufferArray()
|
|
@@ -309,7 +292,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
309
292
|
};
|
|
310
293
|
|
|
311
294
|
const swapPrivateMessageMetadata = {
|
|
312
|
-
|
|
295
|
+
_checkpointNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
|
|
313
296
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
314
297
|
_path: swapPrivateSiblingPath
|
|
315
298
|
.toBufferArray()
|
|
@@ -520,7 +503,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
520
503
|
// );
|
|
521
504
|
|
|
522
505
|
// const withdrawMessageMetadata = {
|
|
523
|
-
//
|
|
506
|
+
// _checkpointNumber: BigInt(uniswapL2Interaction.blockNumber!),
|
|
524
507
|
// _leafIndex: BigInt(withdrawL2MessageIndex),
|
|
525
508
|
// _path: withdrawSiblingPath
|
|
526
509
|
// .toBufferArray()
|
|
@@ -528,7 +511,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
528
511
|
// };
|
|
529
512
|
|
|
530
513
|
// const swapPrivateMessageMetadata = {
|
|
531
|
-
//
|
|
514
|
+
// _checkpointNumber: BigInt(uniswapL2Interaction.blockNumber!),
|
|
532
515
|
// _leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
533
516
|
// _path: swapPrivateSiblingPath
|
|
534
517
|
// .toBufferArray()
|
|
@@ -615,14 +598,16 @@ export const uniswapL1L2TestSuite = (
|
|
|
615
598
|
const expectedMessageHash = await computeAuthWitMessageHash(
|
|
616
599
|
{
|
|
617
600
|
caller: uniswapL2Contract.address,
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
601
|
+
call: await wethCrossChainHarness.l2Token.methods
|
|
602
|
+
.transfer_to_public(
|
|
603
|
+
ownerAddress,
|
|
604
|
+
uniswapL2Contract.address,
|
|
605
|
+
wethAmountToBridge,
|
|
606
|
+
nonceForWETHTransferToPublicApproval,
|
|
607
|
+
)
|
|
608
|
+
.getFunctionCall(),
|
|
624
609
|
},
|
|
625
|
-
|
|
610
|
+
await wallet.getChainInfo(),
|
|
626
611
|
);
|
|
627
612
|
|
|
628
613
|
await expect(
|
|
@@ -650,7 +635,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
650
635
|
// 2. owner gives uniswap approval to transfer the funds to public:
|
|
651
636
|
logger.info('Approving uniswap to transfer funds to public to self on my behalf');
|
|
652
637
|
const nonceForWETHTransferToPublicApproval = new Fr(3n);
|
|
653
|
-
const transferToPublicAuthwith = await
|
|
638
|
+
const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
|
|
654
639
|
caller: uniswapL2Contract.address,
|
|
655
640
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
656
641
|
ownerAddress,
|
|
@@ -675,7 +660,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
675
660
|
Fr.random(),
|
|
676
661
|
ownerEthAddress,
|
|
677
662
|
)
|
|
678
|
-
.
|
|
663
|
+
.send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] })
|
|
664
|
+
.wait(),
|
|
679
665
|
).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
|
|
680
666
|
});
|
|
681
667
|
|
|
@@ -687,7 +673,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
687
673
|
|
|
688
674
|
// 2. Give approval to uniswap to transfer funds to itself
|
|
689
675
|
const nonceForWETHTransferApproval = new Fr(2n);
|
|
690
|
-
const validateActionInteraction = await
|
|
676
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
677
|
+
ownerAddress,
|
|
691
678
|
{
|
|
692
679
|
caller: uniswapL2Contract.address,
|
|
693
680
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -699,7 +686,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
699
686
|
},
|
|
700
687
|
true,
|
|
701
688
|
);
|
|
702
|
-
await validateActionInteraction.send(
|
|
689
|
+
await validateActionInteraction.send().wait();
|
|
703
690
|
|
|
704
691
|
// No approval to call `swap` but should work even without it:
|
|
705
692
|
const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
|
|
@@ -731,23 +718,25 @@ export const uniswapL1L2TestSuite = (
|
|
|
731
718
|
const nonceForWETHTransferApproval = new Fr(3n);
|
|
732
719
|
const nonceForSwap = new Fr(3n);
|
|
733
720
|
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
|
-
|
|
721
|
+
const action = uniswapL2Contract.methods.swap_public(
|
|
722
|
+
ownerAddress,
|
|
723
|
+
wethCrossChainHarness.l2Bridge.address,
|
|
724
|
+
wethAmountToBridge,
|
|
725
|
+
daiCrossChainHarness.l2Bridge.address,
|
|
726
|
+
nonceForWETHTransferApproval,
|
|
727
|
+
uniswapFeeTier,
|
|
728
|
+
minimumOutputAmount,
|
|
729
|
+
ownerAddress,
|
|
730
|
+
secretHashForDepositingSwappedDai,
|
|
731
|
+
ownerEthAddress,
|
|
732
|
+
nonceForSwap,
|
|
733
|
+
);
|
|
734
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
735
|
+
ownerAddress,
|
|
736
|
+
{ caller: approvedUser, action },
|
|
737
|
+
true,
|
|
738
|
+
);
|
|
739
|
+
await validateActionInteraction.send().wait();
|
|
751
740
|
|
|
752
741
|
await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
|
|
753
742
|
});
|
|
@@ -756,7 +745,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
756
745
|
// swap should fail since no transfer approval to uniswap:
|
|
757
746
|
const nonceForWETHTransferApproval = new Fr(4n);
|
|
758
747
|
|
|
759
|
-
const validateActionInteraction = await
|
|
748
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
749
|
+
ownerAddress,
|
|
760
750
|
{
|
|
761
751
|
caller: uniswapL2Contract.address,
|
|
762
752
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -768,7 +758,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
768
758
|
},
|
|
769
759
|
true,
|
|
770
760
|
);
|
|
771
|
-
await validateActionInteraction.send(
|
|
761
|
+
await validateActionInteraction.send().wait();
|
|
772
762
|
|
|
773
763
|
await expect(
|
|
774
764
|
uniswapL2Contract.methods
|
|
@@ -798,7 +788,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
798
788
|
// Owner gives uniswap approval to transfer the funds to public to self on its behalf
|
|
799
789
|
logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
|
|
800
790
|
const nonceForWETHTransferToPublicApproval = new Fr(4n);
|
|
801
|
-
const transferToPublicAuhtwit = await
|
|
791
|
+
const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
|
|
802
792
|
caller: uniswapL2Contract.address,
|
|
803
793
|
action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
|
|
804
794
|
ownerAddress,
|
|
@@ -879,7 +869,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
879
869
|
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
880
870
|
|
|
881
871
|
const withdrawMessageMetadata = {
|
|
882
|
-
|
|
872
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
883
873
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
884
874
|
_path: withdrawSiblingPath
|
|
885
875
|
.toBufferArray()
|
|
@@ -887,7 +877,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
887
877
|
};
|
|
888
878
|
|
|
889
879
|
const swapPrivateMessageMetadata = {
|
|
890
|
-
|
|
880
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
891
881
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
892
882
|
_path: swapPrivateSiblingPath
|
|
893
883
|
.toBufferArray()
|
|
@@ -898,7 +888,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
898
888
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
899
889
|
|
|
900
890
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
901
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
891
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
902
892
|
|
|
903
893
|
// On L1 call swap_public!
|
|
904
894
|
logger.info('call swap_public on L1');
|
|
@@ -926,7 +916,8 @@ export const uniswapL1L2TestSuite = (
|
|
|
926
916
|
|
|
927
917
|
// Owner gives uniswap approval to transfer funds on its behalf
|
|
928
918
|
const nonceForWETHTransferApproval = new Fr(5n);
|
|
929
|
-
const validateActionInteraction = await
|
|
919
|
+
const validateActionInteraction = await wallet.setPublicAuthWit(
|
|
920
|
+
ownerAddress,
|
|
930
921
|
{
|
|
931
922
|
caller: uniswapL2Contract.address,
|
|
932
923
|
action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
|
|
@@ -938,7 +929,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
938
929
|
},
|
|
939
930
|
true,
|
|
940
931
|
);
|
|
941
|
-
await validateActionInteraction.send(
|
|
932
|
+
await validateActionInteraction.send().wait();
|
|
942
933
|
|
|
943
934
|
// Call swap_public on L2
|
|
944
935
|
const secretHashForDepositingSwappedDai = Fr.random();
|
|
@@ -1013,7 +1004,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1013
1004
|
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
1014
1005
|
|
|
1015
1006
|
const withdrawMessageMetadata = {
|
|
1016
|
-
|
|
1007
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
1017
1008
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
1018
1009
|
_path: withdrawSiblingPath
|
|
1019
1010
|
.toBufferArray()
|
|
@@ -1021,7 +1012,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1021
1012
|
};
|
|
1022
1013
|
|
|
1023
1014
|
const swapPublicMessageMetadata = {
|
|
1024
|
-
|
|
1015
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
1025
1016
|
_leafIndex: BigInt(swapPublicL2MessageIndex),
|
|
1026
1017
|
_path: swapPublicSiblingPath
|
|
1027
1018
|
.toBufferArray()
|
|
@@ -1032,7 +1023,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1032
1023
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
1033
1024
|
|
|
1034
1025
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
1035
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
1026
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
1036
1027
|
|
|
1037
1028
|
// Call swap_private on L1
|
|
1038
1029
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
@@ -1,8 +1,10 @@
|
|
|
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
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
5
|
-
import {
|
|
5
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
|
|
6
8
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
9
|
import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
|
|
8
10
|
|
|
@@ -102,7 +104,8 @@ export class LendingSimulator {
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
|
|
105
|
-
const
|
|
107
|
+
const targetSlot = SlotNumber(slot + diff);
|
|
108
|
+
const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
|
|
106
109
|
const timeDiff = ts - this.time;
|
|
107
110
|
this.time = ts;
|
|
108
111
|
|
|
@@ -111,7 +114,7 @@ export class LendingSimulator {
|
|
|
111
114
|
if (dateProvider) {
|
|
112
115
|
dateProvider.setTime(this.time * 1000);
|
|
113
116
|
}
|
|
114
|
-
await this.cc.rollup.markAsProven(await this.rollup.
|
|
117
|
+
await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
|
|
115
118
|
this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -190,7 +193,7 @@ export class LendingSimulator {
|
|
|
190
193
|
expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
|
|
191
194
|
|
|
192
195
|
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:
|
|
196
|
+
const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
|
|
194
197
|
expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
|
|
195
198
|
expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
|
|
196
199
|
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,22 @@ 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
|
+
|
|
65
|
+
```bash
|
|
66
|
+
./spartan/bootstrap.sh metrics-kind
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
# Install Chaos Mesh
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
./spartan/bootstrap.sh chaos-mesh
|
|
73
|
+
```
|
|
74
|
+
|
|
63
75
|
# Deploy stuff
|
|
64
76
|
|
|
65
77
|
```bash
|
|
66
|
-
./spartan/bootstrap.sh network_deploy scenario.local
|
|
78
|
+
./spartan/bootstrap.sh network_deploy scenario.local
|
|
67
79
|
```
|
|
68
80
|
|
|
69
81
|
That will take 1-3 minutes. But at the end you should have everything you need.
|
|
@@ -103,10 +115,10 @@ With the cluster running, you can now easily run tests.
|
|
|
103
115
|
|
|
104
116
|
```bash
|
|
105
117
|
# run one
|
|
106
|
-
./spartan/bootstrap.sh single_test scenario.local
|
|
118
|
+
./spartan/bootstrap.sh single_test scenario.local spartan/smoke.test.ts
|
|
107
119
|
|
|
108
120
|
# run all (serially)
|
|
109
|
-
./spartan/bootstrap.sh network_tests scenario.local
|
|
121
|
+
./spartan/bootstrap.sh network_tests scenario.local
|
|
110
122
|
```
|
|
111
123
|
|
|
112
124
|
Right now, I recommend running the smoke test first, always, as it waits for the committee to exist.
|