@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.0b941701
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 +62 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +281 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +321 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +41 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
- 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 +114 -102
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
- 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 +104 -104
- package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +26 -27
- package/dest/e2e_epochs/epochs_test.d.ts +65 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +236 -49
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +61 -0
- package/dest/e2e_fees/fees_test.d.ts +38 -23
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +162 -183
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +62 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
- 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 +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +281 -27
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +237 -175
- package/dest/e2e_p2p/shared.d.ts +44 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +165 -27
- package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +96 -74
- package/dest/fixtures/e2e_prover_test.d.ts +55 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +278 -0
- package/dest/fixtures/fixtures.d.ts +6 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +5 -5
- 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 +3 -15
- 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 +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +690 -0
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +82 -22
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +31 -12
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- 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/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +44 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +105 -51
- package/dest/shared/gas_portal_test_harness.d.ts +33 -25
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +2 -2
- package/dest/shared/index.d.ts.map +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 +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +176 -126
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +17 -18
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +27 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +233 -62
- package/dest/spartan/tx_metrics.d.ts +54 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +272 -0
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +98 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +257 -0
- package/dest/spartan/utils/nodes.d.ts +31 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +290 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- package/package.json +66 -58
- package/src/bench/client_flows/benchmark.ts +363 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +41 -85
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
- package/src/e2e_deploy_contract/deploy_test.ts +40 -48
- package/src/e2e_epochs/epochs_test.ts +315 -76
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +220 -258
- package/src/e2e_l1_publisher/write_json.ts +82 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +341 -234
- package/src/e2e_p2p/shared.ts +253 -40
- package/src/e2e_token_contract/token_contract_test.ts +115 -126
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +336 -0
- package/src/fixtures/fixtures.ts +5 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup.ts +1017 -0
- package/src/fixtures/setup_p2p_test.ts +127 -39
- package/src/fixtures/token_utils.ts +33 -15
- package/src/fixtures/utils.ts +27 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +103 -91
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +18 -20
- package/src/shared/uniswap_l1_l2.ts +197 -221
- package/src/simulators/lending_simulator.ts +16 -17
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +308 -95
- package/src/spartan/tx_metrics.ts +250 -0
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +62 -0
- package/src/spartan/utils/k8s.ts +375 -0
- package/src/spartan/utils/nodes.ts +323 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -582
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/e2e_prover/e2e_prover_test.js +0 -291
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
- package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.js +0 -17
- package/dest/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -1,71 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
createLogger,
|
|
11
|
-
sleep,
|
|
12
|
-
} from '@aztec/aztec.js';
|
|
13
|
-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
|
|
14
|
-
import { type DeployL1ContractsArgs, RollupContract, createL1Clients } from '@aztec/ethereum';
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
5
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
6
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import type { DeployAztecL1ContractsArgs } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
8
|
+
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
9
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
15
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
|
-
import {
|
|
11
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
12
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
17
13
|
import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
|
|
18
|
-
import { CounterContract } from '@aztec/noir-contracts.js/Counter';
|
|
19
14
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
20
15
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
16
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
21
17
|
import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
|
|
18
|
+
import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
|
|
22
19
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
23
20
|
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
24
|
-
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
25
21
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
22
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
23
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
26
24
|
|
|
27
25
|
import { getContract } from 'viem';
|
|
28
26
|
|
|
29
27
|
import { MNEMONIC } from '../fixtures/fixtures.js';
|
|
30
28
|
import {
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
createSnapshotManager,
|
|
29
|
+
type EndToEndContext,
|
|
30
|
+
type SetupOptions,
|
|
34
31
|
deployAccounts,
|
|
35
|
-
|
|
32
|
+
publicDeployAccounts,
|
|
33
|
+
setup,
|
|
34
|
+
teardown,
|
|
35
|
+
} from '../fixtures/setup.js';
|
|
36
36
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
37
|
-
import {
|
|
38
|
-
type BalancesFn,
|
|
39
|
-
type SetupOptions,
|
|
40
|
-
ensureAccountsPubliclyDeployed,
|
|
41
|
-
getBalancesFn,
|
|
42
|
-
setupCanonicalFeeJuice,
|
|
43
|
-
} from '../fixtures/utils.js';
|
|
37
|
+
import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
|
|
44
38
|
import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
|
|
45
39
|
|
|
46
|
-
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
47
|
-
|
|
48
40
|
/**
|
|
49
|
-
* Test fixture for testing fees. Provides the following
|
|
41
|
+
* Test fixture for testing fees. Provides the following setup steps:
|
|
50
42
|
* InitialAccounts: Initializes 3 Schnorr account contracts.
|
|
51
43
|
* PublicDeployAccounts: Deploys the accounts publicly.
|
|
52
44
|
* DeployFeeJuice: Deploys the Fee Juice contract.
|
|
53
45
|
* FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
|
|
46
|
+
* SponsoredFPCSetup: Deploys Sponsored FPC contract, and bridges gas from L1.
|
|
54
47
|
* FundAlice: Mints private and public bananas to Alice.
|
|
55
48
|
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
56
49
|
*/
|
|
57
50
|
export class FeesTest {
|
|
58
|
-
private
|
|
59
|
-
|
|
51
|
+
private accounts: AztecAddress[] = [];
|
|
52
|
+
public context!: EndToEndContext;
|
|
60
53
|
|
|
61
54
|
public logger: Logger;
|
|
62
|
-
public pxe!: PXE;
|
|
63
55
|
public aztecNode!: AztecNode;
|
|
56
|
+
public aztecNodeAdmin!: AztecNodeAdmin;
|
|
64
57
|
public cheatCodes!: CheatCodes;
|
|
65
58
|
|
|
66
|
-
public
|
|
59
|
+
public wallet!: TestWallet;
|
|
67
60
|
public aliceAddress!: AztecAddress;
|
|
68
|
-
public bobWallet!: AccountWallet;
|
|
69
61
|
public bobAddress!: AztecAddress;
|
|
70
62
|
public sequencerAddress!: AztecAddress;
|
|
71
63
|
public coinbase!: EthAddress;
|
|
@@ -74,14 +66,16 @@ export class FeesTest {
|
|
|
74
66
|
|
|
75
67
|
public gasSettings!: GasSettings;
|
|
76
68
|
|
|
69
|
+
public rollupContract!: RollupContract;
|
|
70
|
+
|
|
77
71
|
public feeJuiceContract!: FeeJuiceContract;
|
|
78
72
|
public bananaCoin!: BananaCoin;
|
|
79
73
|
public bananaFPC!: FPCContract;
|
|
74
|
+
public sponsoredFPC!: SponsoredFPCContract;
|
|
80
75
|
public counterContract!: CounterContract;
|
|
81
76
|
public subscriptionContract!: AppSubscriptionContract;
|
|
82
77
|
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
|
|
83
78
|
|
|
84
|
-
public context!: SubsystemsContext;
|
|
85
79
|
public chainMonitor!: ChainMonitor;
|
|
86
80
|
|
|
87
81
|
public getCoinbaseBalance!: () => Promise<bigint>;
|
|
@@ -89,7 +83,7 @@ export class FeesTest {
|
|
|
89
83
|
public getGasBalanceFn!: BalancesFn;
|
|
90
84
|
public getBananaPublicBalanceFn!: BalancesFn;
|
|
91
85
|
public getBananaPrivateBalanceFn!: BalancesFn;
|
|
92
|
-
public getProverFee!: (blockNumber:
|
|
86
|
+
public getProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
|
|
93
87
|
|
|
94
88
|
public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
|
|
95
89
|
public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
|
|
@@ -98,37 +92,41 @@ export class FeesTest {
|
|
|
98
92
|
constructor(
|
|
99
93
|
testName: string,
|
|
100
94
|
private numberOfAccounts = 3,
|
|
101
|
-
setupOptions: Partial<SetupOptions &
|
|
95
|
+
private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
|
|
102
96
|
) {
|
|
103
97
|
if (!numberOfAccounts) {
|
|
104
98
|
throw new Error('There must be at least 1 initial account.');
|
|
105
99
|
}
|
|
100
|
+
setupOptions.coinbase ??= EthAddress.random();
|
|
101
|
+
this.coinbase = setupOptions.coinbase!;
|
|
106
102
|
this.logger = createLogger(`e2e:e2e_fees:${testName}`);
|
|
107
|
-
this.snapshotManager = createSnapshotManager(
|
|
108
|
-
`e2e_fees/${testName}-${numberOfAccounts}`,
|
|
109
|
-
dataPath,
|
|
110
|
-
{ startProverNode: true, ...setupOptions },
|
|
111
|
-
{ ...setupOptions },
|
|
112
|
-
);
|
|
113
103
|
}
|
|
114
104
|
|
|
115
105
|
async setup() {
|
|
116
|
-
|
|
117
|
-
await
|
|
106
|
+
this.logger.verbose('Setting up fresh context...');
|
|
107
|
+
this.context = await setup(0, {
|
|
108
|
+
startProverNode: true,
|
|
109
|
+
...this.setupOptions,
|
|
110
|
+
fundSponsoredFPC: true,
|
|
111
|
+
skipAccountDeployment: true,
|
|
112
|
+
l1ContractsArgs: { ...this.setupOptions },
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
this.rollupContract = RollupContract.getFromConfig(this.context.config);
|
|
116
|
+
this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider!, this.logger, 200).start();
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
this.chainMonitor = new ChainMonitor(rollupContract, this.logger, 200).start();
|
|
118
|
+
await this.applyBaseSetup();
|
|
121
119
|
|
|
122
120
|
return this;
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
async teardown() {
|
|
126
|
-
this.chainMonitor.stop();
|
|
127
|
-
await this.
|
|
124
|
+
await this.chainMonitor.stop();
|
|
125
|
+
await teardown(this.context);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
setIsMarkingAsProven(b: boolean) {
|
|
131
|
-
this.context.watcher
|
|
129
|
+
this.context.watcher!.setIsMarkingAsProven(b);
|
|
132
130
|
}
|
|
133
131
|
|
|
134
132
|
async catchUpProvenChain() {
|
|
@@ -138,240 +136,204 @@ export class FeesTest {
|
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
|
|
141
|
-
async
|
|
142
|
-
const
|
|
139
|
+
async getBlockRewards() {
|
|
140
|
+
const blockReward = await this.rollupContract.getCheckpointReward();
|
|
141
|
+
const rewardConfig = await this.rollupContract.getRewardConfig();
|
|
142
|
+
|
|
143
|
+
const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
|
|
144
|
+
|
|
145
|
+
const toDistribute = balance > blockReward ? blockReward : balance;
|
|
146
|
+
const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
|
|
147
|
+
const proverBlockRewards = toDistribute - sequencerBlockRewards;
|
|
148
|
+
|
|
149
|
+
return { sequencerBlockRewards, proverBlockRewards };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
|
|
153
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
|
|
143
154
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
144
|
-
await this.feeJuiceContract.methods.claim(
|
|
155
|
+
await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
|
|
145
156
|
}
|
|
146
157
|
|
|
147
158
|
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
148
159
|
async mintPrivateBananas(amount: bigint, address: AztecAddress) {
|
|
149
|
-
const balanceBefore = await this.bananaCoin.methods
|
|
160
|
+
const balanceBefore = await this.bananaCoin.methods
|
|
161
|
+
.balance_of_private(address)
|
|
162
|
+
.simulate({ from: this.aliceAddress });
|
|
150
163
|
|
|
151
|
-
await mintTokensToPrivate(this.bananaCoin, this.
|
|
164
|
+
await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
|
|
152
165
|
|
|
153
|
-
const balanceAfter = await this.bananaCoin.methods
|
|
166
|
+
const balanceAfter = await this.bananaCoin.methods
|
|
167
|
+
.balance_of_private(address)
|
|
168
|
+
.simulate({ from: this.aliceAddress });
|
|
154
169
|
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
|
-
public async
|
|
158
|
-
await this.
|
|
159
|
-
await this.
|
|
160
|
-
await this.
|
|
161
|
-
await this.
|
|
172
|
+
public async applyBaseSetup() {
|
|
173
|
+
await this.applyInitialAccounts();
|
|
174
|
+
await this.applyPublicDeployAccounts();
|
|
175
|
+
await this.applySetupFeeJuice();
|
|
176
|
+
await this.applyDeployBananaToken();
|
|
162
177
|
}
|
|
163
178
|
|
|
164
|
-
async
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
190
|
-
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
191
|
-
aztecNode: aztecNode,
|
|
192
|
-
pxeService: pxe,
|
|
193
|
-
publicClient: publicClient,
|
|
194
|
-
walletClient: walletClient,
|
|
195
|
-
wallet: this.aliceWallet,
|
|
196
|
-
logger: this.logger,
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
);
|
|
179
|
+
async applyInitialAccounts() {
|
|
180
|
+
this.logger.info('Applying initial accounts setup');
|
|
181
|
+
|
|
182
|
+
const { deployedAccounts } = await deployAccounts(
|
|
183
|
+
this.numberOfAccounts,
|
|
184
|
+
this.logger,
|
|
185
|
+
)({
|
|
186
|
+
wallet: this.context.wallet,
|
|
187
|
+
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
this.wallet = this.context.wallet;
|
|
191
|
+
this.aztecNode = this.context.aztecNodeService!;
|
|
192
|
+
this.aztecNodeAdmin = this.context.aztecNodeService!;
|
|
193
|
+
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
|
|
194
|
+
this.cheatCodes = this.context.cheatCodes;
|
|
195
|
+
this.accounts = deployedAccounts.map(a => a.address);
|
|
196
|
+
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
|
|
197
|
+
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
|
|
198
|
+
|
|
199
|
+
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
200
|
+
this.fpcAdmin = this.aliceAddress;
|
|
201
|
+
|
|
202
|
+
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
203
|
+
this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
|
|
200
204
|
}
|
|
201
205
|
|
|
202
|
-
async
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
);
|
|
206
|
+
async applyPublicDeployAccounts() {
|
|
207
|
+
this.logger.info('Applying public deploy accounts setup');
|
|
208
|
+
await publicDeployAccounts(this.wallet, this.accounts);
|
|
206
209
|
}
|
|
207
210
|
|
|
208
|
-
async
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
|
|
220
|
-
|
|
221
|
-
const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
222
|
-
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
223
|
-
aztecNode: context.aztecNode,
|
|
224
|
-
pxeService: context.pxe,
|
|
225
|
-
publicClient: publicClient,
|
|
226
|
-
walletClient: walletClient,
|
|
227
|
-
wallet: this.aliceWallet,
|
|
228
|
-
logger: this.logger,
|
|
229
|
-
});
|
|
230
|
-
},
|
|
211
|
+
async applySetupFeeJuice() {
|
|
212
|
+
this.logger.info('Applying fee juice setup');
|
|
213
|
+
|
|
214
|
+
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
|
|
215
|
+
|
|
216
|
+
this.getGasBalanceFn = getBalancesFn(
|
|
217
|
+
'⛽',
|
|
218
|
+
this.feeJuiceContract.methods.balance_of_public,
|
|
219
|
+
this.aliceAddress,
|
|
220
|
+
this.logger,
|
|
231
221
|
);
|
|
222
|
+
|
|
223
|
+
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
224
|
+
aztecNode: this.context.aztecNodeService!,
|
|
225
|
+
aztecNodeAdmin: this.context.aztecNodeService!,
|
|
226
|
+
l1Client: this.context.deployL1ContractsValues.l1Client,
|
|
227
|
+
wallet: this.wallet,
|
|
228
|
+
logger: this.logger,
|
|
229
|
+
});
|
|
232
230
|
}
|
|
233
231
|
|
|
234
|
-
async
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
232
|
+
async applyDeployBananaToken() {
|
|
233
|
+
this.logger.info('Applying deploy banana token setup');
|
|
234
|
+
|
|
235
|
+
const bananaCoin = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
|
|
236
|
+
from: this.aliceAddress,
|
|
237
|
+
});
|
|
238
|
+
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
239
|
+
|
|
240
|
+
this.bananaCoin = bananaCoin;
|
|
241
|
+
this.getBananaPublicBalanceFn = getBalancesFn(
|
|
242
|
+
'🍌.public',
|
|
243
|
+
this.bananaCoin.methods.balance_of_public,
|
|
244
|
+
this.aliceAddress,
|
|
245
|
+
this.logger,
|
|
246
|
+
);
|
|
247
|
+
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
248
|
+
'🍌.private',
|
|
249
|
+
this.bananaCoin.methods.balance_of_private,
|
|
250
|
+
this.aliceAddress,
|
|
251
|
+
this.logger,
|
|
247
252
|
);
|
|
248
253
|
}
|
|
249
254
|
|
|
250
|
-
public async
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return mana * provingCostPerMana;
|
|
319
|
-
};
|
|
320
|
-
},
|
|
321
|
-
);
|
|
255
|
+
public async applyFPCSetup() {
|
|
256
|
+
this.logger.info('Applying FPC setup');
|
|
257
|
+
|
|
258
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
259
|
+
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
260
|
+
|
|
261
|
+
const bananaCoin = this.bananaCoin;
|
|
262
|
+
const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
|
|
263
|
+
from: this.aliceAddress,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
267
|
+
|
|
268
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
269
|
+
|
|
270
|
+
this.bananaFPC = bananaFPC;
|
|
271
|
+
|
|
272
|
+
const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
|
|
273
|
+
|
|
274
|
+
this.getCoinbaseBalance = async () => {
|
|
275
|
+
const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
|
|
276
|
+
const gasL1 = getContract({
|
|
277
|
+
address: l1FeeJuiceAddress.toString(),
|
|
278
|
+
abi: TestERC20Abi,
|
|
279
|
+
client: l1Client,
|
|
280
|
+
});
|
|
281
|
+
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
this.getCoinbaseSequencerRewards = async () => {
|
|
285
|
+
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
this.getProverFee = async (blockNumber: BlockNumber) => {
|
|
289
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
290
|
+
|
|
291
|
+
// @todo @lherskind As we deal with #13601
|
|
292
|
+
// Right now the value is from `FeeLib.sol`
|
|
293
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
294
|
+
|
|
295
|
+
// We round up
|
|
296
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
297
|
+
|
|
298
|
+
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
299
|
+
const proverCost =
|
|
300
|
+
mulDiv(
|
|
301
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
|
|
302
|
+
1n,
|
|
303
|
+
await this.rollupContract.getManaTarget(),
|
|
304
|
+
) + (await this.rollupContract.getProvingCostPerMana());
|
|
305
|
+
|
|
306
|
+
const price = await this.rollupContract.getEthPerFeeAsset();
|
|
307
|
+
|
|
308
|
+
const mana = block!.header.totalManaUsed.toBigInt();
|
|
309
|
+
return mulDiv(mana * proverCost, 10n ** 12n, price);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public async applySponsoredFPCSetup() {
|
|
314
|
+
this.logger.info('Applying sponsored FPC setup');
|
|
315
|
+
|
|
316
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
317
|
+
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
318
|
+
|
|
319
|
+
const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
|
|
320
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
|
|
321
|
+
|
|
322
|
+
this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
|
|
322
323
|
}
|
|
323
324
|
|
|
324
325
|
public async applyFundAliceWithBananas() {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
() => Promise.resolve(),
|
|
332
|
-
);
|
|
326
|
+
this.logger.info('Applying fund Alice with bananas setup');
|
|
327
|
+
|
|
328
|
+
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
329
|
+
await this.bananaCoin.methods
|
|
330
|
+
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
331
|
+
.send({ from: this.aliceAddress });
|
|
333
332
|
}
|
|
334
333
|
|
|
335
334
|
public async applyFundAliceWithPrivateBananas() {
|
|
336
|
-
|
|
337
|
-
'fund_alice_with_private_bananas',
|
|
338
|
-
async () => {
|
|
339
|
-
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
340
|
-
},
|
|
341
|
-
() => Promise.resolve(),
|
|
342
|
-
);
|
|
343
|
-
}
|
|
335
|
+
this.logger.info('Applying fund Alice with private bananas setup');
|
|
344
336
|
|
|
345
|
-
|
|
346
|
-
await this.snapshotManager.snapshot(
|
|
347
|
-
'setup_subscription',
|
|
348
|
-
async () => {
|
|
349
|
-
const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed();
|
|
350
|
-
|
|
351
|
-
// Deploy subscription contract, that allows subscriptions for SUBSCRIPTION_AMOUNT of bananas
|
|
352
|
-
const subscriptionContract = await AppSubscriptionContract.deploy(
|
|
353
|
-
this.bobWallet,
|
|
354
|
-
counterContract.address,
|
|
355
|
-
this.bobAddress,
|
|
356
|
-
this.bananaCoin.address,
|
|
357
|
-
this.SUBSCRIPTION_AMOUNT,
|
|
358
|
-
this.APP_SPONSORED_TX_GAS_LIMIT,
|
|
359
|
-
)
|
|
360
|
-
.send()
|
|
361
|
-
.deployed();
|
|
362
|
-
|
|
363
|
-
// Mint some Fee Juice to the subscription contract
|
|
364
|
-
// Could also use bridgeFromL1ToL2 from the harness, but this is more direct
|
|
365
|
-
await this.mintAndBridgeFeeJuice(subscriptionContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT);
|
|
366
|
-
return {
|
|
367
|
-
counterContractAddress: counterContract.address,
|
|
368
|
-
subscriptionContractAddress: subscriptionContract.address,
|
|
369
|
-
};
|
|
370
|
-
},
|
|
371
|
-
async ({ counterContractAddress, subscriptionContractAddress }) => {
|
|
372
|
-
this.counterContract = await CounterContract.at(counterContractAddress, this.bobWallet);
|
|
373
|
-
this.subscriptionContract = await AppSubscriptionContract.at(subscriptionContractAddress, this.bobWallet);
|
|
374
|
-
},
|
|
375
|
-
);
|
|
337
|
+
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
376
338
|
}
|
|
377
339
|
}
|