@aztec/end-to-end 0.0.1-commit.24de95ac → 0.0.1-commit.5daedc8
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 +1 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +8 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +53 -30
- 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 +5 -27
- package/dest/bench/utils.d.ts +2 -2
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
- 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 +2 -2
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +1 -1
- 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 +4 -3
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +6 -5
- package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
- package/dest/e2e_fees/bridging_race.notest.js +1 -1
- package/dest/e2e_fees/fees_test.d.ts +1 -1
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +12 -9
- package/dest/e2e_l1_publisher/write_json.d.ts +1 -1
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -4
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +4 -3
- 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 +6 -2
- package/dest/e2e_p2p/p2p_network.d.ts +214 -9
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +5 -3
- package/dest/e2e_p2p/shared.d.ts +5 -5
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +6 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +2 -2
- package/dest/fixtures/e2e_prover_test.d.ts +3 -1
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +18 -14
- package/dest/fixtures/fixtures.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts +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/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +1 -1
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +475 -4
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +15 -7
- package/dest/fixtures/snapshot_manager.d.ts +2 -2
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/token_utils.d.ts +5 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +7 -4
- package/dest/fixtures/utils.d.ts +449 -4
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +11 -12
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/with_telemetry_utils.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- 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 +1 -12
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.d.ts +1 -11
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +1 -1
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +11 -11
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +1 -5
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +4 -2
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.d.ts +5 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +43 -9
- package/dest/spartan/utils.d.ts +20 -18
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +59 -26
- package/package.json +42 -40
- package/src/bench/client_flows/client_flows_benchmark.ts +75 -30
- package/src/bench/client_flows/data_extractor.ts +6 -28
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +2 -2
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +4 -3
- package/src/e2e_deploy_contract/deploy_test.ts +1 -1
- package/src/e2e_epochs/epochs_test.ts +6 -5
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +12 -9
- package/src/e2e_l1_publisher/write_json.ts +5 -4
- package/src/e2e_nested_contract/nested_contract_test.ts +4 -3
- package/src/e2e_p2p/inactivity_slash_test.ts +6 -2
- package/src/e2e_p2p/p2p_network.ts +7 -3
- package/src/e2e_p2p/shared.ts +8 -5
- package/src/e2e_token_contract/token_contract_test.ts +2 -2
- package/src/fixtures/e2e_prover_test.ts +15 -16
- package/src/fixtures/setup_p2p_test.ts +20 -6
- package/src/fixtures/token_utils.ts +4 -4
- package/src/fixtures/utils.ts +35 -16
- package/src/guides/up_quick_start.sh +1 -1
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/uniswap_l1_l2.ts +11 -11
- package/src/simulators/lending_simulator.ts +4 -2
- package/src/spartan/setup_test_wallets.ts +47 -11
- package/src/spartan/utils.ts +64 -24
package/src/fixtures/utils.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
createDelayedL1TxUtilsFromViemWallet,
|
|
33
33
|
startAnvil,
|
|
34
34
|
} from '@aztec/ethereum/test';
|
|
35
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
35
36
|
import { SecretValue } from '@aztec/foundation/config';
|
|
36
37
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
37
38
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -117,16 +118,26 @@ export const setupL1Contracts = async (
|
|
|
117
118
|
args: Partial<DeployL1ContractsArgs> = {},
|
|
118
119
|
chain: Chain = foundry,
|
|
119
120
|
) => {
|
|
120
|
-
const l1Data = await deployL1Contracts(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
const l1Data = await deployL1Contracts(
|
|
122
|
+
l1RpcUrls,
|
|
123
|
+
account,
|
|
124
|
+
chain,
|
|
125
|
+
logger,
|
|
126
|
+
{
|
|
127
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
128
|
+
protocolContractsHash,
|
|
129
|
+
genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
130
|
+
salt: args.salt,
|
|
131
|
+
initialValidators: args.initialValidators,
|
|
132
|
+
...getL1ContractsConfigEnvVars(),
|
|
133
|
+
realVerifier: false,
|
|
134
|
+
...args,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
priorityFeeBumpPercentage: 0,
|
|
138
|
+
priorityFeeRetryBumpPercentage: 0,
|
|
139
|
+
},
|
|
140
|
+
);
|
|
130
141
|
|
|
131
142
|
return l1Data;
|
|
132
143
|
};
|
|
@@ -489,7 +500,7 @@ export async function setup(
|
|
|
489
500
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
490
501
|
);
|
|
491
502
|
|
|
492
|
-
const blockReward = await rollup.
|
|
503
|
+
const blockReward = await rollup.getCheckpointReward();
|
|
493
504
|
const mintAmount = 10_000n * (blockReward as bigint);
|
|
494
505
|
|
|
495
506
|
const feeJuice = getContract({
|
|
@@ -636,7 +647,11 @@ export async function setup(
|
|
|
636
647
|
(opts.initialValidators && opts.initialValidators.length > 0)
|
|
637
648
|
) {
|
|
638
649
|
// We need to advance such that the committee is set up.
|
|
639
|
-
await cheatCodes.rollup.advanceToEpoch(
|
|
650
|
+
await cheatCodes.rollup.advanceToEpoch(
|
|
651
|
+
EpochNumber.fromBigInt(
|
|
652
|
+
BigInt(await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochsForValidatorSet + 1),
|
|
653
|
+
),
|
|
654
|
+
);
|
|
640
655
|
await cheatCodes.rollup.setupEpoch();
|
|
641
656
|
await cheatCodes.rollup.debugRollup();
|
|
642
657
|
}
|
|
@@ -728,7 +743,7 @@ export async function setup(
|
|
|
728
743
|
|
|
729
744
|
export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
|
|
730
745
|
// We have to check whether the accounts are already deployed. This can happen if the test runs against
|
|
731
|
-
// the
|
|
746
|
+
// the local network and the test accounts exist
|
|
732
747
|
const accountsAndAddresses = await Promise.all(
|
|
733
748
|
accountsToDeploy.map(async address => {
|
|
734
749
|
return {
|
|
@@ -848,7 +863,7 @@ export async function setupSponsoredFPC(wallet: Wallet) {
|
|
|
848
863
|
salt: new Fr(SPONSORED_FPC_SALT),
|
|
849
864
|
});
|
|
850
865
|
|
|
851
|
-
await wallet.registerContract(
|
|
866
|
+
await wallet.registerContract(instance, SponsoredFPCContract.artifact);
|
|
852
867
|
getLogger().info(`SponsoredFPC: ${instance.address}`);
|
|
853
868
|
return instance;
|
|
854
869
|
}
|
|
@@ -858,7 +873,7 @@ export async function setupSponsoredFPC(wallet: Wallet) {
|
|
|
858
873
|
* @param wallet - The wallet
|
|
859
874
|
*/
|
|
860
875
|
export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
|
|
861
|
-
await wallet.registerContract(
|
|
876
|
+
await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
|
|
862
877
|
}
|
|
863
878
|
|
|
864
879
|
export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) {
|
|
@@ -893,7 +908,11 @@ export function createAndSyncProverNode(
|
|
|
893
908
|
|
|
894
909
|
// Creating temp store and archiver for simulated prover node
|
|
895
910
|
const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
|
|
896
|
-
const archiver = await createArchiver(
|
|
911
|
+
const archiver = await createArchiver(
|
|
912
|
+
archiverConfig,
|
|
913
|
+
{ blobSinkClient, dateProvider: proverNodeDeps.dateProvider },
|
|
914
|
+
{ blockUntilSync: true },
|
|
915
|
+
);
|
|
897
916
|
|
|
898
917
|
// Prover node config is for simulated proofs
|
|
899
918
|
const proverConfig: ProverNodeConfig = {
|
|
@@ -43,7 +43,7 @@ export class FeeJuicePortalTestingHarnessFactory {
|
|
|
43
43
|
throw new Error('Fee Juice portal not deployed on L1');
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const gasL2 =
|
|
46
|
+
const gasL2 = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
|
|
47
47
|
|
|
48
48
|
return new GasBridgingTestHarness(
|
|
49
49
|
aztecNode,
|
|
@@ -262,7 +262,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
262
262
|
await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
|
|
263
263
|
|
|
264
264
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
265
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
265
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
266
266
|
|
|
267
267
|
// 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
|
|
268
268
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
@@ -287,7 +287,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
287
287
|
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
288
288
|
|
|
289
289
|
const withdrawMessageMetadata = {
|
|
290
|
-
|
|
290
|
+
_checkpointNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
|
|
291
291
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
292
292
|
_path: withdrawSiblingPath
|
|
293
293
|
.toBufferArray()
|
|
@@ -295,7 +295,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
295
295
|
};
|
|
296
296
|
|
|
297
297
|
const swapPrivateMessageMetadata = {
|
|
298
|
-
|
|
298
|
+
_checkpointNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
|
|
299
299
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
300
300
|
_path: swapPrivateSiblingPath
|
|
301
301
|
.toBufferArray()
|
|
@@ -506,7 +506,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
506
506
|
// );
|
|
507
507
|
|
|
508
508
|
// const withdrawMessageMetadata = {
|
|
509
|
-
//
|
|
509
|
+
// _checkpointNumber: BigInt(uniswapL2Interaction.blockNumber!),
|
|
510
510
|
// _leafIndex: BigInt(withdrawL2MessageIndex),
|
|
511
511
|
// _path: withdrawSiblingPath
|
|
512
512
|
// .toBufferArray()
|
|
@@ -514,7 +514,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
514
514
|
// };
|
|
515
515
|
|
|
516
516
|
// const swapPrivateMessageMetadata = {
|
|
517
|
-
//
|
|
517
|
+
// _checkpointNumber: BigInt(uniswapL2Interaction.blockNumber!),
|
|
518
518
|
// _leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
519
519
|
// _path: swapPrivateSiblingPath
|
|
520
520
|
// .toBufferArray()
|
|
@@ -872,7 +872,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
872
872
|
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
873
873
|
|
|
874
874
|
const withdrawMessageMetadata = {
|
|
875
|
-
|
|
875
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
876
876
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
877
877
|
_path: withdrawSiblingPath
|
|
878
878
|
.toBufferArray()
|
|
@@ -880,7 +880,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
880
880
|
};
|
|
881
881
|
|
|
882
882
|
const swapPrivateMessageMetadata = {
|
|
883
|
-
|
|
883
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
884
884
|
_leafIndex: BigInt(swapPrivateL2MessageIndex),
|
|
885
885
|
_path: swapPrivateSiblingPath
|
|
886
886
|
.toBufferArray()
|
|
@@ -891,7 +891,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
891
891
|
await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
|
|
892
892
|
|
|
893
893
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
894
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
894
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
895
895
|
|
|
896
896
|
// On L1 call swap_public!
|
|
897
897
|
logger.info('call swap_public on L1');
|
|
@@ -1007,7 +1007,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1007
1007
|
const withdrawSiblingPath = withdrawResult!.siblingPath;
|
|
1008
1008
|
|
|
1009
1009
|
const withdrawMessageMetadata = {
|
|
1010
|
-
|
|
1010
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
1011
1011
|
_leafIndex: BigInt(withdrawL2MessageIndex),
|
|
1012
1012
|
_path: withdrawSiblingPath
|
|
1013
1013
|
.toBufferArray()
|
|
@@ -1015,7 +1015,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1015
1015
|
};
|
|
1016
1016
|
|
|
1017
1017
|
const swapPublicMessageMetadata = {
|
|
1018
|
-
|
|
1018
|
+
_checkpointNumber: BigInt(withdrawReceipt.blockNumber!),
|
|
1019
1019
|
_leafIndex: BigInt(swapPublicL2MessageIndex),
|
|
1020
1020
|
_path: swapPublicSiblingPath
|
|
1021
1021
|
.toBufferArray()
|
|
@@ -1026,7 +1026,7 @@ export const uniswapL1L2TestSuite = (
|
|
|
1026
1026
|
await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
|
|
1027
1027
|
|
|
1028
1028
|
// Since the outbox is only consumable when the block is proven, we need to set the block to be proven
|
|
1029
|
-
await cheatCodes.rollup.markAsProven(await rollup.
|
|
1029
|
+
await cheatCodes.rollup.markAsProven(await rollup.getCheckpointNumber());
|
|
1030
1030
|
|
|
1031
1031
|
// Call swap_private on L1
|
|
1032
1032
|
logger.info('Execute withdraw and swap on the uniswapPortal!');
|
|
@@ -3,6 +3,7 @@ import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
4
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
5
5
|
import type { RollupContract } from '@aztec/ethereum';
|
|
6
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
6
7
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
7
8
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
8
9
|
import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
|
|
@@ -103,7 +104,8 @@ export class LendingSimulator {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
|
|
106
|
-
const
|
|
107
|
+
const targetSlot = SlotNumber(slot + diff);
|
|
108
|
+
const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
|
|
107
109
|
const timeDiff = ts - this.time;
|
|
108
110
|
this.time = ts;
|
|
109
111
|
|
|
@@ -112,7 +114,7 @@ export class LendingSimulator {
|
|
|
112
114
|
if (dateProvider) {
|
|
113
115
|
dateProvider.setTime(this.time * 1000);
|
|
114
116
|
}
|
|
115
|
-
await this.cc.rollup.markAsProven(await this.rollup.
|
|
117
|
+
await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
|
|
116
118
|
this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
|
|
117
119
|
}
|
|
118
120
|
|
|
@@ -11,7 +11,7 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
11
11
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
12
12
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
13
13
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
14
|
-
import { TestWallet, proveInteraction,
|
|
14
|
+
import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
|
|
15
15
|
|
|
16
16
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
17
17
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
@@ -28,6 +28,11 @@ export interface TestAccounts {
|
|
|
28
28
|
tokenAddress: AztecAddress;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export type TestAccountsWithoutTokens = Omit<
|
|
32
|
+
TestAccounts,
|
|
33
|
+
'tokenAddress' | 'tokenContract' | 'tokenName' | 'tokenAdminAddress'
|
|
34
|
+
>;
|
|
35
|
+
|
|
31
36
|
const TOKEN_NAME = 'USDC';
|
|
32
37
|
const TOKEN_SYMBOL = 'USD';
|
|
33
38
|
const TOKEN_DECIMALS = 18n;
|
|
@@ -42,14 +47,14 @@ export async function setupTestAccountsWithTokens(
|
|
|
42
47
|
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
43
48
|
const wallet = await TestWallet.create(aztecNode);
|
|
44
49
|
|
|
45
|
-
const [recipientAccount, ...accounts] = (await
|
|
50
|
+
const [recipientAccount, ...accounts] = (await registerInitialLocalNetworkAccountsInWallet(wallet)).slice(
|
|
46
51
|
0,
|
|
47
52
|
ACCOUNT_COUNT + 1,
|
|
48
53
|
);
|
|
49
54
|
|
|
50
55
|
const tokenAdmin = accounts[0];
|
|
51
56
|
const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
|
|
52
|
-
const tokenContract =
|
|
57
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
53
58
|
|
|
54
59
|
return {
|
|
55
60
|
aztecNode,
|
|
@@ -63,7 +68,7 @@ export async function setupTestAccountsWithTokens(
|
|
|
63
68
|
};
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
export async function
|
|
71
|
+
export async function deploySponsoredTestAccountsWithTokens(
|
|
67
72
|
wallet: TestWallet,
|
|
68
73
|
aztecNode: AztecNode,
|
|
69
74
|
mintAmount: bigint,
|
|
@@ -96,7 +101,7 @@ export async function deploySponsoredTestAccounts(
|
|
|
96
101
|
new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
|
|
97
102
|
logger,
|
|
98
103
|
);
|
|
99
|
-
const tokenContract =
|
|
104
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
100
105
|
|
|
101
106
|
return {
|
|
102
107
|
aztecNode,
|
|
@@ -110,6 +115,37 @@ export async function deploySponsoredTestAccounts(
|
|
|
110
115
|
};
|
|
111
116
|
}
|
|
112
117
|
|
|
118
|
+
export async function deploySponsoredTestAccounts(
|
|
119
|
+
wallet: TestWallet,
|
|
120
|
+
aztecNode: AztecNode,
|
|
121
|
+
logger: Logger,
|
|
122
|
+
numberOfFundedWallets = 1,
|
|
123
|
+
): Promise<TestAccountsWithoutTokens> {
|
|
124
|
+
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
125
|
+
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
126
|
+
const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
|
|
127
|
+
|
|
128
|
+
await registerSponsoredFPC(wallet);
|
|
129
|
+
|
|
130
|
+
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
131
|
+
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
132
|
+
await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
|
|
133
|
+
await Promise.all(
|
|
134
|
+
fundedAccounts.map(async a => {
|
|
135
|
+
const deployMethod = await a.getDeployMethod();
|
|
136
|
+
await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
|
|
137
|
+
logger.info(`Account deployed at ${a.address}`);
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
aztecNode,
|
|
143
|
+
wallet,
|
|
144
|
+
accounts: fundedAccounts.map(acc => acc.address),
|
|
145
|
+
recipientAddress: recipientAccount.address,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
113
149
|
export async function deployTestAccountsWithTokens(
|
|
114
150
|
nodeUrl: string,
|
|
115
151
|
l1RpcUrls: string[],
|
|
@@ -152,7 +188,7 @@ export async function deployTestAccountsWithTokens(
|
|
|
152
188
|
undefined,
|
|
153
189
|
logger,
|
|
154
190
|
);
|
|
155
|
-
const tokenContract =
|
|
191
|
+
const tokenContract = TokenContract.at(tokenAddress, wallet);
|
|
156
192
|
|
|
157
193
|
return {
|
|
158
194
|
aztecNode,
|
|
@@ -228,9 +264,9 @@ async function deployTokenAndMint(
|
|
|
228
264
|
logger.verbose(`Minting ${mintAmount} public assets to the ${accounts.length} accounts...`);
|
|
229
265
|
|
|
230
266
|
await Promise.all(
|
|
231
|
-
accounts.map(
|
|
232
|
-
|
|
233
|
-
.mint_to_public(acc, mintAmount)
|
|
267
|
+
accounts.map(acc =>
|
|
268
|
+
TokenContract.at(tokenAddress, wallet)
|
|
269
|
+
.methods.mint_to_public(acc, mintAmount)
|
|
234
270
|
.send({ from: admin, fee: { paymentMethod } })
|
|
235
271
|
.wait({ timeout: 600 }),
|
|
236
272
|
),
|
|
@@ -260,8 +296,8 @@ export async function performTransfers({
|
|
|
260
296
|
// Default to sponsored fee payment if no fee method is provided
|
|
261
297
|
const defaultFeePaymentMethod = feePaymentMethod || new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
262
298
|
for (let i = 0; i < rounds; i++) {
|
|
263
|
-
const txs = testAccounts.accounts.map(
|
|
264
|
-
const token =
|
|
299
|
+
const txs = testAccounts.accounts.map(acc => {
|
|
300
|
+
const token = TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
|
|
265
301
|
return proveInteraction(wallet, token.methods.transfer_in_public(acc, recipient, transferAmount, 0), {
|
|
266
302
|
from: acc,
|
|
267
303
|
fee: {
|
package/src/spartan/utils.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { createLogger } from '@aztec/aztec.js/log';
|
|
|
2
2
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
3
3
|
import type { L1ContractAddresses, ViemPublicClient } from '@aztec/ethereum';
|
|
4
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
5
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
5
6
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
6
7
|
import { schemas } from '@aztec/foundation/schemas';
|
|
7
8
|
import { sleep } from '@aztec/foundation/sleep';
|
|
@@ -160,9 +161,42 @@ export async function startPortForward({
|
|
|
160
161
|
return { process, port };
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
export function
|
|
164
|
+
export function getExternalIP(namespace: string, serviceName: string): Promise<string> {
|
|
165
|
+
const { promise, resolve, reject } = promiseWithResolvers<string>();
|
|
166
|
+
const process = spawn(
|
|
167
|
+
'kubectl',
|
|
168
|
+
[
|
|
169
|
+
'get',
|
|
170
|
+
'service',
|
|
171
|
+
'-n',
|
|
172
|
+
namespace,
|
|
173
|
+
`${namespace}-${serviceName}`,
|
|
174
|
+
'--output',
|
|
175
|
+
"jsonpath='{.status.loadBalancer.ingress[0].ip}'",
|
|
176
|
+
],
|
|
177
|
+
{
|
|
178
|
+
stdio: 'pipe',
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
let ip = '';
|
|
183
|
+
process.stdout.on('data', data => {
|
|
184
|
+
ip += data;
|
|
185
|
+
});
|
|
186
|
+
process.on('error', err => {
|
|
187
|
+
reject(err);
|
|
188
|
+
});
|
|
189
|
+
process.on('exit', () => {
|
|
190
|
+
// kubectl prints JSON. Remove the quotes
|
|
191
|
+
resolve(ip.replace(/"|'/g, ''));
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return promise;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function startPortForwardForRPC(namespace: string, resourceType = 'services', index = 0) {
|
|
164
198
|
return startPortForward({
|
|
165
|
-
resource:
|
|
199
|
+
resource: `${resourceType}/${namespace}-rpc-aztec-node-${index}`,
|
|
166
200
|
namespace,
|
|
167
201
|
containerPort: 8080,
|
|
168
202
|
});
|
|
@@ -295,6 +329,32 @@ async function execHelmCommand(args: Parameters<typeof createHelmCommand>[0]) {
|
|
|
295
329
|
return stdout;
|
|
296
330
|
}
|
|
297
331
|
|
|
332
|
+
export async function cleanHelm(instanceName: string, namespace: string, logger: Logger) {
|
|
333
|
+
// uninstall the helm chart if it exists
|
|
334
|
+
logger.info(`Uninstalling helm chart ${instanceName}`);
|
|
335
|
+
await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`);
|
|
336
|
+
// and delete the chaos-mesh resources created by this release
|
|
337
|
+
const deleteByLabel = async (resource: string) => {
|
|
338
|
+
const args = {
|
|
339
|
+
resource,
|
|
340
|
+
namespace: namespace,
|
|
341
|
+
label: `app.kubernetes.io/instance=${instanceName}`,
|
|
342
|
+
} as const;
|
|
343
|
+
logger.info(`Deleting ${resource} resources for release ${instanceName}`);
|
|
344
|
+
await deleteResourceByLabel(args).catch(e => {
|
|
345
|
+
logger.error(`Error deleting ${resource}: ${e}`);
|
|
346
|
+
logger.info(`Force deleting ${resource}`);
|
|
347
|
+
return deleteResourceByLabel({ ...args, force: true });
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
await deleteByLabel('podchaos');
|
|
352
|
+
await deleteByLabel('networkchaos');
|
|
353
|
+
await deleteByLabel('podnetworkchaos');
|
|
354
|
+
await deleteByLabel('workflows');
|
|
355
|
+
await deleteByLabel('workflownodes');
|
|
356
|
+
}
|
|
357
|
+
|
|
298
358
|
/**
|
|
299
359
|
* Installs a Helm chart with the given parameters.
|
|
300
360
|
* @param instanceName - The name of the Helm chart instance.
|
|
@@ -317,7 +377,6 @@ export async function installChaosMeshChart({
|
|
|
317
377
|
targetNamespace,
|
|
318
378
|
valuesFile,
|
|
319
379
|
helmChartDir,
|
|
320
|
-
chaosMeshNamespace = 'chaos-mesh',
|
|
321
380
|
timeout = '10m',
|
|
322
381
|
clean = true,
|
|
323
382
|
values = {},
|
|
@@ -334,32 +393,13 @@ export async function installChaosMeshChart({
|
|
|
334
393
|
logger: Logger;
|
|
335
394
|
}) {
|
|
336
395
|
if (clean) {
|
|
337
|
-
|
|
338
|
-
logger.info(`Uninstalling helm chart ${instanceName}`);
|
|
339
|
-
await execAsync(`helm uninstall ${instanceName} --namespace ${chaosMeshNamespace} --wait --ignore-not-found`);
|
|
340
|
-
// and delete the chaos-mesh resources created by this release
|
|
341
|
-
const deleteByLabel = async (resource: string) => {
|
|
342
|
-
const args = {
|
|
343
|
-
resource,
|
|
344
|
-
namespace: chaosMeshNamespace,
|
|
345
|
-
label: `app.kubernetes.io/instance=${instanceName}`,
|
|
346
|
-
} as const;
|
|
347
|
-
logger.info(`Deleting ${resource} resources for release ${instanceName}`);
|
|
348
|
-
await deleteResourceByLabel(args).catch(e => {
|
|
349
|
-
logger.error(`Error deleting ${resource}: ${e}`);
|
|
350
|
-
logger.info(`Force deleting ${resource}`);
|
|
351
|
-
return deleteResourceByLabel({ ...args, force: true });
|
|
352
|
-
});
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
await deleteByLabel('podchaos');
|
|
356
|
-
await deleteByLabel('networkchaos');
|
|
396
|
+
await cleanHelm(instanceName, targetNamespace, logger);
|
|
357
397
|
}
|
|
358
398
|
|
|
359
399
|
return execHelmCommand({
|
|
360
400
|
instanceName,
|
|
361
401
|
helmChartDir,
|
|
362
|
-
namespace:
|
|
402
|
+
namespace: targetNamespace,
|
|
363
403
|
valuesFile,
|
|
364
404
|
timeout,
|
|
365
405
|
values: { ...values, 'global.targetNamespace': targetNamespace },
|