From 13ef4db333348549faa7114b256bb88f52d2cdc9 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 20 Oct 2023 13:17:27 +0200 Subject: [PATCH 01/27] add draft script and tests to remove 3 easy track factories for RCC, PML, ATC --- scripts/vote_2023_10_31.py | 79 ++++++++++++++++++++++++++++++++++++ tests/test_2023_10_31.py | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 scripts/vote_2023_10_31.py create mode 100644 tests/test_2023_10_31.py diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py new file mode 100644 index 00000000..179219f1 --- /dev/null +++ b/scripts/vote_2023_10_31.py @@ -0,0 +1,79 @@ +""" +Voting 31/10/2023. + +""" + +import time + +from typing import Dict +from brownie.network.transaction import TransactionReceipt +from brownie import interface +from utils.voting import bake_vote_items, confirm_vote_script, create_vote +from utils.agent import agent_forward +from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description +from utils.easy_track import add_evmscript_factory, create_permissions, remove_evmscript_factory + +from utils.config import ( + get_deployer_account, + contracts, + get_is_live, + get_priority_fee, +) + + +description = """ +### Omnibus on-chain vote contains 3 motions: + +1. Switch off TopUp ETs for RCC PML ACT +2. Switch on TopUpStable ETs for RCC PML ACT + +""" + +def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: + """Prepare and run voting.""" + + rcc_dai_topup_factory_old = interface.IEVMScriptFactory("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") + pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") + atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + + call_script_items = [ + # 1. Switch off TopUp ETs for RCC PML ACT + + ## 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track + remove_evmscript_factory(factory=rcc_dai_topup_factory_old), + ## 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track + remove_evmscript_factory(factory=pml_dai_topup_factory_old), + ## 3. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track + remove_evmscript_factory(factory=atc_dai_topup_factory_old), + + # 2. Switch on TopUpStable ETs for RCC PML ACT + ] + + vote_desc_items = [ + f"1) Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track", + f"2) Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track", + f"3) Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track", + ] + + vote_items = bake_vote_items(vote_desc_items, 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_2023_10_31.py b/tests/test_2023_10_31.py new file mode 100644 index 00000000..ded117f2 --- /dev/null +++ b/tests/test_2023_10_31.py @@ -0,0 +1,82 @@ +""" +Tests for voting 31/10/2023 + +""" +from scripts.vote_2023_10_31 import start_vote + +from utils.config import ( + network_name, + contracts, + LDO_HOLDER_ADDRESS_FOR_TESTS, +) +from utils.voting import find_metadata_by_vote_id +from utils.ipfs import get_lido_vote_cid_from_str +from utils.test.tx_tracing_helpers import * +from utils.test.event_validators.easy_track import ( + validate_evmscript_factory_removed_event, +) +from utils.test.event_validators.node_operators_registry import ( + validate_target_validators_count_changed_event, + TargetValidatorsCountChanged, +) +from utils.test.event_validators.permission import validate_grant_role_event + + +def test_vote( + helpers, + accounts, + interface, + vote_ids_from_env, +): + easy_track = interface.EasyTrack("0xF0211b7660680B49De1A7E9f25C65660F0a13Fea") + dao_voting = interface.Voting("0x2e59A20f205bB85a89C53f1936454680651E618e") + + rcc_dai_topup_factory_old = interface.IEVMScriptFactory("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") + pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") + atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + + old_factories_list = easy_track.getEVMScriptFactories() + + assert len(old_factories_list) == 16 + + assert rcc_dai_topup_factory_old in old_factories_list + assert pml_dai_topup_factory_old in old_factories_list + assert atc_dai_topup_factory_old in old_factories_list + + # 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}") + + + updated_factories_list = easy_track.getEVMScriptFactories() + assert len(updated_factories_list) == 13 + + + # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track + assert rcc_dai_topup_factory_old not in updated_factories_list + + # 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track + assert pml_dai_topup_factory_old not in updated_factories_list + + # 3. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track + assert atc_dai_topup_factory_old not in updated_factories_list + + # validate vote events + assert count_vote_items_by_events(vote_tx, dao_voting) == 3, "Incorrect voting items count" + + display_voting_events(vote_tx) + + evs = group_voting_events(vote_tx) + + + validate_evmscript_factory_removed_event(evs[0], rcc_dai_topup_factory_old) + validate_evmscript_factory_removed_event(evs[1], pml_dai_topup_factory_old) + validate_evmscript_factory_removed_event(evs[2], atc_dai_topup_factory_old) + From a24f584f993d82d9447344400fef8e9360d7d039 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 20 Oct 2023 16:54:03 +0200 Subject: [PATCH 02/27] add script and tests for new factories but with old addresses --- scripts/vote_2023_10_31.py | 39 ++++++- tests/test_2023_10_31.py | 224 ++++++++++++++++++++++++++++++++++--- 2 files changed, 243 insertions(+), 20 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 179219f1..e272279a 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -1,4 +1,5 @@ """ +todo: change title Voting 31/10/2023. """ @@ -17,10 +18,10 @@ get_deployer_account, contracts, get_is_live, - get_priority_fee, + get_priority_fee ) - +# todo: change description description = """ ### Omnibus on-chain vote contains 3 motions: @@ -36,6 +37,16 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + # todo: change addresses + rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") + pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") + atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + + # todo: change addresses + rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") + pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") + atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") + call_script_items = [ # 1. Switch off TopUp ETs for RCC PML ACT @@ -47,12 +58,36 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra remove_evmscript_factory(factory=atc_dai_topup_factory_old), # 2. Switch on TopUpStable ETs for RCC PML ACT + + # todo: change addresses + ## 4. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track + add_evmscript_factory( + factory=rcc_stable_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(rcc_stable_registry, "updateSpentAmount")[2:], + ), + ## 5. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track + add_evmscript_factory( + factory=pml_stable_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(pml_stable_registry, "updateSpentAmount")[2:], + ), + ## 6. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track + add_evmscript_factory( + factory=atc_stable_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], + ) ] + # todo: change addresses in 4,5,6 strings vote_desc_items = [ f"1) Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track", f"2) Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track", f"3) Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track", + f"4) Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track", + f"5) Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track", + f"6) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index ded117f2..46eb1fc0 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -4,41 +4,64 @@ """ from scripts.vote_2023_10_31 import start_vote +from eth_abi.abi import encode_single +from brownie import chain, accounts + from utils.config import ( - network_name, contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, ) -from utils.voting import find_metadata_by_vote_id -from utils.ipfs import get_lido_vote_cid_from_str +from utils.easy_track import create_permissions +from utils.agent import agent_forward +from utils.voting import create_vote, bake_vote_items from utils.test.tx_tracing_helpers import * from utils.test.event_validators.easy_track import ( + validate_evmscript_factory_added_event, validate_evmscript_factory_removed_event, + EVMScriptFactoryAdded ) -from utils.test.event_validators.node_operators_registry import ( - validate_target_validators_count_changed_event, - TargetValidatorsCountChanged, -) -from utils.test.event_validators.permission import validate_grant_role_event +eth = "0x0000000000000000000000000000000000000000" +aragonAgentProxy = "0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c" def test_vote( helpers, accounts, interface, vote_ids_from_env, + stranger ): easy_track = interface.EasyTrack("0xF0211b7660680B49De1A7E9f25C65660F0a13Fea") dao_voting = interface.Voting("0x2e59A20f205bB85a89C53f1936454680651E618e") + dai_token = interface.ERC20("0x6B175474E89094C44Da98b954EedeAC495271d0F") + + rcc_trusted_caller_and_recepient = accounts.at("0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", {"force": True}) + pml_trusted_caller_and_recepient = accounts.at("0x17F6b2C738a63a8D3A113a228cfd0b373244633D", {"force": True}) + atc_trusted_caller_and_recepient = accounts.at("0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", {"force": True}) rcc_dai_topup_factory_old = interface.IEVMScriptFactory("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + # todo: change addresses + rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") + pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") + atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + + # todo: change addresses + rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") + pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") + atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") + old_factories_list = easy_track.getEVMScriptFactories() assert len(old_factories_list) == 16 + # todo: uncomment when u get new factories address + # assert rcc_stable_topup_factory not in old_factories_list + # assert pml_stable_topup_factory not in old_factories_list + # assert atc_stable_topup_factory not in old_factories_list + assert rcc_dai_topup_factory_old in old_factories_list assert pml_dai_topup_factory_old in old_factories_list assert atc_dai_topup_factory_old in old_factories_list @@ -54,29 +77,194 @@ def test_vote( print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") - updated_factories_list = easy_track.getEVMScriptFactories() - assert len(updated_factories_list) == 13 - + assert len(updated_factories_list) == 16 + ## todo: uncomment tests # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track - assert rcc_dai_topup_factory_old not in updated_factories_list - + # assert rcc_dai_topup_factory_old not in updated_factories_list # 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track - assert pml_dai_topup_factory_old not in updated_factories_list - + # assert pml_dai_topup_factory_old not in updated_factories_list # 3. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track - assert atc_dai_topup_factory_old not in updated_factories_list + # assert atc_dai_topup_factory_old not in updated_factories_list + + # 4. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track + assert rcc_stable_topup_factory in updated_factories_list + create_and_enact_payment_motion( + easy_track, + rcc_trusted_caller_and_recepient, + rcc_stable_topup_factory, + dai_token, + [rcc_trusted_caller_and_recepient], + [10 * 10**18], + stranger, + ) + check_add_and_remove_recipient_with_voting(rcc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) + + # 5. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track + assert pml_stable_topup_factory in updated_factories_list + create_and_enact_payment_motion( + easy_track, + pml_trusted_caller_and_recepient, + pml_stable_topup_factory, + dai_token, + [pml_trusted_caller_and_recepient], + [10 * 10**18], + stranger, + ) + check_add_and_remove_recipient_with_voting(pml_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) + + # 6. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track + assert atc_stable_topup_factory in updated_factories_list + create_and_enact_payment_motion( + easy_track, + atc_trusted_caller_and_recepient, + atc_stable_topup_factory, + dai_token, + [atc_trusted_caller_and_recepient], + [10 * 10**18], + stranger, + ) + check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) # validate vote events - assert count_vote_items_by_events(vote_tx, dao_voting) == 3, "Incorrect voting items count" + assert count_vote_items_by_events(vote_tx, dao_voting) == 6, "Incorrect voting items count" display_voting_events(vote_tx) evs = group_voting_events(vote_tx) - validate_evmscript_factory_removed_event(evs[0], rcc_dai_topup_factory_old) validate_evmscript_factory_removed_event(evs[1], pml_dai_topup_factory_old) validate_evmscript_factory_removed_event(evs[2], atc_dai_topup_factory_old) + validate_evmscript_factory_added_event( + evs[3], + EVMScriptFactoryAdded( + factory_addr=rcc_stable_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(rcc_stable_registry, "updateSpentAmount")[2:], + ), + ) + validate_evmscript_factory_added_event( + evs[4], + EVMScriptFactoryAdded( + factory_addr=pml_stable_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(pml_stable_registry, "updateSpentAmount")[2:], + ), + ) + validate_evmscript_factory_added_event( + evs[5], + EVMScriptFactoryAdded( + factory_addr=atc_stable_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], + ), + ) + +# todo: move to utils +def create_and_enact_payment_motion( + easy_track, + trusted_caller, + factory, + token, + recievers, + transfer_amounts, + stranger, +): + agent = accounts.at(aragonAgentProxy, {"force": True}) + agent_balance_before = balance_of(agent, token) + recievers_balance_before = [balance_of(reciever, token) for reciever in recievers] + motions_before = easy_track.getMotions() + + recievers_addresses = [reciever.address for reciever in recievers] + + calldata = _encode_calldata("(address[],uint256[])", [recievers_addresses, transfer_amounts]) + + tx = easy_track.createMotion(factory, calldata, {"from": trusted_caller}) + + motions = easy_track.getMotions() + assert len(motions) == len(motions_before) + 1 + + chain.sleep(60 * 60 * 24 * 3) + chain.mine() + + easy_track.enactMotion( + motions[-1][0], + tx.events["MotionCreated"]["_evmScriptCallData"], + {"from": stranger}, + ) + + recievers_balance_after = [balance_of(reciever, token)for reciever in recievers] + for i in range(len(recievers)): + assert recievers_balance_after[i] == recievers_balance_before[i] + transfer_amounts[i] + + agent_balance_after = balance_of(agent, token) + + assert agent_balance_after == agent_balance_before - sum(transfer_amounts) + +def _encode_calldata(signature, values): + return "0x" + encode_single(signature, values).hex() + +def balance_of(address, token): + if token == eth: + return address.balance() + else: + return token.balanceOf(address) + +def check_add_and_remove_recipient_with_voting(registry, helpers, ldo_holder, dao_voting): + recipient_candidate = accounts[0] + title = "" + recipients_length_before = len(registry.getAllowedRecipients()) + + assert not registry.isRecipientAllowed(recipient_candidate) + + call_script_items = [ + agent_forward( + [ + ( + registry.address, + registry.addRecipient.encode_input(recipient_candidate, title), + ) + ] + ) + ] + vote_desc_items = ["Add recipient"] + vote_items = bake_vote_items(vote_desc_items, call_script_items) + + vote_id = create_vote(vote_items, {"from": ldo_holder})[0] + + helpers.execute_vote( + vote_id=vote_id, + accounts=accounts, + dao_voting=dao_voting, + skip_time=3 * 60 * 60 * 24, + ) + + assert registry.isRecipientAllowed(recipient_candidate) + assert len(registry.getAllowedRecipients()) == recipients_length_before + 1, 'Wrong whitelist length' + + call_script_items = [ + agent_forward( + [ + ( + registry.address, + registry.removeRecipient.encode_input(recipient_candidate), + ) + ] + ) + ] + vote_desc_items = ["Remove recipient"] + vote_items = bake_vote_items(vote_desc_items, call_script_items) + + vote_id = create_vote(vote_items, {"from": ldo_holder})[0] + + helpers.execute_vote( + vote_id=vote_id, + accounts=accounts, + dao_voting=dao_voting, + skip_time=3 * 60 * 60 * 24, + ) + assert not registry.isRecipientAllowed(recipient_candidate) + assert len(registry.getAllowedRecipients()) == recipients_length_before, 'Wrong whitelist length' From a68403d331987b0fb8cdc8e5578d717ec5387124 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Wed, 25 Oct 2023 11:24:01 +0200 Subject: [PATCH 03/27] add usdt and usdc permissions --- configs/config_mainnet.py | 2 + interfaces/TopUpAllowedRecipients.json | 39 ++-- scripts/vote_2023_10_31.py | 155 ++++++++++++++-- tests/test_2023_10_31.py | 247 ++++++++++++++++++++++++- 4 files changed, 397 insertions(+), 46 deletions(-) diff --git a/configs/config_mainnet.py b/configs/config_mainnet.py index e02936df..bf30d49c 100644 --- a/configs/config_mainnet.py +++ b/configs/config_mainnet.py @@ -75,6 +75,8 @@ ] # General network addresses DAI_TOKEN = "0x6b175474e89094c44da98b954eedeac495271d0f" +USDT_TOKEN = "0xdac17f958d2ee523a2206206994597c13d831ec7" +USDC_TOKEN = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" WETH_TOKEN = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # diff --git a/interfaces/TopUpAllowedRecipients.json b/interfaces/TopUpAllowedRecipients.json index db2756e9..45e69579 100644 --- a/interfaces/TopUpAllowedRecipients.json +++ b/interfaces/TopUpAllowedRecipients.json @@ -13,12 +13,12 @@ }, { "internalType": "address", - "name": "_finance", + "name": "_allowedTokensRegistry", "type": "address" }, { "internalType": "address", - "name": "_token", + "name": "_finance", "type": "address" }, { @@ -35,7 +35,20 @@ "name": "allowedRecipientsRegistry", "outputs": [ { - "internalType": "contract AllowedRecipientsRegistry", + "internalType": "contract IAllowedRecipientsRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "allowedTokensRegistry", + "outputs": [ + { + "internalType": "contract IAllowedTokensRegistry", "name": "", "type": "address" } @@ -77,6 +90,11 @@ ], "name": "decodeEVMScriptCallData", "outputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, { "internalType": "address[]", "name": "recipients", @@ -96,7 +114,7 @@ "name": "easyTrack", "outputs": [ { - "internalType": "contract EasyTrack", + "internalType": "contract IEasyTrack", "name": "", "type": "address" } @@ -117,19 +135,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [], - "name": "token", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [], "name": "trustedCaller", diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index e272279a..ad190931 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -6,19 +6,27 @@ import time -from typing import Dict +from typing import Dict, List from brownie.network.transaction import TransactionReceipt -from brownie import interface +from brownie import interface, ZERO_ADDRESS from utils.voting import bake_vote_items, confirm_vote_script, create_vote from utils.agent import agent_forward from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description from utils.easy_track import add_evmscript_factory, create_permissions, remove_evmscript_factory +from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if +from utils.permissions import encode_permission_revoke, encode_permission_grant_p from utils.config import ( get_deployer_account, contracts, get_is_live, - get_priority_fee + get_priority_fee, + EASYTRACK_EVMSCRIPT_EXECUTOR, + LIDO, + LDO_TOKEN, + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN ) # todo: change description @@ -30,6 +38,99 @@ """ +eth = { + "limit": 1_000 * (10**18), + "address": ZERO_ADDRESS, +} + +steth = { + "limit": 1_000 * (10**18), + "address": LIDO, +} + +ldo = { + "limit": 5_000_000 * (10**18), + "address": LDO_TOKEN, +} + +dai = { + "limit": 2_000_000 * (10**18), + "address": DAI_TOKEN, +} + +usdc = { + "limit": 2_000_000 * (10**18), + "address": USDC_TOKEN, +} + +usdt = { + "limit": 2_000_000 * (10**18), + "address": USDT_TOKEN, +} + +def amount_limits() -> List[Param]: + token_arg_index = 0 + amount_arg_index = 2 + + return [ + # 0: if (1) then (2) else (3) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=1, success=2, failure=3) + ), + # 1: (_token == LDO) + Param(token_arg_index, Op.EQ, ArgumentValue(ldo["address"])), + # 2: { return _amount <= 5_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(ldo["limit"])), + # 3: else if (4) then (5) else (6) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=4, success=5, failure=6) + ), + # 4: (_token == ETH) + Param(token_arg_index, Op.EQ, ArgumentValue(eth["address"])), + # 5: { return _amount <= 1000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(eth["limit"])), + # 6: else if (7) then (8) else (9) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=7, success=8, failure=9) + ), + # 7: (_token == DAI) + Param(token_arg_index, Op.EQ, ArgumentValue(dai["address"])), + # 8: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(dai["limit"])), + # 9: else if (10) then (11) else (12) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=10, success=11, failure=12), + ), + # 10: (_token == USDT) + Param(token_arg_index, Op.EQ, ArgumentValue(usdt["address"])), + # 11: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(usdt["limit"])), + # 12: else if (13) then (14) else (15) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=13, success=14, failure=15), + ), + # 13: (_token == USDC) + Param(token_arg_index, Op.EQ, ArgumentValue(usdc["address"])), + # 14: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(usdc["limit"])), + # 15: else if (16) then (17) else (18) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=16, success=17, failure=18), + ), + # 16: (_token == stETH) + Param(token_arg_index, Op.EQ, ArgumentValue(steth["address"])), + # 17: { return _amount <= 1000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(steth["limit"])), + # 18: else { return false } + Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), + ] + def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: """Prepare and run voting.""" @@ -42,37 +143,49 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") - # todo: change addresses + # addresses stay same rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") call_script_items = [ - # 1. Switch off TopUp ETs for RCC PML ACT - ## 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track + # 1. Revoke role CREATE_PAYMENTS_ROLE from EVM script executor + encode_permission_revoke( + target_app=contracts.finance, + permission_name="CREATE_PAYMENTS_ROLE", + revoke_from=EASYTRACK_EVMSCRIPT_EXECUTOR, + ), + # 2. Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 + # with limits: 1000 ETH, 1000 stETH, 5M LDO, 2M DAI, 2M USTD, 2M USDC + encode_permission_grant_p( + target_app=contracts.finance, + permission_name="CREATE_PAYMENTS_ROLE", + grant_to=EASYTRACK_EVMSCRIPT_EXECUTOR, + params=amount_limits(), + ), + + ## 3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track remove_evmscript_factory(factory=rcc_dai_topup_factory_old), - ## 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track + ## 4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track remove_evmscript_factory(factory=pml_dai_topup_factory_old), - ## 3. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track + ## 5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track remove_evmscript_factory(factory=atc_dai_topup_factory_old), - # 2. Switch on TopUpStable ETs for RCC PML ACT - # todo: change addresses - ## 4. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track + ## 6. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track add_evmscript_factory( factory=rcc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") + create_permissions(rcc_stable_registry, "updateSpentAmount")[2:], ), - ## 5. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track + ## 7. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track add_evmscript_factory( factory=pml_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") + create_permissions(pml_stable_registry, "updateSpentAmount")[2:], ), - ## 6. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track + ## 8. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track add_evmscript_factory( factory=atc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") @@ -80,14 +193,16 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ) ] - # todo: change addresses in 4,5,6 strings + # todo: change addresses in 6,7,8 strings vote_desc_items = [ - f"1) Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track", - f"2) Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track", - f"3) Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track", - f"4) Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track", - f"5) Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track", - f"6) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", + f"1) Revoke role CREATE_PAYMENTS_ROLE from EVM script executor", + f"2) Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", + f"3) Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track", + f"4) Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track", + f"5) Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track", + f"6) Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track", + f"7) Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track", + f"8) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 46eb1fc0..973c1f0a 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -5,11 +5,17 @@ from scripts.vote_2023_10_31 import start_vote from eth_abi.abi import encode_single -from brownie import chain, accounts +from brownie import chain, accounts, ZERO_ADDRESS, reverts +import math from utils.config import ( contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, + LIDO, + LDO_TOKEN, + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN ) from utils.easy_track import create_permissions from utils.agent import agent_forward @@ -20,20 +26,47 @@ validate_evmscript_factory_removed_event, EVMScriptFactoryAdded ) +from utils.test.event_validators.permission import ( + Permission, + validate_permission_grantp_event, + validate_permission_revoke_event, +) +from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if + eth = "0x0000000000000000000000000000000000000000" aragonAgentProxy = "0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c" +STETH_ERROR_MARGIN = 2 + +permission = Permission( + entity="0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", # EVMScriptExecutor + app="0xB9E5CBB9CA5b0d659238807E84D0176930753d86", # Finance Aragon App + role="0x5de467a460382d13defdc02aacddc9c7d6605d6d4e0b8bd2f70732cae8ea17bc", +) # keccak256('CREATE_PAYMENTS_ROLE') + +def has_payments_permission(acl, finance, sender, token, receiver, amount) -> bool: + return acl.hasPermission["address,address,bytes32,uint[]"]( + sender, finance, finance.CREATE_PAYMENTS_ROLE(), [token, receiver, amount] + ) def test_vote( helpers, accounts, interface, vote_ids_from_env, - stranger + stranger, + ldo_holder ): easy_track = interface.EasyTrack("0xF0211b7660680B49De1A7E9f25C65660F0a13Fea") dao_voting = interface.Voting("0x2e59A20f205bB85a89C53f1936454680651E618e") dai_token = interface.ERC20("0x6B175474E89094C44Da98b954EedeAC495271d0F") + acl = interface.ACL("0x9895f0f17cc1d1891b6f18ee0b483b6f221b37bb") + finance = interface.Finance("0xB9E5CBB9CA5b0d659238807E84D0176930753d86") + agent = accounts.at("0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c", {"force": True}) + evmscriptexecutor = accounts.at("0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", {"force": True}) + steth_token = interface.ERC20("0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84") + ldo_token = interface.ERC20("0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32") + rcc_trusted_caller_and_recepient = accounts.at("0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", {"force": True}) pml_trusted_caller_and_recepient = accounts.at("0x17F6b2C738a63a8D3A113a228cfd0b373244633D", {"force": True}) @@ -66,6 +99,13 @@ def test_vote( assert pml_dai_topup_factory_old in old_factories_list assert atc_dai_topup_factory_old in old_factories_list + assert has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) + assert has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) + assert has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) + assert has_payments_permission(acl, finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) + assert not has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) + assert not has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) + # START VOTE if len(vote_ids_from_env) > 0: (vote_id,) = vote_ids_from_env @@ -80,6 +120,98 @@ def test_vote( updated_factories_list = easy_track.getEVMScriptFactories() assert len(updated_factories_list) == 16 + + assert has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) + assert has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) + assert has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) + assert has_payments_permission(acl, finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) + assert has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) + assert has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) + + assert not has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"] + 1) + assert not has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"] + 1) + assert not has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"] + 1) + assert not has_payments_permission(acl, finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"] + 1) + assert not has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"] + 1) + assert not has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"] + 1) + + assert not has_payments_permission(acl, finance, accounts[0].address, eth["address"], ldo_holder.address, eth["limit"]) + # assert not has_payments_permission(acl, finance, accounts[0].address, usdc_token, ldo_holder.address, 1) + + # 1000 ETH + # agent_balance_before = agent.balance() + # eth_balance_before = stranger.balance() + # print("agent_balance_before=",agent_balance_before); + # with reverts("APP_AUTH_FAILED"): + # finance.newImmediatePayment( + # ZERO_ADDRESS, + # stranger, + # 1000 * 10**18 + 1, + # "ETH transfer", + # {"from": evmscriptexecutor}, + # ) + # finance.newImmediatePayment( + # ZERO_ADDRESS, stranger, 1000 * 10**18, "ETH transfer", {"from": evmscriptexecutor} + # ) + # assert agent.balance() == agent_balance_before - 1000 * 10**18 + # assert stranger.balance() == eth_balance_before + 1000 * 10**18 + + + # 1000 stETH + # agent_steth_balance_before = steth_token.balanceOf(agent) + # stETH_balance_before = steth_token.balanceOf(stranger) + # with reverts("APP_AUTH_FAILED"): + # finance.newImmediatePayment( + # steth_token, + # stranger, + # 1000 * 10**18 + 1, + # "stETH transfer", + # {"from": evmscriptexecutor}, + # ) + # finance.newImmediatePayment( + # steth_token, stranger, 1000 * 10**18, "stETH transfer", {"from": evmscriptexecutor} + # ) + # assert math.isclose( + # steth_token.balanceOf(agent), agent_steth_balance_before - 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN + # ) + # assert math.isclose( + # steth_token.balanceOf(stranger), stETH_balance_before + 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN + # ) + + # # 5_000_000 LDO + # agent_ldo_balance_before = ldo_token.balanceOf(agent) + # ldo_balance_before = ldo_token.balanceOf(stranger) + # with reverts("APP_AUTH_FAILED"): + # finance.newImmediatePayment( + # ldo_token, + # stranger, + # 5_000_000 * 10**18 + 1, + # "LDO transfer", + # {"from": evmscriptexecutor}, + # ) + # finance.newImmediatePayment( + # ldo_token, stranger, 5_000_000 * 10**18, "LDO transfer", {"from": evmscriptexecutor} + # ) + # assert ldo_token.balanceOf(agent) == agent_ldo_balance_before - 5_000_000 * 10**18 + # assert ldo_token.balanceOf(stranger) == ldo_balance_before + 5_000_000 * 10**18 + + # # 2_000_000 DAI + # agent_dai_balance_before = dai_token.balanceOf(agent) + # dai_balance_before = dai_token.balanceOf(stranger) + # with reverts("APP_AUTH_FAILED"): + # finance.newImmediatePayment( + # dai_token, + # stranger, + # 2_000_000 * 10**18 + 1, + # "DAI transfer", + # {"from": evmscriptexecutor}, + # ) + # finance.newImmediatePayment( + # dai_token, stranger, 2_000_000 * 10**18, "DAI transfer", {"from": evmscriptexecutor} + # ) + # assert dai_token.balanceOf(agent) == agent_dai_balance_before - 2_000_000 * 10**18 + # assert dai_token.balanceOf(stranger) == dai_balance_before + 2_000_000 * 10**18 + ## todo: uncomment tests # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track # assert rcc_dai_topup_factory_old not in updated_factories_list @@ -128,17 +260,20 @@ def test_vote( check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) # validate vote events - assert count_vote_items_by_events(vote_tx, dao_voting) == 6, "Incorrect voting items count" + assert count_vote_items_by_events(vote_tx, dao_voting) == 8, "Incorrect voting items count" display_voting_events(vote_tx) evs = group_voting_events(vote_tx) - validate_evmscript_factory_removed_event(evs[0], rcc_dai_topup_factory_old) - validate_evmscript_factory_removed_event(evs[1], pml_dai_topup_factory_old) - validate_evmscript_factory_removed_event(evs[2], atc_dai_topup_factory_old) + validate_permission_revoke_event(evs[0], permission) + validate_permission_grantp_event(evs[1], permission, amount_limits()) + + validate_evmscript_factory_removed_event(evs[2], rcc_dai_topup_factory_old) + validate_evmscript_factory_removed_event(evs[3], pml_dai_topup_factory_old) + validate_evmscript_factory_removed_event(evs[4], atc_dai_topup_factory_old) validate_evmscript_factory_added_event( - evs[3], + evs[5], EVMScriptFactoryAdded( factory_addr=rcc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") @@ -146,7 +281,7 @@ def test_vote( ), ) validate_evmscript_factory_added_event( - evs[4], + evs[6], EVMScriptFactoryAdded( factory_addr=pml_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") @@ -154,7 +289,7 @@ def test_vote( ), ) validate_evmscript_factory_added_event( - evs[5], + evs[7], EVMScriptFactoryAdded( factory_addr=atc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") @@ -268,3 +403,97 @@ def check_add_and_remove_recipient_with_voting(registry, helpers, ldo_holder, da assert not registry.isRecipientAllowed(recipient_candidate) assert len(registry.getAllowedRecipients()) == recipients_length_before, 'Wrong whitelist length' + + +eth = { + "limit": 1_000 * (10**18), + "address": ZERO_ADDRESS, +} + +steth = { + "limit": 1_000 * (10**18), + "address": LIDO, +} + +ldo = { + "limit": 5_000_000 * (10**18), + "address": LDO_TOKEN, +} + +dai = { + "limit": 2_000_000 * (10**18), + "address": DAI_TOKEN, +} + +usdc = { + "limit": 2_000_000 * (10**18), + "address": USDC_TOKEN, +} + +usdt = { + "limit": 2_000_000 * (10**18), + "address": USDT_TOKEN, +} + +def amount_limits() -> List[Param]: + token_arg_index = 0 + amount_arg_index = 2 + + return [ + # 0: if (1) then (2) else (3) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=1, success=2, failure=3) + ), + # 1: (_token == LDO) + Param(token_arg_index, Op.EQ, ArgumentValue(ldo["address"])), + # 2: { return _amount <= 5_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(ldo["limit"])), + # 3: else if (4) then (5) else (6) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=4, success=5, failure=6) + ), + # 4: (_token == ETH) + Param(token_arg_index, Op.EQ, ArgumentValue(eth["address"])), + # 5: { return _amount <= 1000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(eth["limit"])), + # 6: else if (7) then (8) else (9) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=7, success=8, failure=9) + ), + # 7: (_token == DAI) + Param(token_arg_index, Op.EQ, ArgumentValue(dai["address"])), + # 8: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(dai["limit"])), + # 9: else if (10) then (11) else (12) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=10, success=11, failure=12), + ), + # 10: (_token == USDT) + Param(token_arg_index, Op.EQ, ArgumentValue(usdt["address"])), + # 11: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(usdt["limit"])), + # 12: else if (13) then (14) else (15) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=13, success=14, failure=15), + ), + # 13: (_token == USDC) + Param(token_arg_index, Op.EQ, ArgumentValue(usdc["address"])), + # 14: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(usdc["limit"])), + # 15: else if (16) then (17) else (18) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=16, success=17, failure=18), + ), + # 16: (_token == stETH) + Param(token_arg_index, Op.EQ, ArgumentValue(steth["address"])), + # 17: { return _amount <= 1000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(steth["limit"])), + # 18: else { return false } + Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), + ] \ No newline at end of file From 13af5d469cbb7b19c61570525b9fb0314756ea39 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Wed, 25 Oct 2023 16:26:56 +0300 Subject: [PATCH 04/27] test: fix negative report test cases The operators setup has been changed drastically. Node Operator #1 is fully exited ATM. --- .../test_accounting_oracle_negative.py | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/acceptance/test_accounting_oracle_negative.py b/tests/acceptance/test_accounting_oracle_negative.py index 0412fbaa..8e5241f4 100644 --- a/tests/acceptance/test_accounting_oracle_negative.py +++ b/tests/acceptance/test_accounting_oracle_negative.py @@ -179,8 +179,8 @@ class TestSubmitReportExtraDataList: def test_too_short_extra_data_item(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [2]), - build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [1], [2])[:36], + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [2]), + build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [2], [2])[:36], ) ) @@ -189,8 +189,8 @@ def test_too_short_extra_data_item(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1, 2, 3, 4], [2]), - build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [1], [2]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2, 3, 4, 5], [2]), + build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [2], [2]), ) ) @@ -200,7 +200,7 @@ def test_too_short_extra_data_item(self): def test_nos_count_zero(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [2]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [2]), build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [], [1]), ) ) @@ -211,8 +211,8 @@ def test_nos_count_zero(self): def test_module_id_zero(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [2]), - build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 0, [1], [1]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [2]), + build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 0, [2], [1]), ) ) @@ -220,11 +220,10 @@ def test_module_id_zero(self): self.report(extra_data) def test_unexpected_extra_data_index(self): - extra_data = b"".join( ( - build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), - build_extra_data_item(2, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [1], [1]), + build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), + build_extra_data_item(2, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 2, [2], [1]), ) ) @@ -233,8 +232,8 @@ def test_unexpected_extra_data_index(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), - build_extra_data_item(3, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), + build_extra_data_item(3, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), ) ) @@ -243,8 +242,8 @@ def test_unexpected_extra_data_index(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), ) ) @@ -265,8 +264,8 @@ def test_unsupported_extra_data_type(self): def test_invalid_extra_data_sort_order(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), - build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [1], [1]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), + build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_STUCK_VALIDATORS, 1, [2], [1]), ) ) @@ -280,8 +279,8 @@ def test_invalid_extra_data_sort_order(self): extra_data = b"".join( ( - build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_EXITED_VALIDATORS, 1, [1], [1]), - build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_EXITED_VALIDATORS, 1, [1], [1]), + build_extra_data_item(0, ItemType.EXTRA_DATA_TYPE_EXITED_VALIDATORS, 1, [38], [1]), + build_extra_data_item(1, ItemType.EXTRA_DATA_TYPE_EXITED_VALIDATORS, 1, [38], [1]), ) ) @@ -295,8 +294,8 @@ def test_invalid_extra_data_sort_order(self): def test_unexpected_extra_data_item(self, extra_data_service: ExtraDataService) -> None: extra_data = extra_data_service.collect( - {(1, 1): 1}, - {(1, 1): 1}, + {(1, 38): 1}, + {(1, 38): 1}, MAX_ACCOUNTING_EXTRA_DATA_LIST_ITEMS_COUNT, 1, ) @@ -322,8 +321,8 @@ def test_already_processed( extra_data_service: ExtraDataService, ): extra_data = extra_data_service.collect( - {(1, 1): 1}, - {(1, 1): 1}, + {(1, 38): 1}, + {(1, 38): 1}, MAX_ACCOUNTING_EXTRA_DATA_LIST_ITEMS_COUNT, 1, ) From eb4ebf544aabf74c34236fd04eb071c9d8e9bdf6 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Wed, 25 Oct 2023 17:01:11 +0300 Subject: [PATCH 05/27] test: fix vebo and ao edge cases --- tests/acceptance/test_veb_negative.py | 4 ++-- tests/regression/test_accounting_oracle_extra_data.py | 4 ++-- tests/regression/test_validator_exit_bus_happy_path.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/acceptance/test_veb_negative.py b/tests/acceptance/test_veb_negative.py index a5cad6ba..19356e2b 100644 --- a/tests/acceptance/test_veb_negative.py +++ b/tests/acceptance/test_veb_negative.py @@ -221,7 +221,7 @@ def test_handle_consensus_report_data_wrong_module_id(contract, ref_slot): def test_handle_consensus_report_data_second_exit(contract, ref_slot): - no_global_index = (module_id, no_id) = (1, 1) + no_global_index = (module_id, no_id) = (1, 38) validator_id = 1 validator_key = contracts.node_operators_registry.getSigningKey(no_id, validator_id)[0] validator = LidoValidator(validator_id, validator_key) @@ -287,7 +287,7 @@ def test_handle_consensus_report_data_second_exit(contract, ref_slot): def test_handle_consensus_report_data_invalid_request_order(contract, ref_slot): - no_global_index = (_, no_id) = (1, 1) + no_global_index = (_, no_id) = (1, 38) validator_id = 1 validator_key = contracts.node_operators_registry.getSigningKey(no_id, validator_id)[0] validator = LidoValidator(validator_id, validator_key) diff --git a/tests/regression/test_accounting_oracle_extra_data.py b/tests/regression/test_accounting_oracle_extra_data.py index c9a24e21..13b991cd 100644 --- a/tests/regression/test_accounting_oracle_extra_data.py +++ b/tests/regression/test_accounting_oracle_extra_data.py @@ -21,8 +21,8 @@ def test_accounting_oracle_too_node_ops_per_extra_data_item(extra_data_service): item_count = MAX_ACCOUNTING_EXTRA_DATA_LIST_ITEMS_COUNT extra_data = extra_data_service.collect( - {(1, i): i for i in range(nos_per_item_count)}, - {(1, i): get_exited_count(i) for i in range(nos_per_item_count)}, + {(1, i): i for i in range(20, 20 + nos_per_item_count)}, + {(1, i): get_exited_count(i) for i in range(20, 20 + nos_per_item_count)}, item_count, nos_per_item_count, ) diff --git a/tests/regression/test_validator_exit_bus_happy_path.py b/tests/regression/test_validator_exit_bus_happy_path.py index 109928ae..6053274d 100644 --- a/tests/regression/test_validator_exit_bus_happy_path.py +++ b/tests/regression/test_validator_exit_bus_happy_path.py @@ -74,7 +74,7 @@ def test_send_zero_validators_to_exit(helpers): def test_send_validator_to_exit(helpers, web3): - no_global_index = (module_id, no_id) = (1, 1) + no_global_index = (module_id, no_id) = (1, 38) validator_id = 1 validator_key = contracts.node_operators_registry.getSigningKey(no_id, validator_id)[0] validator = LidoValidator(validator_id, validator_key) @@ -134,8 +134,8 @@ def test_send_multiple_validators_to_exit(helpers, web3): """ The same as test above but with multiple validators on different node operators """ - first_no_global_index = (first_module_id, first_no_id) = (1, 9) - second_no_global_index = (second_module_id, second_no_id) = (1, 10) + first_no_global_index = (first_module_id, first_no_id) = (1, 37) + second_no_global_index = (second_module_id, second_no_id) = (1, 38) first_validator_id = 2 second_validator_id = 3 first_validator_key = contracts.node_operators_registry.getSigningKey(first_no_id, first_validator_id)[0] From 6bcefd5dde3c68c02be7e93f904022e5610e9cd6 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Wed, 25 Oct 2023 17:04:27 +0200 Subject: [PATCH 06/27] add balance limit tests --- scripts/vote_2023_10_31.py | 4 +- tests/test_2023_10_31.py | 419 ++++++++++++++++++++++--------------- 2 files changed, 258 insertions(+), 165 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index ad190931..546990ce 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -59,12 +59,12 @@ } usdc = { - "limit": 2_000_000 * (10**18), + "limit": 2_000_000 * (10**6), "address": USDC_TOKEN, } usdt = { - "limit": 2_000_000 * (10**18), + "limit": 2_000_000 * (10**6), "address": USDT_TOKEN, } diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 973c1f0a..b041f0a7 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -15,7 +15,8 @@ LDO_TOKEN, DAI_TOKEN, USDC_TOKEN, - USDT_TOKEN + USDT_TOKEN, + CHAIN_DEPOSIT_CONTRACT ) from utils.easy_track import create_permissions from utils.agent import agent_forward @@ -33,7 +34,6 @@ ) from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if - eth = "0x0000000000000000000000000000000000000000" aragonAgentProxy = "0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c" STETH_ERROR_MARGIN = 2 @@ -44,6 +44,99 @@ role="0x5de467a460382d13defdc02aacddc9c7d6605d6d4e0b8bd2f70732cae8ea17bc", ) # keccak256('CREATE_PAYMENTS_ROLE') +eth = { + "limit": 1_000 * (10**18), + "address": ZERO_ADDRESS, +} + +steth = { + "limit": 1_000 * (10**18), + "address": LIDO, +} + +ldo = { + "limit": 5_000_000 * (10**18), + "address": LDO_TOKEN, +} + +dai = { + "limit": 2_000_000 * (10**18), + "address": DAI_TOKEN, +} + +usdc = { + "limit": 2_000_000 * (10**6), + "address": USDC_TOKEN, +} + +usdt = { + "limit": 2_000_000 * (10**6), + "address": USDT_TOKEN, +} + +def amount_limits() -> List[Param]: + token_arg_index = 0 + amount_arg_index = 2 + + return [ + # 0: if (1) then (2) else (3) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=1, success=2, failure=3) + ), + # 1: (_token == LDO) + Param(token_arg_index, Op.EQ, ArgumentValue(ldo["address"])), + # 2: { return _amount <= 5_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(ldo["limit"])), + # 3: else if (4) then (5) else (6) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=4, success=5, failure=6) + ), + # 4: (_token == ETH) + Param(token_arg_index, Op.EQ, ArgumentValue(eth["address"])), + # 5: { return _amount <= 1000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(eth["limit"])), + # 6: else if (7) then (8) else (9) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=7, success=8, failure=9) + ), + # 7: (_token == DAI) + Param(token_arg_index, Op.EQ, ArgumentValue(dai["address"])), + # 8: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(dai["limit"])), + # 9: else if (10) then (11) else (12) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=10, success=11, failure=12), + ), + # 10: (_token == USDT) + Param(token_arg_index, Op.EQ, ArgumentValue(usdt["address"])), + # 11: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(usdt["limit"])), + # 12: else if (13) then (14) else (15) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=13, success=14, failure=15), + ), + # 13: (_token == USDC) + Param(token_arg_index, Op.EQ, ArgumentValue(usdc["address"])), + # 14: { return _amount <= 2_000_000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(usdc["limit"])), + # 15: else if (16) then (17) else (18) + Param( + SpecialArgumentID.LOGIC_OP_PARAM_ID, + Op.IF_ELSE, + encode_argument_value_if(condition=16, success=17, failure=18), + ), + # 16: (_token == stETH) + Param(token_arg_index, Op.EQ, ArgumentValue(steth["address"])), + # 17: { return _amount <= 1000 } + Param(amount_arg_index, Op.LTE, ArgumentValue(steth["limit"])), + # 18: else { return false } + Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), + ] + def has_payments_permission(acl, finance, sender, token, receiver, amount) -> bool: return acl.hasPermission["address,address,bytes32,uint[]"]( sender, finance, finance.CREATE_PAYMENTS_ROLE(), [token, receiver, amount] @@ -59,14 +152,10 @@ def test_vote( ): easy_track = interface.EasyTrack("0xF0211b7660680B49De1A7E9f25C65660F0a13Fea") dao_voting = interface.Voting("0x2e59A20f205bB85a89C53f1936454680651E618e") - dai_token = interface.ERC20("0x6B175474E89094C44Da98b954EedeAC495271d0F") acl = interface.ACL("0x9895f0f17cc1d1891b6f18ee0b483b6f221b37bb") finance = interface.Finance("0xB9E5CBB9CA5b0d659238807E84D0176930753d86") agent = accounts.at("0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c", {"force": True}) evmscriptexecutor = accounts.at("0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", {"force": True}) - steth_token = interface.ERC20("0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84") - ldo_token = interface.ERC20("0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32") - rcc_trusted_caller_and_recepient = accounts.at("0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", {"force": True}) pml_trusted_caller_and_recepient = accounts.at("0x17F6b2C738a63a8D3A113a228cfd0b373244633D", {"force": True}) @@ -106,6 +195,9 @@ def test_vote( assert not has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) assert not has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) + # какие лимиты в реджистрях + rcc_stable_registry.getPeriodState() + # START VOTE if len(vote_ids_from_env) > 0: (vote_id,) = vote_ids_from_env @@ -138,79 +230,172 @@ def test_vote( assert not has_payments_permission(acl, finance, accounts[0].address, eth["address"], ldo_holder.address, eth["limit"]) # assert not has_payments_permission(acl, finance, accounts[0].address, usdc_token, ldo_holder.address, 1) + + # ETH + deposit = accounts.at(CHAIN_DEPOSIT_CONTRACT, {"force": True}) + deposit.transfer(agent.address, "1000 ether") + # 1000 ETH - # agent_balance_before = agent.balance() - # eth_balance_before = stranger.balance() - # print("agent_balance_before=",agent_balance_before); - # with reverts("APP_AUTH_FAILED"): - # finance.newImmediatePayment( - # ZERO_ADDRESS, - # stranger, - # 1000 * 10**18 + 1, - # "ETH transfer", - # {"from": evmscriptexecutor}, - # ) - # finance.newImmediatePayment( - # ZERO_ADDRESS, stranger, 1000 * 10**18, "ETH transfer", {"from": evmscriptexecutor} - # ) - # assert agent.balance() == agent_balance_before - 1000 * 10**18 - # assert stranger.balance() == eth_balance_before + 1000 * 10**18 + agent_balance_before = agent.balance() + eth_balance_before = stranger.balance() + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + ZERO_ADDRESS, + stranger, + 1000 * 10**18 + 1, + "ETH transfer", + {"from": evmscriptexecutor}, + ) + finance.newImmediatePayment( + ZERO_ADDRESS, + stranger, + 1000 * 10**18, + "ETH transfer", + {"from": evmscriptexecutor} + ) + assert agent.balance() == agent_balance_before - 1000 * 10**18 + assert stranger.balance() == eth_balance_before + 1000 * 10**18 # 1000 stETH - # agent_steth_balance_before = steth_token.balanceOf(agent) - # stETH_balance_before = steth_token.balanceOf(stranger) - # with reverts("APP_AUTH_FAILED"): - # finance.newImmediatePayment( - # steth_token, - # stranger, - # 1000 * 10**18 + 1, - # "stETH transfer", - # {"from": evmscriptexecutor}, - # ) - # finance.newImmediatePayment( - # steth_token, stranger, 1000 * 10**18, "stETH transfer", {"from": evmscriptexecutor} - # ) - # assert math.isclose( - # steth_token.balanceOf(agent), agent_steth_balance_before - 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN - # ) - # assert math.isclose( - # steth_token.balanceOf(stranger), stETH_balance_before + 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN - # ) + steth_token = interface.ERC20(LIDO) + agent_steth_balance_before = steth_token.balanceOf(agent) + stETH_balance_before = steth_token.balanceOf(stranger) + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + steth_token, + stranger, + 1000 * 10**18 + 1, + "stETH transfer", + {"from": evmscriptexecutor}, + ) + finance.newImmediatePayment( + steth_token, + stranger, + 1000 * 10**18, + "stETH transfer", + {"from": evmscriptexecutor} + ) + assert math.isclose(steth_token.balanceOf(agent), agent_steth_balance_before - 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN) + assert math.isclose(steth_token.balanceOf(stranger), stETH_balance_before + 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN) # # 5_000_000 LDO - # agent_ldo_balance_before = ldo_token.balanceOf(agent) - # ldo_balance_before = ldo_token.balanceOf(stranger) - # with reverts("APP_AUTH_FAILED"): - # finance.newImmediatePayment( - # ldo_token, - # stranger, - # 5_000_000 * 10**18 + 1, - # "LDO transfer", - # {"from": evmscriptexecutor}, - # ) - # finance.newImmediatePayment( - # ldo_token, stranger, 5_000_000 * 10**18, "LDO transfer", {"from": evmscriptexecutor} - # ) - # assert ldo_token.balanceOf(agent) == agent_ldo_balance_before - 5_000_000 * 10**18 - # assert ldo_token.balanceOf(stranger) == ldo_balance_before + 5_000_000 * 10**18 + ldo_token = interface.ERC20(LDO_TOKEN) + agent_ldo_balance_before = ldo_token.balanceOf(agent) + ldo_balance_before = ldo_token.balanceOf(stranger) + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + ldo_token, + stranger, + 5_000_000 * 10**18 + 1, + "LDO transfer", + {"from": evmscriptexecutor}, + ) + finance.newImmediatePayment( + ldo_token, + stranger, + 5_000_000 * 10**18, + "LDO transfer", + {"from": evmscriptexecutor} + ) + assert ldo_token.balanceOf(agent) == agent_ldo_balance_before - 5_000_000 * 10**18 + assert ldo_token.balanceOf(stranger) == ldo_balance_before + 5_000_000 * 10**18 + + # DAI + dai_token = interface.ERC20(DAI_TOKEN) + DAI_HOLDER = "0x075e72a5eDf65F0A5f44699c7654C1a76941Ddc8" + dai_token.transfer(agent.address, 2_000_000 * 10**18, { 'from': DAI_HOLDER }) # # 2_000_000 DAI - # agent_dai_balance_before = dai_token.balanceOf(agent) - # dai_balance_before = dai_token.balanceOf(stranger) - # with reverts("APP_AUTH_FAILED"): - # finance.newImmediatePayment( - # dai_token, - # stranger, - # 2_000_000 * 10**18 + 1, - # "DAI transfer", - # {"from": evmscriptexecutor}, - # ) - # finance.newImmediatePayment( - # dai_token, stranger, 2_000_000 * 10**18, "DAI transfer", {"from": evmscriptexecutor} - # ) - # assert dai_token.balanceOf(agent) == agent_dai_balance_before - 2_000_000 * 10**18 - # assert dai_token.balanceOf(stranger) == dai_balance_before + 2_000_000 * 10**18 + agent_dai_balance_before = dai_token.balanceOf(agent) + dai_balance_before = dai_token.balanceOf(stranger) + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + dai_token, + stranger, + 2_000_000 * 10**18 + 1, + "DAI transfer", + {"from": evmscriptexecutor}, + ) + finance.newImmediatePayment( + dai_token, + stranger, + 2_000_000 * 10**18, + "DAI transfer", + {"from": evmscriptexecutor} + ) + assert dai_token.balanceOf(agent) == agent_dai_balance_before - 2_000_000 * 10**18 + assert dai_token.balanceOf(stranger) == dai_balance_before + 2_000_000 * 10**18 + + # USDC + usdc_token = interface.ERC20(USDC_TOKEN) + USDC_HOLDER = "0xcEe284F754E854890e311e3280b767F80797180d" + usdc_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': USDC_HOLDER }) + + # # 2_000_000 USDC + agent_usdc_balance_before = usdc_token.balanceOf(agent) + usdc_balance_before = usdc_token.balanceOf(stranger) + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + usdc_token, + stranger, + 2_000_000 * 10**6 + 1, + "USDC transfer", + {"from": evmscriptexecutor}, + ) + finance.newImmediatePayment( + usdc_token, + stranger, + 2_000_000 * 10**6, + "USDC transfer", + {"from": evmscriptexecutor} + ) + assert usdc_token.balanceOf(agent) == agent_usdc_balance_before - 2_000_000 * 10**6 + assert usdc_token.balanceOf(stranger) == usdc_balance_before + 2_000_000 * 10**6 + + + # USDT + usdt_token = interface.ERC20(USDT_TOKEN) + USDT_HOLDER = "0xF977814e90dA44bFA03b6295A0616a897441aceC" + usdt_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': USDT_HOLDER }) + + # # 2_000_000 USDT + agent_usdt_balance_before = usdt_token.balanceOf(agent) + usdt_balance_before = usdt_token.balanceOf(stranger) + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + usdt_token, + stranger, + 2_000_000 * 10**6 + 1, + "USDT transfer", + {"from": evmscriptexecutor}, + ) + finance.newImmediatePayment( + usdt_token, + stranger, + 2_000_000 * 10**6, + "USDT transfer", + {"from": evmscriptexecutor} + ) + assert usdt_token.balanceOf(agent) == agent_usdt_balance_before - 2_000_000 * 10**6 + assert usdt_token.balanceOf(stranger) == usdt_balance_before + 2_000_000 * 10**6 + + # MATIC + MATIC_TOKEN = "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0" + MATIC_HOLDER = "0x5e3Ef299fDDf15eAa0432E6e66473ace8c13D908" + matic_token = interface.ERC20(MATIC_TOKEN) + matic_token.transfer(agent.address, 1, { 'from': MATIC_HOLDER }) + + with reverts("APP_AUTH_FAILED"): + finance.newImmediatePayment( + matic_token, + stranger, + 1, + "MATIC transfer", + {"from": evmscriptexecutor}, + ) + + ## todo: uncomment tests # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track @@ -405,95 +590,3 @@ def check_add_and_remove_recipient_with_voting(registry, helpers, ldo_holder, da assert len(registry.getAllowedRecipients()) == recipients_length_before, 'Wrong whitelist length' -eth = { - "limit": 1_000 * (10**18), - "address": ZERO_ADDRESS, -} - -steth = { - "limit": 1_000 * (10**18), - "address": LIDO, -} - -ldo = { - "limit": 5_000_000 * (10**18), - "address": LDO_TOKEN, -} - -dai = { - "limit": 2_000_000 * (10**18), - "address": DAI_TOKEN, -} - -usdc = { - "limit": 2_000_000 * (10**18), - "address": USDC_TOKEN, -} - -usdt = { - "limit": 2_000_000 * (10**18), - "address": USDT_TOKEN, -} - -def amount_limits() -> List[Param]: - token_arg_index = 0 - amount_arg_index = 2 - - return [ - # 0: if (1) then (2) else (3) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=1, success=2, failure=3) - ), - # 1: (_token == LDO) - Param(token_arg_index, Op.EQ, ArgumentValue(ldo["address"])), - # 2: { return _amount <= 5_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(ldo["limit"])), - # 3: else if (4) then (5) else (6) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=4, success=5, failure=6) - ), - # 4: (_token == ETH) - Param(token_arg_index, Op.EQ, ArgumentValue(eth["address"])), - # 5: { return _amount <= 1000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(eth["limit"])), - # 6: else if (7) then (8) else (9) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=7, success=8, failure=9) - ), - # 7: (_token == DAI) - Param(token_arg_index, Op.EQ, ArgumentValue(dai["address"])), - # 8: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(dai["limit"])), - # 9: else if (10) then (11) else (12) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=10, success=11, failure=12), - ), - # 10: (_token == USDT) - Param(token_arg_index, Op.EQ, ArgumentValue(usdt["address"])), - # 11: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(usdt["limit"])), - # 12: else if (13) then (14) else (15) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=13, success=14, failure=15), - ), - # 13: (_token == USDC) - Param(token_arg_index, Op.EQ, ArgumentValue(usdc["address"])), - # 14: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(usdc["limit"])), - # 15: else if (16) then (17) else (18) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=16, success=17, failure=18), - ), - # 16: (_token == stETH) - Param(token_arg_index, Op.EQ, ArgumentValue(steth["address"])), - # 17: { return _amount <= 1000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(steth["limit"])), - # 18: else { return false } - Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), - ] \ No newline at end of file From 7e3a82543371f10924908f2756df1099702feb50 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Wed, 25 Oct 2023 18:29:35 +0200 Subject: [PATCH 07/27] check registry limits --- tests/test_2023_10_31.py | 76 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index b041f0a7..6d84be04 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -195,8 +195,42 @@ def test_vote( assert not has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) assert not has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) - # какие лимиты в реджистрях - rcc_stable_registry.getPeriodState() + # check regsitries limits before voting + ( + rcc_already_spent_amount, + rcc_spendable_balanceInPeriod, + rcc_period_start_timestamp, + rcc_period_end_timestamp + ) = rcc_stable_registry.getPeriodState() + + assert rcc_already_spent_amount == 800000000000000000000000 + assert rcc_spendable_balanceInPeriod == 2200000000000000000000000 + assert rcc_period_start_timestamp == 1696118400 + assert rcc_period_end_timestamp == 1704067200 + + ( + pml_already_spent_amount, + pml_spendable_balanceInPeriod, + pml_period_start_timestamp, + pml_period_end_timestamp + ) = pml_stable_registry.getPeriodState() + + assert pml_already_spent_amount == 1500000000000000000000000 + assert pml_spendable_balanceInPeriod == 4500000000000000000000000 + assert pml_period_start_timestamp == 1696118400 + assert pml_period_end_timestamp == 1704067200 + + ( + atc_already_spent_amount, + atc_spendable_balanceInPeriod, + atc_period_start_timestamp, + atc_period_end_timestamp + ) = atc_stable_registry.getPeriodState() + + assert atc_already_spent_amount == 800000000000000000000000 + assert atc_spendable_balanceInPeriod == 700000000000000000000000 + assert atc_period_start_timestamp == 1696118400 + assert atc_period_end_timestamp == 1704067200 # START VOTE if len(vote_ids_from_env) > 0: @@ -212,6 +246,43 @@ def test_vote( updated_factories_list = easy_track.getEVMScriptFactories() assert len(updated_factories_list) == 16 + # check regsitries limits after voting + ( + rcc_already_spent_amount, + rcc_spendable_balanceInPeriod, + rcc_period_start_timestamp, + rcc_period_end_timestamp + ) = rcc_stable_registry.getPeriodState() + + assert rcc_already_spent_amount == 800000000000000000000000 + assert rcc_spendable_balanceInPeriod == 2200000000000000000000000 + assert rcc_period_start_timestamp == 1696118400 + assert rcc_period_end_timestamp == 1704067200 + + ( + pml_already_spent_amount, + pml_spendable_balanceInPeriod, + pml_period_start_timestamp, + pml_period_end_timestamp + ) = pml_stable_registry.getPeriodState() + + assert pml_already_spent_amount == 1500000000000000000000000 + assert pml_spendable_balanceInPeriod == 4500000000000000000000000 + assert pml_period_start_timestamp == 1696118400 + assert pml_period_end_timestamp == 1704067200 + + ( + atc_already_spent_amount, + atc_spendable_balanceInPeriod, + atc_period_start_timestamp, + atc_period_end_timestamp + ) = atc_stable_registry.getPeriodState() + + assert atc_already_spent_amount == 800000000000000000000000 + assert atc_spendable_balanceInPeriod == 700000000000000000000000 + assert atc_period_start_timestamp == 1696118400 + assert atc_period_end_timestamp == 1704067200 + assert has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) assert has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) @@ -230,7 +301,6 @@ def test_vote( assert not has_payments_permission(acl, finance, accounts[0].address, eth["address"], ldo_holder.address, eth["limit"]) # assert not has_payments_permission(acl, finance, accounts[0].address, usdc_token, ldo_holder.address, 1) - # ETH deposit = accounts.at(CHAIN_DEPOSIT_CONTRACT, {"force": True}) deposit.transfer(agent.address, "1000 ether") From 7a24f24778315d1e8cc3fac45e604a31d2d4a7a2 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Wed, 25 Oct 2023 20:10:32 +0200 Subject: [PATCH 08/27] change node operator name --- scripts/vote_2023_10_31.py | 22 +++++++++++++++++----- tests/test_2023_10_31.py | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 546990ce..91704703 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -14,7 +14,8 @@ from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description from utils.easy_track import add_evmscript_factory, create_permissions, remove_evmscript_factory from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if -from utils.permissions import encode_permission_revoke, encode_permission_grant_p +from utils.permissions import encode_permission_revoke, encode_permission_grant_p, encode_permission_grant, encode_permission_create +from utils.node_operators import encode_set_node_operator_name from utils.config import ( get_deployer_account, @@ -148,8 +149,11 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") - call_script_items = [ + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) + prysmatic_labs_node_id = 27 + prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" + call_script_items = [ # 1. Revoke role CREATE_PAYMENTS_ROLE from EVM script executor encode_permission_revoke( target_app=contracts.finance, @@ -163,8 +167,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra permission_name="CREATE_PAYMENTS_ROLE", grant_to=EASYTRACK_EVMSCRIPT_EXECUTOR, params=amount_limits(), - ), - + ), ## 3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track remove_evmscript_factory(factory=rcc_dai_topup_factory_old), ## 4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track @@ -190,7 +193,13 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra factory=atc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], - ) + ), + # 9. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting + encode_permission_grant(target_app=NO_registry, permission_name="MANAGE_NODE_OPERATOR_ROLE", grant_to=contracts.voting), + # 10. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` + encode_set_node_operator_name(prysmatic_labs_node_id, prysmatic_labs_node_new_name, NO_registry), + # 11. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting + encode_permission_revoke(NO_registry, "MANAGE_NODE_OPERATOR_ROLE", revoke_from=contracts.voting), ] # todo: change addresses in 6,7,8 strings @@ -203,6 +212,9 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra f"6) Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track", f"7) Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track", f"8) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", + f"9) Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting", + f"10) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", + f"11) Revoke MANAGE_NODE_OPERATOR_ROLE from Voting", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 6d84be04..5dbae095 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -232,6 +232,15 @@ def test_vote( assert atc_period_start_timestamp == 1696118400 assert atc_period_end_timestamp == 1704067200 + # Check node operator name before + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) + prysmatic_labs_node_id = 27 + prysmatic_labs_node_old_name = "Prysmatic Labs" + prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" + prysmatic_labs_node_data_before_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) + + assert prysmatic_labs_node_data_before_voting["name"] == prysmatic_labs_node_old_name, "Incorrect NO#27 name before" + # START VOTE if len(vote_ids_from_env) > 0: (vote_id,) = vote_ids_from_env @@ -283,7 +292,11 @@ def test_vote( assert atc_period_start_timestamp == 1696118400 assert atc_period_end_timestamp == 1704067200 + # node operator name + prysmatic_labs_node_data_after_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) + assert prysmatic_labs_node_data_after_voting["name"] == prysmatic_labs_node_new_name, "Incorrect NO#27 name after" + # permissions assert has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) assert has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) assert has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) @@ -423,7 +436,6 @@ def test_vote( assert usdc_token.balanceOf(agent) == agent_usdc_balance_before - 2_000_000 * 10**6 assert usdc_token.balanceOf(stranger) == usdc_balance_before + 2_000_000 * 10**6 - # USDT usdt_token = interface.ERC20(USDT_TOKEN) USDT_HOLDER = "0xF977814e90dA44bFA03b6295A0616a897441aceC" @@ -465,8 +477,6 @@ def test_vote( {"from": evmscriptexecutor}, ) - - ## todo: uncomment tests # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track # assert rcc_dai_topup_factory_old not in updated_factories_list @@ -515,7 +525,7 @@ def test_vote( check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) # validate vote events - assert count_vote_items_by_events(vote_tx, dao_voting) == 8, "Incorrect voting items count" + assert count_vote_items_by_events(vote_tx, dao_voting) == 11, "Incorrect voting items count" display_voting_events(vote_tx) From b5074e5b4e7ac2ca58e8a2f63016130ea571320b Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Thu, 26 Oct 2023 00:21:41 +0200 Subject: [PATCH 09/27] add stETH to registries --- scripts/vote_2023_10_31.py | 64 ++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 91704703..1047ac67 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -16,6 +16,7 @@ from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if from utils.permissions import encode_permission_revoke, encode_permission_grant_p, encode_permission_grant, encode_permission_create from utils.node_operators import encode_set_node_operator_name +from utils.finance import make_steth_payout from utils.config import ( get_deployer_account, @@ -149,11 +150,16 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") + rcc_multisig_address = "0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437" + pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" + atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) prysmatic_labs_node_id = 27 prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" call_script_items = [ + # I. Add USDT and USDC to EVMScriptExecutor permissions # 1. Revoke role CREATE_PAYMENTS_ROLE from EVM script executor encode_permission_revoke( target_app=contracts.finance, @@ -168,13 +174,14 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra grant_to=EASYTRACK_EVMSCRIPT_EXECUTOR, params=amount_limits(), ), + + # II. Switch ET DAI top-up setups into ET Stables setups for RCC PML ATC ## 3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track remove_evmscript_factory(factory=rcc_dai_topup_factory_old), ## 4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track remove_evmscript_factory(factory=pml_dai_topup_factory_old), ## 5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track remove_evmscript_factory(factory=atc_dai_topup_factory_old), - # todo: change addresses ## 6. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track add_evmscript_factory( @@ -194,12 +201,46 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra permissions=create_permissions(contracts.finance, "newImmediatePayment") + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], ), - # 9. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting - encode_permission_grant(target_app=NO_registry, permission_name="MANAGE_NODE_OPERATOR_ROLE", grant_to=contracts.voting), - # 10. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` - encode_set_node_operator_name(prysmatic_labs_node_id, prysmatic_labs_node_new_name, NO_registry), - # 11. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting - encode_permission_revoke(NO_registry, "MANAGE_NODE_OPERATOR_ROLE", revoke_from=contracts.voting), + + # III. stETH transfers to RCC PML ATC + # 9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 + make_steth_payout( + target_address=rcc_multisig_address, + steth_in_wei=1 * (10**18), + reference="Fund Gas Funder multisig" + ), + # 10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D + make_steth_payout( + target_address=pml_multisig_address, + steth_in_wei=1 * (10**18), + reference="Fund Gas Funder multisig" + ), + # 11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + make_steth_payout( + target_address=atc_multisig_address, + steth_in_wei=1 * (10**18), + reference="Fund Gas Funder multisig" + ), + + # IV. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' + # 12. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting + encode_permission_grant( + target_app=NO_registry, + permission_name="MANAGE_NODE_OPERATOR_ROLE", + grant_to=contracts.voting + ), + # 13. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` + encode_set_node_operator_name( + prysmatic_labs_node_id, + prysmatic_labs_node_new_name, + NO_registry + ), + # 14. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting + encode_permission_revoke( + NO_registry, + "MANAGE_NODE_OPERATOR_ROLE", + revoke_from=contracts.voting + ), ] # todo: change addresses in 6,7,8 strings @@ -212,9 +253,12 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra f"6) Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track", f"7) Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track", f"8) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", - f"9) Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting", - f"10) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", - f"11) Revoke MANAGE_NODE_OPERATOR_ROLE from Voting", + f"9) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", + f"10) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", + f"11) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", + f"12) Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting", + f"13) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", + f"14) Revoke MANAGE_NODE_OPERATOR_ROLE from Voting", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) From 7fd8f5230f546131044fe37cca90c4b129553b5e Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Thu, 26 Oct 2023 15:43:44 +0200 Subject: [PATCH 10/27] refactoring + remove node renaming --- scripts/vote_2023_10_31.py | 58 ++++----- tests/test_2023_10_31.py | 243 +++++++++++++++++-------------------- utils/config.py | 8 ++ 3 files changed, 144 insertions(+), 165 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 1047ac67..acf5789a 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -10,12 +10,10 @@ from brownie.network.transaction import TransactionReceipt from brownie import interface, ZERO_ADDRESS from utils.voting import bake_vote_items, confirm_vote_script, create_vote -from utils.agent import agent_forward from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description from utils.easy_track import add_evmscript_factory, create_permissions, remove_evmscript_factory from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if -from utils.permissions import encode_permission_revoke, encode_permission_grant_p, encode_permission_grant, encode_permission_create -from utils.node_operators import encode_set_node_operator_name +from utils.permissions import encode_permission_revoke, encode_permission_grant_p from utils.finance import make_steth_payout from utils.config import ( @@ -33,10 +31,25 @@ # todo: change description description = """ -### Omnibus on-chain vote contains 3 motions: -1. Switch off TopUp ETs for RCC PML ACT -2. Switch on TopUpStable ETs for RCC PML ACT +I. Add USDT and USDC to EVMScriptExecutor permissions +1. Remove CREATE_PAYMENTS_ROLE from EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 +2. Add CREATE_PAYMENTS_ROLE to EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 with single transfer limits of 1,000 ETH, 1,000 stETH, 5,000,000 LDO, 2,000,000 DAI, 2,000,000 USDC, 2,000,000 USDT + +II. Switch ET DAI top-up setups into ET Stables setups for RCC PML ATC +3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track +4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track +5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track +6. Add RCC stable top up EVM script factory TBA +7. Add PML stable top up EVM script factory TBA +8. Add ATC stable top up EVM script factory TBA + +III. stETH transfers to RCC PML ATC +9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 +10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D +11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + +IV. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' """ @@ -154,10 +167,6 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" - NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) - prysmatic_labs_node_id = 27 - prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" - call_script_items = [ # I. Add USDT and USDC to EVMScriptExecutor permissions # 1. Revoke role CREATE_PAYMENTS_ROLE from EVM script executor @@ -220,30 +229,10 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra target_address=atc_multisig_address, steth_in_wei=1 * (10**18), reference="Fund Gas Funder multisig" - ), - - # IV. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' - # 12. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting - encode_permission_grant( - target_app=NO_registry, - permission_name="MANAGE_NODE_OPERATOR_ROLE", - grant_to=contracts.voting - ), - # 13. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` - encode_set_node_operator_name( - prysmatic_labs_node_id, - prysmatic_labs_node_new_name, - NO_registry - ), - # 14. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting - encode_permission_revoke( - NO_registry, - "MANAGE_NODE_OPERATOR_ROLE", - revoke_from=contracts.voting - ), + ) ] - # todo: change addresses in 6,7,8 strings + # todo: change addresses in 6,7,8 strings and stETH amount vote_desc_items = [ f"1) Revoke role CREATE_PAYMENTS_ROLE from EVM script executor", f"2) Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", @@ -255,10 +244,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra f"8) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", f"9) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", f"10) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", - f"11) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", - f"12) Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting", - f"13) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", - f"14) Revoke MANAGE_NODE_OPERATOR_ROLE from Voting", + f"11) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 5dbae095..f7ba4ce3 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -2,22 +2,11 @@ Tests for voting 31/10/2023 """ -from scripts.vote_2023_10_31 import start_vote +import math +from scripts.vote_2023_10_31 import start_vote from eth_abi.abi import encode_single from brownie import chain, accounts, ZERO_ADDRESS, reverts -import math - -from utils.config import ( - contracts, - LDO_HOLDER_ADDRESS_FOR_TESTS, - LIDO, - LDO_TOKEN, - DAI_TOKEN, - USDC_TOKEN, - USDT_TOKEN, - CHAIN_DEPOSIT_CONTRACT -) from utils.easy_track import create_permissions from utils.agent import agent_forward from utils.voting import create_vote, bake_vote_items @@ -32,15 +21,32 @@ validate_permission_grantp_event, validate_permission_revoke_event, ) -from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if +from utils.permission_parameters import ( + Param, + SpecialArgumentID, + Op, + ArgumentValue, + encode_argument_value_if +) +from utils.config import ( + contracts, + LDO_HOLDER_ADDRESS_FOR_TESTS, + LIDO, + LDO_TOKEN, + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN, + CHAIN_DEPOSIT_CONTRACT, + FINANCE, + AGENT +) eth = "0x0000000000000000000000000000000000000000" -aragonAgentProxy = "0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c" STETH_ERROR_MARGIN = 2 permission = Permission( entity="0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", # EVMScriptExecutor - app="0xB9E5CBB9CA5b0d659238807E84D0176930753d86", # Finance Aragon App + app=FINANCE, # Finance Aragon App role="0x5de467a460382d13defdc02aacddc9c7d6605d6d4e0b8bd2f70732cae8ea17bc", ) # keccak256('CREATE_PAYMENTS_ROLE') @@ -150,12 +156,11 @@ def test_vote( stranger, ldo_holder ): - easy_track = interface.EasyTrack("0xF0211b7660680B49De1A7E9f25C65660F0a13Fea") - dao_voting = interface.Voting("0x2e59A20f205bB85a89C53f1936454680651E618e") - acl = interface.ACL("0x9895f0f17cc1d1891b6f18ee0b483b6f221b37bb") - finance = interface.Finance("0xB9E5CBB9CA5b0d659238807E84D0176930753d86") agent = accounts.at("0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c", {"force": True}) evmscriptexecutor = accounts.at("0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", {"force": True}) + usdt_holder = "0xF977814e90dA44bFA03b6295A0616a897441aceC" + usdc_holder = "0xcEe284F754E854890e311e3280b767F80797180d" + dai_holder = "0x075e72a5eDf65F0A5f44699c7654C1a76941Ddc8" rcc_trusted_caller_and_recepient = accounts.at("0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", {"force": True}) pml_trusted_caller_and_recepient = accounts.at("0x17F6b2C738a63a8D3A113a228cfd0b373244633D", {"force": True}) @@ -175,8 +180,7 @@ def test_vote( pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") - old_factories_list = easy_track.getEVMScriptFactories() - + old_factories_list = contracts.easy_track.getEVMScriptFactories() assert len(old_factories_list) == 16 # todo: uncomment when u get new factories address @@ -188,14 +192,14 @@ def test_vote( assert pml_dai_topup_factory_old in old_factories_list assert atc_dai_topup_factory_old in old_factories_list - assert has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) - assert has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) - assert has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) - assert has_payments_permission(acl, finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) - assert not has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) - assert not has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) - # check regsitries limits before voting + # check regsitries parameters before voting ( rcc_already_spent_amount, rcc_spendable_balanceInPeriod, @@ -232,15 +236,6 @@ def test_vote( assert atc_period_start_timestamp == 1696118400 assert atc_period_end_timestamp == 1704067200 - # Check node operator name before - NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) - prysmatic_labs_node_id = 27 - prysmatic_labs_node_old_name = "Prysmatic Labs" - prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" - prysmatic_labs_node_data_before_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) - - assert prysmatic_labs_node_data_before_voting["name"] == prysmatic_labs_node_old_name, "Incorrect NO#27 name before" - # START VOTE if len(vote_ids_from_env) > 0: (vote_id,) = vote_ids_from_env @@ -252,10 +247,10 @@ def test_vote( print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") - updated_factories_list = easy_track.getEVMScriptFactories() + updated_factories_list = contracts.easy_track.getEVMScriptFactories() assert len(updated_factories_list) == 16 - # check regsitries limits after voting + # check regsitries parameters after voting ( rcc_already_spent_amount, rcc_spendable_balanceInPeriod, @@ -292,44 +287,39 @@ def test_vote( assert atc_period_start_timestamp == 1696118400 assert atc_period_end_timestamp == 1704067200 - # node operator name - prysmatic_labs_node_data_after_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) - assert prysmatic_labs_node_data_after_voting["name"] == prysmatic_labs_node_new_name, "Incorrect NO#27 name after" - # permissions - assert has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) - assert has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) - assert has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) - assert has_payments_permission(acl, finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) - assert has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) - assert has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) - - assert not has_payments_permission(acl, finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"] + 1) - assert not has_payments_permission(acl, finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"] + 1) - assert not has_payments_permission(acl, finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"] + 1) - assert not has_payments_permission(acl, finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"] + 1) - assert not has_payments_permission(acl, finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"] + 1) - assert not has_payments_permission(acl, finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"] + 1) - - assert not has_payments_permission(acl, finance, accounts[0].address, eth["address"], ldo_holder.address, eth["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) + assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) + + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"] + 1) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"] + 1) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"] + 1) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"] + 1) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"] + 1) + assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"] + 1) + + assert not has_payments_permission(contracts.acl, contracts.finance, accounts[0].address, eth["address"], ldo_holder.address, eth["limit"]) # assert not has_payments_permission(acl, finance, accounts[0].address, usdc_token, ldo_holder.address, 1) # ETH deposit = accounts.at(CHAIN_DEPOSIT_CONTRACT, {"force": True}) deposit.transfer(agent.address, "1000 ether") - - # 1000 ETH + # Check ETH limits. 1000 ETH agent_balance_before = agent.balance() eth_balance_before = stranger.balance() with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( + contracts.finance.newImmediatePayment( ZERO_ADDRESS, stranger, 1000 * 10**18 + 1, "ETH transfer", {"from": evmscriptexecutor}, ) - finance.newImmediatePayment( + contracts.finance.newImmediatePayment( ZERO_ADDRESS, stranger, 1000 * 10**18, @@ -339,20 +329,20 @@ def test_vote( assert agent.balance() == agent_balance_before - 1000 * 10**18 assert stranger.balance() == eth_balance_before + 1000 * 10**18 - - # 1000 stETH + # stETH + # Check stETH limits. 1000 stETH. steth_token = interface.ERC20(LIDO) agent_steth_balance_before = steth_token.balanceOf(agent) stETH_balance_before = steth_token.balanceOf(stranger) with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( + contracts.finance.newImmediatePayment( steth_token, stranger, 1000 * 10**18 + 1, "stETH transfer", {"from": evmscriptexecutor}, ) - finance.newImmediatePayment( + contracts.finance.newImmediatePayment( steth_token, stranger, 1000 * 10**18, @@ -362,114 +352,108 @@ def test_vote( assert math.isclose(steth_token.balanceOf(agent), agent_steth_balance_before - 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN) assert math.isclose(steth_token.balanceOf(stranger), stETH_balance_before + 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN) - # # 5_000_000 LDO - ldo_token = interface.ERC20(LDO_TOKEN) - agent_ldo_balance_before = ldo_token.balanceOf(agent) - ldo_balance_before = ldo_token.balanceOf(stranger) + # LDO + # Check LDO limits. 5_000_000 LDO + agent_ldo_balance_before = contracts.ldo_token.balanceOf(agent) + ldo_balance_before = contracts.ldo_token.balanceOf(stranger) with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( - ldo_token, + contracts.finance.newImmediatePayment( + contracts.ldo_token, stranger, 5_000_000 * 10**18 + 1, "LDO transfer", {"from": evmscriptexecutor}, ) - finance.newImmediatePayment( - ldo_token, + contracts.finance.newImmediatePayment( + contracts.ldo_token, stranger, 5_000_000 * 10**18, "LDO transfer", {"from": evmscriptexecutor} ) - assert ldo_token.balanceOf(agent) == agent_ldo_balance_before - 5_000_000 * 10**18 - assert ldo_token.balanceOf(stranger) == ldo_balance_before + 5_000_000 * 10**18 + assert contracts.ldo_token.balanceOf(agent) == agent_ldo_balance_before - 5_000_000 * 10**18 + assert contracts.ldo_token.balanceOf(stranger) == ldo_balance_before + 5_000_000 * 10**18 # DAI - dai_token = interface.ERC20(DAI_TOKEN) - DAI_HOLDER = "0x075e72a5eDf65F0A5f44699c7654C1a76941Ddc8" - dai_token.transfer(agent.address, 2_000_000 * 10**18, { 'from': DAI_HOLDER }) - - # # 2_000_000 DAI - agent_dai_balance_before = dai_token.balanceOf(agent) - dai_balance_before = dai_token.balanceOf(stranger) + # Top up agent DAI balance. + contracts.dai_token.transfer(agent.address, 2_000_000 * 10**18, { 'from': dai_holder }) + # Check DAI limits. 2_000_000 DAI + agent_dai_balance_before = contracts.dai_token.balanceOf(agent) + dai_balance_before = contracts.dai_token.balanceOf(stranger) with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( - dai_token, + contracts.finance.newImmediatePayment( + contracts.dai_token, stranger, 2_000_000 * 10**18 + 1, "DAI transfer", {"from": evmscriptexecutor}, ) - finance.newImmediatePayment( - dai_token, + contracts.finance.newImmediatePayment( + contracts.dai_token, stranger, 2_000_000 * 10**18, "DAI transfer", {"from": evmscriptexecutor} ) - assert dai_token.balanceOf(agent) == agent_dai_balance_before - 2_000_000 * 10**18 - assert dai_token.balanceOf(stranger) == dai_balance_before + 2_000_000 * 10**18 + assert contracts.dai_token.balanceOf(agent) == agent_dai_balance_before - 2_000_000 * 10**18 + assert contracts.dai_token.balanceOf(stranger) == dai_balance_before + 2_000_000 * 10**18 # USDC - usdc_token = interface.ERC20(USDC_TOKEN) - USDC_HOLDER = "0xcEe284F754E854890e311e3280b767F80797180d" - usdc_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': USDC_HOLDER }) - - # # 2_000_000 USDC - agent_usdc_balance_before = usdc_token.balanceOf(agent) - usdc_balance_before = usdc_token.balanceOf(stranger) + # Top up agent USDC balance. + contracts.usdc_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': usdc_holder }) + # Check USDC limits. 2_000_000 USDC + agent_usdc_balance_before = contracts.usdc_token.balanceOf(agent) + usdc_balance_before = contracts.usdc_token.balanceOf(stranger) with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( - usdc_token, + contracts.finance.newImmediatePayment( + contracts.usdc_token, stranger, 2_000_000 * 10**6 + 1, "USDC transfer", {"from": evmscriptexecutor}, ) - finance.newImmediatePayment( - usdc_token, + contracts.finance.newImmediatePayment( + contracts.usdc_token, stranger, 2_000_000 * 10**6, "USDC transfer", {"from": evmscriptexecutor} ) - assert usdc_token.balanceOf(agent) == agent_usdc_balance_before - 2_000_000 * 10**6 - assert usdc_token.balanceOf(stranger) == usdc_balance_before + 2_000_000 * 10**6 + assert contracts.usdc_token.balanceOf(agent) == agent_usdc_balance_before - 2_000_000 * 10**6 + assert contracts.usdc_token.balanceOf(stranger) == usdc_balance_before + 2_000_000 * 10**6 # USDT - usdt_token = interface.ERC20(USDT_TOKEN) - USDT_HOLDER = "0xF977814e90dA44bFA03b6295A0616a897441aceC" - usdt_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': USDT_HOLDER }) - - # # 2_000_000 USDT - agent_usdt_balance_before = usdt_token.balanceOf(agent) - usdt_balance_before = usdt_token.balanceOf(stranger) + # Top up agent USDT balance. + contracts.usdt_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': usdt_holder }) + # Check USDT limits. 2_000_000 USDT + agent_usdt_balance_before = contracts.usdt_token.balanceOf(agent) + usdt_balance_before = contracts.usdt_token.balanceOf(stranger) with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( - usdt_token, + contracts.finance.newImmediatePayment( + contracts.usdt_token, stranger, 2_000_000 * 10**6 + 1, "USDT transfer", {"from": evmscriptexecutor}, ) - finance.newImmediatePayment( - usdt_token, + contracts.finance.newImmediatePayment( + contracts.usdt_token, stranger, 2_000_000 * 10**6, "USDT transfer", {"from": evmscriptexecutor} ) - assert usdt_token.balanceOf(agent) == agent_usdt_balance_before - 2_000_000 * 10**6 - assert usdt_token.balanceOf(stranger) == usdt_balance_before + 2_000_000 * 10**6 + assert contracts.usdt_token.balanceOf(agent) == agent_usdt_balance_before - 2_000_000 * 10**6 + assert contracts.usdt_token.balanceOf(stranger) == usdt_balance_before + 2_000_000 * 10**6 # MATIC + # Check token that is not supported. MATIC_TOKEN = "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0" MATIC_HOLDER = "0x5e3Ef299fDDf15eAa0432E6e66473ace8c13D908" matic_token = interface.ERC20(MATIC_TOKEN) matic_token.transfer(agent.address, 1, { 'from': MATIC_HOLDER }) - with reverts("APP_AUTH_FAILED"): - finance.newImmediatePayment( + contracts.finance.newImmediatePayment( matic_token, stranger, 1, @@ -488,44 +472,45 @@ def test_vote( # 4. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track assert rcc_stable_topup_factory in updated_factories_list create_and_enact_payment_motion( - easy_track, + contracts.easy_track, rcc_trusted_caller_and_recepient, rcc_stable_topup_factory, - dai_token, + contracts.dai_token, [rcc_trusted_caller_and_recepient], [10 * 10**18], stranger, ) - check_add_and_remove_recipient_with_voting(rcc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) + check_add_and_remove_recipient_with_voting(rcc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) # 5. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track assert pml_stable_topup_factory in updated_factories_list create_and_enact_payment_motion( - easy_track, + contracts.easy_track, pml_trusted_caller_and_recepient, pml_stable_topup_factory, - dai_token, + contracts.dai_token, [pml_trusted_caller_and_recepient], [10 * 10**18], stranger, ) - check_add_and_remove_recipient_with_voting(pml_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) + check_add_and_remove_recipient_with_voting(pml_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) # 6. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track assert atc_stable_topup_factory in updated_factories_list create_and_enact_payment_motion( - easy_track, + contracts.easy_track, atc_trusted_caller_and_recepient, atc_stable_topup_factory, - dai_token, + contracts.dai_token, [atc_trusted_caller_and_recepient], [10 * 10**18], stranger, ) - check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, dao_voting) + check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) # validate vote events - assert count_vote_items_by_events(vote_tx, dao_voting) == 11, "Incorrect voting items count" + print("count_vote_items_by_events", count_vote_items_by_events(vote_tx, contracts.voting)) + assert count_vote_items_by_events(vote_tx, contracts.voting) == 11, "Incorrect voting items count" display_voting_events(vote_tx) @@ -572,7 +557,7 @@ def create_and_enact_payment_motion( transfer_amounts, stranger, ): - agent = accounts.at(aragonAgentProxy, {"force": True}) + agent = accounts.at(AGENT, {"force": True}) agent_balance_before = balance_of(agent, token) recievers_balance_before = [balance_of(reciever, token) for reciever in recievers] motions_before = easy_track.getMotions() diff --git a/utils/config.py b/utils/config.py index 54ebab3e..4a7c3593 100644 --- a/utils/config.py +++ b/utils/config.py @@ -224,6 +224,14 @@ def relay_allowed_list(self) -> interface.MEVBoostRelayAllowedList: def dai_token(self) -> interface.ERC20: return interface.ERC20(DAI_TOKEN) + @property + def usdt_token(self) -> interface.ERC20: + return interface.ERC20(USDT_TOKEN) + + @property + def usdc_token(self) -> interface.ERC20: + return interface.ERC20(USDC_TOKEN) + @property def weth_token(self) -> interface.WethToken: return interface.WethToken(WETH_TOKEN) From 4604658f2fc84fafb5cf2bb4e28a5e1ce1345b13 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 27 Oct 2023 13:06:05 +0200 Subject: [PATCH 11/27] fixes: additional check for registiries, steth from agent to rcc, pml, atc tests --- scripts/vote_2023_10_31.py | 8 +- tests/test_2023_10_31.py | 253 +++++++++++++------------------------ 2 files changed, 93 insertions(+), 168 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index acf5789a..0ec58040 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -176,7 +176,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra revoke_from=EASYTRACK_EVMSCRIPT_EXECUTOR, ), # 2. Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 - # with limits: 1000 ETH, 1000 stETH, 5M LDO, 2M DAI, 2M USTD, 2M USDC + # with limits: 1000 ETH, 1000 stETH, 5M LDO, 2M DAI, 2M USDT, 2M USDC encode_permission_grant_p( target_app=contracts.finance, permission_name="CREATE_PAYMENTS_ROLE", @@ -216,19 +216,19 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra make_steth_payout( target_address=rcc_multisig_address, steth_in_wei=1 * (10**18), - reference="Fund Gas Funder multisig" + reference="Fund RCC multisig" ), # 10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D make_steth_payout( target_address=pml_multisig_address, steth_in_wei=1 * (10**18), - reference="Fund Gas Funder multisig" + reference="Fund PML multisig" ), # 11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 make_steth_payout( target_address=atc_multisig_address, steth_in_wei=1 * (10**18), - reference="Fund Gas Funder multisig" + reference="Fund ATC multisig" ) ] diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index f7ba4ce3..f6e3d7a6 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -21,6 +21,14 @@ validate_permission_grantp_event, validate_permission_revoke_event, ) +from utils.test.easy_track_helpers import ( + create_and_enact_payment_motion, + check_add_and_remove_recipient_with_voting +) +from utils.test.event_validators.payout import ( + Payout, + validate_token_payout_event +) from utils.permission_parameters import ( Param, SpecialArgumentID, @@ -143,11 +151,6 @@ def amount_limits() -> List[Param]: Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), ] -def has_payments_permission(acl, finance, sender, token, receiver, amount) -> bool: - return acl.hasPermission["address,address,bytes32,uint[]"]( - sender, finance, finance.CREATE_PAYMENTS_ROLE(), [token, receiver, amount] - ) - def test_vote( helpers, accounts, @@ -156,15 +159,18 @@ def test_vote( stranger, ldo_holder ): - agent = accounts.at("0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c", {"force": True}) + agent = accounts.at(AGENT, {"force": True}) evmscriptexecutor = accounts.at("0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", {"force": True}) usdt_holder = "0xF977814e90dA44bFA03b6295A0616a897441aceC" usdc_holder = "0xcEe284F754E854890e311e3280b767F80797180d" dai_holder = "0x075e72a5eDf65F0A5f44699c7654C1a76941Ddc8" + rcc_multisig_address = "0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437" + pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" + atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" - rcc_trusted_caller_and_recepient = accounts.at("0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", {"force": True}) - pml_trusted_caller_and_recepient = accounts.at("0x17F6b2C738a63a8D3A113a228cfd0b373244633D", {"force": True}) - atc_trusted_caller_and_recepient = accounts.at("0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", {"force": True}) + rcc_trusted_caller_and_recepient = accounts.at(rcc_multisig_address, {"force": True}) + pml_trusted_caller_and_recepient = accounts.at(pml_multisig_address, {"force": True}) + atc_trusted_caller_and_recepient = accounts.at(atc_multisig_address, {"force": True}) rcc_dai_topup_factory_old = interface.IEVMScriptFactory("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") @@ -201,40 +207,45 @@ def test_vote( # check regsitries parameters before voting ( - rcc_already_spent_amount, - rcc_spendable_balanceInPeriod, - rcc_period_start_timestamp, - rcc_period_end_timestamp + rcc_already_spent_amount_before, + rcc_spendable_balanceInPeriod_before, + rcc_period_start_timestamp_before, + rcc_period_end_timestamp_before ) = rcc_stable_registry.getPeriodState() - assert rcc_already_spent_amount == 800000000000000000000000 - assert rcc_spendable_balanceInPeriod == 2200000000000000000000000 - assert rcc_period_start_timestamp == 1696118400 - assert rcc_period_end_timestamp == 1704067200 + assert rcc_already_spent_amount_before == 800000000000000000000000 + assert rcc_spendable_balanceInPeriod_before == 2200000000000000000000000 + assert rcc_period_start_timestamp_before == 1696118400 + assert rcc_period_end_timestamp_before == 1704067200 ( - pml_already_spent_amount, - pml_spendable_balanceInPeriod, - pml_period_start_timestamp, - pml_period_end_timestamp + pml_already_spent_amount_before, + pml_spendable_balanceInPeriod_before, + pml_period_start_timestamp_before, + pml_period_end_timestamp_before ) = pml_stable_registry.getPeriodState() - assert pml_already_spent_amount == 1500000000000000000000000 - assert pml_spendable_balanceInPeriod == 4500000000000000000000000 - assert pml_period_start_timestamp == 1696118400 - assert pml_period_end_timestamp == 1704067200 + assert pml_already_spent_amount_before == 1500000000000000000000000 + assert pml_spendable_balanceInPeriod_before == 4500000000000000000000000 + assert pml_period_start_timestamp_before == 1696118400 + assert pml_period_end_timestamp_before == 1704067200 ( - atc_already_spent_amount, - atc_spendable_balanceInPeriod, - atc_period_start_timestamp, - atc_period_end_timestamp + atc_already_spent_amount_before, + atc_spendable_balanceInPeriod_before, + atc_period_start_timestamp_before, + atc_period_end_timestamp_before ) = atc_stable_registry.getPeriodState() - assert atc_already_spent_amount == 800000000000000000000000 - assert atc_spendable_balanceInPeriod == 700000000000000000000000 - assert atc_period_start_timestamp == 1696118400 - assert atc_period_end_timestamp == 1704067200 + assert atc_already_spent_amount_before == 800000000000000000000000 + assert atc_spendable_balanceInPeriod_before == 700000000000000000000000 + assert atc_period_start_timestamp_before == 1696118400 + assert atc_period_end_timestamp_before == 1704067200 + + rcc_multisig_balance_before = contracts.lido.balanceOf(rcc_multisig_address) + pml_multisig_balance_before = contracts.lido.balanceOf(pml_multisig_address) + atc_multisig_balance_before = contracts.lido.balanceOf(atc_multisig_address) + dao_balance_before = contracts.lido.balanceOf(AGENT) # START VOTE if len(vote_ids_from_env) > 0: @@ -250,42 +261,57 @@ def test_vote( updated_factories_list = contracts.easy_track.getEVMScriptFactories() assert len(updated_factories_list) == 16 - # check regsitries parameters after voting + rcc_multisig_balance_after = contracts.lido.balanceOf(rcc_multisig_address) + pml_multisig_balance_after = contracts.lido.balanceOf(pml_multisig_address) + atc_multisig_balance_after = contracts.lido.balanceOf(atc_multisig_address) + dao_balance_after = contracts.lido.balanceOf(AGENT) + + rcc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) + pml_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) + atc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) + dao_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18) + 1 * (10**18) + 1 * (10**18)) + + steth_balance_checker(rcc_multisig_balance_after - rcc_multisig_balance_before, rcc_fund_payout.amount) + steth_balance_checker(pml_multisig_balance_after - pml_multisig_balance_before, pml_fund_payout.amount) + steth_balance_checker(atc_multisig_balance_after - atc_multisig_balance_before, atc_fund_payout.amount) + steth_balance_checker(dao_balance_before - dao_balance_after, dao_fund_payout.amount) + + # check registries parameters after voting ( - rcc_already_spent_amount, - rcc_spendable_balanceInPeriod, - rcc_period_start_timestamp, - rcc_period_end_timestamp + rcc_already_spent_amount_after, + rcc_spendable_balanceInPeriod_after, + rcc_period_start_timestamp_after, + rcc_period_end_timestamp_after ) = rcc_stable_registry.getPeriodState() - assert rcc_already_spent_amount == 800000000000000000000000 - assert rcc_spendable_balanceInPeriod == 2200000000000000000000000 - assert rcc_period_start_timestamp == 1696118400 - assert rcc_period_end_timestamp == 1704067200 + assert rcc_already_spent_amount_before == rcc_already_spent_amount_after == 800000000000000000000000 + assert rcc_spendable_balanceInPeriod_before == rcc_spendable_balanceInPeriod_after == 2200000000000000000000000 + assert rcc_period_start_timestamp_before == rcc_period_start_timestamp_after == 1696118400 + assert rcc_period_end_timestamp_before == rcc_period_end_timestamp_after == 1704067200 ( - pml_already_spent_amount, - pml_spendable_balanceInPeriod, - pml_period_start_timestamp, - pml_period_end_timestamp + pml_already_spent_amount_after, + pml_spendable_balanceInPeriod_after, + pml_period_start_timestamp_after, + pml_period_end_timestamp_after ) = pml_stable_registry.getPeriodState() - assert pml_already_spent_amount == 1500000000000000000000000 - assert pml_spendable_balanceInPeriod == 4500000000000000000000000 - assert pml_period_start_timestamp == 1696118400 - assert pml_period_end_timestamp == 1704067200 + assert pml_already_spent_amount_before == pml_already_spent_amount_after == 1500000000000000000000000 + assert pml_spendable_balanceInPeriod_before == pml_spendable_balanceInPeriod_after == 4500000000000000000000000 + assert pml_period_start_timestamp_before == pml_period_start_timestamp_after == 1696118400 + assert pml_period_end_timestamp_before == pml_period_end_timestamp_after == 1704067200 ( - atc_already_spent_amount, - atc_spendable_balanceInPeriod, - atc_period_start_timestamp, - atc_period_end_timestamp + atc_already_spent_amount_after, + atc_spendable_balanceInPeriod_after, + atc_period_start_timestamp_after, + atc_period_end_timestamp_after ) = atc_stable_registry.getPeriodState() - assert atc_already_spent_amount == 800000000000000000000000 - assert atc_spendable_balanceInPeriod == 700000000000000000000000 - assert atc_period_start_timestamp == 1696118400 - assert atc_period_end_timestamp == 1704067200 + assert atc_already_spent_amount_before == atc_already_spent_amount_after == 800000000000000000000000 + assert atc_spendable_balanceInPeriod_before == atc_spendable_balanceInPeriod_after == 700000000000000000000000 + assert atc_period_start_timestamp_before == atc_period_start_timestamp_after == 1696118400 + assert atc_period_end_timestamp_before == atc_period_end_timestamp_after == 1704067200 # permissions assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) @@ -547,111 +573,10 @@ def test_vote( ), ) -# todo: move to utils -def create_and_enact_payment_motion( - easy_track, - trusted_caller, - factory, - token, - recievers, - transfer_amounts, - stranger, -): - agent = accounts.at(AGENT, {"force": True}) - agent_balance_before = balance_of(agent, token) - recievers_balance_before = [balance_of(reciever, token) for reciever in recievers] - motions_before = easy_track.getMotions() - - recievers_addresses = [reciever.address for reciever in recievers] - - calldata = _encode_calldata("(address[],uint256[])", [recievers_addresses, transfer_amounts]) - - tx = easy_track.createMotion(factory, calldata, {"from": trusted_caller}) - - motions = easy_track.getMotions() - assert len(motions) == len(motions_before) + 1 - - chain.sleep(60 * 60 * 24 * 3) - chain.mine() - - easy_track.enactMotion( - motions[-1][0], - tx.events["MotionCreated"]["_evmScriptCallData"], - {"from": stranger}, - ) - - recievers_balance_after = [balance_of(reciever, token)for reciever in recievers] - for i in range(len(recievers)): - assert recievers_balance_after[i] == recievers_balance_before[i] + transfer_amounts[i] - - agent_balance_after = balance_of(agent, token) - - assert agent_balance_after == agent_balance_before - sum(transfer_amounts) - -def _encode_calldata(signature, values): - return "0x" + encode_single(signature, values).hex() - -def balance_of(address, token): - if token == eth: - return address.balance() - else: - return token.balanceOf(address) - -def check_add_and_remove_recipient_with_voting(registry, helpers, ldo_holder, dao_voting): - recipient_candidate = accounts[0] - title = "" - recipients_length_before = len(registry.getAllowedRecipients()) - - assert not registry.isRecipientAllowed(recipient_candidate) - - call_script_items = [ - agent_forward( - [ - ( - registry.address, - registry.addRecipient.encode_input(recipient_candidate, title), - ) - ] - ) - ] - vote_desc_items = ["Add recipient"] - vote_items = bake_vote_items(vote_desc_items, call_script_items) - - vote_id = create_vote(vote_items, {"from": ldo_holder})[0] - - helpers.execute_vote( - vote_id=vote_id, - accounts=accounts, - dao_voting=dao_voting, - skip_time=3 * 60 * 60 * 24, - ) - - assert registry.isRecipientAllowed(recipient_candidate) - assert len(registry.getAllowedRecipients()) == recipients_length_before + 1, 'Wrong whitelist length' - - call_script_items = [ - agent_forward( - [ - ( - registry.address, - registry.removeRecipient.encode_input(recipient_candidate), - ) - ] - ) - ] - vote_desc_items = ["Remove recipient"] - vote_items = bake_vote_items(vote_desc_items, call_script_items) - - vote_id = create_vote(vote_items, {"from": ldo_holder})[0] - - helpers.execute_vote( - vote_id=vote_id, - accounts=accounts, - dao_voting=dao_voting, - skip_time=3 * 60 * 60 * 24, +def has_payments_permission(acl, finance, sender, token, receiver, amount) -> bool: + return acl.hasPermission["address,address,bytes32,uint[]"]( + sender, finance, finance.CREATE_PAYMENTS_ROLE(), [token, receiver, amount] ) - assert not registry.isRecipientAllowed(recipient_candidate) - assert len(registry.getAllowedRecipients()) == recipients_length_before, 'Wrong whitelist length' - - +def steth_balance_checker(lhs_value: int, rhs_value: int): + assert (lhs_value + 5) // 10 == (rhs_value + 5) // 10 \ No newline at end of file From f8c36ea1cd115429526516507caa98082551fe23 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 27 Oct 2023 15:43:41 +0200 Subject: [PATCH 12/27] update fabric addresses, fix tests --- scripts/vote_2023_10_31.py | 28 ++++------ tests/test_2023_10_31.py | 96 ++++++++++++++++++++++++-------- utils/test/easy_track_helpers.py | 2 +- 3 files changed, 86 insertions(+), 40 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 0ec58040..e181ca5c 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -40,17 +40,15 @@ 3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track 4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track 5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track -6. Add RCC stable top up EVM script factory TBA -7. Add PML stable top up EVM script factory TBA -8. Add ATC stable top up EVM script factory TBA +6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 +7. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D +8. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab III. stETH transfers to RCC PML ATC 9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D 11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 -IV. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' - """ eth = { @@ -153,12 +151,10 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") - # todo: change addresses - rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") - pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") - atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x75bDecbb6453a901EBBB945215416561547dfDD4") + pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D") + atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab") - # addresses stay same rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") @@ -192,19 +188,19 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ## 5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track remove_evmscript_factory(factory=atc_dai_topup_factory_old), # todo: change addresses - ## 6. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track + ## 6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track add_evmscript_factory( factory=rcc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") + create_permissions(rcc_stable_registry, "updateSpentAmount")[2:], ), - ## 7. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track + ## 7. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D to Easy Track add_evmscript_factory( factory=pml_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") + create_permissions(pml_stable_registry, "updateSpentAmount")[2:], ), - ## 8. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track + ## 8. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab to Easy Track add_evmscript_factory( factory=atc_stable_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") @@ -239,9 +235,9 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra f"3) Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track", f"4) Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track", f"5) Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track", - f"6) Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track", - f"7) Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track", - f"8) Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track", + f"6) Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track", + f"7) Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D to Easy Track", + f"8) Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab to Easy Track", f"9) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", f"10) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", f"11) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index f6e3d7a6..7cb95090 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -176,10 +176,9 @@ def test_vote( pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") - # todo: change addresses - rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") - pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") - atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") + rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x75bDecbb6453a901EBBB945215416561547dfDD4") + pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D") + atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab") # todo: change addresses rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") @@ -189,10 +188,9 @@ def test_vote( old_factories_list = contracts.easy_track.getEVMScriptFactories() assert len(old_factories_list) == 16 - # todo: uncomment when u get new factories address - # assert rcc_stable_topup_factory not in old_factories_list - # assert pml_stable_topup_factory not in old_factories_list - # assert atc_stable_topup_factory not in old_factories_list + assert rcc_stable_topup_factory not in old_factories_list + assert pml_stable_topup_factory not in old_factories_list + assert atc_stable_topup_factory not in old_factories_list assert rcc_dai_topup_factory_old in old_factories_list assert pml_dai_topup_factory_old in old_factories_list @@ -267,14 +265,13 @@ def test_vote( dao_balance_after = contracts.lido.balanceOf(AGENT) rcc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) - pml_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) - atc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) - dao_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18) + 1 * (10**18) + 1 * (10**18)) + pml_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=pml_multisig_address, amount=1 * (10**18)) + atc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=atc_multisig_address, amount=1 * (10**18)) steth_balance_checker(rcc_multisig_balance_after - rcc_multisig_balance_before, rcc_fund_payout.amount) steth_balance_checker(pml_multisig_balance_after - pml_multisig_balance_before, pml_fund_payout.amount) steth_balance_checker(atc_multisig_balance_after - atc_multisig_balance_before, atc_fund_payout.amount) - steth_balance_checker(dao_balance_before - dao_balance_after, dao_fund_payout.amount) + steth_balance_checker(dao_balance_before - dao_balance_after, 1 * (10**18) + 1 * (10**18) + 1 * (10**18)) # check registries parameters after voting ( @@ -328,9 +325,6 @@ def test_vote( assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"] + 1) assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"] + 1) - assert not has_payments_permission(contracts.acl, contracts.finance, accounts[0].address, eth["address"], ldo_holder.address, eth["limit"]) - # assert not has_payments_permission(acl, finance, accounts[0].address, usdc_token, ldo_holder.address, 1) - # ETH deposit = accounts.at(CHAIN_DEPOSIT_CONTRACT, {"force": True}) deposit.transfer(agent.address, "1000 ether") @@ -489,13 +483,13 @@ def test_vote( ## todo: uncomment tests # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track - # assert rcc_dai_topup_factory_old not in updated_factories_list + assert rcc_dai_topup_factory_old not in updated_factories_list # 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track - # assert pml_dai_topup_factory_old not in updated_factories_list + assert pml_dai_topup_factory_old not in updated_factories_list # 3. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track - # assert atc_dai_topup_factory_old not in updated_factories_list + assert atc_dai_topup_factory_old not in updated_factories_list - # 4. Add RCC stable top up EVM script factory 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e to Easy Track + # 4. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track assert rcc_stable_topup_factory in updated_factories_list create_and_enact_payment_motion( contracts.easy_track, @@ -506,9 +500,27 @@ def test_vote( [10 * 10**18], stranger, ) + create_and_enact_payment_motion( + contracts.easy_track, + rcc_trusted_caller_and_recepient, + rcc_stable_topup_factory, + contracts.usdt_token, + [rcc_trusted_caller_and_recepient], + [10 * 10**6], + stranger, + ) + create_and_enact_payment_motion( + contracts.easy_track, + rcc_trusted_caller_and_recepient, + rcc_stable_topup_factory, + contracts.usdc_token, + [rcc_trusted_caller_and_recepient], + [10 * 10**6], + stranger, + ) check_add_and_remove_recipient_with_voting(rcc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) - # 5. Add PML stable top up EVM script factory 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD to Easy Track + # 5. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D to Easy Track assert pml_stable_topup_factory in updated_factories_list create_and_enact_payment_motion( contracts.easy_track, @@ -519,9 +531,27 @@ def test_vote( [10 * 10**18], stranger, ) + create_and_enact_payment_motion( + contracts.easy_track, + pml_trusted_caller_and_recepient, + pml_stable_topup_factory, + contracts.usdt_token, + [pml_trusted_caller_and_recepient], + [10 * 10**6], + stranger, + ) + create_and_enact_payment_motion( + contracts.easy_track, + pml_trusted_caller_and_recepient, + pml_stable_topup_factory, + contracts.usdc_token, + [pml_trusted_caller_and_recepient], + [10 * 10**6], + stranger, + ) check_add_and_remove_recipient_with_voting(pml_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) - # 6. Add ATC stable top up EVM script factory 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 to Easy Track + # 6. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab to Easy Track assert atc_stable_topup_factory in updated_factories_list create_and_enact_payment_motion( contracts.easy_track, @@ -532,10 +562,27 @@ def test_vote( [10 * 10**18], stranger, ) + create_and_enact_payment_motion( + contracts.easy_track, + atc_trusted_caller_and_recepient, + atc_stable_topup_factory, + contracts.usdt_token, + [atc_trusted_caller_and_recepient], + [10 * 10**6], + stranger, + ) + create_and_enact_payment_motion( + contracts.easy_track, + atc_trusted_caller_and_recepient, + atc_stable_topup_factory, + contracts.usdc_token, + [atc_trusted_caller_and_recepient], + [10 * 10**6], + stranger, + ) check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) # validate vote events - print("count_vote_items_by_events", count_vote_items_by_events(vote_tx, contracts.voting)) assert count_vote_items_by_events(vote_tx, contracts.voting) == 11, "Incorrect voting items count" display_voting_events(vote_tx) @@ -544,7 +591,6 @@ def test_vote( validate_permission_revoke_event(evs[0], permission) validate_permission_grantp_event(evs[1], permission, amount_limits()) - validate_evmscript_factory_removed_event(evs[2], rcc_dai_topup_factory_old) validate_evmscript_factory_removed_event(evs[3], pml_dai_topup_factory_old) validate_evmscript_factory_removed_event(evs[4], atc_dai_topup_factory_old) @@ -572,6 +618,10 @@ def test_vote( + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], ), ) + validate_token_payout_event(evs[8], rcc_fund_payout, True) + validate_token_payout_event(evs[9], pml_fund_payout, True) + validate_token_payout_event(evs[10], atc_fund_payout, True) + def has_payments_permission(acl, finance, sender, token, receiver, amount) -> bool: return acl.hasPermission["address,address,bytes32,uint[]"]( diff --git a/utils/test/easy_track_helpers.py b/utils/test/easy_track_helpers.py index 4951a433..27a0a2fe 100644 --- a/utils/test/easy_track_helpers.py +++ b/utils/test/easy_track_helpers.py @@ -29,7 +29,7 @@ def create_and_enact_payment_motion( recievers_addresses = [reciever.address for reciever in recievers] - calldata = _encode_calldata("(address[],uint256[])", [recievers_addresses, transfer_amounts]) + calldata = _encode_calldata("(address,address[],uint256[])", [token.address, recievers_addresses, transfer_amounts]) tx = easy_track.createMotion(factory, calldata, {"from": trusted_caller}) From e97169a70f5b18d962bc2026db87083deb5255a4 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Mon, 30 Oct 2023 10:31:24 +0100 Subject: [PATCH 13/27] update description --- scripts/vote_2023_10_31.py | 43 ++++++++++++++++++++++---------------- tests/test_2023_10_31.py | 2 -- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index e181ca5c..f55d14cb 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -1,7 +1,23 @@ """ -todo: change title Voting 31/10/2023. +I. Add USDT and USDC to EVMScriptExecutor permissions +1. Remove CREATE_PAYMENTS_ROLE from EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 +2. Add CREATE_PAYMENTS_ROLE to EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 with single transfer limits of 1,000 ETH, 1,000 stETH, 5,000,000 LDO, 2,000,000 DAI, 2,000,000 USDC, 2,000,000 USDT + +II. Switch ET DAI top-up setups into ET Stables setups for RCC PML ATC +3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track +4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track +5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track +6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 +7. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D +8. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab + +III. stETH transfers to RCC PML ATC +9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 +10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D +11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + """ import time @@ -29,26 +45,19 @@ USDT_TOKEN ) -# todo: change description description = """ +### Omnibus on-chain vote contains: -I. Add USDT and USDC to EVMScriptExecutor permissions -1. Remove CREATE_PAYMENTS_ROLE from EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 -2. Add CREATE_PAYMENTS_ROLE to EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 with single transfer limits of 1,000 ETH, 1,000 stETH, 5,000,000 LDO, 2,000,000 DAI, 2,000,000 USDC, 2,000,000 USDT +Two motions to **optimize [Lido Contributors Group's multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) funding operations by [upgrading the Easy Track setup](https://research.lido.fi/t/updating-the-easy-track-setups-to-allow-dai-usdt-usdc-payments-for-lido-contributors-group/5738)**, allowing it to work with DAI, USDT, USDC instead of DAI-only. -II. Switch ET DAI top-up setups into ET Stables setups for RCC PML ATC -3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track -4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track -5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track -6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 -7. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D -8. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab +1. Grant to `EVMScripExecutor` the permissions to transfer USDT and USDC in addition to current ETH, stETH, LDO, and DAI. Items 1,2. +2. Switch the Easy Track DAI top-up setup to the Easy Track DAI, USDT, and USDC top-up setup for all [Lido Contributors Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)). Items 3-8. -III. stETH transfers to RCC PML ATC -9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 -10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D -11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 +The new version of contracts was [audited by Oxorio](LINK_TO_AUDIT). + +And last motion is +3. **stETH transfer to the [Lido Contributor's Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069)** ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 9-11. """ eth = { @@ -187,7 +196,6 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra remove_evmscript_factory(factory=pml_dai_topup_factory_old), ## 5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track remove_evmscript_factory(factory=atc_dai_topup_factory_old), - # todo: change addresses ## 6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track add_evmscript_factory( factory=rcc_stable_topup_factory, @@ -228,7 +236,6 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ) ] - # todo: change addresses in 6,7,8 strings and stETH amount vote_desc_items = [ f"1) Revoke role CREATE_PAYMENTS_ROLE from EVM script executor", f"2) Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 7cb95090..3bb61c02 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -180,7 +180,6 @@ def test_vote( pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D") atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab") - # todo: change addresses rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") @@ -481,7 +480,6 @@ def test_vote( {"from": evmscriptexecutor}, ) - ## todo: uncomment tests # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track assert rcc_dai_topup_factory_old not in updated_factories_list # 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track From 9c05fea0ea810398582395be2c0892fe7fb9aabf Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 31 Oct 2023 11:52:13 +0100 Subject: [PATCH 14/27] remove factories, add node renaming --- scripts/vote_2023_10_31.py | 231 +++----------- tests/test_2023_10_31.py | 611 +++---------------------------------- 2 files changed, 93 insertions(+), 749 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index f55d14cb..02dc17af 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -1,48 +1,31 @@ """ Voting 31/10/2023. -I. Add USDT and USDC to EVMScriptExecutor permissions -1. Remove CREATE_PAYMENTS_ROLE from EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 -2. Add CREATE_PAYMENTS_ROLE to EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 with single transfer limits of 1,000 ETH, 1,000 stETH, 5,000,000 LDO, 2,000,000 DAI, 2,000,000 USDC, 2,000,000 USDT +I. stETH transfers to RCC PML ATC +1. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 +2. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D +3. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 -II. Switch ET DAI top-up setups into ET Stables setups for RCC PML ATC -3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track -4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track -5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track -6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 -7. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D -8. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab +II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' -III. stETH transfers to RCC PML ATC -9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 -10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D -11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 """ import time -from typing import Dict, List +from typing import Dict +from brownie import interface from brownie.network.transaction import TransactionReceipt -from brownie import interface, ZERO_ADDRESS from utils.voting import bake_vote_items, confirm_vote_script, create_vote from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description -from utils.easy_track import add_evmscript_factory, create_permissions, remove_evmscript_factory -from utils.permission_parameters import Param, SpecialArgumentID, Op, ArgumentValue, encode_argument_value_if -from utils.permissions import encode_permission_revoke, encode_permission_grant_p +from utils.permissions import encode_permission_revoke, encode_permission_grant +from utils.node_operators import encode_set_node_operator_name from utils.finance import make_steth_payout - from utils.config import ( - get_deployer_account, contracts, + get_deployer_account, get_is_live, get_priority_fee, - EASYTRACK_EVMSCRIPT_EXECUTOR, - LIDO, - LDO_TOKEN, - DAI_TOKEN, - USDC_TOKEN, - USDT_TOKEN ) description = """ @@ -60,194 +43,66 @@ 3. **stETH transfer to the [Lido Contributor's Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069)** ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 9-11. """ -eth = { - "limit": 1_000 * (10**18), - "address": ZERO_ADDRESS, -} - -steth = { - "limit": 1_000 * (10**18), - "address": LIDO, -} - -ldo = { - "limit": 5_000_000 * (10**18), - "address": LDO_TOKEN, -} - -dai = { - "limit": 2_000_000 * (10**18), - "address": DAI_TOKEN, -} - -usdc = { - "limit": 2_000_000 * (10**6), - "address": USDC_TOKEN, -} - -usdt = { - "limit": 2_000_000 * (10**6), - "address": USDT_TOKEN, -} - -def amount_limits() -> List[Param]: - token_arg_index = 0 - amount_arg_index = 2 - - return [ - # 0: if (1) then (2) else (3) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=1, success=2, failure=3) - ), - # 1: (_token == LDO) - Param(token_arg_index, Op.EQ, ArgumentValue(ldo["address"])), - # 2: { return _amount <= 5_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(ldo["limit"])), - # 3: else if (4) then (5) else (6) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=4, success=5, failure=6) - ), - # 4: (_token == ETH) - Param(token_arg_index, Op.EQ, ArgumentValue(eth["address"])), - # 5: { return _amount <= 1000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(eth["limit"])), - # 6: else if (7) then (8) else (9) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=7, success=8, failure=9) - ), - # 7: (_token == DAI) - Param(token_arg_index, Op.EQ, ArgumentValue(dai["address"])), - # 8: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(dai["limit"])), - # 9: else if (10) then (11) else (12) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=10, success=11, failure=12), - ), - # 10: (_token == USDT) - Param(token_arg_index, Op.EQ, ArgumentValue(usdt["address"])), - # 11: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(usdt["limit"])), - # 12: else if (13) then (14) else (15) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=13, success=14, failure=15), - ), - # 13: (_token == USDC) - Param(token_arg_index, Op.EQ, ArgumentValue(usdc["address"])), - # 14: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(usdc["limit"])), - # 15: else if (16) then (17) else (18) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=16, success=17, failure=18), - ), - # 16: (_token == stETH) - Param(token_arg_index, Op.EQ, ArgumentValue(steth["address"])), - # 17: { return _amount <= 1000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(steth["limit"])), - # 18: else { return false } - Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), - ] def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: """Prepare and run voting.""" - rcc_dai_topup_factory_old = interface.IEVMScriptFactory("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") - pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") - atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") - - rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x75bDecbb6453a901EBBB945215416561547dfDD4") - pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D") - atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab") - - rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") - pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") - atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") - rcc_multisig_address = "0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437" pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" - call_script_items = [ - # I. Add USDT and USDC to EVMScriptExecutor permissions - # 1. Revoke role CREATE_PAYMENTS_ROLE from EVM script executor - encode_permission_revoke( - target_app=contracts.finance, - permission_name="CREATE_PAYMENTS_ROLE", - revoke_from=EASYTRACK_EVMSCRIPT_EXECUTOR, - ), - # 2. Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977 - # with limits: 1000 ETH, 1000 stETH, 5M LDO, 2M DAI, 2M USDT, 2M USDC - encode_permission_grant_p( - target_app=contracts.finance, - permission_name="CREATE_PAYMENTS_ROLE", - grant_to=EASYTRACK_EVMSCRIPT_EXECUTOR, - params=amount_limits(), - ), - - # II. Switch ET DAI top-up setups into ET Stables setups for RCC PML ATC - ## 3. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track - remove_evmscript_factory(factory=rcc_dai_topup_factory_old), - ## 4. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track - remove_evmscript_factory(factory=pml_dai_topup_factory_old), - ## 5. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track - remove_evmscript_factory(factory=atc_dai_topup_factory_old), - ## 6. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track - add_evmscript_factory( - factory=rcc_stable_topup_factory, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(rcc_stable_registry, "updateSpentAmount")[2:], - ), - ## 7. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D to Easy Track - add_evmscript_factory( - factory=pml_stable_topup_factory, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(pml_stable_registry, "updateSpentAmount")[2:], - ), - ## 8. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab to Easy Track - add_evmscript_factory( - factory=atc_stable_topup_factory, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], - ), + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) + prysmatic_labs_node_id = 27 + prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" - # III. stETH transfers to RCC PML ATC - # 9. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 + call_script_items = [ + # I. stETH transfers to RCC PML ATC + # 1. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 make_steth_payout( target_address=rcc_multisig_address, steth_in_wei=1 * (10**18), reference="Fund RCC multisig" ), - # 10. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D + # 2. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D make_steth_payout( target_address=pml_multisig_address, steth_in_wei=1 * (10**18), reference="Fund PML multisig" ), - # 11. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + # 3. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 make_steth_payout( target_address=atc_multisig_address, steth_in_wei=1 * (10**18), reference="Fund ATC multisig" + ), + # II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' + # 4. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting + encode_permission_grant( + target_app=NO_registry, + permission_name="MANAGE_NODE_OPERATOR_ROLE", + grant_to=contracts.voting + ), + # 5. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` + encode_set_node_operator_name( + prysmatic_labs_node_id, + prysmatic_labs_node_new_name, + NO_registry + ), + # 6. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting + encode_permission_revoke( + NO_registry, + "MANAGE_NODE_OPERATOR_ROLE", + revoke_from=contracts.voting ) ] vote_desc_items = [ - f"1) Revoke role CREATE_PAYMENTS_ROLE from EVM script executor", - f"2) Grant role CREATE_PAYMENTS_ROLE to EasyTrack EVMScriptExecutor 0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", - f"3) Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track", - f"4) Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track", - f"5) Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track", - f"6) Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track", - f"7) Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D to Easy Track", - f"8) Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab to Easy Track", - f"9) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", - f"10) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", - f"11) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" + f"1) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", + f"2) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", + f"3) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", + f"4) Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting", + f"5) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", + f"6) Revoke MANAGE_NODE_OPERATOR_ROLE from Voting", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 3bb61c02..4b44ac03 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -3,247 +3,63 @@ """ -import math from scripts.vote_2023_10_31 import start_vote -from eth_abi.abi import encode_single -from brownie import chain, accounts, ZERO_ADDRESS, reverts -from utils.easy_track import create_permissions -from utils.agent import agent_forward -from utils.voting import create_vote, bake_vote_items +from brownie import interface, web3 from utils.test.tx_tracing_helpers import * -from utils.test.event_validators.easy_track import ( - validate_evmscript_factory_added_event, - validate_evmscript_factory_removed_event, - EVMScriptFactoryAdded +from utils.test.event_validators.payout import ( + Payout, + validate_token_payout_event ) from utils.test.event_validators.permission import ( Permission, - validate_permission_grantp_event, validate_permission_revoke_event, + validate_permission_grant_event ) -from utils.test.easy_track_helpers import ( - create_and_enact_payment_motion, - check_add_and_remove_recipient_with_voting -) -from utils.test.event_validators.payout import ( - Payout, - validate_token_payout_event -) -from utils.permission_parameters import ( - Param, - SpecialArgumentID, - Op, - ArgumentValue, - encode_argument_value_if +from utils.test.event_validators.node_operators_registry import ( + validate_node_operator_name_set_event, + NodeOperatorNameSetItem, ) from utils.config import ( contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, LIDO, - LDO_TOKEN, - DAI_TOKEN, - USDC_TOKEN, - USDT_TOKEN, - CHAIN_DEPOSIT_CONTRACT, - FINANCE, AGENT ) -eth = "0x0000000000000000000000000000000000000000" -STETH_ERROR_MARGIN = 2 - -permission = Permission( - entity="0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", # EVMScriptExecutor - app=FINANCE, # Finance Aragon App - role="0x5de467a460382d13defdc02aacddc9c7d6605d6d4e0b8bd2f70732cae8ea17bc", -) # keccak256('CREATE_PAYMENTS_ROLE') - -eth = { - "limit": 1_000 * (10**18), - "address": ZERO_ADDRESS, -} - -steth = { - "limit": 1_000 * (10**18), - "address": LIDO, -} - -ldo = { - "limit": 5_000_000 * (10**18), - "address": LDO_TOKEN, -} - -dai = { - "limit": 2_000_000 * (10**18), - "address": DAI_TOKEN, -} - -usdc = { - "limit": 2_000_000 * (10**6), - "address": USDC_TOKEN, -} - -usdt = { - "limit": 2_000_000 * (10**6), - "address": USDT_TOKEN, -} - -def amount_limits() -> List[Param]: - token_arg_index = 0 - amount_arg_index = 2 - - return [ - # 0: if (1) then (2) else (3) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=1, success=2, failure=3) - ), - # 1: (_token == LDO) - Param(token_arg_index, Op.EQ, ArgumentValue(ldo["address"])), - # 2: { return _amount <= 5_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(ldo["limit"])), - # 3: else if (4) then (5) else (6) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=4, success=5, failure=6) - ), - # 4: (_token == ETH) - Param(token_arg_index, Op.EQ, ArgumentValue(eth["address"])), - # 5: { return _amount <= 1000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(eth["limit"])), - # 6: else if (7) then (8) else (9) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, Op.IF_ELSE, encode_argument_value_if(condition=7, success=8, failure=9) - ), - # 7: (_token == DAI) - Param(token_arg_index, Op.EQ, ArgumentValue(dai["address"])), - # 8: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(dai["limit"])), - # 9: else if (10) then (11) else (12) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=10, success=11, failure=12), - ), - # 10: (_token == USDT) - Param(token_arg_index, Op.EQ, ArgumentValue(usdt["address"])), - # 11: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(usdt["limit"])), - # 12: else if (13) then (14) else (15) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=13, success=14, failure=15), - ), - # 13: (_token == USDC) - Param(token_arg_index, Op.EQ, ArgumentValue(usdc["address"])), - # 14: { return _amount <= 2_000_000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(usdc["limit"])), - # 15: else if (16) then (17) else (18) - Param( - SpecialArgumentID.LOGIC_OP_PARAM_ID, - Op.IF_ELSE, - encode_argument_value_if(condition=16, success=17, failure=18), - ), - # 16: (_token == stETH) - Param(token_arg_index, Op.EQ, ArgumentValue(steth["address"])), - # 17: { return _amount <= 1000 } - Param(amount_arg_index, Op.LTE, ArgumentValue(steth["limit"])), - # 18: else { return false } - Param(SpecialArgumentID.PARAM_VALUE_PARAM_ID, Op.RET, ArgumentValue(0)), - ] - def test_vote( helpers, accounts, - interface, - vote_ids_from_env, - stranger, - ldo_holder + vote_ids_from_env ): - agent = accounts.at(AGENT, {"force": True}) - evmscriptexecutor = accounts.at("0xFE5986E06210aC1eCC1aDCafc0cc7f8D63B3F977", {"force": True}) - usdt_holder = "0xF977814e90dA44bFA03b6295A0616a897441aceC" - usdc_holder = "0xcEe284F754E854890e311e3280b767F80797180d" - dai_holder = "0x075e72a5eDf65F0A5f44699c7654C1a76941Ddc8" rcc_multisig_address = "0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437" pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" - rcc_trusted_caller_and_recepient = accounts.at(rcc_multisig_address, {"force": True}) - pml_trusted_caller_and_recepient = accounts.at(pml_multisig_address, {"force": True}) - atc_trusted_caller_and_recepient = accounts.at(atc_multisig_address, {"force": True}) - - rcc_dai_topup_factory_old = interface.IEVMScriptFactory("0x84f74733ede9bFD53c1B3Ea96338867C94EC313e") - pml_dai_topup_factory_old = interface.IEVMScriptFactory("0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD") - atc_dai_topup_factory_old = interface.IEVMScriptFactory("0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07") - - rcc_stable_topup_factory = interface.TopUpAllowedRecipients("0x75bDecbb6453a901EBBB945215416561547dfDD4") - pml_stable_topup_factory = interface.TopUpAllowedRecipients("0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D") - atc_stable_topup_factory = interface.TopUpAllowedRecipients("0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab") - - rcc_stable_registry = interface.AllowedRecipientRegistry("0xDc1A0C7849150f466F07d48b38eAA6cE99079f80") - pml_stable_registry = interface.AllowedRecipientRegistry("0xDFfCD3BF14796a62a804c1B16F877Cf7120379dB") - atc_stable_registry = interface.AllowedRecipientRegistry("0xe07305F43B11F230EaA951002F6a55a16419B707") - - old_factories_list = contracts.easy_track.getEVMScriptFactories() - assert len(old_factories_list) == 16 - - assert rcc_stable_topup_factory not in old_factories_list - assert pml_stable_topup_factory not in old_factories_list - assert atc_stable_topup_factory not in old_factories_list - - assert rcc_dai_topup_factory_old in old_factories_list - assert pml_dai_topup_factory_old in old_factories_list - assert atc_dai_topup_factory_old in old_factories_list - - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) - - # check regsitries parameters before voting - ( - rcc_already_spent_amount_before, - rcc_spendable_balanceInPeriod_before, - rcc_period_start_timestamp_before, - rcc_period_end_timestamp_before - ) = rcc_stable_registry.getPeriodState() - - assert rcc_already_spent_amount_before == 800000000000000000000000 - assert rcc_spendable_balanceInPeriod_before == 2200000000000000000000000 - assert rcc_period_start_timestamp_before == 1696118400 - assert rcc_period_end_timestamp_before == 1704067200 - - ( - pml_already_spent_amount_before, - pml_spendable_balanceInPeriod_before, - pml_period_start_timestamp_before, - pml_period_end_timestamp_before - ) = pml_stable_registry.getPeriodState() - - assert pml_already_spent_amount_before == 1500000000000000000000000 - assert pml_spendable_balanceInPeriod_before == 4500000000000000000000000 - assert pml_period_start_timestamp_before == 1696118400 - assert pml_period_end_timestamp_before == 1704067200 - - ( - atc_already_spent_amount_before, - atc_spendable_balanceInPeriod_before, - atc_period_start_timestamp_before, - atc_period_end_timestamp_before - ) = atc_stable_registry.getPeriodState() - - assert atc_already_spent_amount_before == 800000000000000000000000 - assert atc_spendable_balanceInPeriod_before == 700000000000000000000000 - assert atc_period_start_timestamp_before == 1696118400 - assert atc_period_end_timestamp_before == 1704067200 - rcc_multisig_balance_before = contracts.lido.balanceOf(rcc_multisig_address) pml_multisig_balance_before = contracts.lido.balanceOf(pml_multisig_address) atc_multisig_balance_before = contracts.lido.balanceOf(atc_multisig_address) dao_balance_before = contracts.lido.balanceOf(AGENT) + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) + prysmatic_labs_node_id = 27 + prysmatic_labs_node_old_name = "Prysmatic Labs" + prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" + prysmatic_labs_node_data_before_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) + + MANAGE_NODE_OPERATOR_ROLE = web3.keccak(text="MANAGE_NODE_OPERATOR_ROLE") + permission = Permission( + entity=contracts.voting, app=contracts.node_operators_registry, role=MANAGE_NODE_OPERATOR_ROLE.hex() + ) + permission_manage_no = Permission( + entity=contracts.voting, + app=NO_registry, + role=NO_registry.MANAGE_NODE_OPERATOR_ROLE(), + ) + + # Check node operator name before + assert not contracts.acl.hasPermission(*permission_manage_no) + assert prysmatic_labs_node_data_before_voting["name"] == prysmatic_labs_node_old_name, "Incorrect NO#27 name before" + # START VOTE if len(vote_ids_from_env) > 0: (vote_id,) = vote_ids_from_env @@ -255,9 +71,6 @@ def test_vote( print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") - updated_factories_list = contracts.easy_track.getEVMScriptFactories() - assert len(updated_factories_list) == 16 - rcc_multisig_balance_after = contracts.lido.balanceOf(rcc_multisig_address) pml_multisig_balance_after = contracts.lido.balanceOf(pml_multisig_address) atc_multisig_balance_after = contracts.lido.balanceOf(atc_multisig_address) @@ -272,359 +85,35 @@ def test_vote( steth_balance_checker(atc_multisig_balance_after - atc_multisig_balance_before, atc_fund_payout.amount) steth_balance_checker(dao_balance_before - dao_balance_after, 1 * (10**18) + 1 * (10**18) + 1 * (10**18)) - # check registries parameters after voting - ( - rcc_already_spent_amount_after, - rcc_spendable_balanceInPeriod_after, - rcc_period_start_timestamp_after, - rcc_period_end_timestamp_after - ) = rcc_stable_registry.getPeriodState() + # node operator name + assert not contracts.acl.hasPermission(*permission_manage_no) - assert rcc_already_spent_amount_before == rcc_already_spent_amount_after == 800000000000000000000000 - assert rcc_spendable_balanceInPeriod_before == rcc_spendable_balanceInPeriod_after == 2200000000000000000000000 - assert rcc_period_start_timestamp_before == rcc_period_start_timestamp_after == 1696118400 - assert rcc_period_end_timestamp_before == rcc_period_end_timestamp_after == 1704067200 + prysmatic_labs_node_data_after_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) - ( - pml_already_spent_amount_after, - pml_spendable_balanceInPeriod_after, - pml_period_start_timestamp_after, - pml_period_end_timestamp_after - ) = pml_stable_registry.getPeriodState() - - assert pml_already_spent_amount_before == pml_already_spent_amount_after == 1500000000000000000000000 - assert pml_spendable_balanceInPeriod_before == pml_spendable_balanceInPeriod_after == 4500000000000000000000000 - assert pml_period_start_timestamp_before == pml_period_start_timestamp_after == 1696118400 - assert pml_period_end_timestamp_before == pml_period_end_timestamp_after == 1704067200 - - ( - atc_already_spent_amount_after, - atc_spendable_balanceInPeriod_after, - atc_period_start_timestamp_after, - atc_period_end_timestamp_after - ) = atc_stable_registry.getPeriodState() - - assert atc_already_spent_amount_before == atc_already_spent_amount_after == 800000000000000000000000 - assert atc_spendable_balanceInPeriod_before == atc_spendable_balanceInPeriod_after == 700000000000000000000000 - assert atc_period_start_timestamp_before == atc_period_start_timestamp_after == 1696118400 - assert atc_period_end_timestamp_before == atc_period_end_timestamp_after == 1704067200 - - # permissions - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"]) - assert has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"]) - - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, eth["address"], ldo_holder.address, eth["limit"] + 1) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, steth["address"], ldo_holder.address, steth["limit"] + 1) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, ldo["address"], ldo_holder.address, ldo["limit"] + 1) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, dai["address"], ldo_holder.address, dai["limit"] + 1) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdt["address"], ldo_holder.address, usdt["limit"] + 1) - assert not has_payments_permission(contracts.acl, contracts.finance, permission.entity, usdc["address"], ldo_holder.address, usdc["limit"] + 1) - - # ETH - deposit = accounts.at(CHAIN_DEPOSIT_CONTRACT, {"force": True}) - deposit.transfer(agent.address, "1000 ether") - # Check ETH limits. 1000 ETH - agent_balance_before = agent.balance() - eth_balance_before = stranger.balance() - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - ZERO_ADDRESS, - stranger, - 1000 * 10**18 + 1, - "ETH transfer", - {"from": evmscriptexecutor}, - ) - contracts.finance.newImmediatePayment( - ZERO_ADDRESS, - stranger, - 1000 * 10**18, - "ETH transfer", - {"from": evmscriptexecutor} - ) - assert agent.balance() == agent_balance_before - 1000 * 10**18 - assert stranger.balance() == eth_balance_before + 1000 * 10**18 - - # stETH - # Check stETH limits. 1000 stETH. - steth_token = interface.ERC20(LIDO) - agent_steth_balance_before = steth_token.balanceOf(agent) - stETH_balance_before = steth_token.balanceOf(stranger) - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - steth_token, - stranger, - 1000 * 10**18 + 1, - "stETH transfer", - {"from": evmscriptexecutor}, - ) - contracts.finance.newImmediatePayment( - steth_token, - stranger, - 1000 * 10**18, - "stETH transfer", - {"from": evmscriptexecutor} - ) - assert math.isclose(steth_token.balanceOf(agent), agent_steth_balance_before - 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN) - assert math.isclose(steth_token.balanceOf(stranger), stETH_balance_before + 1000 * 10**18, abs_tol=STETH_ERROR_MARGIN) - - # LDO - # Check LDO limits. 5_000_000 LDO - agent_ldo_balance_before = contracts.ldo_token.balanceOf(agent) - ldo_balance_before = contracts.ldo_token.balanceOf(stranger) - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - contracts.ldo_token, - stranger, - 5_000_000 * 10**18 + 1, - "LDO transfer", - {"from": evmscriptexecutor}, - ) - contracts.finance.newImmediatePayment( - contracts.ldo_token, - stranger, - 5_000_000 * 10**18, - "LDO transfer", - {"from": evmscriptexecutor} - ) - assert contracts.ldo_token.balanceOf(agent) == agent_ldo_balance_before - 5_000_000 * 10**18 - assert contracts.ldo_token.balanceOf(stranger) == ldo_balance_before + 5_000_000 * 10**18 - - # DAI - # Top up agent DAI balance. - contracts.dai_token.transfer(agent.address, 2_000_000 * 10**18, { 'from': dai_holder }) - # Check DAI limits. 2_000_000 DAI - agent_dai_balance_before = contracts.dai_token.balanceOf(agent) - dai_balance_before = contracts.dai_token.balanceOf(stranger) - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - contracts.dai_token, - stranger, - 2_000_000 * 10**18 + 1, - "DAI transfer", - {"from": evmscriptexecutor}, - ) - contracts.finance.newImmediatePayment( - contracts.dai_token, - stranger, - 2_000_000 * 10**18, - "DAI transfer", - {"from": evmscriptexecutor} - ) - assert contracts.dai_token.balanceOf(agent) == agent_dai_balance_before - 2_000_000 * 10**18 - assert contracts.dai_token.balanceOf(stranger) == dai_balance_before + 2_000_000 * 10**18 - - # USDC - # Top up agent USDC balance. - contracts.usdc_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': usdc_holder }) - # Check USDC limits. 2_000_000 USDC - agent_usdc_balance_before = contracts.usdc_token.balanceOf(agent) - usdc_balance_before = contracts.usdc_token.balanceOf(stranger) - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - contracts.usdc_token, - stranger, - 2_000_000 * 10**6 + 1, - "USDC transfer", - {"from": evmscriptexecutor}, - ) - contracts.finance.newImmediatePayment( - contracts.usdc_token, - stranger, - 2_000_000 * 10**6, - "USDC transfer", - {"from": evmscriptexecutor} - ) - assert contracts.usdc_token.balanceOf(agent) == agent_usdc_balance_before - 2_000_000 * 10**6 - assert contracts.usdc_token.balanceOf(stranger) == usdc_balance_before + 2_000_000 * 10**6 - - # USDT - # Top up agent USDT balance. - contracts.usdt_token.transfer(agent.address, 2_000_000 * 10**6, { 'from': usdt_holder }) - # Check USDT limits. 2_000_000 USDT - agent_usdt_balance_before = contracts.usdt_token.balanceOf(agent) - usdt_balance_before = contracts.usdt_token.balanceOf(stranger) - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - contracts.usdt_token, - stranger, - 2_000_000 * 10**6 + 1, - "USDT transfer", - {"from": evmscriptexecutor}, - ) - contracts.finance.newImmediatePayment( - contracts.usdt_token, - stranger, - 2_000_000 * 10**6, - "USDT transfer", - {"from": evmscriptexecutor} - ) - assert contracts.usdt_token.balanceOf(agent) == agent_usdt_balance_before - 2_000_000 * 10**6 - assert contracts.usdt_token.balanceOf(stranger) == usdt_balance_before + 2_000_000 * 10**6 - - # MATIC - # Check token that is not supported. - MATIC_TOKEN = "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0" - MATIC_HOLDER = "0x5e3Ef299fDDf15eAa0432E6e66473ace8c13D908" - matic_token = interface.ERC20(MATIC_TOKEN) - matic_token.transfer(agent.address, 1, { 'from': MATIC_HOLDER }) - with reverts("APP_AUTH_FAILED"): - contracts.finance.newImmediatePayment( - matic_token, - stranger, - 1, - "MATIC transfer", - {"from": evmscriptexecutor}, - ) - - # 1. Remove RCC DAI top up EVM script factory (old ver) 0x84f74733ede9bFD53c1B3Ea96338867C94EC313e from Easy Track - assert rcc_dai_topup_factory_old not in updated_factories_list - # 2. Remove PML DAI top up EVM script factory (old ver) 0x4E6D3A5023A38cE2C4c5456d3760357fD93A22cD from Easy Track - assert pml_dai_topup_factory_old not in updated_factories_list - # 3. Remove ATC DAI top up EVM script factory (old ver) 0x67Fb97ABB9035E2e93A7e3761a0d0571c5d7CD07 from Easy Track - assert atc_dai_topup_factory_old not in updated_factories_list - - # 4. Add RCC stable top up EVM script factory 0x75bDecbb6453a901EBBB945215416561547dfDD4 to Easy Track - assert rcc_stable_topup_factory in updated_factories_list - create_and_enact_payment_motion( - contracts.easy_track, - rcc_trusted_caller_and_recepient, - rcc_stable_topup_factory, - contracts.dai_token, - [rcc_trusted_caller_and_recepient], - [10 * 10**18], - stranger, - ) - create_and_enact_payment_motion( - contracts.easy_track, - rcc_trusted_caller_and_recepient, - rcc_stable_topup_factory, - contracts.usdt_token, - [rcc_trusted_caller_and_recepient], - [10 * 10**6], - stranger, - ) - create_and_enact_payment_motion( - contracts.easy_track, - rcc_trusted_caller_and_recepient, - rcc_stable_topup_factory, - contracts.usdc_token, - [rcc_trusted_caller_and_recepient], - [10 * 10**6], - stranger, - ) - check_add_and_remove_recipient_with_voting(rcc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) - - # 5. Add PML stable top up EVM script factory 0x92a27C4e5e35cFEa112ACaB53851Ec70e2D99a8D to Easy Track - assert pml_stable_topup_factory in updated_factories_list - create_and_enact_payment_motion( - contracts.easy_track, - pml_trusted_caller_and_recepient, - pml_stable_topup_factory, - contracts.dai_token, - [pml_trusted_caller_and_recepient], - [10 * 10**18], - stranger, - ) - create_and_enact_payment_motion( - contracts.easy_track, - pml_trusted_caller_and_recepient, - pml_stable_topup_factory, - contracts.usdt_token, - [pml_trusted_caller_and_recepient], - [10 * 10**6], - stranger, - ) - create_and_enact_payment_motion( - contracts.easy_track, - pml_trusted_caller_and_recepient, - pml_stable_topup_factory, - contracts.usdc_token, - [pml_trusted_caller_and_recepient], - [10 * 10**6], - stranger, - ) - check_add_and_remove_recipient_with_voting(pml_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) - - # 6. Add ATC stable top up EVM script factory 0x1843Bc35d1fD15AbE1913b9f72852a79457C42Ab to Easy Track - assert atc_stable_topup_factory in updated_factories_list - create_and_enact_payment_motion( - contracts.easy_track, - atc_trusted_caller_and_recepient, - atc_stable_topup_factory, - contracts.dai_token, - [atc_trusted_caller_and_recepient], - [10 * 10**18], - stranger, - ) - create_and_enact_payment_motion( - contracts.easy_track, - atc_trusted_caller_and_recepient, - atc_stable_topup_factory, - contracts.usdt_token, - [atc_trusted_caller_and_recepient], - [10 * 10**6], - stranger, - ) - create_and_enact_payment_motion( - contracts.easy_track, - atc_trusted_caller_and_recepient, - atc_stable_topup_factory, - contracts.usdc_token, - [atc_trusted_caller_and_recepient], - [10 * 10**6], - stranger, - ) - check_add_and_remove_recipient_with_voting(atc_stable_registry, helpers, LDO_HOLDER_ADDRESS_FOR_TESTS, contracts.voting) + assert prysmatic_labs_node_data_before_voting["active"] == prysmatic_labs_node_data_after_voting["active"] + assert prysmatic_labs_node_data_after_voting["name"] == prysmatic_labs_node_new_name, "Incorrect NO#27 name after" + assert prysmatic_labs_node_data_before_voting["rewardAddress"] == prysmatic_labs_node_data_after_voting["rewardAddress"] + compare_NO_validators_data(prysmatic_labs_node_data_before_voting, prysmatic_labs_node_data_after_voting) # validate vote events - assert count_vote_items_by_events(vote_tx, contracts.voting) == 11, "Incorrect voting items count" + assert count_vote_items_by_events(vote_tx, contracts.voting) == 6, "Incorrect voting items count" display_voting_events(vote_tx) evs = group_voting_events(vote_tx) - validate_permission_revoke_event(evs[0], permission) - validate_permission_grantp_event(evs[1], permission, amount_limits()) - validate_evmscript_factory_removed_event(evs[2], rcc_dai_topup_factory_old) - validate_evmscript_factory_removed_event(evs[3], pml_dai_topup_factory_old) - validate_evmscript_factory_removed_event(evs[4], atc_dai_topup_factory_old) - validate_evmscript_factory_added_event( - evs[5], - EVMScriptFactoryAdded( - factory_addr=rcc_stable_topup_factory, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(rcc_stable_registry, "updateSpentAmount")[2:], - ), - ) - validate_evmscript_factory_added_event( - evs[6], - EVMScriptFactoryAdded( - factory_addr=pml_stable_topup_factory, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(pml_stable_registry, "updateSpentAmount")[2:], - ), - ) - validate_evmscript_factory_added_event( - evs[7], - EVMScriptFactoryAdded( - factory_addr=atc_stable_topup_factory, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(atc_stable_registry, "updateSpentAmount")[2:], - ), - ) - validate_token_payout_event(evs[8], rcc_fund_payout, True) - validate_token_payout_event(evs[9], pml_fund_payout, True) - validate_token_payout_event(evs[10], atc_fund_payout, True) - - -def has_payments_permission(acl, finance, sender, token, receiver, amount) -> bool: - return acl.hasPermission["address,address,bytes32,uint[]"]( - sender, finance, finance.CREATE_PAYMENTS_ROLE(), [token, receiver, amount] - ) + validate_token_payout_event(evs[0], rcc_fund_payout, True) + validate_token_payout_event(evs[1], pml_fund_payout, True) + validate_token_payout_event(evs[2], atc_fund_payout, True) + validate_permission_grant_event(evs[3], permission) + validate_node_operator_name_set_event(evs[4], NodeOperatorNameSetItem(nodeOperatorId=prysmatic_labs_node_id, name=prysmatic_labs_node_new_name)) + validate_permission_revoke_event(evs[5], permission_manage_no) def steth_balance_checker(lhs_value: int, rhs_value: int): - assert (lhs_value + 5) // 10 == (rhs_value + 5) // 10 \ No newline at end of file + assert (lhs_value + 5) // 10 == (rhs_value + 5) // 10 + +def compare_NO_validators_data(data_before, data_after): + assert data_before["totalVettedValidators"] == data_after["totalVettedValidators"] + assert data_before["totalExitedValidators"] == data_after["totalExitedValidators"] + assert data_before["totalAddedValidators"] == data_after["totalAddedValidators"] + assert data_before["totalDepositedValidators"] == data_after["totalDepositedValidators"] \ No newline at end of file From 36dc72219d84490b615c3d3e21882d0e0b3fd2ce Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 31 Oct 2023 12:25:24 +0100 Subject: [PATCH 15/27] update description, fix tests --- scripts/vote_2023_10_31.py | 17 +++++------------ tests/test_2023_10_31.py | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 02dc17af..44c1bf63 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -7,7 +7,9 @@ 3. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' - +4. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting +5. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs +6. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting """ @@ -31,19 +33,10 @@ description = """ ### Omnibus on-chain vote contains: -Two motions to **optimize [Lido Contributors Group's multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) funding operations by [upgrading the Easy Track setup](https://research.lido.fi/t/updating-the-easy-track-setups-to-allow-dai-usdt-usdc-payments-for-lido-contributors-group/5738)**, allowing it to work with DAI, USDT, USDC instead of DAI-only. - -1. Grant to `EVMScripExecutor` the permissions to transfer USDT and USDC in addition to current ETH, stETH, LDO, and DAI. Items 1,2. -2. Switch the Easy Track DAI top-up setup to the Easy Track DAI, USDT, and USDC top-up setup for all [Lido Contributors Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)). Items 3-8. - -The new version of contracts was [audited by Oxorio](LINK_TO_AUDIT). - -And last motion is - -3. **stETH transfer to the [Lido Contributor's Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069)** ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 9-11. +1. stETH transfer to the [Lido Contributors Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 1-3. +2. Changing the Node Operator's (#id - 27) name, as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/16). Items 4-6. """ - def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: """Prepare and run voting.""" diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 4b44ac03..fc7bdb5c 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -83,7 +83,7 @@ def test_vote( steth_balance_checker(rcc_multisig_balance_after - rcc_multisig_balance_before, rcc_fund_payout.amount) steth_balance_checker(pml_multisig_balance_after - pml_multisig_balance_before, pml_fund_payout.amount) steth_balance_checker(atc_multisig_balance_after - atc_multisig_balance_before, atc_fund_payout.amount) - steth_balance_checker(dao_balance_before - dao_balance_after, 1 * (10**18) + 1 * (10**18) + 1 * (10**18)) + steth_balance_checker(dao_balance_before - dao_balance_after, rcc_fund_payout.amount + pml_fund_payout.amount + atc_fund_payout.amount) # node operator name assert not contracts.acl.hasPermission(*permission_manage_no) From 616b3b322606cc6e73cf48acb37e7446e5679c07 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 31 Oct 2023 13:46:06 +0100 Subject: [PATCH 16/27] fix tests for correct events when forward agent node renaming --- scripts/vote_2023_10_31.py | 37 ++++++------------- tests/test_2023_10_31.py | 18 ++------- .../node_operators_registry.py | 2 +- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 44c1bf63..94f1c19d 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -7,9 +7,7 @@ 3. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' -4. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting -5. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs -6. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting +4. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs """ @@ -18,6 +16,7 @@ from typing import Dict from brownie import interface from brownie.network.transaction import TransactionReceipt +from utils.agent import agent_forward from utils.voting import bake_vote_items, confirm_vote_script, create_vote from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description from utils.permissions import encode_permission_revoke, encode_permission_grant @@ -34,7 +33,7 @@ ### Omnibus on-chain vote contains: 1. stETH transfer to the [Lido Contributors Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 1-3. -2. Changing the Node Operator's (#id - 27) name, as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/16). Items 4-6. +2. Changing the Node Operator's (#id - 27) name, as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/16). Item 4. """ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: @@ -69,33 +68,21 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra reference="Fund ATC multisig" ), # II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' - # 4. Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting - encode_permission_grant( - target_app=NO_registry, - permission_name="MANAGE_NODE_OPERATOR_ROLE", - grant_to=contracts.voting - ), - # 5. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` - encode_set_node_operator_name( - prysmatic_labs_node_id, - prysmatic_labs_node_new_name, - NO_registry - ), - # 6. Revoke MANAGE_NODE_OPERATOR_ROLE from Voting - encode_permission_revoke( - NO_registry, - "MANAGE_NODE_OPERATOR_ROLE", - revoke_from=contracts.voting - ) + # 4. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` + agent_forward([ + encode_set_node_operator_name( + prysmatic_labs_node_id, + prysmatic_labs_node_new_name, + NO_registry + ) + ]) ] vote_desc_items = [ f"1) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", f"2) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", f"3) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", - f"4) Grant NodeOperatorsRegistry.MANAGE_NODE_OPERATOR_ROLE to voting", - f"5) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", - f"6) Revoke MANAGE_NODE_OPERATOR_ROLE from Voting", + f"4) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index fc7bdb5c..7cab5214 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -4,17 +4,13 @@ """ from scripts.vote_2023_10_31 import start_vote -from brownie import interface, web3 +from brownie import interface from utils.test.tx_tracing_helpers import * from utils.test.event_validators.payout import ( Payout, validate_token_payout_event ) -from utils.test.event_validators.permission import ( - Permission, - validate_permission_revoke_event, - validate_permission_grant_event -) +from utils.test.event_validators.permission import Permission from utils.test.event_validators.node_operators_registry import ( validate_node_operator_name_set_event, NodeOperatorNameSetItem, @@ -46,10 +42,6 @@ def test_vote( prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" prysmatic_labs_node_data_before_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) - MANAGE_NODE_OPERATOR_ROLE = web3.keccak(text="MANAGE_NODE_OPERATOR_ROLE") - permission = Permission( - entity=contracts.voting, app=contracts.node_operators_registry, role=MANAGE_NODE_OPERATOR_ROLE.hex() - ) permission_manage_no = Permission( entity=contracts.voting, app=NO_registry, @@ -96,7 +88,7 @@ def test_vote( compare_NO_validators_data(prysmatic_labs_node_data_before_voting, prysmatic_labs_node_data_after_voting) # validate vote events - assert count_vote_items_by_events(vote_tx, contracts.voting) == 6, "Incorrect voting items count" + assert count_vote_items_by_events(vote_tx, contracts.voting) == 4, "Incorrect voting items count" display_voting_events(vote_tx) @@ -105,9 +97,7 @@ def test_vote( validate_token_payout_event(evs[0], rcc_fund_payout, True) validate_token_payout_event(evs[1], pml_fund_payout, True) validate_token_payout_event(evs[2], atc_fund_payout, True) - validate_permission_grant_event(evs[3], permission) - validate_node_operator_name_set_event(evs[4], NodeOperatorNameSetItem(nodeOperatorId=prysmatic_labs_node_id, name=prysmatic_labs_node_new_name)) - validate_permission_revoke_event(evs[5], permission_manage_no) + validate_node_operator_name_set_event(evs[3], NodeOperatorNameSetItem(nodeOperatorId=prysmatic_labs_node_id, name=prysmatic_labs_node_new_name)) def steth_balance_checker(lhs_value: int, rhs_value: int): assert (lhs_value + 5) // 10 == (rhs_value + 5) // 10 diff --git a/utils/test/event_validators/node_operators_registry.py b/utils/test/event_validators/node_operators_registry.py index b303c744..6a2ae793 100644 --- a/utils/test/event_validators/node_operators_registry.py +++ b/utils/test/event_validators/node_operators_registry.py @@ -60,7 +60,7 @@ def validate_node_operator_staking_limit_set_event( def validate_node_operator_name_set_event( event: EventDict, node_operator_name_item: NodeOperatorNameSetItem ): - _events_chain = ["LogScriptCall", "KeysOpIndexSet", "NodeOperatorNameSet"] + _events_chain = ["LogScriptCall", "LogScriptCall", "NodeOperatorNameSet", "ScriptResult"] validate_events_chain([e.name for e in event], _events_chain) From 4bb795164575962eac6699d52e4bbf7e8a53e5e9 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 31 Oct 2023 14:16:10 +0100 Subject: [PATCH 17/27] add node operator number --- scripts/vote_2023_10_31.py | 3 +-- tests/test_2023_10_31.py | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 94f1c19d..09b5d6a0 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -19,7 +19,6 @@ from utils.agent import agent_forward from utils.voting import bake_vote_items, confirm_vote_script, create_vote from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description -from utils.permissions import encode_permission_revoke, encode_permission_grant from utils.node_operators import encode_set_node_operator_name from utils.finance import make_steth_payout from utils.config import ( @@ -82,7 +81,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra f"1) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", f"2) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", f"3) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", - f"4) Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs", + f"4) Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs'", ] vote_items = bake_vote_items(vote_desc_items, call_script_items) diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 7cab5214..94e05b21 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -42,14 +42,7 @@ def test_vote( prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" prysmatic_labs_node_data_before_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) - permission_manage_no = Permission( - entity=contracts.voting, - app=NO_registry, - role=NO_registry.MANAGE_NODE_OPERATOR_ROLE(), - ) - # Check node operator name before - assert not contracts.acl.hasPermission(*permission_manage_no) assert prysmatic_labs_node_data_before_voting["name"] == prysmatic_labs_node_old_name, "Incorrect NO#27 name before" # START VOTE @@ -78,8 +71,6 @@ def test_vote( steth_balance_checker(dao_balance_before - dao_balance_after, rcc_fund_payout.amount + pml_fund_payout.amount + atc_fund_payout.amount) # node operator name - assert not contracts.acl.hasPermission(*permission_manage_no) - prysmatic_labs_node_data_after_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) assert prysmatic_labs_node_data_before_voting["active"] == prysmatic_labs_node_data_after_voting["active"] From 58335cd3beb0116648967709b81b6f5a85281f8b Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 31 Oct 2023 14:57:17 +0100 Subject: [PATCH 18/27] update steth amounts --- scripts/vote_2023_10_31.py | 24 ++++++++++++------------ tests/test_2023_10_31.py | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/vote_2023_10_31.py b/scripts/vote_2023_10_31.py index 09b5d6a0..e574a3e2 100644 --- a/scripts/vote_2023_10_31.py +++ b/scripts/vote_2023_10_31.py @@ -2,9 +2,9 @@ Voting 31/10/2023. I. stETH transfers to RCC PML ATC -1. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 -2. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D -3. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 +1. Transfer 279 stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 +2. Transfer 447 stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D +3. Transfer 391 stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' 4. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs @@ -48,22 +48,22 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra call_script_items = [ # I. stETH transfers to RCC PML ATC - # 1. Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 + # 1. Transfer 279 stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 make_steth_payout( target_address=rcc_multisig_address, - steth_in_wei=1 * (10**18), + steth_in_wei=279 * (10**18), reference="Fund RCC multisig" ), - # 2. Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D + # 2. Transfer 447 stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D make_steth_payout( target_address=pml_multisig_address, - steth_in_wei=1 * (10**18), + steth_in_wei=447 * (10**18), reference="Fund PML multisig" ), - # 3. Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + # 3. Transfer 391 stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 make_steth_payout( target_address=atc_multisig_address, - steth_in_wei=1 * (10**18), + steth_in_wei=391 * (10**18), reference="Fund ATC multisig" ), # II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' @@ -78,9 +78,9 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ] vote_desc_items = [ - f"1) Transfer TBA stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", - f"2) Transfer TBA stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", - f"3) Transfer TBA stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", + f"1) Transfer 279 stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", + f"2) Transfer 447 stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", + f"3) Transfer 391 stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", f"4) Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs'", ] diff --git a/tests/test_2023_10_31.py b/tests/test_2023_10_31.py index 94e05b21..a6d50fa1 100644 --- a/tests/test_2023_10_31.py +++ b/tests/test_2023_10_31.py @@ -61,9 +61,9 @@ def test_vote( atc_multisig_balance_after = contracts.lido.balanceOf(atc_multisig_address) dao_balance_after = contracts.lido.balanceOf(AGENT) - rcc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=1 * (10**18)) - pml_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=pml_multisig_address, amount=1 * (10**18)) - atc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=atc_multisig_address, amount=1 * (10**18)) + rcc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=279 * (10**18)) + pml_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=pml_multisig_address, amount=447 * (10**18)) + atc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=atc_multisig_address, amount=391 * (10**18)) steth_balance_checker(rcc_multisig_balance_after - rcc_multisig_balance_before, rcc_fund_payout.amount) steth_balance_checker(pml_multisig_balance_after - pml_multisig_balance_before, pml_fund_payout.amount) From 4923cf669b5826bf67f589a7c3623a2856fee3dc Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin Date: Tue, 31 Oct 2023 17:11:15 +0300 Subject: [PATCH 19/27] update timeout gas limit --- network-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/network-config.yaml b/network-config.yaml index 86250b3b..5421dd4d 100644 --- a/network-config.yaml +++ b/network-config.yaml @@ -3,13 +3,13 @@ development: cmd_settings: accounts: 10 fork: mainnet - gas_limit: 12000000 + gas_limit: 30000000 mnemonic: brownie port: 8545 host: http://127.0.0.1 id: mainnet-fork name: Ganache-CLI (Mainnet Fork) - timeout: 180 + timeout: 360 # https://github.com/mds1/multicall#multicall2-contract-addresses multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" - cmd: ./ganache.sh @@ -17,25 +17,25 @@ development: accounts: 10 chain_id: 5 fork: goerli - gas_limit: 12000000 + gas_limit: 300000000 mnemonic: brownie port: 8545 host: http://127.0.0.1 id: goerli-fork name: goerli-fork - timeout: 180 + timeout: 360 - cmd: ./ganache.sh cmd_settings: accounts: 10 chain_id: 1337 fork: http://127.0.0.1:7777 - gas_limit: 12000000 + gas_limit: 300000000 mnemonic: brownie port: 8545 host: http://127.0.0.1 id: local-fork name: local-fork explorer: https://api.etherscan.io/api - timeout: 180 + timeout: 360 # https://github.com/mds1/multicall#multicall2-contract-addresses multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" From c8ab7ff8dbae2a3ea063ad939895a9f0847a4ba5 Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin Date: Tue, 31 Oct 2023 17:12:03 +0300 Subject: [PATCH 20/27] fix gas limit --- network-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network-config.yaml b/network-config.yaml index 5421dd4d..a57a33a3 100644 --- a/network-config.yaml +++ b/network-config.yaml @@ -17,7 +17,7 @@ development: accounts: 10 chain_id: 5 fork: goerli - gas_limit: 300000000 + gas_limit: 30000000 mnemonic: brownie port: 8545 host: http://127.0.0.1 @@ -29,7 +29,7 @@ development: accounts: 10 chain_id: 1337 fork: http://127.0.0.1:7777 - gas_limit: 300000000 + gas_limit: 30000000 mnemonic: brownie port: 8545 host: http://127.0.0.1 From 92904d338be0a67992725dce395a1fb13e0bbd4d Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 3 Nov 2023 16:03:17 +0100 Subject: [PATCH 21/27] reject and archive voting --- {scripts => archive/scripts}/vote_2023_10_31.py | 1 + {tests => archive/tests}/test_2023_10_31.py | 0 2 files changed, 1 insertion(+) rename {scripts => archive/scripts}/vote_2023_10_31.py (99%) rename {tests => archive/tests}/test_2023_10_31.py (100%) diff --git a/scripts/vote_2023_10_31.py b/archive/scripts/vote_2023_10_31.py similarity index 99% rename from scripts/vote_2023_10_31.py rename to archive/scripts/vote_2023_10_31.py index e574a3e2..39df96ff 100644 --- a/scripts/vote_2023_10_31.py +++ b/archive/scripts/vote_2023_10_31.py @@ -9,6 +9,7 @@ II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' 4. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs +The vote REJECTED. """ import time diff --git a/tests/test_2023_10_31.py b/archive/tests/test_2023_10_31.py similarity index 100% rename from tests/test_2023_10_31.py rename to archive/tests/test_2023_10_31.py From 66e0be4a16ea843b358b4752db4de7eb8e82686e Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 7 Nov 2023 12:33:10 +0100 Subject: [PATCH 22/27] add new voting with node 27 renaming and top up ballance of RCC, PML, ATC --- scripts/vote_2023_11_07.py | 109 +++++++++++++++++++++++++++++++++++++ tests/test_2023_11_07.py | 100 ++++++++++++++++++++++++++++++++++ 2 files changed, 209 insertions(+) create mode 100644 scripts/vote_2023_11_07.py create mode 100644 tests/test_2023_11_07.py diff --git a/scripts/vote_2023_11_07.py b/scripts/vote_2023_11_07.py new file mode 100644 index 00000000..b0dd180c --- /dev/null +++ b/scripts/vote_2023_11_07.py @@ -0,0 +1,109 @@ +""" +Voting 07/11/2023. + +I. stETH transfers to RCC PML ATC +1. Transfer 272 stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 +2. Transfer 434 stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D +3. Transfer 380 stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + +II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' +4. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs + +The vote REJECTED. +""" + +import time + +from typing import Dict +from brownie import interface +from brownie.network.transaction import TransactionReceipt +from utils.agent import agent_forward +from utils.voting import bake_vote_items, confirm_vote_script, create_vote +from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description +from utils.node_operators import encode_set_node_operator_name +from utils.finance import make_steth_payout +from utils.config import ( + contracts, + get_deployer_account, + get_is_live, + get_priority_fee, +) + +description = """ +### Omnibus on-chain vote contains: + +1. stETH transfer to the [Lido Contributors Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 1-3. +2. Changing the Node Operator's (#id - 27) name, as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/16). Item 4. +""" + +def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: + """Prepare and run voting.""" + + rcc_multisig_address = "0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437" + pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" + atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" + + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) + prysmatic_labs_node_id = 27 + prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" + + call_script_items = [ + # I. stETH transfers to RCC PML ATC + # 1. Transfer 272 stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437 + make_steth_payout( + target_address=rcc_multisig_address, + steth_in_wei=272 * (10**18), + reference="Fund RCC multisig" + ), + # 2. Transfer 434 stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D + make_steth_payout( + target_address=pml_multisig_address, + steth_in_wei=434 * (10**18), + reference="Fund PML multisig" + ), + # 3. Transfer 380 stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956 + make_steth_payout( + target_address=atc_multisig_address, + steth_in_wei=380 * (10**18), + reference="Fund ATC multisig" + ), + # II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' + # 4. Change node operator #27 name from `Prysmatic Labs` to `Prysm Team at Offchain Labs` + agent_forward([ + encode_set_node_operator_name( + prysmatic_labs_node_id, + prysmatic_labs_node_new_name, + NO_registry + ) + ]) + ] + + vote_desc_items = [ + f"1) Transfer 272 stETH to RCC 0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437", + f"2) Transfer 434 stETH to PML 0x17F6b2C738a63a8D3A113a228cfd0b373244633D", + f"3) Transfer 380 stETH to ATC 0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956", + f"4) Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs'", + ] + + vote_items = bake_vote_items(vote_desc_items, 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_2023_11_07.py b/tests/test_2023_11_07.py new file mode 100644 index 00000000..762d7975 --- /dev/null +++ b/tests/test_2023_11_07.py @@ -0,0 +1,100 @@ +""" +Tests for voting 07/11/2023 + +""" + +from scripts.vote_2023_11_07 import start_vote +from brownie import interface +from utils.test.tx_tracing_helpers import * +from utils.test.event_validators.payout import ( + Payout, + validate_token_payout_event +) +from utils.test.event_validators.permission import Permission +from utils.test.event_validators.node_operators_registry import ( + validate_node_operator_name_set_event, + NodeOperatorNameSetItem, +) +from utils.config import ( + contracts, + LDO_HOLDER_ADDRESS_FOR_TESTS, + LIDO, + AGENT +) + +def test_vote( + helpers, + accounts, + vote_ids_from_env +): + rcc_multisig_address = "0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437" + pml_multisig_address = "0x17F6b2C738a63a8D3A113a228cfd0b373244633D" + atc_multisig_address = "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956" + + rcc_multisig_balance_before = contracts.lido.balanceOf(rcc_multisig_address) + pml_multisig_balance_before = contracts.lido.balanceOf(pml_multisig_address) + atc_multisig_balance_before = contracts.lido.balanceOf(atc_multisig_address) + dao_balance_before = contracts.lido.balanceOf(AGENT) + + NO_registry = interface.NodeOperatorsRegistry(contracts.node_operators_registry) + prysmatic_labs_node_id = 27 + prysmatic_labs_node_old_name = "Prysmatic Labs" + prysmatic_labs_node_new_name = "Prysm Team at Offchain Labs" + prysmatic_labs_node_data_before_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) + + # Check node operator name before + assert prysmatic_labs_node_data_before_voting["name"] == prysmatic_labs_node_old_name, "Incorrect NO#27 name 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}") + + rcc_multisig_balance_after = contracts.lido.balanceOf(rcc_multisig_address) + pml_multisig_balance_after = contracts.lido.balanceOf(pml_multisig_address) + atc_multisig_balance_after = contracts.lido.balanceOf(atc_multisig_address) + dao_balance_after = contracts.lido.balanceOf(AGENT) + + rcc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=rcc_multisig_address, amount=272 * (10**18)) + pml_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=pml_multisig_address, amount=434 * (10**18)) + atc_fund_payout = Payout(token_addr=LIDO, from_addr=contracts.agent, to_addr=atc_multisig_address, amount=380 * (10**18)) + + steth_balance_checker(rcc_multisig_balance_after - rcc_multisig_balance_before, rcc_fund_payout.amount) + steth_balance_checker(pml_multisig_balance_after - pml_multisig_balance_before, pml_fund_payout.amount) + steth_balance_checker(atc_multisig_balance_after - atc_multisig_balance_before, atc_fund_payout.amount) + steth_balance_checker(dao_balance_before - dao_balance_after, rcc_fund_payout.amount + pml_fund_payout.amount + atc_fund_payout.amount) + + # node operator name + prysmatic_labs_node_data_after_voting = NO_registry.getNodeOperator(prysmatic_labs_node_id, True) + + assert prysmatic_labs_node_data_before_voting["active"] == prysmatic_labs_node_data_after_voting["active"] + assert prysmatic_labs_node_data_after_voting["name"] == prysmatic_labs_node_new_name, "Incorrect NO#27 name after" + assert prysmatic_labs_node_data_before_voting["rewardAddress"] == prysmatic_labs_node_data_after_voting["rewardAddress"] + compare_NO_validators_data(prysmatic_labs_node_data_before_voting, prysmatic_labs_node_data_after_voting) + + # validate vote events + assert count_vote_items_by_events(vote_tx, contracts.voting) == 4, "Incorrect voting items count" + + display_voting_events(vote_tx) + + evs = group_voting_events(vote_tx) + + validate_token_payout_event(evs[0], rcc_fund_payout, True) + validate_token_payout_event(evs[1], pml_fund_payout, True) + validate_token_payout_event(evs[2], atc_fund_payout, True) + validate_node_operator_name_set_event(evs[3], NodeOperatorNameSetItem(nodeOperatorId=prysmatic_labs_node_id, name=prysmatic_labs_node_new_name)) + +def steth_balance_checker(lhs_value: int, rhs_value: int): + assert (lhs_value + 5) // 10 == (rhs_value + 5) // 10 + +def compare_NO_validators_data(data_before, data_after): + assert data_before["totalVettedValidators"] == data_after["totalVettedValidators"] + assert data_before["totalExitedValidators"] == data_after["totalExitedValidators"] + assert data_before["totalAddedValidators"] == data_after["totalAddedValidators"] + assert data_before["totalDepositedValidators"] == data_after["totalDepositedValidators"] \ No newline at end of file From bef5ec5dd7d156714067da932efd732e18b1353f Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 7 Nov 2023 14:32:22 +0100 Subject: [PATCH 23/27] fix lido validator test --- tests/acceptance/test_lido.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/test_lido.py b/tests/acceptance/test_lido.py index c06bd63a..001d7e35 100644 --- a/tests/acceptance/test_lido.py +++ b/tests/acceptance/test_lido.py @@ -86,6 +86,8 @@ def test_steth(contract): def test_lido_state(contract): stake_limit = contract.getStakeLimitFullInfo() + (total_exited_validators, _, _) = contracts.staking_router.getStakingModuleSummary(1) + assert stake_limit["isStakingPaused"] == False assert stake_limit["isStakingLimitSet"] == True assert stake_limit["maxStakeLimit"] == LIDO_MAX_STAKE_LIMIT_ETH * ONE_ETH @@ -97,7 +99,7 @@ def test_lido_state(contract): assert beacon_stat["beaconValidators"] >= last_seen_beacon_validators # might break once enough exited validators registered # they are not excluded from the 'beaconValidators' counter even though have zero balance - assert beacon_stat["beaconBalance"] >= 31 * 1e18 * beacon_stat["beaconValidators"], "no full withdrawals happened" + assert beacon_stat["beaconBalance"] >= 32 * 1e18 * (beacon_stat["beaconValidators"] - total_exited_validators), "no full withdrawals happened" assert beacon_stat["depositedValidators"] >= beacon_stat["beaconValidators"] assert contract.getTotalELRewardsCollected() >= last_seen_total_rewards_collected From a9282519351f1a996f666ed70a3403fa238058aa Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 7 Nov 2023 14:34:08 +0100 Subject: [PATCH 24/27] update description --- scripts/vote_2023_11_07.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/vote_2023_11_07.py b/scripts/vote_2023_11_07.py index b0dd180c..f0e8e8df 100644 --- a/scripts/vote_2023_11_07.py +++ b/scripts/vote_2023_11_07.py @@ -9,7 +9,6 @@ II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' 4. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs -The vote REJECTED. """ import time @@ -34,6 +33,8 @@ 1. stETH transfer to the [Lido Contributors Group multisigs](https://research.lido.fi/t/ref-introducing-the-lido-contributors-group-including-pool-maintenance-labs-and-argo-technology-consulting/3069) ([RCC](https://app.safe.global/settings/setup?safe=eth:0xDE06d17Db9295Fa8c4082D4f73Ff81592A3aC437), [PML](https://app.safe.global/settings/setup?safe=eth:0x17F6b2C738a63a8D3A113a228cfd0b373244633D), and [ATC](https://app.safe.global/settings/setup?safe=eth:0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956)), as previously [requested on the forum](https://research.lido.fi/t/lido-v2-may-1-2023-december-31-2023-lido-ongoing-grant-request/4476/11). Items 1-3. 2. Changing the Node Operator's (#id - 27) name, as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/16). Item 4. + +That's a rerun of [vote #166](https://vote.lido.fi/vote/166). """ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: From 65b68253b8c1d7f84af18b9d9444c0355efae3b9 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Tue, 7 Nov 2023 14:50:01 +0100 Subject: [PATCH 25/27] update vyper version to 0.3.7 in contracts --- contracts/EtherFunder.vy | 2 +- contracts/MockCallTarget.vy | 2 +- contracts/OnchainMetrics.vy | 2 +- contracts/RewardsManagerTokensRecoverer.vy | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/EtherFunder.vy b/contracts/EtherFunder.vy index 4febb6b8..cc8b3e60 100644 --- a/contracts/EtherFunder.vy +++ b/contracts/EtherFunder.vy @@ -1,4 +1,4 @@ -# @version 0.3.1 +# @version 0.3.7 # @author psirex # @licence MIT diff --git a/contracts/MockCallTarget.vy b/contracts/MockCallTarget.vy index bee1c4c3..1dd30b36 100644 --- a/contracts/MockCallTarget.vy +++ b/contracts/MockCallTarget.vy @@ -1,4 +1,4 @@ -# @version 0.2.15 +# @version 0.3.7 called: public(bool) diff --git a/contracts/OnchainMetrics.vy b/contracts/OnchainMetrics.vy index 9d359bb0..d70bba3d 100644 --- a/contracts/OnchainMetrics.vy +++ b/contracts/OnchainMetrics.vy @@ -1,4 +1,4 @@ -# @version 0.2.15 +# @version 0.3.7 # @author skozin # @licence MIT diff --git a/contracts/RewardsManagerTokensRecoverer.vy b/contracts/RewardsManagerTokensRecoverer.vy index 9bd5d4fa..acaabc52 100644 --- a/contracts/RewardsManagerTokensRecoverer.vy +++ b/contracts/RewardsManagerTokensRecoverer.vy @@ -1,4 +1,4 @@ -# @version 0.3.1 +# @version 0.3.7 # @notice A contract to recover tokens from RewardsManager contract # @license MIT From 439f7eb29f99c62597b293ff592a60593b1c6f9f Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin Date: Tue, 7 Nov 2023 11:12:56 +0300 Subject: [PATCH 26/27] fix events parsing --- ...test_node-operators-registry-happy-path.py | 97 +++++++++++++++---- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/tests/regression/test_node-operators-registry-happy-path.py b/tests/regression/test_node-operators-registry-happy-path.py index c5557587..9eeb3277 100644 --- a/tests/regression/test_node-operators-registry-happy-path.py +++ b/tests/regression/test_node-operators-registry-happy-path.py @@ -1,6 +1,7 @@ import pytest from web3 import Web3 -from brownie import chain, ZERO_ADDRESS +import eth_abi +from brownie import chain, ZERO_ADDRESS, web3 from utils.test.extra_data import ( ExtraDataService, @@ -276,17 +277,23 @@ def test_node_operators(nor, extra_data_service, impersonated_voting, eth_whale) assert nor.isOperatorPenalized(base_no_id) == False # Events - assert extra_report_tx.events["ExitedSigningKeysCountChanged"][0]["nodeOperatorId"] == tested_no_id_first - assert extra_report_tx.events["ExitedSigningKeysCountChanged"][0]["exitedValidatorsCount"] == 5 - - assert extra_report_tx.events["ExitedSigningKeysCountChanged"][1]["nodeOperatorId"] == tested_no_id_second - assert extra_report_tx.events["ExitedSigningKeysCountChanged"][1]["exitedValidatorsCount"] == 5 + exited_signing_keys_count_events = parse_exited_signing_keys_count_changed_logs( + filter_transfer_logs(extra_report_tx.logs, web3.keccak(text="ExitedSigningKeysCountChanged(uint256,uint256)")) + ) + assert exited_signing_keys_count_events[0]["nodeOperatorId"] == tested_no_id_first + assert exited_signing_keys_count_events[0]["exitedValidatorsCount"] == 5 - assert extra_report_tx.events["StuckPenaltyStateChanged"][0]["nodeOperatorId"] == tested_no_id_first - assert extra_report_tx.events["StuckPenaltyStateChanged"][0]["stuckValidatorsCount"] == 2 + assert exited_signing_keys_count_events[1]["nodeOperatorId"] == tested_no_id_second + assert exited_signing_keys_count_events[1]["exitedValidatorsCount"] == 5 + + stuck_penalty_state_changed_events = parse_stuck_penalty_state_changed_logs( + filter_transfer_logs(extra_report_tx.logs, web3.keccak(text="StuckPenaltyStateChanged(uint256,uint256,uint256,uint256)")) + ) + assert stuck_penalty_state_changed_events[0]["nodeOperatorId"] == tested_no_id_first + assert stuck_penalty_state_changed_events[0]["stuckValidatorsCount"] == 2 - assert extra_report_tx.events["StuckPenaltyStateChanged"][1]["nodeOperatorId"] == tested_no_id_second - assert extra_report_tx.events["StuckPenaltyStateChanged"][1]["stuckValidatorsCount"] == 2 + assert stuck_penalty_state_changed_events[1]["nodeOperatorId"] == tested_no_id_second + assert stuck_penalty_state_changed_events[1]["stuckValidatorsCount"] == 2 # Deposit keys ( @@ -406,11 +413,17 @@ def test_node_operators(nor, extra_data_service, impersonated_voting, eth_whale) assert nor.isOperatorPenalized(base_no_id) == False # events - assert extra_report_tx.events["ExitedSigningKeysCountChanged"][0]["nodeOperatorId"] == tested_no_id_first - assert extra_report_tx.events["ExitedSigningKeysCountChanged"][0]["exitedValidatorsCount"] == 7 + exited_signing_keys_count_events = parse_exited_signing_keys_count_changed_logs( + filter_transfer_logs(extra_report_tx.logs, web3.keccak(text="ExitedSigningKeysCountChanged(uint256,uint256)")) + ) + assert exited_signing_keys_count_events[0]["nodeOperatorId"] == tested_no_id_first + assert exited_signing_keys_count_events[0]["exitedValidatorsCount"] == 7 - assert extra_report_tx.events["StuckPenaltyStateChanged"][0]["nodeOperatorId"] == tested_no_id_first - assert extra_report_tx.events["StuckPenaltyStateChanged"][0]["stuckValidatorsCount"] == 0 + stuck_penalty_state_changed_events = parse_stuck_penalty_state_changed_logs( + filter_transfer_logs(extra_report_tx.logs, web3.keccak(text="StuckPenaltyStateChanged(uint256,uint256,uint256,uint256)")) + ) + assert stuck_penalty_state_changed_events[0]["nodeOperatorId"] == tested_no_id_first + assert stuck_penalty_state_changed_events[0]["stuckValidatorsCount"] == 0 # Case 3 # -- PENALTY_DELAY time passes @@ -730,8 +743,11 @@ def test_node_operators(nor, extra_data_service, impersonated_voting, eth_whale) target_limit_tx = nor.updateTargetValidatorsLimits(tested_no_id_first, True, 0, {"from": STAKING_ROUTER}) - assert target_limit_tx.events["TargetValidatorsCountChanged"][0]["nodeOperatorId"] == tested_no_id_first - assert target_limit_tx.events["TargetValidatorsCountChanged"][0]["targetValidatorsCount"] == 0 + target_validators_count_changed_events = parse_target_validators_count_changed( + filter_transfer_logs(target_limit_tx.logs, web3.keccak(text="TargetValidatorsCountChanged(uint256,uint256)")) + ) + assert target_validators_count_changed_events[0]["nodeOperatorId"] == tested_no_id_first + assert target_validators_count_changed_events[0]["targetValidatorsCount"] == 0 first_no_summary_after = nor.getNodeOperatorSummary(tested_no_id_first) @@ -755,8 +771,10 @@ def test_node_operators(nor, extra_data_service, impersonated_voting, eth_whale) # Disable target limit target_limit_tx = nor.updateTargetValidatorsLimits(tested_no_id_first, False, 0, {"from": STAKING_ROUTER}) - - assert target_limit_tx.events["TargetValidatorsCountChanged"][0]["nodeOperatorId"] == tested_no_id_first + target_validators_count_changed_events = parse_target_validators_count_changed( + filter_transfer_logs(target_limit_tx.logs, web3.keccak(text="TargetValidatorsCountChanged(uint256,uint256)")) + ) + assert target_validators_count_changed_events[0]["nodeOperatorId"] == tested_no_id_first first_no_summary_after = nor.getNodeOperatorSummary(tested_no_id_first) @@ -777,3 +795,46 @@ def test_node_operators(nor, extra_data_service, impersonated_voting, eth_whale) assert deposited_keys_first_before != deposited_keys_first_after assert deposited_keys_second_before != deposited_keys_second_after assert deposited_keys_base_before != deposited_keys_base_after + + +def filter_transfer_logs(logs, transfer_topic): + return list(filter(lambda l: l["topics"][0] == transfer_topic, logs)) + + +def parse_exited_signing_keys_count_changed_logs(logs): + res = [] + for l in logs: + res.append( + { + "nodeOperatorId": eth_abi.decode_abi(["uint256"], l["topics"][1])[0], + "exitedValidatorsCount": eth_abi.decode_single("uint256", bytes.fromhex(l["data"][2:])), + } + ) + return res + + +def parse_stuck_penalty_state_changed_logs(logs): + res = [] + for l in logs: + data = eth_abi.decode(["uint256","uint256","uint256"], bytes.fromhex(l["data"][2:])) + res.append( + { + "nodeOperatorId": eth_abi.decode_abi(["uint256"], l["topics"][1])[0], + "stuckValidatorsCount": data[0], + "refundedValidatorsCount": data[1], + "stuckPenaltyEndTimestamp": data[2], + } + ) + return res + +def parse_target_validators_count_changed(logs): + res = [] + for l in logs: + res.append( + { + "nodeOperatorId": eth_abi.decode_abi(["uint256"], l["topics"][1])[0], + "targetValidatorsCount": eth_abi.decode_single("uint256", bytes.fromhex(l["data"][2:])), + } + ) + return res + From edcd94c69ab37f91fe4b791d006c6ca7d674f8c0 Mon Sep 17 00:00:00 2001 From: Anton Kovalchuk Date: Fri, 10 Nov 2023 15:48:50 +0100 Subject: [PATCH 27/27] mark and move vote to archive --- {scripts => archive/scripts}/vote_2023_11_07.py | 1 + {tests => archive/tests}/test_2023_11_07.py | 0 2 files changed, 1 insertion(+) rename {scripts => archive/scripts}/vote_2023_11_07.py (98%) rename {tests => archive/tests}/test_2023_11_07.py (100%) diff --git a/scripts/vote_2023_11_07.py b/archive/scripts/vote_2023_11_07.py similarity index 98% rename from scripts/vote_2023_11_07.py rename to archive/scripts/vote_2023_11_07.py index f0e8e8df..a37b29db 100644 --- a/scripts/vote_2023_11_07.py +++ b/archive/scripts/vote_2023_11_07.py @@ -9,6 +9,7 @@ II. Change the on-chain name of node operator with id 27 from 'Prysmatic Labs' to 'Prysm Team at Offchain Labs' 4. Change node operator name from Prysmatic Labs to Prysm Team at Offchain Labs +Vote passed & executed on Nov-10-2023 02:43:23 PM +UTC, block 18542216 """ import time diff --git a/tests/test_2023_11_07.py b/archive/tests/test_2023_11_07.py similarity index 100% rename from tests/test_2023_11_07.py rename to archive/tests/test_2023_11_07.py