@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.017a351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dest/bench/client_flows/benchmark.d.ts +76 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +298 -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 +318 -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 +124 -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 +46 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +30 -20
- 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 +137 -106
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +44 -33
- 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 +136 -103
- package/dest/e2e_deploy_contract/deploy_test.d.ts +20 -11
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +28 -28
- package/dest/e2e_epochs/epochs_test.d.ts +98 -24
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +366 -61
- 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 +42 -24
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +194 -182
- package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +56 -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 +16 -16
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +38 -43
- 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 +137 -0
- package/dest/e2e_p2p/p2p_network.d.ts +287 -31
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +281 -183
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +206 -0
- package/dest/e2e_p2p/shared.d.ts +73 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +205 -27
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +30 -15
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +110 -76
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +56 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +267 -0
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +79 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +76 -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/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- 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/schnorr_hardcoded_account_contract.d.ts +25 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
- package/dest/fixtures/setup.d.ts +272 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +735 -0
- package/dest/fixtures/setup_p2p_test.d.ts +28 -16
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +103 -32
- 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 +30 -13
- 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/forward-compatibility/wallet_rpc_client.d.ts +7 -0
- package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
- package/dest/forward-compatibility/wallet_service.d.ts +3 -0
- package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_service.js +109 -0
- package/dest/index.d.ts +1 -1
- package/dest/install_legacy_contracts.d.cts +10 -0
- package/dest/install_legacy_contracts.d.cts.map +1 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- 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 +46 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +113 -55
- package/dest/shared/gas_portal_test_harness.d.ts +39 -28
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +64 -34
- package/dest/shared/index.d.ts +3 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +42 -2
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- 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 +202 -135
- package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
- package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +16 -9
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +38 -27
- 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 +12 -30
- package/dest/spartan/setup_test_wallets.d.ts +36 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +301 -63
- package/dest/spartan/tx_metrics.d.ts +102 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +475 -0
- package/dest/spartan/utils/bot.d.ts +28 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +142 -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 +19 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +23 -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 +11 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +22 -0
- package/dest/spartan/utils/k8s.d.ts +128 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +381 -0
- package/dest/spartan/utils/nodes.d.ts +40 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +461 -0
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/spartan/utils/scripts.d.ts +30 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +81 -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/dest/test-wallet/test_wallet.d.ts +85 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +273 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +66 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +53 -0
- package/dest/test-wallet/worker_wallet.d.ts +53 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +155 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +22 -0
- package/package.json +79 -64
- package/src/bench/client_flows/benchmark.ts +382 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +399 -0
- package/src/bench/client_flows/config.ts +69 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +49 -87
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +164 -172
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +194 -183
- package/src/e2e_deploy_contract/deploy_test.ts +42 -49
- package/src/e2e_epochs/epochs_test.ts +451 -93
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +249 -262
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +51 -60
- package/src/e2e_p2p/inactivity_slash_test.ts +180 -0
- package/src/e2e_p2p/p2p_network.ts +391 -240
- package/src/e2e_p2p/reqresp/utils.ts +274 -0
- package/src/e2e_p2p/shared.ts +304 -39
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +140 -124
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +329 -0
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +98 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +19 -13
- package/src/fixtures/ha_setup.ts +188 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +1056 -0
- package/src/fixtures/setup_p2p_test.ts +142 -54
- package/src/fixtures/token_utils.ts +34 -16
- package/src/fixtures/utils.ts +29 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/guides/up_quick_start.sh +9 -19
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +112 -0
- 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 +116 -90
- package/src/shared/gas_portal_test_harness.ts +75 -56
- package/src/shared/index.ts +2 -1
- package/src/shared/jest_setup.ts +52 -2
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +19 -20
- package/src/shared/uniswap_l1_l2.ts +259 -234
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +43 -26
- package/src/simulators/token_simulator.ts +18 -34
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +420 -96
- package/src/spartan/tx_metrics.ts +434 -0
- package/src/spartan/utils/bot.ts +188 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +29 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +71 -0
- package/src/spartan/utils/k8s.ts +535 -0
- package/src/spartan/utils/nodes.ts +543 -0
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/spartan/utils/scripts.ts +99 -0
- package/src/spartan/utils.ts +1 -582
- package/src/test-wallet/test_wallet.ts +376 -0
- package/src/test-wallet/utils.ts +108 -0
- package/src/test-wallet/wallet_worker_script.ts +63 -0
- package/src/test-wallet/worker_wallet.ts +218 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
- 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,64 @@
|
|
|
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, getTokenAllowedSetupFunctions } 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';
|
|
26
23
|
|
|
27
24
|
import { getContract } from 'viem';
|
|
28
25
|
|
|
29
|
-
import { MNEMONIC } from '../fixtures/fixtures.js';
|
|
26
|
+
import { MNEMONIC, getPaddedMaxFeesPerGas } from '../fixtures/fixtures.js';
|
|
30
27
|
import {
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
createSnapshotManager,
|
|
28
|
+
type EndToEndContext,
|
|
29
|
+
type SetupOptions,
|
|
34
30
|
deployAccounts,
|
|
35
|
-
|
|
31
|
+
ensureAuthRegistryPublished,
|
|
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
|
-
|
|
46
|
-
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
39
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
47
40
|
|
|
48
41
|
/**
|
|
49
|
-
* Test fixture for testing fees. Provides the following
|
|
42
|
+
* Test fixture for testing fees. Provides the following setup steps:
|
|
50
43
|
* InitialAccounts: Initializes 3 Schnorr account contracts.
|
|
51
44
|
* PublicDeployAccounts: Deploys the accounts publicly.
|
|
52
45
|
* DeployFeeJuice: Deploys the Fee Juice contract.
|
|
53
46
|
* FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
|
|
47
|
+
* SponsoredFPCSetup: Deploys Sponsored FPC contract, and bridges gas from L1.
|
|
54
48
|
* FundAlice: Mints private and public bananas to Alice.
|
|
55
49
|
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
56
50
|
*/
|
|
57
51
|
export class FeesTest {
|
|
58
|
-
private
|
|
59
|
-
|
|
52
|
+
private accounts: AztecAddress[] = [];
|
|
53
|
+
public context!: EndToEndContext;
|
|
60
54
|
|
|
61
55
|
public logger: Logger;
|
|
62
|
-
public pxe!: PXE;
|
|
63
56
|
public aztecNode!: AztecNode;
|
|
57
|
+
public aztecNodeAdmin!: AztecNodeAdmin;
|
|
64
58
|
public cheatCodes!: CheatCodes;
|
|
65
59
|
|
|
66
|
-
public
|
|
60
|
+
public wallet!: TestWallet;
|
|
67
61
|
public aliceAddress!: AztecAddress;
|
|
68
|
-
public bobWallet!: AccountWallet;
|
|
69
62
|
public bobAddress!: AztecAddress;
|
|
70
63
|
public sequencerAddress!: AztecAddress;
|
|
71
64
|
public coinbase!: EthAddress;
|
|
@@ -74,14 +67,16 @@ export class FeesTest {
|
|
|
74
67
|
|
|
75
68
|
public gasSettings!: GasSettings;
|
|
76
69
|
|
|
70
|
+
public rollupContract!: RollupContract;
|
|
71
|
+
|
|
77
72
|
public feeJuiceContract!: FeeJuiceContract;
|
|
78
73
|
public bananaCoin!: BananaCoin;
|
|
79
74
|
public bananaFPC!: FPCContract;
|
|
75
|
+
public sponsoredFPC!: SponsoredFPCContract;
|
|
80
76
|
public counterContract!: CounterContract;
|
|
81
77
|
public subscriptionContract!: AppSubscriptionContract;
|
|
82
78
|
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
|
|
83
79
|
|
|
84
|
-
public context!: SubsystemsContext;
|
|
85
80
|
public chainMonitor!: ChainMonitor;
|
|
86
81
|
|
|
87
82
|
public getCoinbaseBalance!: () => Promise<bigint>;
|
|
@@ -89,7 +84,9 @@ export class FeesTest {
|
|
|
89
84
|
public getGasBalanceFn!: BalancesFn;
|
|
90
85
|
public getBananaPublicBalanceFn!: BalancesFn;
|
|
91
86
|
public getBananaPrivateBalanceFn!: BalancesFn;
|
|
92
|
-
public getProverFee!: (blockNumber:
|
|
87
|
+
public getProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
|
|
88
|
+
public getCommittedProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
|
|
89
|
+
public getCommittedBurn!: (blockNumber: BlockNumber) => Promise<bigint>;
|
|
93
90
|
|
|
94
91
|
public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
|
|
95
92
|
public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
|
|
@@ -98,33 +95,41 @@ export class FeesTest {
|
|
|
98
95
|
constructor(
|
|
99
96
|
testName: string,
|
|
100
97
|
private numberOfAccounts = 3,
|
|
101
|
-
setupOptions: Partial<SetupOptions &
|
|
98
|
+
private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
|
|
102
99
|
) {
|
|
103
100
|
if (!numberOfAccounts) {
|
|
104
101
|
throw new Error('There must be at least 1 initial account.');
|
|
105
102
|
}
|
|
103
|
+
setupOptions.coinbase ??= EthAddress.random();
|
|
104
|
+
this.coinbase = setupOptions.coinbase!;
|
|
106
105
|
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
106
|
}
|
|
114
107
|
|
|
115
|
-
async setup() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
108
|
+
async setup(opts: Partial<SetupOptions> = {}) {
|
|
109
|
+
this.logger.verbose('Setting up fresh context...');
|
|
110
|
+
// Token allowlist entries are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
|
|
111
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
112
|
+
this.context = await setup(0, {
|
|
113
|
+
startProverNode: true,
|
|
114
|
+
...this.setupOptions,
|
|
115
|
+
...opts,
|
|
116
|
+
fundSponsoredFPC: true,
|
|
117
|
+
skipAccountDeployment: true,
|
|
118
|
+
l1ContractsArgs: { ...this.setupOptions },
|
|
119
|
+
txPublicSetupAllowListExtend: [...(this.setupOptions.txPublicSetupAllowListExtend ?? []), ...tokenAllowList],
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
this.rollupContract = RollupContract.getFromConfig(this.context.config);
|
|
123
|
+
this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider, this.logger, 200).start();
|
|
124
|
+
|
|
125
|
+
await this.applyBaseSetup();
|
|
121
126
|
|
|
122
127
|
return this;
|
|
123
128
|
}
|
|
124
129
|
|
|
125
130
|
async teardown() {
|
|
126
|
-
this.chainMonitor.stop();
|
|
127
|
-
await this.
|
|
131
|
+
await this.chainMonitor.stop();
|
|
132
|
+
await teardown(this.context);
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
setIsMarkingAsProven(b: boolean) {
|
|
@@ -133,245 +138,227 @@ export class FeesTest {
|
|
|
133
138
|
|
|
134
139
|
async catchUpProvenChain() {
|
|
135
140
|
const bn = await this.aztecNode.getBlockNumber();
|
|
136
|
-
while ((await this.aztecNode.
|
|
141
|
+
while ((await this.aztecNode.getBlockNumber('proven')) < bn) {
|
|
137
142
|
await sleep(1000);
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
async
|
|
142
|
-
const
|
|
146
|
+
async getBlockRewards() {
|
|
147
|
+
const blockReward = await this.rollupContract.getCheckpointReward();
|
|
148
|
+
const rewardConfig = await this.rollupContract.getRewardConfig();
|
|
149
|
+
|
|
150
|
+
const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
|
|
151
|
+
|
|
152
|
+
const toDistribute = balance > blockReward ? blockReward : balance;
|
|
153
|
+
const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
|
|
154
|
+
const proverBlockRewards = toDistribute - sequencerBlockRewards;
|
|
155
|
+
|
|
156
|
+
return { sequencerBlockRewards, proverBlockRewards };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
|
|
160
|
+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
|
|
143
161
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
144
|
-
await this.feeJuiceContract.methods.claim(
|
|
162
|
+
await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
148
166
|
async mintPrivateBananas(amount: bigint, address: AztecAddress) {
|
|
149
|
-
const balanceBefore = await this.bananaCoin.methods
|
|
167
|
+
const { result: balanceBefore } = await this.bananaCoin.methods
|
|
168
|
+
.balance_of_private(address)
|
|
169
|
+
.simulate({ from: address });
|
|
150
170
|
|
|
151
|
-
await mintTokensToPrivate(this.bananaCoin, this.
|
|
171
|
+
await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
|
|
152
172
|
|
|
153
|
-
const balanceAfter = await this.bananaCoin.methods
|
|
173
|
+
const { result: balanceAfter } = await this.bananaCoin.methods
|
|
174
|
+
.balance_of_private(address)
|
|
175
|
+
.simulate({ from: address });
|
|
154
176
|
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
155
177
|
}
|
|
156
178
|
|
|
157
|
-
public async
|
|
158
|
-
await this.
|
|
159
|
-
await this.
|
|
160
|
-
await this.
|
|
161
|
-
await this.
|
|
179
|
+
public async applyBaseSetup() {
|
|
180
|
+
await this.applyInitialAccounts();
|
|
181
|
+
await this.applyEnsureAuthRegistryPublished();
|
|
182
|
+
await this.applyPublicDeployAccounts();
|
|
183
|
+
await this.applySetupFeeJuice();
|
|
184
|
+
await this.applyDeployBananaToken();
|
|
162
185
|
}
|
|
163
186
|
|
|
164
|
-
async
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
deployAccounts(this.numberOfAccounts, this.logger),
|
|
168
|
-
async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig }) => {
|
|
169
|
-
this.pxe = pxe;
|
|
170
|
-
this.aztecNode = aztecNode;
|
|
171
|
-
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) });
|
|
172
|
-
this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
173
|
-
this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
174
|
-
this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
175
|
-
[this.aliceWallet, this.bobWallet] = this.wallets.slice(0, 2);
|
|
176
|
-
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.wallets.map(w => w.getAddress());
|
|
177
|
-
|
|
178
|
-
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
179
|
-
this.fpcAdmin = this.aliceAddress;
|
|
180
|
-
|
|
181
|
-
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
182
|
-
this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.aliceWallet);
|
|
183
|
-
if (this.numberOfAccounts > 1) {
|
|
184
|
-
const bobInstance = (await this.bobWallet.getContractMetadata(this.bobAddress)).contractInstance;
|
|
185
|
-
await this.aliceWallet.registerAccount(deployedAccounts[1].secret, await computePartialAddress(bobInstance!));
|
|
186
|
-
}
|
|
187
|
-
this.coinbase = EthAddress.random();
|
|
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
|
-
);
|
|
187
|
+
async applyEnsureAuthRegistryPublished() {
|
|
188
|
+
this.logger.info('Ensuring AuthRegistry published');
|
|
189
|
+
await ensureAuthRegistryPublished(this.wallet, this.aliceAddress);
|
|
200
190
|
}
|
|
201
191
|
|
|
202
|
-
async
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
192
|
+
async applyInitialAccounts() {
|
|
193
|
+
this.logger.info('Applying initial accounts setup');
|
|
194
|
+
|
|
195
|
+
const { deployedAccounts } = await deployAccounts(
|
|
196
|
+
this.numberOfAccounts,
|
|
197
|
+
this.logger,
|
|
198
|
+
)({
|
|
199
|
+
wallet: this.context.wallet,
|
|
200
|
+
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
this.wallet = this.context.wallet;
|
|
204
|
+
this.aztecNode = this.context.aztecNodeService;
|
|
205
|
+
this.aztecNodeAdmin = this.context.aztecNodeService;
|
|
206
|
+
this.gasSettings = GasSettings.fallback({
|
|
207
|
+
maxFeesPerGas: await getPaddedMaxFeesPerGas(this.aztecNode),
|
|
208
|
+
});
|
|
209
|
+
this.cheatCodes = this.context.cheatCodes;
|
|
210
|
+
this.accounts = deployedAccounts.map(a => a.address);
|
|
211
|
+
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
|
|
212
|
+
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
|
|
213
|
+
|
|
214
|
+
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
215
|
+
this.fpcAdmin = this.aliceAddress;
|
|
216
|
+
|
|
217
|
+
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
218
|
+
this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
|
|
206
219
|
}
|
|
207
220
|
|
|
208
|
-
async
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
async context => {
|
|
212
|
-
await setupCanonicalFeeJuice(context.pxe);
|
|
213
|
-
},
|
|
214
|
-
async (_data, context) => {
|
|
215
|
-
this.context = context;
|
|
216
|
-
|
|
217
|
-
this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.aliceWallet);
|
|
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
|
-
},
|
|
231
|
-
);
|
|
221
|
+
async applyPublicDeployAccounts() {
|
|
222
|
+
this.logger.info('Applying public deploy accounts setup');
|
|
223
|
+
await publicDeployAccounts(this.wallet, this.accounts);
|
|
232
224
|
}
|
|
233
225
|
|
|
234
|
-
async
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
);
|
|
226
|
+
async applySetupFeeJuice() {
|
|
227
|
+
this.logger.info('Applying fee juice setup');
|
|
228
|
+
|
|
229
|
+
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
|
|
230
|
+
|
|
231
|
+
this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
|
|
232
|
+
|
|
233
|
+
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
234
|
+
aztecNode: this.context.aztecNodeService,
|
|
235
|
+
aztecNodeAdmin: this.context.aztecNodeService,
|
|
236
|
+
l1Client: this.context.deployL1ContractsValues.l1Client,
|
|
237
|
+
wallet: this.wallet,
|
|
238
|
+
logger: this.logger,
|
|
239
|
+
});
|
|
248
240
|
}
|
|
249
241
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(FEE_FUNDING_FOR_TESTER_ACCOUNT, bananaFPC.address);
|
|
265
|
-
|
|
266
|
-
return {
|
|
267
|
-
bananaFPCAddress: bananaFPC.address,
|
|
268
|
-
feeJuiceAddress: feeJuiceContract.address,
|
|
269
|
-
l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress,
|
|
270
|
-
rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
271
|
-
};
|
|
272
|
-
},
|
|
273
|
-
async (data, context) => {
|
|
274
|
-
const bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.aliceWallet);
|
|
275
|
-
this.bananaFPC = bananaFPC;
|
|
276
|
-
|
|
277
|
-
const logger = this.logger;
|
|
278
|
-
this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, logger);
|
|
279
|
-
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
280
|
-
'🍌.private',
|
|
281
|
-
this.bananaCoin.methods.balance_of_private,
|
|
282
|
-
logger,
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
this.getCoinbaseBalance = async () => {
|
|
286
|
-
const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
287
|
-
const gasL1 = getContract({
|
|
288
|
-
address: data.l1FeeJuiceAddress.toString(),
|
|
289
|
-
abi: TestERC20Abi,
|
|
290
|
-
client: walletClient,
|
|
291
|
-
});
|
|
292
|
-
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
this.getCoinbaseSequencerRewards = async () => {
|
|
296
|
-
const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
297
|
-
const rollup = getContract({
|
|
298
|
-
address: data.rollupAddress.toString(),
|
|
299
|
-
abi: RollupAbi,
|
|
300
|
-
client: walletClient,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
return await rollup.read.getSequencerRewards([this.coinbase.toString()]);
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
this.getProverFee = async (blockNumber: number) => {
|
|
307
|
-
const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
308
|
-
const rollup = getContract({
|
|
309
|
-
address: data.rollupAddress.toString(),
|
|
310
|
-
abi: RollupAbi,
|
|
311
|
-
client: walletClient,
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
const provingCostPerMana = await rollup.read.getProvingCostPerManaInFeeAsset();
|
|
315
|
-
|
|
316
|
-
const block = await this.pxe.getBlock(blockNumber);
|
|
317
|
-
const mana = block!.header.totalManaUsed.toBigInt();
|
|
318
|
-
return mana * provingCostPerMana;
|
|
319
|
-
};
|
|
320
|
-
},
|
|
242
|
+
async applyDeployBananaToken() {
|
|
243
|
+
this.logger.info('Applying deploy banana token setup');
|
|
244
|
+
|
|
245
|
+
const { contract: bananaCoin } = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
|
|
246
|
+
from: this.aliceAddress,
|
|
247
|
+
});
|
|
248
|
+
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
249
|
+
|
|
250
|
+
this.bananaCoin = bananaCoin;
|
|
251
|
+
this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, this.logger);
|
|
252
|
+
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
253
|
+
'🍌.private',
|
|
254
|
+
this.bananaCoin.methods.balance_of_private,
|
|
255
|
+
this.logger,
|
|
321
256
|
);
|
|
322
257
|
}
|
|
323
258
|
|
|
259
|
+
public async applyFPCSetup() {
|
|
260
|
+
this.logger.info('Applying FPC setup');
|
|
261
|
+
|
|
262
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
263
|
+
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
264
|
+
|
|
265
|
+
const bananaCoin = this.bananaCoin;
|
|
266
|
+
const { contract: bananaFPC } = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
|
|
267
|
+
from: this.aliceAddress,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
271
|
+
|
|
272
|
+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
273
|
+
|
|
274
|
+
this.bananaFPC = bananaFPC;
|
|
275
|
+
|
|
276
|
+
const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
|
|
277
|
+
|
|
278
|
+
this.getCoinbaseBalance = async () => {
|
|
279
|
+
const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
|
|
280
|
+
const gasL1 = getContract({
|
|
281
|
+
address: l1FeeJuiceAddress.toString(),
|
|
282
|
+
abi: TestERC20Abi,
|
|
283
|
+
client: l1Client,
|
|
284
|
+
});
|
|
285
|
+
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
this.getCoinbaseSequencerRewards = async () => {
|
|
289
|
+
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
this.getProverFee = async (blockNumber: BlockNumber) => {
|
|
293
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
294
|
+
|
|
295
|
+
// @todo @lherskind As we deal with #13601
|
|
296
|
+
// Right now the value is from `FeeLib.sol`
|
|
297
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
|
|
298
|
+
|
|
299
|
+
// We round up
|
|
300
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
301
|
+
|
|
302
|
+
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
303
|
+
const proverCost =
|
|
304
|
+
mulDiv(
|
|
305
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
|
|
306
|
+
1n,
|
|
307
|
+
await this.rollupContract.getManaTarget(),
|
|
308
|
+
) + (await this.rollupContract.getProvingCostPerMana());
|
|
309
|
+
|
|
310
|
+
const price = await this.rollupContract.getEthPerFeeAsset();
|
|
311
|
+
|
|
312
|
+
const mana = block!.header.totalManaUsed.toBigInt();
|
|
313
|
+
return mulDiv(mana * proverCost, 10n ** 12n, price);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Reads the prover fee that the rollup actually committed for the block's checkpoint, which is what
|
|
318
|
+
* RewardLib uses to pay prover rewards. Unlike `getProverFee`, this does not re-derive the value
|
|
319
|
+
* from current L1 fees or current eth-per-fee-asset price, so it is robust to pipelined fee-asset-price
|
|
320
|
+
* drift between propose-time and reward-payout-time.
|
|
321
|
+
*/
|
|
322
|
+
this.getCommittedProverFee = async (blockNumber: BlockNumber) => {
|
|
323
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
324
|
+
const feeHeader = await this.rollupContract.getFeeHeader(BigInt(block!.checkpointNumber));
|
|
325
|
+
return feeHeader.manaUsed * feeHeader.proverCost;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// RewardLib computes sequencerFee = checkpointFee - burn - proverFee where burn = manaUsed * congestionCost.
|
|
329
|
+
// The fixture's typical case keeps congestionCost at zero, but reading it explicitly avoids latent bugs
|
|
330
|
+
// when test load changes excess mana.
|
|
331
|
+
this.getCommittedBurn = async (blockNumber: BlockNumber) => {
|
|
332
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
333
|
+
const feeHeader = await this.rollupContract.getFeeHeader(BigInt(block!.checkpointNumber));
|
|
334
|
+
return feeHeader.manaUsed * feeHeader.congestionCost;
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
public async applySponsoredFPCSetup() {
|
|
339
|
+
this.logger.info('Applying sponsored FPC setup');
|
|
340
|
+
|
|
341
|
+
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
342
|
+
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
343
|
+
|
|
344
|
+
const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
|
|
345
|
+
this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
|
|
346
|
+
|
|
347
|
+
this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
|
|
348
|
+
}
|
|
349
|
+
|
|
324
350
|
public async applyFundAliceWithBananas() {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
() => Promise.resolve(),
|
|
332
|
-
);
|
|
351
|
+
this.logger.info('Applying fund Alice with bananas setup');
|
|
352
|
+
|
|
353
|
+
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
354
|
+
await this.bananaCoin.methods
|
|
355
|
+
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
356
|
+
.send({ from: this.aliceAddress });
|
|
333
357
|
}
|
|
334
358
|
|
|
335
359
|
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
|
-
}
|
|
360
|
+
this.logger.info('Applying fund Alice with private bananas setup');
|
|
344
361
|
|
|
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
|
-
);
|
|
362
|
+
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
376
363
|
}
|
|
377
364
|
}
|