From 27822fb1e43e69336c7d76547a5211e953b0994b Mon Sep 17 00:00:00 2001 From: Arti Date: Mon, 20 Jan 2025 13:02:43 +0100 Subject: [PATCH 01/13] Finish script + basic tests --- package.json | 3 +- scripts/vote_2025_01_28.py | 132 ++++++++++++++++++++++++++++++++++ tests/test_vote_2025_01_28.py | 44 ++++++++++++ utils/csm.py | 8 +++ utils/staking_module.py | 9 +++ 5 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 scripts/vote_2025_01_28.py create mode 100644 tests/test_vote_2025_01_28.py create mode 100644 utils/csm.py diff --git a/package.json b/package.json index ca9ca8b0..0dd7c294 100644 --- a/package.json +++ b/package.json @@ -8,5 +8,6 @@ "homepage": "https://mainnet.lido.fi", "dependencies": { "@lido-js/ganache": "=7.9.2-lido" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py new file mode 100644 index 00000000..1212297d --- /dev/null +++ b/scripts/vote_2025_01_28.py @@ -0,0 +1,132 @@ +""" +Voting 28/01/2025. + +I. Community staking module: limit increase + turn off EA mode +1. Grant MODULE_MANAGER_ROLE +2. Activate public release mode +3. Grant STAKING_MODULE_MANAGE_ROLE +4. Increase share from 1% to 2% +5. Revoke MODULE_MANAGER_ROLE +6. Revoke STAKING_MODULE_MANAGE_ROLE + +II. NO Acquisitions - Bridgetower is now part of Solstice Staking +1. Change name of Bridgetower to Solstice + +""" + +import time + +from typing import Dict, Tuple, Optional, List + +from brownie import interface +from brownie.network.transaction import TransactionReceipt +from utils.voting import bake_vote_items, confirm_vote_script, create_vote +from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description +from utils.permissions import ( + encode_oz_revoke_role, + encode_oz_grant_role +) + +from utils.node_operators import encode_set_node_operator_name + +from utils.config import ( + get_deployer_account, + contracts, + get_is_live, + get_priority_fee, +) + +from utils.staking_module import update_staking_module + +from utils.csm import activate_public_release + +from utils.agent import agent_forward + +description = """ +1. **Community staking module**: limit increase + turn off EA mode + +2. **NO Acquisitions** - Bridgetower is now part of Solstice Staking +""" + +def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: + """Prepare and run voting.""" + voting: interface.Voting = contracts.voting + csm: interface.CSModule = contracts.csm + staking_router: interface.StakingRouter = contracts.staking_router + csm_module_id = 3 + new_stake_share_limit = 200 + + vote_desc_items, call_script_items = zip( + # + # I. Community staking module: limit increase + turn off EA mode + # + ( + "1. Grant MODULE_MANAGER_ROLE", + encode_oz_grant_role(csm, "MODULE_MANAGER_ROLE", voting) + ), + ( + "2. Activate public release mode", + agent_forward( + [ + activate_public_release(csm.address) + ] + ), + ), + ( + "3. Grant STAKING_MODULE_MANAGE_ROLE", + encode_oz_grant_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", voting) + ), + ( + "4. Increase share from 1% to 2%", + agent_forward( + [ + update_staking_module(csm_module_id, new_stake_share_limit, 125, 600, 400, 30, 25) + ] + ), + ), + ( + "5. Revoke MODULE_MANAGER_ROLE", + encode_oz_revoke_role(csm, "MODULE_MANAGER_ROLE", revoke_from=voting) + ), + ( + "6. Revoke STAKING_MODULE_MANAGE_ROLE", + encode_oz_revoke_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", voting) + ), + # + # II. NO Acquisitions - Bridgetower is now part of Solstice Staking + # + ( + "1. Change name of Bridgetower to Solstice", + agent_forward( + [ + encode_set_node_operator_name( + id=17, name="Solstice", registry=contracts.node_operators_registry + ), + ] + ), + ), + ) + + vote_items = bake_vote_items(list(vote_desc_items), list(call_script_items)) + + if silent: + desc_ipfs = calculate_vote_ipfs_description(description) + else: + desc_ipfs = upload_vote_ipfs_description(description) + + return confirm_vote_script(vote_items, silent, desc_ipfs) and list( + create_vote(vote_items, tx_params, desc_ipfs=desc_ipfs) + ) + + +def main(): + tx_params = {"from": get_deployer_account()} + + if get_is_live(): + tx_params["priority_fee"] = get_priority_fee() + + vote_id, _ = start_vote(tx_params=tx_params, silent=False) + + vote_id >= 0 and print(f"Vote created: {vote_id}.") + + time.sleep(5) # hack for waiting thread #2. diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py new file mode 100644 index 00000000..8dd061ec --- /dev/null +++ b/tests/test_vote_2025_01_28.py @@ -0,0 +1,44 @@ +""" +Tests for voting 28/01/2025. +""" + +from typing import Dict, Tuple, List, NamedTuple +from scripts.vote_2025_01_28 import start_vote +from brownie import interface +from utils.test.tx_tracing_helpers import * +from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS +from utils.config import contracts + +def test_vote(helpers, accounts, vote_ids_from_env, stranger): + + csm: interface.CSModule = contracts.csm + staking_router: interface.StakingRouter = contracts.staking_router + node_operators_registry = contracts.node_operators_registry + + # 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}") + + # + # I. Community staking module: limit increase + turn off EA mode + # + # 2. Activate public release mode + assert csm.publicRelease() == True + + # 4. Increase share from 1% to 2% + assert staking_router.getStakingModule(3)["stakeShareLimit"] == 200 + + # + # II. NO Acquisitions - Bridgetower is now part of Solstice Staking + # + # 1. Change name of Bridgetower to Solstice + assert node_operators_registry.getNodeOperator(17, True)["name"] == "Solstice" + + # events + display_voting_events(vote_tx) + evs = group_voting_events(vote_tx) diff --git a/utils/csm.py b/utils/csm.py new file mode 100644 index 00000000..ccf91647 --- /dev/null +++ b/utils/csm.py @@ -0,0 +1,8 @@ +from typing import Tuple +from brownie import interface + +from utils.config import contracts + +def activate_public_release(csm_address: str) -> Tuple[str, str]: + csm = interface.CSModule(csm_address) + return (csm.address, csm.activatePublicRelease.encode_input()) diff --git a/utils/staking_module.py b/utils/staking_module.py index daaf5813..be0e761c 100644 --- a/utils/staking_module.py +++ b/utils/staking_module.py @@ -1,3 +1,4 @@ +from typing import Dict, Tuple, List, NamedTuple from brownie import reverts # type: ignore from brownie import convert from web3 import Web3 @@ -29,3 +30,11 @@ def calc_module_reward_shares(module_id, shares_minted_as_fees): module_idx = distribution[1].index(module_id) return distribution[2][module_idx] * shares_minted_as_fees // distribution[3] +def update_staking_module(staking_module_id, stake_share_limit, + priority_exit_share_threshold, staking_module_fee, + treasury_fee, max_deposits_per_block, + min_deposit_block_distance) -> Tuple[str, str]: + return (contracts.staking_router.address, contracts.staking_router.updateStakingModule.encode_input( + staking_module_id, stake_share_limit, priority_exit_share_threshold, staking_module_fee, + treasury_fee, max_deposits_per_block, min_deposit_block_distance + )) From dd68a7c4bbb5b68b57b6db92c1b6a3f81e327fa3 Mon Sep 17 00:00:00 2001 From: Arti Date: Mon, 20 Jan 2025 13:07:35 +0100 Subject: [PATCH 02/13] Change ipfs description --- scripts/vote_2025_01_28.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py index 1212297d..098aca96 100644 --- a/scripts/vote_2025_01_28.py +++ b/scripts/vote_2025_01_28.py @@ -10,7 +10,7 @@ 6. Revoke STAKING_MODULE_MANAGE_ROLE II. NO Acquisitions - Bridgetower is now part of Solstice Staking -1. Change name of Bridgetower to Solstice +7. Change name of Bridgetower to Solstice """ @@ -43,9 +43,14 @@ from utils.agent import agent_forward description = """ -1. **Community staking module**: limit increase + turn off EA mode - -2. **NO Acquisitions** - Bridgetower is now part of Solstice Staking +1. **Transition Community Staking Module to Permissionless Phase** by activating public release +and **increasing the share limit** from 1% to 2%, +as [approved on Snapshot](https://snapshot.org/#/s:lido-snapshot.eth/proposal/0x7cbd5e9cb95bda9581831daf8b0e72d1ad0b068d2cbd3bda2a2f6ae378464f26). +Items 1-6. + +2. **Rename Node Operator ID 17 from BridgeTower to Solstice** +as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/41). +Item 7. """ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: @@ -96,7 +101,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra # II. NO Acquisitions - Bridgetower is now part of Solstice Staking # ( - "1. Change name of Bridgetower to Solstice", + "7. Change name of Bridgetower to Solstice", agent_forward( [ encode_set_node_operator_name( From c107d6589199366a1dd86dbe178791a1e15eac31 Mon Sep 17 00:00:00 2001 From: Arti Date: Mon, 20 Jan 2025 19:10:03 +0100 Subject: [PATCH 03/13] Tests and script are ready --- scripts/vote_2025_01_28.py | 29 +++++++++++++++++++++++------ tests/test_vote_2025_01_28.py | 6 +++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py index 098aca96..ef55d645 100644 --- a/scripts/vote_2025_01_28.py +++ b/scripts/vote_2025_01_28.py @@ -59,7 +59,8 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra csm: interface.CSModule = contracts.csm staking_router: interface.StakingRouter = contracts.staking_router csm_module_id = 3 - new_stake_share_limit = 200 + new_stake_share_limit = 200 #2% + new_priority_exit_share_threshold = 250 #2.5% vote_desc_items, call_script_items = zip( # @@ -67,7 +68,11 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra # ( "1. Grant MODULE_MANAGER_ROLE", - encode_oz_grant_role(csm, "MODULE_MANAGER_ROLE", voting) + agent_forward( + [ + encode_oz_grant_role(csm, "MODULE_MANAGER_ROLE", contracts.agent) + ] + ), ), ( "2. Activate public release mode", @@ -79,23 +84,35 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ), ( "3. Grant STAKING_MODULE_MANAGE_ROLE", - encode_oz_grant_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", voting) + agent_forward( + [ + encode_oz_grant_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) + ] + ), ), ( "4. Increase share from 1% to 2%", agent_forward( [ - update_staking_module(csm_module_id, new_stake_share_limit, 125, 600, 400, 30, 25) + update_staking_module(csm_module_id, new_stake_share_limit, new_priority_exit_share_threshold, 600, 400, 30, 25) ] ), ), ( "5. Revoke MODULE_MANAGER_ROLE", - encode_oz_revoke_role(csm, "MODULE_MANAGER_ROLE", revoke_from=voting) + agent_forward( + [ + encode_oz_revoke_role(csm, "MODULE_MANAGER_ROLE", revoke_from=contracts.agent) + ] + ), ), ( "6. Revoke STAKING_MODULE_MANAGE_ROLE", - encode_oz_revoke_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", voting) + agent_forward( + [ + encode_oz_revoke_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) + ] + ), ), # # II. NO Acquisitions - Bridgetower is now part of Solstice Staking diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py index 8dd061ec..9418b8ab 100644 --- a/tests/test_vote_2025_01_28.py +++ b/tests/test_vote_2025_01_28.py @@ -7,7 +7,6 @@ from brownie import interface from utils.test.tx_tracing_helpers import * from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS -from utils.config import contracts def test_vote(helpers, accounts, vote_ids_from_env, stranger): @@ -33,6 +32,11 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): # 4. Increase share from 1% to 2% assert staking_router.getStakingModule(3)["stakeShareLimit"] == 200 + # 5. Revoke MODULE_MANAGER_ROLE" + assert csm.hasRole(0x79dfcec784e591aafcf60db7db7b029a5c8b12aac4afd4e8c4eb740430405fa6, contracts.agent) == False + + # 6. Revoke STAKING_MODULE_MANAGE_ROLE" + assert staking_router.hasRole(0x3105bcbf19d4417b73ae0e58d508a65ecf75665e46c2622d8521732de6080c48, contracts.agent) == False # # II. NO Acquisitions - Bridgetower is now part of Solstice Staking # From 385245f5c0117d31c2ccccc032c809b61466867f Mon Sep 17 00:00:00 2001 From: Arti Date: Tue, 21 Jan 2025 12:18:48 +0100 Subject: [PATCH 04/13] Fix acceptance/test_csm + regression/test_csm --- scripts/vote_2025_01_28.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py index ef55d645..c587db2b 100644 --- a/scripts/vote_2025_01_28.py +++ b/scripts/vote_2025_01_28.py @@ -82,14 +82,14 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ] ), ), - ( - "3. Grant STAKING_MODULE_MANAGE_ROLE", - agent_forward( - [ - encode_oz_grant_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) - ] - ), - ), + # ( + # "3. Grant STAKING_MODULE_MANAGE_ROLE", + # agent_forward( + # [ + # encode_oz_grant_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) + # ] + # ), + # ), ( "4. Increase share from 1% to 2%", agent_forward( @@ -106,14 +106,14 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ] ), ), - ( - "6. Revoke STAKING_MODULE_MANAGE_ROLE", - agent_forward( - [ - encode_oz_revoke_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) - ] - ), - ), + # ( + # "6. Revoke STAKING_MODULE_MANAGE_ROLE", + # agent_forward( + # [ + # encode_oz_revoke_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) + # ] + # ), + # ), # # II. NO Acquisitions - Bridgetower is now part of Solstice Staking # From 37812eebd9e08eb68404f807ede83c909a1f8d39 Mon Sep 17 00:00:00 2001 From: Arti Date: Tue, 21 Jan 2025 12:23:23 +0100 Subject: [PATCH 05/13] Fix test_vote_2025_01_28.py --- tests/test_vote_2025_01_28.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py index 9418b8ab..24fb3eb7 100644 --- a/tests/test_vote_2025_01_28.py +++ b/tests/test_vote_2025_01_28.py @@ -35,8 +35,6 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): # 5. Revoke MODULE_MANAGER_ROLE" assert csm.hasRole(0x79dfcec784e591aafcf60db7db7b029a5c8b12aac4afd4e8c4eb740430405fa6, contracts.agent) == False - # 6. Revoke STAKING_MODULE_MANAGE_ROLE" - assert staking_router.hasRole(0x3105bcbf19d4417b73ae0e58d508a65ecf75665e46c2622d8521732de6080c48, contracts.agent) == False # # II. NO Acquisitions - Bridgetower is now part of Solstice Staking # From c04d56e5e05130bd3542340e191b49d7608e9345 Mon Sep 17 00:00:00 2001 From: Arti Date: Tue, 21 Jan 2025 18:42:41 +0100 Subject: [PATCH 06/13] Fix acceptance/test_staking_router.py + acceptance/test_csm.py --- configs/config_mainnet.py | 4 ++-- tests/acceptance/test_csm.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/config_mainnet.py b/configs/config_mainnet.py index 1c784fe6..024f72d6 100644 --- a/configs/config_mainnet.py +++ b/configs/config_mainnet.py @@ -353,8 +353,8 @@ CS_MODULE_NAME = "Community Staking" CS_MODULE_MODULE_FEE_BP = 600 CS_MODULE_TREASURY_FEE_BP = 400 -CS_MODULE_TARGET_SHARE_BP = 100 -CS_MODULE_PRIORITY_EXIT_SHARE_THRESHOLD = 125 +CS_MODULE_TARGET_SHARE_BP = 200 +CS_MODULE_PRIORITY_EXIT_SHARE_THRESHOLD = 250 CS_MODULE_MAX_DEPOSITS_PER_BLOCK = 30 CS_MODULE_MIN_DEPOSIT_BLOCK_DISTANCE = 25 diff --git a/tests/acceptance/test_csm.py b/tests/acceptance/test_csm.py index 90cf13dc..a473e0c5 100644 --- a/tests/acceptance/test_csm.py +++ b/tests/acceptance/test_csm.py @@ -80,7 +80,7 @@ def test_init_state(self, csm): assert csm.accounting() == CS_ACCOUNTING_ADDRESS assert not csm.isPaused() - assert not csm.publicRelease() + assert csm.publicRelease() class TestAccounting: From fd47286c7793080672cfb91035eabc511801a85e Mon Sep 17 00:00:00 2001 From: Arti Date: Wed, 22 Jan 2025 13:11:17 +0100 Subject: [PATCH 07/13] Fix script and test (follow comments from Kate) --- scripts/vote_2025_01_28.py | 69 ++++++++++++++++------------------- tests/test_vote_2025_01_28.py | 65 +++++++++++++++++++++++++++------ utils/staking_module.py | 10 +---- 3 files changed, 86 insertions(+), 58 deletions(-) diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py index c587db2b..f956df5d 100644 --- a/scripts/vote_2025_01_28.py +++ b/scripts/vote_2025_01_28.py @@ -1,16 +1,14 @@ """ Voting 28/01/2025. -I. Community staking module: limit increase + turn off EA mode -1. Grant MODULE_MANAGER_ROLE -2. Activate public release mode -3. Grant STAKING_MODULE_MANAGE_ROLE -4. Increase share from 1% to 2% -5. Revoke MODULE_MANAGER_ROLE -6. Revoke STAKING_MODULE_MANAGE_ROLE +I. CSM: Enable Permissionless Phase and Increase the Share Limit +1. Grant MODULE_MANAGER_ROLE on CS Module to Aragon Agent +2. Activate public release mode on CS Module +3. Increase stake share limit from 1% to 2% on CS Module +4. Revoke MODULE_MANAGER_ROLE on CS Module from Aragon Agent -II. NO Acquisitions - Bridgetower is now part of Solstice Staking -7. Change name of Bridgetower to Solstice +II. NO Acquisitions: Bridgetower is now part of Solstice Staking +5. Rename Node Operator ID 17 from BridgeTower to Solstice """ @@ -36,8 +34,6 @@ get_priority_fee, ) -from utils.staking_module import update_staking_module - from utils.csm import activate_public_release from utils.agent import agent_forward @@ -46,11 +42,11 @@ 1. **Transition Community Staking Module to Permissionless Phase** by activating public release and **increasing the share limit** from 1% to 2%, as [approved on Snapshot](https://snapshot.org/#/s:lido-snapshot.eth/proposal/0x7cbd5e9cb95bda9581831daf8b0e72d1ad0b068d2cbd3bda2a2f6ae378464f26). -Items 1-6. +Items 1-4. 2. **Rename Node Operator ID 17 from BridgeTower to Solstice** as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/41). -Item 7. +Item 5. """ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: @@ -61,13 +57,17 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra csm_module_id = 3 new_stake_share_limit = 200 #2% new_priority_exit_share_threshold = 250 #2.5% + old_staking_module_fee = 600 + old_treasury_fee = 400 + old_max_deposits_per_block = 30 + old_min_deposit_block_distance = 25 vote_desc_items, call_script_items = zip( # - # I. Community staking module: limit increase + turn off EA mode + # I. CSM: Enable Permissionless Phase and Increase the Share Limit # ( - "1. Grant MODULE_MANAGER_ROLE", + "1. Grant MODULE_MANAGER_ROLE on CS Module to Aragon Agent", agent_forward( [ encode_oz_grant_role(csm, "MODULE_MANAGER_ROLE", contracts.agent) @@ -75,50 +75,36 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ), ), ( - "2. Activate public release mode", + "2. Activate public release mode on CS Module", agent_forward( [ activate_public_release(csm.address) ] ), ), - # ( - # "3. Grant STAKING_MODULE_MANAGE_ROLE", - # agent_forward( - # [ - # encode_oz_grant_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) - # ] - # ), - # ), ( - "4. Increase share from 1% to 2%", + "3. Increase stake share limit from 1% to 2% on CS Module", agent_forward( [ - update_staking_module(csm_module_id, new_stake_share_limit, new_priority_exit_share_threshold, 600, 400, 30, 25) + update_staking_module(csm_module_id, new_stake_share_limit, new_priority_exit_share_threshold, + old_staking_module_fee, old_treasury_fee, old_max_deposits_per_block, + old_min_deposit_block_distance) ] ), ), ( - "5. Revoke MODULE_MANAGER_ROLE", + "4. Revoke MODULE_MANAGER_ROLE on CS Module from Aragon Agent", agent_forward( [ encode_oz_revoke_role(csm, "MODULE_MANAGER_ROLE", revoke_from=contracts.agent) ] ), ), - # ( - # "6. Revoke STAKING_MODULE_MANAGE_ROLE", - # agent_forward( - # [ - # encode_oz_revoke_role(staking_router, "STAKING_MODULE_MANAGE_ROLE", contracts.agent) - # ] - # ), - # ), # - # II. NO Acquisitions - Bridgetower is now part of Solstice Staking + # II. NO Acquisitions: Bridgetower is now part of Solstice Staking # ( - "7. Change name of Bridgetower to Solstice", + "5. Rename Node Operator ID 17 from BridgeTower to Solstice", agent_forward( [ encode_set_node_operator_name( @@ -152,3 +138,12 @@ def main(): vote_id >= 0 and print(f"Vote created: {vote_id}.") time.sleep(5) # hack for waiting thread #2. + +def update_staking_module(staking_module_id, stake_share_limit, + priority_exit_share_threshold, staking_module_fee, + treasury_fee, max_deposits_per_block, + min_deposit_block_distance) -> Tuple[str, str]: + return (contracts.staking_router.address, contracts.staking_router.updateStakingModule.encode_input( + staking_module_id, stake_share_limit, priority_exit_share_threshold, staking_module_fee, + treasury_fee, max_deposits_per_block, min_deposit_block_distance + )) diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py index 24fb3eb7..667e53c0 100644 --- a/tests/test_vote_2025_01_28.py +++ b/tests/test_vote_2025_01_28.py @@ -7,12 +7,43 @@ from brownie import interface from utils.test.tx_tracing_helpers import * from utils.config import 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 def test_vote(helpers, accounts, vote_ids_from_env, stranger): - csm: interface.CSModule = contracts.csm - staking_router: interface.StakingRouter = contracts.staking_router - node_operators_registry = contracts.node_operators_registry + csm = interface.CSModule("0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F") + staking_router = interface.StakingRouter("0xFdDf38947aFB03C621C71b06C9C70bce73f12999") + node_operators_registry = interface.NodeOperatorsRegistry("0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5") + agent = interface.Agent("0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c") + module_manager_role = "0x79dfcec784e591aafcf60db7db7b029a5c8b12aac4afd4e8c4eb740430405fa6" + new_stake_share_limit = 200 #2% + new_priority_exit_share_threshold = 250 + new_name = "Solstice" + old_name = "BridgeTower" + old_stake_share_limit = 100 #1% + old_priority_exit_share_threshold = 125 + old_staking_module_fee = 600 + old_treasury_fee = 400 + old_max_deposits_per_block = 30 + old_min_deposit_block_distance = 25 + + # Agent doesn't have MODULE_MANAGER_ROLE + assert csm.hasRole(module_manager_role, agent) == False + + # Public release mode is not active + assert csm.publicRelease() == False + + # Check old data + assert staking_router.getStakingModule(3)["stakeShareLimit"] == old_stake_share_limit + assert staking_router.getStakingModule(3)["priorityExitShareThreshold"] == old_priority_exit_share_threshold + assert staking_router.getStakingModule(3)["stakingModuleFee"] == old_staking_module_fee + assert staking_router.getStakingModule(3)["treasuryFee"] == old_treasury_fee + assert staking_router.getStakingModule(3)["maxDepositsPerBlock"] == old_max_deposits_per_block + assert staking_router.getStakingModule(3)["minDepositBlockDistance"] == old_min_deposit_block_distance + + # Check old name + assert node_operators_registry.getNodeOperator(17, True)["name"] == old_name # START VOTE if len(vote_ids_from_env) > 0: @@ -24,23 +55,33 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") # - # I. Community staking module: limit increase + turn off EA mode + # I. CSM: Enable Permissionless Phase and Increase the Share Limit # - # 2. Activate public release mode + # 2. Activate public release mode on CS Module assert csm.publicRelease() == True - # 4. Increase share from 1% to 2% - assert staking_router.getStakingModule(3)["stakeShareLimit"] == 200 + # 3. Increase stake share limit from 1% to 2% on CS Module + assert staking_router.getStakingModule(3)["stakeShareLimit"] == new_stake_share_limit + assert staking_router.getStakingModule(3)["priorityExitShareThreshold"] == new_priority_exit_share_threshold + assert staking_router.getStakingModule(3)["stakingModuleFee"] == old_staking_module_fee + assert staking_router.getStakingModule(3)["treasuryFee"] == old_treasury_fee + assert staking_router.getStakingModule(3)["maxDepositsPerBlock"] == old_max_deposits_per_block + assert staking_router.getStakingModule(3)["minDepositBlockDistance"] == old_min_deposit_block_distance - # 5. Revoke MODULE_MANAGER_ROLE" - assert csm.hasRole(0x79dfcec784e591aafcf60db7db7b029a5c8b12aac4afd4e8c4eb740430405fa6, contracts.agent) == False + # 4. Revoke MODULE_MANAGER_ROLE on CS Module from Aragon Agent + assert csm.hasRole(module_manager_role, agent) == False # - # II. NO Acquisitions - Bridgetower is now part of Solstice Staking + # II. NO Acquisitions: Bridgetower is now part of Solstice Staking # - # 1. Change name of Bridgetower to Solstice - assert node_operators_registry.getNodeOperator(17, True)["name"] == "Solstice" + # 5. Rename Node Operator ID 17 from BridgeTower to Solstice + assert node_operators_registry.getNodeOperator(17, True)["name"] == new_name # events display_voting_events(vote_tx) evs = group_voting_events(vote_tx) + + metadata = find_metadata_by_vote_id(vote_id) + assert get_lido_vote_cid_from_str(metadata) == "bafkreigbpza6idonsbsbaj2c75hfopkijcjwiz6yomk3cseqki3fj4ctha" + + assert count_vote_items_by_events(vote_tx, contracts.voting) == 5, "Incorrect voting items count" diff --git a/utils/staking_module.py b/utils/staking_module.py index be0e761c..6a408492 100644 --- a/utils/staking_module.py +++ b/utils/staking_module.py @@ -1,5 +1,5 @@ +from brownie import reverts # type: ignore from typing import Dict, Tuple, List, NamedTuple -from brownie import reverts # type: ignore from brownie import convert from web3 import Web3 @@ -30,11 +30,3 @@ def calc_module_reward_shares(module_id, shares_minted_as_fees): module_idx = distribution[1].index(module_id) return distribution[2][module_idx] * shares_minted_as_fees // distribution[3] -def update_staking_module(staking_module_id, stake_share_limit, - priority_exit_share_threshold, staking_module_fee, - treasury_fee, max_deposits_per_block, - min_deposit_block_distance) -> Tuple[str, str]: - return (contracts.staking_router.address, contracts.staking_router.updateStakingModule.encode_input( - staking_module_id, stake_share_limit, priority_exit_share_threshold, staking_module_fee, - treasury_fee, max_deposits_per_block, min_deposit_block_distance - )) From 11540c0745457352b2c96361043cf09422fa02e7 Mon Sep 17 00:00:00 2001 From: skhomuti Date: Thu, 23 Jan 2025 12:18:38 +0500 Subject: [PATCH 08/13] extended csm regression tests fixed minor things --- tests/regression/test_csm.py | 23 +++++++++++++++++++++-- tests/test_vote_2025_01_28.py | 33 +++++++++++++++++---------------- utils/test/csm_helpers.py | 4 ---- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/tests/regression/test_csm.py b/tests/regression/test_csm.py index e6f3f266..8ce2d46a 100644 --- a/tests/regression/test_csm.py +++ b/tests/regression/test_csm.py @@ -43,6 +43,10 @@ def fee_distributor(): def fee_oracle(): return contracts.cs_fee_oracle +@pytest.fixture(scope="module") +def early_adoption(): + return contracts.cs_early_adoption + @pytest.fixture def node_operator(csm, accounting) -> int: @@ -98,8 +102,23 @@ def distribute_reward_tree(node_operator, ref_slot): @pytest.mark.parametrize("address, proof", get_ea_members()) -def test_add_ea_node_operator(csm, accounting, address, proof): - csm_add_node_operator(csm, accounting, address, proof) +def test_add_ea_node_operator(csm, accounting, early_adoption, address, proof): + no_id = csm_add_node_operator(csm, accounting, address, proof) + no = csm.getNodeOperator(no_id) + + assert no['managerAddress'] == address + assert no['rewardAddress'] == address + assert accounting.getBondCurveId(no_id) == early_adoption.CURVE_ID() + + +def test_add_node_operator_permissionless(csm, accounting, accounts): + address = accounts[8].address + no_id = csm_add_node_operator(csm, accounting, address, proof=[]) + no = csm.getNodeOperator(no_id) + + assert no['managerAddress'] == address + assert no['rewardAddress'] == address + assert accounting.getBondCurveId(no_id) == accounting.DEFAULT_BOND_CURVE_ID() @pytest.mark.usefixtures("pause_modules") diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py index 667e53c0..0331bee4 100644 --- a/tests/test_vote_2025_01_28.py +++ b/tests/test_vote_2025_01_28.py @@ -17,6 +17,7 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): node_operators_registry = interface.NodeOperatorsRegistry("0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5") agent = interface.Agent("0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c") module_manager_role = "0x79dfcec784e591aafcf60db7db7b029a5c8b12aac4afd4e8c4eb740430405fa6" + csm_module_id = 3 new_stake_share_limit = 200 #2% new_priority_exit_share_threshold = 250 new_name = "Solstice" @@ -29,18 +30,18 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): old_min_deposit_block_distance = 25 # Agent doesn't have MODULE_MANAGER_ROLE - assert csm.hasRole(module_manager_role, agent) == False + assert csm.hasRole(module_manager_role, agent) is False # Public release mode is not active - assert csm.publicRelease() == False + assert csm.publicRelease() is False # Check old data - assert staking_router.getStakingModule(3)["stakeShareLimit"] == old_stake_share_limit - assert staking_router.getStakingModule(3)["priorityExitShareThreshold"] == old_priority_exit_share_threshold - assert staking_router.getStakingModule(3)["stakingModuleFee"] == old_staking_module_fee - assert staking_router.getStakingModule(3)["treasuryFee"] == old_treasury_fee - assert staking_router.getStakingModule(3)["maxDepositsPerBlock"] == old_max_deposits_per_block - assert staking_router.getStakingModule(3)["minDepositBlockDistance"] == old_min_deposit_block_distance + assert staking_router.getStakingModule(csm_module_id)["stakeShareLimit"] == old_stake_share_limit + assert staking_router.getStakingModule(csm_module_id)["priorityExitShareThreshold"] == old_priority_exit_share_threshold + assert staking_router.getStakingModule(csm_module_id)["stakingModuleFee"] == old_staking_module_fee + assert staking_router.getStakingModule(csm_module_id)["treasuryFee"] == old_treasury_fee + assert staking_router.getStakingModule(csm_module_id)["maxDepositsPerBlock"] == old_max_deposits_per_block + assert staking_router.getStakingModule(csm_module_id)["minDepositBlockDistance"] == old_min_deposit_block_distance # Check old name assert node_operators_registry.getNodeOperator(17, True)["name"] == old_name @@ -58,18 +59,18 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): # I. CSM: Enable Permissionless Phase and Increase the Share Limit # # 2. Activate public release mode on CS Module - assert csm.publicRelease() == True + assert csm.publicRelease() is True # 3. Increase stake share limit from 1% to 2% on CS Module - assert staking_router.getStakingModule(3)["stakeShareLimit"] == new_stake_share_limit - assert staking_router.getStakingModule(3)["priorityExitShareThreshold"] == new_priority_exit_share_threshold - assert staking_router.getStakingModule(3)["stakingModuleFee"] == old_staking_module_fee - assert staking_router.getStakingModule(3)["treasuryFee"] == old_treasury_fee - assert staking_router.getStakingModule(3)["maxDepositsPerBlock"] == old_max_deposits_per_block - assert staking_router.getStakingModule(3)["minDepositBlockDistance"] == old_min_deposit_block_distance + assert staking_router.getStakingModule(csm_module_id)["stakeShareLimit"] == new_stake_share_limit + assert staking_router.getStakingModule(csm_module_id)["priorityExitShareThreshold"] == new_priority_exit_share_threshold + assert staking_router.getStakingModule(csm_module_id)["stakingModuleFee"] == old_staking_module_fee + assert staking_router.getStakingModule(csm_module_id)["treasuryFee"] == old_treasury_fee + assert staking_router.getStakingModule(csm_module_id)["maxDepositsPerBlock"] == old_max_deposits_per_block + assert staking_router.getStakingModule(csm_module_id)["minDepositBlockDistance"] == old_min_deposit_block_distance # 4. Revoke MODULE_MANAGER_ROLE on CS Module from Aragon Agent - assert csm.hasRole(module_manager_role, agent) == False + assert csm.hasRole(module_manager_role, agent) is False # # II. NO Acquisitions: Bridgetower is now part of Solstice Staking diff --git a/utils/test/csm_helpers.py b/utils/test/csm_helpers.py index eb374780..a99bb0be 100644 --- a/utils/test/csm_helpers.py +++ b/utils/test/csm_helpers.py @@ -170,10 +170,6 @@ def csm_upload_keys(csm, accounting, no_id, keys_count=5): def fill_csm_operators_with_keys(target_operators_count, keys_count): - if not contracts.csm.publicRelease(): - contracts.csm.grantRole(contracts.csm.MODULE_MANAGER_ROLE(), contracts.agent, {"from": contracts.agent}) - contracts.csm.activatePublicRelease({"from": contracts.agent}) - csm_node_operators_before = contracts.csm.getNodeOperatorsCount() added_operators_count = 0 for no_id in range(0, min(csm_node_operators_before, target_operators_count)): From 6995d82ea74b382a0d06efe826ce34d18216ccfa Mon Sep 17 00:00:00 2001 From: Arti Date: Fri, 24 Jan 2025 18:47:30 +0100 Subject: [PATCH 09/13] Change the description and follow-up for the comments --- package.json | 3 +-- scripts/vote_2025_01_28.py | 6 ++++-- utils/staking_module.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0dd7c294..ca9ca8b0 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,5 @@ "homepage": "https://mainnet.lido.fi", "dependencies": { "@lido-js/ganache": "=7.9.2-lido" - }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + } } diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py index f956df5d..fea7c38f 100644 --- a/scripts/vote_2025_01_28.py +++ b/scripts/vote_2025_01_28.py @@ -4,7 +4,7 @@ I. CSM: Enable Permissionless Phase and Increase the Share Limit 1. Grant MODULE_MANAGER_ROLE on CS Module to Aragon Agent 2. Activate public release mode on CS Module -3. Increase stake share limit from 1% to 2% on CS Module +3. Increase the stake share limit from 1% to 2% and the priority exit threshold from 1.25% to 2.5% on CS Module 4. Revoke MODULE_MANAGER_ROLE on CS Module from Aragon Agent II. NO Acquisitions: Bridgetower is now part of Solstice Staking @@ -42,6 +42,8 @@ 1. **Transition Community Staking Module to Permissionless Phase** by activating public release and **increasing the share limit** from 1% to 2%, as [approved on Snapshot](https://snapshot.org/#/s:lido-snapshot.eth/proposal/0x7cbd5e9cb95bda9581831daf8b0e72d1ad0b068d2cbd3bda2a2f6ae378464f26). +Alongside the share limit, [it is proposed](https://research.lido.fi/t/community-staking-module/5917/86) to **raise the priority exit share threshold +**from 1.25% to 2.5% to maintain parameter ratios. Items 1-4. 2. **Rename Node Operator ID 17 from BridgeTower to Solstice** @@ -83,7 +85,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ), ), ( - "3. Increase stake share limit from 1% to 2% on CS Module", + "3. Increase the stake share limit from 1% to 2% and the priority exit threshold from 1.25 to 2.5 on CS Module", agent_forward( [ update_staking_module(csm_module_id, new_stake_share_limit, new_priority_exit_share_threshold, diff --git a/utils/staking_module.py b/utils/staking_module.py index 6a408492..b13bdf99 100644 --- a/utils/staking_module.py +++ b/utils/staking_module.py @@ -1,4 +1,4 @@ -from brownie import reverts # type: ignore +from brownie import reverts # type: ignore from typing import Dict, Tuple, List, NamedTuple from brownie import convert from web3 import Web3 From 348e0c41fe8fe881315320432f558ebecf5bbc79 Mon Sep 17 00:00:00 2001 From: Arti Date: Fri, 24 Jan 2025 18:49:37 +0100 Subject: [PATCH 10/13] Fix the test --- tests/test_vote_2025_01_28.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py index 0331bee4..cc4a3db1 100644 --- a/tests/test_vote_2025_01_28.py +++ b/tests/test_vote_2025_01_28.py @@ -83,6 +83,6 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): evs = group_voting_events(vote_tx) metadata = find_metadata_by_vote_id(vote_id) - assert get_lido_vote_cid_from_str(metadata) == "bafkreigbpza6idonsbsbaj2c75hfopkijcjwiz6yomk3cseqki3fj4ctha" + assert get_lido_vote_cid_from_str(metadata) == "bafkreiath3pynqu7vmfb7bsfq2vp6jpqxz54mvfmjp7a6tq3thg6lqvvam" assert count_vote_items_by_events(vote_tx, contracts.voting) == 5, "Incorrect voting items count" From ae907927afd72cc7f3bd63d1ae250457c101289b Mon Sep 17 00:00:00 2001 From: skhomuti Date: Mon, 27 Jan 2025 12:30:23 +0500 Subject: [PATCH 11/13] add tests for uploading keys more than EA limit --- tests/regression/test_csm.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/regression/test_csm.py b/tests/regression/test_csm.py index 8ce2d46a..36bcf429 100644 --- a/tests/regression/test_csm.py +++ b/tests/regression/test_csm.py @@ -121,6 +121,34 @@ def test_add_node_operator_permissionless(csm, accounting, accounts): assert accounting.getBondCurveId(no_id) == accounting.DEFAULT_BOND_CURVE_ID() +def test_add_node_operator_keys_more_than_limit(csm, accounting): + address, proof = get_ea_member() + keys_count = csm.MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE() + 1 + no_id = csm_add_node_operator(csm, accounting, address, proof, keys_count=keys_count) + no = csm.getNodeOperator(no_id) + + assert no["totalAddedKeys"] == keys_count + + +def test_add_node_operator_permissionless_keys_more_than_limit(csm, accounting, accounts): + keys_count = csm.MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE() + 1 + address = accounts[8].address + no_id = csm_add_node_operator(csm, accounting, address, proof=[], keys_count=keys_count) + no = csm.getNodeOperator(no_id) + + assert no["totalAddedKeys"] == keys_count + + +def test_upload_keys_more_than_limit(csm, accounting, node_operator): + no = csm.getNodeOperator(node_operator) + keys_before = no["totalAddedKeys"] + keys_count = csm.MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE() - keys_before + 1 + csm_upload_keys(csm, accounting, node_operator, keys_count) + + no = csm.getNodeOperator(node_operator) + assert no["totalAddedKeys"] == keys_count + keys_before + + @pytest.mark.usefixtures("pause_modules") def test_deposit(node_operator, csm): (_, _, depositable_validators_count) = csm.getStakingModuleSummary() From 90c13fd0306515eef3820ab00ad0f59586dada83 Mon Sep 17 00:00:00 2001 From: Arti Date: Mon, 27 Jan 2025 14:44:39 +0100 Subject: [PATCH 12/13] Add validation for the events; fix the format of the description --- scripts/vote_2025_01_28.py | 15 +++------- tests/test_vote_2025_01_28.py | 30 ++++++++++++++++++- utils/test/event_validators/csm.py | 7 +++++ utils/test/event_validators/staking_router.py | 10 ++++--- 4 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 utils/test/event_validators/csm.py diff --git a/scripts/vote_2025_01_28.py b/scripts/vote_2025_01_28.py index fea7c38f..3f0ad1aa 100644 --- a/scripts/vote_2025_01_28.py +++ b/scripts/vote_2025_01_28.py @@ -39,16 +39,9 @@ from utils.agent import agent_forward description = """ -1. **Transition Community Staking Module to Permissionless Phase** by activating public release -and **increasing the share limit** from 1% to 2%, -as [approved on Snapshot](https://snapshot.org/#/s:lido-snapshot.eth/proposal/0x7cbd5e9cb95bda9581831daf8b0e72d1ad0b068d2cbd3bda2a2f6ae378464f26). -Alongside the share limit, [it is proposed](https://research.lido.fi/t/community-staking-module/5917/86) to **raise the priority exit share threshold -**from 1.25% to 2.5% to maintain parameter ratios. -Items 1-4. - -2. **Rename Node Operator ID 17 from BridgeTower to Solstice** -as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/41). -Item 5. +1. **Transition Community Staking Module to Permissionless Phase** by activating public release and **increasing the share limit** from 1% to 2%, as [approved on Snapshot](https://snapshot.org/#/s:lido-snapshot.eth/proposal/0x7cbd5e9cb95bda9581831daf8b0e72d1ad0b068d2cbd3bda2a2f6ae378464f26). Alongside the share limit, [it is proposed](https://research.lido.fi/t/community-staking-module/5917/86) to **raise the priority exit share threshold **from 1.25% to 2.5% to maintain parameter ratios. Items 1-4. + +2. **Rename Node Operator ID 17 from BridgeTower to Solstice** as [requested on the forum](https://research.lido.fi/t/node-operator-registry-name-reward-address-change/4170/41). Item 5. """ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: @@ -85,7 +78,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ), ), ( - "3. Increase the stake share limit from 1% to 2% and the priority exit threshold from 1.25 to 2.5 on CS Module", + "3. Increase the stake share limit from 1% to 2% and the priority exit threshold from 1.25% to 2.5% on CS Module", agent_forward( [ update_staking_module(csm_module_id, new_stake_share_limit, new_priority_exit_share_threshold, diff --git a/tests/test_vote_2025_01_28.py b/tests/test_vote_2025_01_28.py index cc4a3db1..f68cd0d8 100644 --- a/tests/test_vote_2025_01_28.py +++ b/tests/test_vote_2025_01_28.py @@ -9,6 +9,10 @@ from utils.config import 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.event_validators.csm import validate_public_release_event +from utils.test.event_validators.staking_router import validate_staking_module_update_event, StakingModuleItem +from utils.test.event_validators.node_operators_registry import validate_node_operator_name_set_event, NodeOperatorNameSetItem +from utils.test.event_validators.permission import validate_grant_role_event, validate_revoke_role_event def test_vote(helpers, accounts, vote_ids_from_env, stranger): @@ -83,6 +87,30 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger): evs = group_voting_events(vote_tx) metadata = find_metadata_by_vote_id(vote_id) - assert get_lido_vote_cid_from_str(metadata) == "bafkreiath3pynqu7vmfb7bsfq2vp6jpqxz54mvfmjp7a6tq3thg6lqvvam" + assert get_lido_vote_cid_from_str(metadata) == "bafkreierrixpk7pszth7pkgau7iyhb4mxolskst62oyfat3ltfrnh355ty" assert count_vote_items_by_events(vote_tx, contracts.voting) == 5, "Incorrect voting items count" + + # validate events + validate_grant_role_event(evs[0], module_manager_role, agent.address, agent.address) + + validate_public_release_event(evs[1]) + + expected_staking_module_item = StakingModuleItem( + id=csm_module_id, + name="Community Staking", + address=None, + target_share=new_stake_share_limit, + module_fee=old_staking_module_fee, + treasury_fee=old_treasury_fee, + ) + + validate_staking_module_update_event(evs[2], expected_staking_module_item) + + validate_revoke_role_event(evs[3], module_manager_role, agent.address, agent.address) + + expected_node_operator_item = NodeOperatorNameSetItem( + nodeOperatorId=17, + name="Solstice", + ) + validate_node_operator_name_set_event(evs[4], expected_node_operator_item) diff --git a/utils/test/event_validators/csm.py b/utils/test/event_validators/csm.py new file mode 100644 index 00000000..05a6b04c --- /dev/null +++ b/utils/test/event_validators/csm.py @@ -0,0 +1,7 @@ +from brownie.network.event import EventDict +from .common import validate_events_chain + +def validate_public_release_event(event: EventDict): + _events_chain = ['LogScriptCall', 'LogScriptCall', 'PublicRelease', 'ScriptResult'] + validate_events_chain([e.name for e in event], _events_chain) + assert event.count("PublicRelease") == 1 diff --git a/utils/test/event_validators/staking_router.py b/utils/test/event_validators/staking_router.py index 8ebc9c77..355fe8cb 100644 --- a/utils/test/event_validators/staking_router.py +++ b/utils/test/event_validators/staking_router.py @@ -53,18 +53,20 @@ def validate_staking_module_update_event(event: EventDict, module_item: StakingM _events_chain = [ "LogScriptCall", "LogScriptCall", - "StakingModuleTargetShareSet", + "StakingModuleShareLimitSet", "StakingModuleFeesSet", + "StakingModuleMaxDepositsPerBlockSet", + "StakingModuleMinDepositBlockDistanceSet", "ScriptResult", ] validate_events_chain([e.name for e in event], _events_chain) - assert event.count("StakingModuleTargetShareSet") == 1 + assert event.count("StakingModuleShareLimitSet") == 1 assert event.count("StakingModuleFeesSet") == 1 - assert event["StakingModuleTargetShareSet"]["stakingModuleId"] == module_item.id - assert event["StakingModuleTargetShareSet"]["targetShare"] == module_item.target_share + assert event["StakingModuleShareLimitSet"]["stakingModuleId"] == module_item.id + assert event["StakingModuleShareLimitSet"]["stakeShareLimit"] == module_item.target_share assert event["StakingModuleFeesSet"]["stakingModuleId"] == module_item.id assert event["StakingModuleFeesSet"]["stakingModuleFee"] == module_item.module_fee From c161123dd19000be55fb6ff149436883fc41b86e Mon Sep 17 00:00:00 2001 From: Arti Date: Mon, 27 Jan 2025 16:49:56 +0100 Subject: [PATCH 13/13] Remove unnecessary import from utils/staking_module --- utils/staking_module.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/staking_module.py b/utils/staking_module.py index b13bdf99..daaf5813 100644 --- a/utils/staking_module.py +++ b/utils/staking_module.py @@ -1,5 +1,4 @@ from brownie import reverts # type: ignore -from typing import Dict, Tuple, List, NamedTuple from brownie import convert from web3 import Web3