diff --git a/configs/config_holesky.py b/configs/config_holesky.py index 51658631..60fdc6ea 100644 --- a/configs/config_holesky.py +++ b/configs/config_holesky.py @@ -79,9 +79,9 @@ "0x1d835790d93a28fb30d998c0cb27426e5d2d7c8c", ] # General network addresses -DAI_TOKEN = "" -USDT_TOKEN = "" -USDC_TOKEN = "" +DAI_TOKEN = "0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c" +USDT_TOKEN = "0x86f6c353a0965eb069cd7f4f91c1afef8c725551" +USDC_TOKEN = "0x9715b2786f1053294fc8952df923b95cab9aac42" WETH_TOKEN = "" diff --git a/scripts/vote_2024_10_08_holesky.py b/scripts/vote_2024_10_08_holesky.py new file mode 100644 index 00000000..f113eae5 --- /dev/null +++ b/scripts/vote_2024_10_08_holesky.py @@ -0,0 +1,78 @@ +""" +Voting 08/10/2024 + +""" + +import time + +from typing import Dict, Tuple, Optional, List + +from brownie import interface +from brownie.network.transaction import TransactionReceipt +from utils.voting import bake_vote_items, confirm_vote_script, create_vote +from utils.easy_track import add_evmscript_factory, create_permissions +from utils.permission_parameters import Param, SpecialArgumentID, ArgumentValue, Op +from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description + +from utils.config import ( + get_deployer_account, + contracts, + get_is_live, + get_priority_fee, +) + +from utils.easy_track import ( + add_evmscript_factory, + create_permissions, + remove_evmscript_factory +) + +description = """ +1. **Add Alliance Ops stablecoins top up EVM script factory, as decided in the [Snapshot vote](https://snapshot.org/#/lido-snapshot.eth/proposal/0xa478fa5518769096eda2b7403a1d4104ca47de3102e8a9abab8640ef1b50650c). + +""" + +def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: + """Prepare and run voting.""" + + alliance_ops_topup_factory = interface.TopUpAllowedRecipients("0x343fa5f0c79277e2d27e440f40420d619f962a23") + alliance_ops_registry = interface.AllowedRecipientRegistry("0xe1ba8dee84a4df8e99e495419365d979cdb19991") + + vote_desc_items, call_script_items = zip( + # + # I. Add Alliance Ops stablecoins top up EVM script factory + # + ( + "1) Add Alliance Ops stablecoins top up EVM script factory 0x343fa5f0c79277e2d27e440f40420d619f962a23", + add_evmscript_factory( + factory=alliance_ops_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_registry, "updateSpentAmount")[2:], + ), + ), + ) + + vote_items = bake_vote_items(list(vote_desc_items), list(call_script_items)) + + if silent: + desc_ipfs = calculate_vote_ipfs_description(description) + else: + desc_ipfs = upload_vote_ipfs_description(description) + + return confirm_vote_script(vote_items, silent, desc_ipfs) and list( + create_vote(vote_items, tx_params, desc_ipfs=desc_ipfs) + ) + + +def main(): + tx_params = {"from": get_deployer_account()} + + if get_is_live(): + tx_params["priority_fee"] = get_priority_fee() + + vote_id, _ = start_vote(tx_params=tx_params, silent=False) + + vote_id >= 0 and print(f"Vote created: {vote_id}.") + + time.sleep(5) # hack for waiting thread #2. + diff --git a/tests/test_2024_10_08_holesky.py b/tests/test_2024_10_08_holesky.py new file mode 100644 index 00000000..03821c2d --- /dev/null +++ b/tests/test_2024_10_08_holesky.py @@ -0,0 +1,126 @@ +""" +Tests for voting 08/10/2024 +Add ET setup for Alliance + +""" + +from scripts.vote_2024_10_08_holesky import start_vote +from brownie import interface, ZERO_ADDRESS, reverts, web3, accounts, convert +from utils.test.tx_tracing_helpers import * +from utils.voting import find_metadata_by_vote_id +from utils.ipfs import get_lido_vote_cid_from_str +from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name +from utils.easy_track import create_permissions +from configs.config_holesky import ( + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN, +) +from utils.test.easy_track_helpers import create_and_enact_payment_motion, check_add_and_remove_recipient_with_voting +from utils.test.event_validators.easy_track import ( + validate_evmscript_factory_added_event, + EVMScriptFactoryAdded, +) + +def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): + + steth = interface.StETH("0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034") + easy_track = interface.EasyTrack("0x1763b9ED3586B08AE796c7787811a2E1bc16163a") + + evm_script_factories_before = easy_track.getEVMScriptFactories() + + alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry("0xe1ba8dee84a4df8e99e495419365d979cdb19991") + alliance_ops_top_up_evm_script_factory_new = interface.TopUpAllowedRecipients("0x343fa5f0c79277e2d27e440f40420d619f962a23") + alliance_multisig_acc = accounts.at("0x96d2Ff1C4D30f592B91fd731E218247689a76915", force=True) # Testnet DAO-Ops&QA Multisig + + assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before + + # START VOTE + if len(vote_ids_from_env) > 0: + (vote_id,) = vote_ids_from_env + else: + tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS} + vote_id, _ = start_vote(tx_params, silent=True) + + vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting) + + print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") + + evm_script_factories_after = easy_track.getEVMScriptFactories() + + assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after + + dai_transfer_amount = 1_000 * 10**18 + usdc_transfer_amount = 1_000 * 10**6 + usdt_transfer_amount = 1_000 * 10**6 + + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Dai(DAI_TOKEN), + recievers=[alliance_multisig_acc], + transfer_amounts=[dai_transfer_amount], + stranger=stranger, + ) + + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdc(USDC_TOKEN), + recievers=[alliance_multisig_acc], + transfer_amounts=[usdc_transfer_amount], + stranger=stranger, + ) + + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdt(USDT_TOKEN), + recievers=[alliance_multisig_acc], + transfer_amounts=[usdt_transfer_amount], + stranger=stranger, + ) + + with reverts("TOKEN_NOT_ALLOWED"): + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=steth, + recievers=[alliance_multisig_acc], + transfer_amounts=[1], + stranger=stranger, + ) + + check_add_and_remove_recipient_with_voting( + registry=alliance_ops_allowed_recipients_registry, + helpers=helpers, + ldo_holder=ldo_holder, + dao_voting=contracts.voting, + ) + + # validate vote events + assert count_vote_items_by_events(vote_tx, contracts.voting) == 1, "Incorrect voting items count" + + metadata = find_metadata_by_vote_id(vote_id) + + assert get_lido_vote_cid_from_str(metadata) == "bafkreibbrlprupitulahcrl57uda4nkzrbfajtrhhsaa3cbx5of4t2huoa" # todo: поменять адрес после тестовой публикации голоосвания на форке + + display_voting_events(vote_tx) + + if bypass_events_decoding or network_name() in ("holesky", "holesky-fork"): + return + + evs = group_voting_events(vote_tx) + + validate_evmscript_factory_added_event( + evs[0], + EVMScriptFactoryAdded( + factory_addr=alliance_ops_top_up_evm_script_factory_new, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], + ), + )