@aztec/end-to-end 0.0.1-commit.c2eed6949 → 0.0.1-commit.c52d6e7
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 +229 -14
- package/dest/automine/automine_test_context.d.ts +85 -0
- package/dest/automine/automine_test_context.d.ts.map +1 -0
- package/dest/automine/automine_test_context.js +98 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
- package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
- package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +23 -36
- package/dest/automine/token/token_contract_test.d.ts +40 -0
- package/dest/automine/token/token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +24 -39
- package/dest/automine/token/token_test_helpers.d.ts +73 -0
- package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
- package/dest/automine/token/token_test_helpers.js +97 -0
- package/dest/bench/client_flows/benchmark.d.ts +15 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +19 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +6 -6
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +56 -58
- package/dest/bench/client_flows/data_extractor.js +1 -0
- package/dest/bench/utils.d.ts +3 -3
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +97 -6
- package/dest/composed/ha/ha_full_setup.d.ts +77 -0
- package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
- package/dest/composed/ha/ha_full_setup.js +383 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.d.ts +1 -1
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
- package/dest/fixtures/authwit_proxy.js +4 -0
- package/dest/fixtures/e2e_prover_test.d.ts +12 -9
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +53 -35
- package/dest/fixtures/fixtures.d.ts +79 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +80 -0
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -2
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/ha_setup.d.ts +4 -4
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +5 -2
- 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/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 +81 -42
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +289 -198
- package/dest/fixtures/setup_p2p_test.d.ts +10 -6
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +11 -11
- package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
- package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
- package/dest/fixtures/standard_contracts_genesis.js +25 -0
- package/dest/fixtures/timing.d.ts +42 -0
- package/dest/fixtures/timing.d.ts.map +1 -0
- package/dest/fixtures/timing.js +72 -0
- package/dest/fixtures/token_utils.d.ts +22 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +23 -6
- package/dest/fixtures/utils.d.ts +2 -2
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +1 -1
- package/dest/fixtures/wait_helpers.d.ts +135 -0
- package/dest/fixtures/wait_helpers.d.ts.map +1 -0
- package/dest/fixtures/wait_helpers.js +154 -0
- 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/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/multi-node/block-production/setup.d.ts +97 -0
- package/dest/multi-node/block-production/setup.d.ts.map +1 -0
- package/dest/multi-node/block-production/setup.js +158 -0
- package/dest/multi-node/governance/setup.d.ts +67 -0
- package/dest/multi-node/governance/setup.d.ts.map +1 -0
- package/dest/multi-node/governance/setup.js +126 -0
- package/dest/multi-node/multi_node_test_context.d.ts +212 -0
- package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
- package/dest/multi-node/multi_node_test_context.js +347 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/inactivity_setup.js +111 -0
- package/dest/multi-node/slashing/setup.d.ts +167 -0
- package/dest/multi-node/slashing/setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/setup.js +275 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +19 -10
- package/dest/p2p/p2p_network.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.js +82 -38
- package/dest/p2p/reqresp/utils.d.ts +19 -0
- package/dest/p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/reqresp/utils.js +32 -29
- package/dest/p2p/shared.d.ts +72 -0
- package/dest/p2p/shared.d.ts.map +1 -0
- package/dest/p2p/shared.js +212 -0
- package/dest/shared/cross_chain_test_harness.d.ts +6 -4
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +33 -21
- package/dest/shared/gas_portal_test_harness.d.ts +9 -6
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +26 -15
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +12 -5
- package/dest/shared/timing_env.d.js +5 -0
- package/dest/shared/timing_env.js +365 -0
- 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 +50 -37
- 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/lending_simulator.d.ts +10 -3
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +24 -12
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
- package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
- package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
- package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
- package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
- package/dest/single-node/fees/fees_test.d.ts +95 -0
- package/dest/single-node/fees/fees_test.d.ts.map +1 -0
- package/dest/single-node/fees/fees_test.js +344 -0
- package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
- package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
- package/dest/single-node/l1-reorgs/setup.js +57 -0
- package/dest/single-node/partial-proofs/setup.d.ts +5 -0
- package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
- package/dest/single-node/partial-proofs/setup.js +5 -0
- package/dest/single-node/proving/setup.d.ts +5 -0
- package/dest/single-node/proving/setup.d.ts.map +1 -0
- package/dest/single-node/proving/setup.js +5 -0
- package/dest/single-node/recovery/setup.d.ts +5 -0
- package/dest/single-node/recovery/setup.d.ts.map +1 -0
- package/dest/single-node/recovery/setup.js +5 -0
- package/dest/single-node/setup.d.ts +49 -0
- package/dest/single-node/setup.d.ts.map +1 -0
- package/dest/single-node/setup.js +56 -0
- package/dest/single-node/single_node_test_context.d.ts +374 -0
- package/dest/single-node/single_node_test_context.d.ts.map +1 -0
- package/dest/single-node/single_node_test_context.js +847 -0
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +84 -50
- package/dest/spartan/tx_metrics.d.ts +27 -4
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +105 -20
- package/dest/spartan/utils/config.d.ts +9 -35
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +2 -2
- package/dest/test-wallet/test_wallet.d.ts +39 -10
- package/dest/test-wallet/test_wallet.d.ts.map +1 -1
- package/dest/test-wallet/test_wallet.js +166 -59
- package/dest/test-wallet/utils.d.ts +38 -3
- package/dest/test-wallet/utils.d.ts.map +1 -1
- package/dest/test-wallet/utils.js +65 -10
- package/dest/test-wallet/wallet_worker_script.js +12 -4
- package/dest/test-wallet/worker_wallet.d.ts +9 -8
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet.js +10 -4
- package/dest/test-wallet/worker_wallet_schema.d.ts +3 -273
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet_schema.js +15 -2
- package/package.json +47 -42
- package/src/automine/README.md +60 -0
- package/src/automine/automine_test_context.ts +153 -0
- package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
- package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
- package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +24 -47
- package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +25 -48
- package/src/automine/token/token_test_helpers.ts +138 -0
- package/src/bench/client_flows/benchmark.ts +21 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +106 -80
- package/src/bench/client_flows/data_extractor.ts +1 -0
- package/src/bench/utils.ts +110 -6
- package/src/composed/ha/ha_full_setup.ts +466 -0
- package/src/fixtures/authwit_proxy.ts +4 -0
- package/src/fixtures/e2e_prover_test.ts +68 -52
- package/src/fixtures/fixtures.ts +100 -0
- package/src/fixtures/get_acvm_config.ts +2 -8
- package/src/fixtures/get_bb_config.ts +1 -2
- package/src/fixtures/ha_setup.ts +11 -5
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +361 -256
- package/src/fixtures/setup_p2p_test.ts +15 -11
- package/src/fixtures/standard_contracts_genesis.ts +28 -0
- package/src/fixtures/timing.ts +97 -0
- package/src/fixtures/token_utils.ts +40 -8
- package/src/fixtures/utils.ts +2 -3
- package/src/fixtures/wait_helpers.ts +333 -0
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +106 -0
- package/src/guides/up_quick_start.sh +5 -2
- package/src/infra/README.md +12 -0
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +112 -0
- package/src/multi-node/README.md +96 -0
- package/src/multi-node/block-production/setup.ts +272 -0
- package/src/multi-node/governance/setup.ts +172 -0
- package/src/multi-node/multi_node_test_context.ts +447 -0
- package/src/multi-node/slashing/inactivity_setup.ts +139 -0
- package/src/multi-node/slashing/setup.ts +433 -0
- package/src/p2p/README.md +78 -0
- package/src/{e2e_p2p → p2p}/p2p_network.ts +95 -50
- package/src/{e2e_p2p → p2p}/reqresp/utils.ts +35 -28
- package/src/p2p/shared.ts +329 -0
- package/src/shared/cross_chain_test_harness.ts +36 -17
- package/src/shared/gas_portal_test_harness.ts +34 -17
- package/src/shared/submit-transactions.ts +13 -5
- package/src/shared/timing_env.d.mts +39 -0
- package/src/shared/timing_env.mjs +363 -0
- package/src/shared/uniswap_l1_l2.ts +80 -43
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +28 -14
- package/src/single-node/README.md +66 -0
- package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
- package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
- package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
- package/src/single-node/fees/fees_test.ts +434 -0
- package/src/single-node/l1-reorgs/setup.ts +93 -0
- package/src/single-node/partial-proofs/setup.ts +8 -0
- package/src/single-node/proving/setup.ts +15 -0
- package/src/single-node/recovery/setup.ts +8 -0
- package/src/single-node/setup.ts +63 -0
- package/src/single-node/single_node_test_context.ts +1058 -0
- package/src/spartan/setup_test_wallets.ts +87 -47
- package/src/spartan/tx_metrics.ts +107 -23
- package/src/spartan/utils/nodes.ts +2 -2
- package/src/test-wallet/test_wallet.ts +185 -60
- package/src/test-wallet/utils.ts +104 -11
- package/src/test-wallet/wallet_worker_script.ts +11 -5
- package/src/test-wallet/worker_wallet.ts +19 -16
- package/src/test-wallet/worker_wallet_schema.ts +4 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -55
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -129
- package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.js +0 -50
- package/dest/e2e_epochs/epochs_test.d.ts +0 -104
- package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
- package/dest/e2e_epochs/epochs_test.js +0 -389
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
- package/dest/e2e_fees/fees_test.d.ts +0 -88
- package/dest/e2e_fees/fees_test.d.ts.map +0 -1
- package/dest/e2e_fees/fees_test.js +0 -255
- package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
- package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.js +0 -56
- package/dest/e2e_multi_validator/utils.d.ts +0 -12
- package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +0 -54
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
- package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.d.ts +0 -66
- package/dest/e2e_p2p/shared.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.js +0 -212
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -193
- package/src/e2e_deploy_contract/deploy_test.ts +0 -85
- package/src/e2e_epochs/epochs_test.ts +0 -499
- package/src/e2e_fees/fees_test.ts +0 -331
- package/src/e2e_l1_publisher/write_json.ts +0 -77
- package/src/e2e_nested_contract/nested_contract_test.ts +0 -75
- package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
- package/src/e2e_p2p/shared.ts +0 -343
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
- /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
- /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
|
@@ -1,331 +0,0 @@
|
|
|
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';
|
|
10
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
11
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
12
|
-
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
13
|
-
import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
|
|
14
|
-
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
15
|
-
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
16
|
-
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
17
|
-
import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
|
|
18
|
-
import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
|
|
19
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
20
|
-
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
21
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
22
|
-
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
23
|
-
|
|
24
|
-
import { getContract } from 'viem';
|
|
25
|
-
|
|
26
|
-
import { MNEMONIC } from '../fixtures/fixtures.js';
|
|
27
|
-
import {
|
|
28
|
-
type EndToEndContext,
|
|
29
|
-
type SetupOptions,
|
|
30
|
-
deployAccounts,
|
|
31
|
-
publicDeployAccounts,
|
|
32
|
-
setup,
|
|
33
|
-
teardown,
|
|
34
|
-
} from '../fixtures/setup.js';
|
|
35
|
-
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
36
|
-
import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
|
|
37
|
-
import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
|
|
38
|
-
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Test fixture for testing fees. Provides the following setup steps:
|
|
42
|
-
* InitialAccounts: Initializes 3 Schnorr account contracts.
|
|
43
|
-
* PublicDeployAccounts: Deploys the accounts publicly.
|
|
44
|
-
* DeployFeeJuice: Deploys the Fee Juice contract.
|
|
45
|
-
* FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
|
|
46
|
-
* SponsoredFPCSetup: Deploys Sponsored FPC contract, and bridges gas from L1.
|
|
47
|
-
* FundAlice: Mints private and public bananas to Alice.
|
|
48
|
-
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
49
|
-
*/
|
|
50
|
-
export class FeesTest {
|
|
51
|
-
private accounts: AztecAddress[] = [];
|
|
52
|
-
public context!: EndToEndContext;
|
|
53
|
-
|
|
54
|
-
public logger: Logger;
|
|
55
|
-
public aztecNode!: AztecNode;
|
|
56
|
-
public aztecNodeAdmin!: AztecNodeAdmin;
|
|
57
|
-
public cheatCodes!: CheatCodes;
|
|
58
|
-
|
|
59
|
-
public wallet!: TestWallet;
|
|
60
|
-
public aliceAddress!: AztecAddress;
|
|
61
|
-
public bobAddress!: AztecAddress;
|
|
62
|
-
public sequencerAddress!: AztecAddress;
|
|
63
|
-
public coinbase!: EthAddress;
|
|
64
|
-
|
|
65
|
-
public fpcAdmin!: AztecAddress;
|
|
66
|
-
|
|
67
|
-
public gasSettings!: GasSettings;
|
|
68
|
-
|
|
69
|
-
public rollupContract!: RollupContract;
|
|
70
|
-
|
|
71
|
-
public feeJuiceContract!: FeeJuiceContract;
|
|
72
|
-
public bananaCoin!: BananaCoin;
|
|
73
|
-
public bananaFPC!: FPCContract;
|
|
74
|
-
public sponsoredFPC!: SponsoredFPCContract;
|
|
75
|
-
public counterContract!: CounterContract;
|
|
76
|
-
public subscriptionContract!: AppSubscriptionContract;
|
|
77
|
-
public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
|
|
78
|
-
|
|
79
|
-
public chainMonitor!: ChainMonitor;
|
|
80
|
-
|
|
81
|
-
public getCoinbaseBalance!: () => Promise<bigint>;
|
|
82
|
-
public getCoinbaseSequencerRewards!: () => Promise<bigint>;
|
|
83
|
-
public getGasBalanceFn!: BalancesFn;
|
|
84
|
-
public getBananaPublicBalanceFn!: BalancesFn;
|
|
85
|
-
public getBananaPrivateBalanceFn!: BalancesFn;
|
|
86
|
-
public getProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
|
|
87
|
-
|
|
88
|
-
public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
|
|
89
|
-
public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
|
|
90
|
-
public readonly APP_SPONSORED_TX_GAS_LIMIT = BigInt(10e9);
|
|
91
|
-
|
|
92
|
-
constructor(
|
|
93
|
-
testName: string,
|
|
94
|
-
private numberOfAccounts = 3,
|
|
95
|
-
private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
|
|
96
|
-
) {
|
|
97
|
-
if (!numberOfAccounts) {
|
|
98
|
-
throw new Error('There must be at least 1 initial account.');
|
|
99
|
-
}
|
|
100
|
-
setupOptions.coinbase ??= EthAddress.random();
|
|
101
|
-
this.coinbase = setupOptions.coinbase!;
|
|
102
|
-
this.logger = createLogger(`e2e:e2e_fees:${testName}`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async setup() {
|
|
106
|
-
this.logger.verbose('Setting up fresh context...');
|
|
107
|
-
// Token allowlist entries are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
|
|
108
|
-
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
109
|
-
this.context = await setup(0, {
|
|
110
|
-
startProverNode: true,
|
|
111
|
-
...this.setupOptions,
|
|
112
|
-
fundSponsoredFPC: true,
|
|
113
|
-
skipAccountDeployment: true,
|
|
114
|
-
l1ContractsArgs: { ...this.setupOptions },
|
|
115
|
-
txPublicSetupAllowListExtend: [...(this.setupOptions.txPublicSetupAllowListExtend ?? []), ...tokenAllowList],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
this.rollupContract = RollupContract.getFromConfig(this.context.config);
|
|
119
|
-
this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider, this.logger, 200).start();
|
|
120
|
-
|
|
121
|
-
await this.applyBaseSetup();
|
|
122
|
-
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async teardown() {
|
|
127
|
-
await this.chainMonitor.stop();
|
|
128
|
-
await teardown(this.context);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
setIsMarkingAsProven(b: boolean) {
|
|
132
|
-
this.context.watcher.setIsMarkingAsProven(b);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async catchUpProvenChain() {
|
|
136
|
-
const bn = await this.aztecNode.getBlockNumber();
|
|
137
|
-
while ((await this.aztecNode.getProvenBlockNumber()) < bn) {
|
|
138
|
-
await sleep(1000);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async getBlockRewards() {
|
|
143
|
-
const blockReward = await this.rollupContract.getCheckpointReward();
|
|
144
|
-
const rewardConfig = await this.rollupContract.getRewardConfig();
|
|
145
|
-
|
|
146
|
-
const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
|
|
147
|
-
|
|
148
|
-
const toDistribute = balance > blockReward ? blockReward : balance;
|
|
149
|
-
const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
|
|
150
|
-
const proverBlockRewards = toDistribute - sequencerBlockRewards;
|
|
151
|
-
|
|
152
|
-
return { sequencerBlockRewards, proverBlockRewards };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
|
|
156
|
-
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
|
|
157
|
-
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
158
|
-
await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
162
|
-
async mintPrivateBananas(amount: bigint, address: AztecAddress) {
|
|
163
|
-
const { result: balanceBefore } = await this.bananaCoin.methods
|
|
164
|
-
.balance_of_private(address)
|
|
165
|
-
.simulate({ from: address });
|
|
166
|
-
|
|
167
|
-
await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
|
|
168
|
-
|
|
169
|
-
const { result: balanceAfter } = await this.bananaCoin.methods
|
|
170
|
-
.balance_of_private(address)
|
|
171
|
-
.simulate({ from: address });
|
|
172
|
-
expect(balanceAfter).toEqual(balanceBefore + amount);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public async applyBaseSetup() {
|
|
176
|
-
await this.applyInitialAccounts();
|
|
177
|
-
await this.applyPublicDeployAccounts();
|
|
178
|
-
await this.applySetupFeeJuice();
|
|
179
|
-
await this.applyDeployBananaToken();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async applyInitialAccounts() {
|
|
183
|
-
this.logger.info('Applying initial accounts setup');
|
|
184
|
-
|
|
185
|
-
const { deployedAccounts } = await deployAccounts(
|
|
186
|
-
this.numberOfAccounts,
|
|
187
|
-
this.logger,
|
|
188
|
-
)({
|
|
189
|
-
wallet: this.context.wallet,
|
|
190
|
-
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
this.wallet = this.context.wallet;
|
|
194
|
-
this.aztecNode = this.context.aztecNodeService;
|
|
195
|
-
this.aztecNodeAdmin = this.context.aztecNodeService;
|
|
196
|
-
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
|
|
197
|
-
this.cheatCodes = this.context.cheatCodes;
|
|
198
|
-
this.accounts = deployedAccounts.map(a => a.address);
|
|
199
|
-
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
|
|
200
|
-
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
|
|
201
|
-
|
|
202
|
-
// We set Alice as the FPC admin to avoid the need for deployment of another account.
|
|
203
|
-
this.fpcAdmin = this.aliceAddress;
|
|
204
|
-
|
|
205
|
-
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
206
|
-
this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async applyPublicDeployAccounts() {
|
|
210
|
-
this.logger.info('Applying public deploy accounts setup');
|
|
211
|
-
await publicDeployAccounts(this.wallet, this.accounts);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async applySetupFeeJuice() {
|
|
215
|
-
this.logger.info('Applying fee juice setup');
|
|
216
|
-
|
|
217
|
-
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
|
|
218
|
-
|
|
219
|
-
this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
|
|
220
|
-
|
|
221
|
-
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
222
|
-
aztecNode: this.context.aztecNodeService,
|
|
223
|
-
aztecNodeAdmin: this.context.aztecNodeService,
|
|
224
|
-
l1Client: this.context.deployL1ContractsValues.l1Client,
|
|
225
|
-
wallet: this.wallet,
|
|
226
|
-
logger: this.logger,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
async applyDeployBananaToken() {
|
|
231
|
-
this.logger.info('Applying deploy banana token setup');
|
|
232
|
-
|
|
233
|
-
const { contract: bananaCoin } = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
|
|
234
|
-
from: this.aliceAddress,
|
|
235
|
-
});
|
|
236
|
-
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
|
|
237
|
-
|
|
238
|
-
this.bananaCoin = bananaCoin;
|
|
239
|
-
this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, this.logger);
|
|
240
|
-
this.getBananaPrivateBalanceFn = getBalancesFn(
|
|
241
|
-
'🍌.private',
|
|
242
|
-
this.bananaCoin.methods.balance_of_private,
|
|
243
|
-
this.logger,
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
public async applyFPCSetup() {
|
|
248
|
-
this.logger.info('Applying FPC setup');
|
|
249
|
-
|
|
250
|
-
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
251
|
-
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
252
|
-
|
|
253
|
-
const bananaCoin = this.bananaCoin;
|
|
254
|
-
const { contract: bananaFPC } = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
|
|
255
|
-
from: this.aliceAddress,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
|
|
259
|
-
|
|
260
|
-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
|
|
261
|
-
|
|
262
|
-
this.bananaFPC = bananaFPC;
|
|
263
|
-
|
|
264
|
-
const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
|
|
265
|
-
|
|
266
|
-
this.getCoinbaseBalance = async () => {
|
|
267
|
-
const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
|
|
268
|
-
const gasL1 = getContract({
|
|
269
|
-
address: l1FeeJuiceAddress.toString(),
|
|
270
|
-
abi: TestERC20Abi,
|
|
271
|
-
client: l1Client,
|
|
272
|
-
});
|
|
273
|
-
return await gasL1.read.balanceOf([this.coinbase.toString()]);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
this.getCoinbaseSequencerRewards = async () => {
|
|
277
|
-
return await this.rollupContract.getSequencerRewards(this.coinbase);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
this.getProverFee = async (blockNumber: BlockNumber) => {
|
|
281
|
-
const block = await this.aztecNode.getBlock(blockNumber);
|
|
282
|
-
|
|
283
|
-
// @todo @lherskind As we deal with #13601
|
|
284
|
-
// Right now the value is from `FeeLib.sol`
|
|
285
|
-
const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
|
|
286
|
-
|
|
287
|
-
// We round up
|
|
288
|
-
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
289
|
-
|
|
290
|
-
const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
|
|
291
|
-
const proverCost =
|
|
292
|
-
mulDiv(
|
|
293
|
-
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
|
|
294
|
-
1n,
|
|
295
|
-
await this.rollupContract.getManaTarget(),
|
|
296
|
-
) + (await this.rollupContract.getProvingCostPerMana());
|
|
297
|
-
|
|
298
|
-
const price = await this.rollupContract.getEthPerFeeAsset();
|
|
299
|
-
|
|
300
|
-
const mana = block!.header.totalManaUsed.toBigInt();
|
|
301
|
-
return mulDiv(mana * proverCost, 10n ** 12n, price);
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
public async applySponsoredFPCSetup() {
|
|
306
|
-
this.logger.info('Applying sponsored FPC setup');
|
|
307
|
-
|
|
308
|
-
const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
|
|
309
|
-
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
|
|
310
|
-
|
|
311
|
-
const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
|
|
312
|
-
this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
|
|
313
|
-
|
|
314
|
-
this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
public async applyFundAliceWithBananas() {
|
|
318
|
-
this.logger.info('Applying fund Alice with bananas setup');
|
|
319
|
-
|
|
320
|
-
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
321
|
-
await this.bananaCoin.methods
|
|
322
|
-
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
|
|
323
|
-
.send({ from: this.aliceAddress });
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
public async applyFundAliceWithPrivateBananas() {
|
|
327
|
-
this.logger.info('Applying fund Alice with private bananas setup');
|
|
328
|
-
|
|
329
|
-
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { BatchedBlob, Blob, getEthBlobEvaluationInputs, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
4
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
6
|
-
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
7
|
-
|
|
8
|
-
import { writeFile } from 'fs/promises';
|
|
9
|
-
|
|
10
|
-
const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates a json object that can be used to test the solidity contract.
|
|
14
|
-
* The json object must be put into
|
|
15
|
-
*/
|
|
16
|
-
export async function writeJson(
|
|
17
|
-
fileName: string,
|
|
18
|
-
checkpointHeader: CheckpointHeader,
|
|
19
|
-
block: L2Block,
|
|
20
|
-
l1ToL2Content: Fr[],
|
|
21
|
-
blobs: Blob[],
|
|
22
|
-
batchedBlob: BatchedBlob,
|
|
23
|
-
recipientAddress: AztecAddress,
|
|
24
|
-
deployerAddress: `0x${string}`,
|
|
25
|
-
): Promise<void> {
|
|
26
|
-
if (!AZTEC_GENERATE_TEST_DATA) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
// Path relative to the package.json in the end-to-end folder
|
|
30
|
-
const path = `../../l1-contracts/test/fixtures/${fileName}.json`;
|
|
31
|
-
|
|
32
|
-
const asHex = (value: Fr | Buffer | EthAddress | AztecAddress, size = 64) => {
|
|
33
|
-
const buffer = Buffer.isBuffer(value) ? value : value.toBuffer();
|
|
34
|
-
return `0x${buffer.toString('hex').padStart(size, '0')}`;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const jsonObject = {
|
|
38
|
-
populate: {
|
|
39
|
-
l1ToL2Content: l1ToL2Content.map(value => asHex(value)),
|
|
40
|
-
recipient: asHex(recipientAddress.toField()),
|
|
41
|
-
sender: deployerAddress,
|
|
42
|
-
},
|
|
43
|
-
messages: {
|
|
44
|
-
l2ToL1Messages: block.body.txEffects.flatMap(txEffect => txEffect.l2ToL1Msgs).map(value => asHex(value)),
|
|
45
|
-
},
|
|
46
|
-
checkpoint: {
|
|
47
|
-
// The json formatting in forge is a bit brittle, so we convert Fr to a number in the few values below.
|
|
48
|
-
// This should not be a problem for testing as long as the values are not larger than u32.
|
|
49
|
-
archive: asHex(block.archive.root),
|
|
50
|
-
blobCommitments: getPrefixedEthBlobCommitments(blobs),
|
|
51
|
-
batchedBlobInputs: getEthBlobEvaluationInputs(batchedBlob),
|
|
52
|
-
checkpointNumber: block.number,
|
|
53
|
-
body: `0x${block.body.toBuffer().toString('hex')}`,
|
|
54
|
-
header: {
|
|
55
|
-
lastArchiveRoot: asHex(checkpointHeader.lastArchiveRoot),
|
|
56
|
-
blockHeadersHash: asHex(checkpointHeader.blockHeadersHash),
|
|
57
|
-
blobsHash: asHex(checkpointHeader.blobsHash),
|
|
58
|
-
inHash: asHex(checkpointHeader.inHash),
|
|
59
|
-
outHash: asHex(checkpointHeader.epochOutHash),
|
|
60
|
-
slotNumber: Number(checkpointHeader.slotNumber),
|
|
61
|
-
timestamp: Number(checkpointHeader.timestamp),
|
|
62
|
-
coinbase: asHex(checkpointHeader.coinbase, 40),
|
|
63
|
-
feeRecipient: asHex(checkpointHeader.feeRecipient),
|
|
64
|
-
gasFees: {
|
|
65
|
-
feePerDaGas: Number(checkpointHeader.gasFees.feePerDaGas),
|
|
66
|
-
feePerL2Gas: Number(checkpointHeader.gasFees.feePerL2Gas),
|
|
67
|
-
},
|
|
68
|
-
totalManaUsed: checkpointHeader.totalManaUsed.toNumber(),
|
|
69
|
-
},
|
|
70
|
-
headerHash: asHex(checkpointHeader.hash()),
|
|
71
|
-
numTxs: block.body.txEffects.length,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const output = JSON.stringify(jsonObject, null, 2);
|
|
76
|
-
await writeFile(path, output, 'utf8');
|
|
77
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { 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 type { Wallet } from '@aztec/aztec.js/wallet';
|
|
5
|
-
import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
|
|
6
|
-
import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
type EndToEndContext,
|
|
10
|
-
deployAccounts,
|
|
11
|
-
publicDeployAccounts,
|
|
12
|
-
setup,
|
|
13
|
-
teardown as teardownSubsystems,
|
|
14
|
-
} from '../fixtures/setup.js';
|
|
15
|
-
|
|
16
|
-
export class NestedContractTest {
|
|
17
|
-
context!: EndToEndContext;
|
|
18
|
-
logger: Logger;
|
|
19
|
-
wallet!: Wallet;
|
|
20
|
-
defaultAccountAddress!: AztecAddress;
|
|
21
|
-
aztecNode!: AztecNode;
|
|
22
|
-
|
|
23
|
-
parentContract!: ParentContract;
|
|
24
|
-
childContract!: ChildContract;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
testName: string,
|
|
28
|
-
private numberOfAccounts = 1,
|
|
29
|
-
) {
|
|
30
|
-
this.logger = createLogger(`e2e:e2e_nested_contract:${testName}`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Applies base setup by deploying accounts and publicly deploying them.
|
|
35
|
-
*/
|
|
36
|
-
async applyBaseSetup() {
|
|
37
|
-
this.logger.info('Deploying accounts');
|
|
38
|
-
const { deployedAccounts } = await deployAccounts(
|
|
39
|
-
this.numberOfAccounts,
|
|
40
|
-
this.logger,
|
|
41
|
-
)({
|
|
42
|
-
wallet: this.context.wallet,
|
|
43
|
-
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
44
|
-
});
|
|
45
|
-
this.wallet = this.context.wallet;
|
|
46
|
-
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
47
|
-
this.aztecNode = this.context.aztecNodeService;
|
|
48
|
-
|
|
49
|
-
this.logger.info('Public deploy accounts');
|
|
50
|
-
await publicDeployAccounts(this.wallet, [this.defaultAccountAddress]);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async setup() {
|
|
54
|
-
this.logger.info('Setting up fresh subsystems');
|
|
55
|
-
this.context = await setup(0, {
|
|
56
|
-
fundSponsoredFPC: true,
|
|
57
|
-
skipAccountDeployment: true,
|
|
58
|
-
});
|
|
59
|
-
await this.applyBaseSetup();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async teardown() {
|
|
63
|
-
await teardownSubsystems(this.context);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async applyManual() {
|
|
67
|
-
this.logger.info('Deploying parent and child contracts');
|
|
68
|
-
({ contract: this.parentContract } = await ParentContract.deploy(this.wallet).send({
|
|
69
|
-
from: this.defaultAccountAddress,
|
|
70
|
-
}));
|
|
71
|
-
({ contract: this.childContract } = await ChildContract.deploy(this.wallet).send({
|
|
72
|
-
from: this.defaultAccountAddress,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
-
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
-
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
5
|
-
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
import 'jest-extended';
|
|
8
|
-
import os from 'os';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
|
|
11
|
-
import { createNodes } from '../fixtures/setup_p2p_test.js';
|
|
12
|
-
import { P2PNetworkTest } from './p2p_network.js';
|
|
13
|
-
|
|
14
|
-
const NUM_NODES = 6;
|
|
15
|
-
const NUM_VALIDATORS = NUM_NODES;
|
|
16
|
-
const COMMITTEE_SIZE = NUM_VALIDATORS;
|
|
17
|
-
const SLASHING_QUORUM = 3;
|
|
18
|
-
const EPOCH_DURATION = 2;
|
|
19
|
-
const SLASHING_ROUND_SIZE_IN_EPOCHS = 2;
|
|
20
|
-
const BOOT_NODE_UDP_PORT = 4500;
|
|
21
|
-
const ETHEREUM_SLOT_DURATION = process.env.CI ? 8 : 4;
|
|
22
|
-
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
23
|
-
const SLASHING_UNIT = BigInt(1e18);
|
|
24
|
-
const SLASHING_AMOUNT = SLASHING_UNIT * 3n;
|
|
25
|
-
|
|
26
|
-
// How many epochs it may take to set everything up, so we dont slash during this period
|
|
27
|
-
const SETUP_EPOCH_DURATION = 8;
|
|
28
|
-
|
|
29
|
-
export class P2PInactivityTest {
|
|
30
|
-
public nodes!: AztecNodeService[];
|
|
31
|
-
public activeNodes!: AztecNodeService[];
|
|
32
|
-
public inactiveNodes!: AztecNodeService[];
|
|
33
|
-
|
|
34
|
-
public rollup!: RollupContract;
|
|
35
|
-
public offlineValidators!: EthAddress[];
|
|
36
|
-
|
|
37
|
-
private dataDir: string;
|
|
38
|
-
private inactiveNodeCount: number;
|
|
39
|
-
private keepInitialNode: boolean;
|
|
40
|
-
|
|
41
|
-
constructor(
|
|
42
|
-
public readonly test: P2PNetworkTest,
|
|
43
|
-
opts: { inactiveNodeCount: number; keepInitialNode?: boolean },
|
|
44
|
-
) {
|
|
45
|
-
this.dataDir = fs.mkdtempSync(path.join(os.tmpdir(), test.testName));
|
|
46
|
-
this.inactiveNodeCount = opts.inactiveNodeCount;
|
|
47
|
-
this.keepInitialNode = opts.keepInitialNode ?? false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static async create(
|
|
51
|
-
testName: string,
|
|
52
|
-
opts: { slashInactivityConsecutiveEpochThreshold: number; inactiveNodeCount: number; keepInitialNode?: boolean },
|
|
53
|
-
) {
|
|
54
|
-
const test = await P2PNetworkTest.create({
|
|
55
|
-
testName,
|
|
56
|
-
numberOfNodes: 0,
|
|
57
|
-
numberOfValidators: NUM_VALIDATORS,
|
|
58
|
-
basePort: BOOT_NODE_UDP_PORT,
|
|
59
|
-
startProverNode: true,
|
|
60
|
-
initialConfig: {
|
|
61
|
-
proverNodeConfig: { proverNodeEpochProvingDelayMs: AZTEC_SLOT_DURATION * 1000 },
|
|
62
|
-
aztecTargetCommitteeSize: COMMITTEE_SIZE,
|
|
63
|
-
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
64
|
-
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
65
|
-
aztecProofSubmissionEpochs: 1024, // effectively do not reorg
|
|
66
|
-
listenAddress: '127.0.0.1',
|
|
67
|
-
minTxsPerBlock: 0,
|
|
68
|
-
aztecEpochDuration: EPOCH_DURATION,
|
|
69
|
-
validatorReexecute: false,
|
|
70
|
-
sentinelEnabled: true,
|
|
71
|
-
slashingQuorum: SLASHING_QUORUM,
|
|
72
|
-
slashingRoundSizeInEpochs: SLASHING_ROUND_SIZE_IN_EPOCHS,
|
|
73
|
-
slashInactivityTargetPercentage: 0.8,
|
|
74
|
-
slashGracePeriodL2Slots: SETUP_EPOCH_DURATION * EPOCH_DURATION, // do not slash during setup
|
|
75
|
-
slashAmountSmall: SLASHING_UNIT,
|
|
76
|
-
slashAmountMedium: SLASHING_UNIT * 2n,
|
|
77
|
-
slashAmountLarge: SLASHING_UNIT * 3n,
|
|
78
|
-
...opts,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
return new P2PInactivityTest(test, opts);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public async setup() {
|
|
85
|
-
await this.test.setup();
|
|
86
|
-
await this.test.applyBaseSetup();
|
|
87
|
-
|
|
88
|
-
// Set slashing penalties for inactivity
|
|
89
|
-
const { rollup } = await this.test.getContracts();
|
|
90
|
-
const [activationThreshold, ejectionThreshold, localEjectionThreshold] = await Promise.all([
|
|
91
|
-
rollup.getActivationThreshold(),
|
|
92
|
-
rollup.getEjectionThreshold(),
|
|
93
|
-
rollup.getLocalEjectionThreshold(),
|
|
94
|
-
]);
|
|
95
|
-
const biggestEjection = ejectionThreshold > localEjectionThreshold ? ejectionThreshold : localEjectionThreshold;
|
|
96
|
-
expect(activationThreshold - SLASHING_AMOUNT).toBeLessThan(biggestEjection);
|
|
97
|
-
this.test.ctx.aztecNodeConfig.slashInactivityPenalty = SLASHING_AMOUNT;
|
|
98
|
-
this.rollup = rollup;
|
|
99
|
-
|
|
100
|
-
if (!this.keepInitialNode) {
|
|
101
|
-
await this.test.ctx.aztecNodeService.stop();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Create all active nodes
|
|
105
|
-
this.activeNodes = await createNodes(
|
|
106
|
-
this.test.ctx.aztecNodeConfig,
|
|
107
|
-
this.test.ctx.dateProvider,
|
|
108
|
-
this.test.bootstrapNodeEnr,
|
|
109
|
-
NUM_NODES - this.inactiveNodeCount - Number(this.keepInitialNode),
|
|
110
|
-
BOOT_NODE_UDP_PORT,
|
|
111
|
-
this.test.prefilledPublicData,
|
|
112
|
-
this.dataDir,
|
|
113
|
-
undefined,
|
|
114
|
-
Number(this.keepInitialNode),
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
// And the ones with an initially disabled sequencer
|
|
118
|
-
const inactiveConfig = { ...this.test.ctx.aztecNodeConfig, dontStartSequencer: true };
|
|
119
|
-
this.inactiveNodes = await createNodes(
|
|
120
|
-
inactiveConfig,
|
|
121
|
-
this.test.ctx.dateProvider,
|
|
122
|
-
this.test.bootstrapNodeEnr,
|
|
123
|
-
this.inactiveNodeCount,
|
|
124
|
-
BOOT_NODE_UDP_PORT,
|
|
125
|
-
this.test.prefilledPublicData,
|
|
126
|
-
this.dataDir,
|
|
127
|
-
undefined,
|
|
128
|
-
NUM_NODES - this.inactiveNodeCount,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
this.nodes = [
|
|
132
|
-
...(this.keepInitialNode ? [this.test.ctx.aztecNodeService] : []),
|
|
133
|
-
...this.activeNodes,
|
|
134
|
-
...this.inactiveNodes,
|
|
135
|
-
];
|
|
136
|
-
|
|
137
|
-
if (this.nodes.length !== NUM_NODES) {
|
|
138
|
-
throw new Error(`Expected ${NUM_NODES} nodes but got ${this.nodes.length}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.offlineValidators = this.test.validators
|
|
142
|
-
.slice(this.test.validators.length - this.inactiveNodeCount)
|
|
143
|
-
.map(a => a.attester);
|
|
144
|
-
|
|
145
|
-
this.test.logger.warn(`Setup complete. Offline validators are ${this.offlineValidators.join(', ')}.`, {
|
|
146
|
-
validators: this.test.validators,
|
|
147
|
-
offlineValidators: this.offlineValidators,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// Wait for P2P mesh to be fully formed before starting slashing period
|
|
151
|
-
// This prevents race conditions where validators propose blocks before the network is ready
|
|
152
|
-
await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
|
|
153
|
-
|
|
154
|
-
this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION - 1} (slashing will start after it is completed)`);
|
|
155
|
-
await this.test.ctx.cheatCodes.rollup.advanceToEpoch(EpochNumber(SETUP_EPOCH_DURATION - 1));
|
|
156
|
-
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public async teardown() {
|
|
161
|
-
await this.test.stopNodes(this.nodes);
|
|
162
|
-
await this.test.teardown();
|
|
163
|
-
for (let i = 0; i < NUM_NODES; i++) {
|
|
164
|
-
fs.rmSync(`${this.dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public get ctx() {
|
|
169
|
-
return this.test.ctx;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public get logger() {
|
|
173
|
-
return this.test.logger;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
public get slashingAmount() {
|
|
177
|
-
return SLASHING_AMOUNT;
|
|
178
|
-
}
|
|
179
|
-
}
|