-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from lidofinance/vote_2023_09_12
Vote 2023-09-12
- Loading branch information
Showing
8 changed files
with
392 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
""" | ||
Voting 164 12/09/2023 | ||
Vote REJECTED | ||
""" | ||
|
||
import time | ||
|
||
from typing import Dict | ||
|
||
from brownie.network.transaction import TransactionReceipt | ||
from brownie import web3, interface # type: ignore | ||
from utils.agent import agent_forward | ||
|
||
from utils.voting import bake_vote_items, confirm_vote_script, create_vote | ||
|
||
from utils.config import ( | ||
get_deployer_account, | ||
get_is_live, | ||
get_priority_fee, | ||
contracts, | ||
) | ||
|
||
from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description | ||
|
||
description = """ | ||
The proposal is to support **Jump Crypto voluntarily exits from the validator set** by setting `targetValidatorsCount` to 0. | ||
Algorithm would prioritise exiting Jump Crypto validators in order to fulfil users' withdrawals requests. | ||
Jump Crypto request on [forum](https://research.lido.fi/t/lido-dao-proposal-to-set-targetvalidatorscount-for-jump-crypto-operator-to-0-to-wind-down-the-jump-crypto-legacy-set/5259). | ||
""" | ||
|
||
|
||
def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: | ||
"""Prepare and run voting.""" | ||
|
||
# contracts.node_operators_registry.getNodeOperator(1, True) | ||
JUMP_CRYPTO_ID = 1 | ||
# web3.keccak(text="STAKING_MODULE_MANAGE_ROLE") | ||
STAKING_MODULE_MANAGE_ROLE = "0x3105bcbf19d4417b73ae0e58d508a65ecf75665e46c2622d8521732de6080c48" | ||
|
||
call_script_items = [ | ||
# 1. Support **Jump Crypto voluntarily exits from the validator set** by setting `targetValidatorsCount` to 0. | ||
## 1) Grant STAKING_MODULE_MANAGE_ROLE to Lido Agent | ||
agent_forward( | ||
[ | ||
( | ||
contracts.staking_router.address, | ||
contracts.staking_router.grantRole.encode_input( | ||
STAKING_MODULE_MANAGE_ROLE, contracts.agent.address | ||
), | ||
) | ||
] | ||
), | ||
## 2) Set Jump Crypto targetValidatorsCount to 0 | ||
agent_forward( | ||
[ | ||
( | ||
contracts.staking_router.address, | ||
contracts.staking_router.updateTargetValidatorsLimits.encode_input(1, JUMP_CRYPTO_ID, True, 0), | ||
) | ||
] | ||
), | ||
] | ||
|
||
vote_desc_items = [ | ||
f"1) Grant STAKING_MODULE_MANAGE_ROLE to Lido Agent", | ||
f"2) Set Jump Crypto targetValidatorsLimits to 0", | ||
] | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
""" | ||
Tests for voting 12/09/2023 | ||
""" | ||
from archive.scripts.vote_2023_09_12 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.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, | ||
bypass_events_decoding, | ||
vote_ids_from_env, | ||
accounts, | ||
): | ||
# params | ||
agent = contracts.agent | ||
nor = contracts.node_operators_registry | ||
staking_router = contracts.staking_router | ||
target_NO_id = 1 | ||
target_validators_count_change_request = TargetValidatorsCountChanged( | ||
nodeOperatorId=target_NO_id, targetValidatorsCount=0 | ||
) | ||
|
||
# web3.keccak(text="STAKING_MODULE_MANAGE_ROLE") | ||
STAKING_MODULE_MANAGE_ROLE = "0x3105bcbf19d4417b73ae0e58d508a65ecf75665e46c2622d8521732de6080c48" | ||
|
||
# 1) | ||
assert staking_router.hasRole(STAKING_MODULE_MANAGE_ROLE, agent.address) == False | ||
|
||
# 2) | ||
NO_summary_before = nor.getNodeOperatorSummary(target_NO_id) | ||
assert NO_summary_before[0] == False | ||
assert NO_summary_before[1] == 0 | ||
assert NO_summary_before[2] == 0 | ||
assert NO_summary_before[3] == 0 | ||
assert NO_summary_before[4] == 0 | ||
assert NO_summary_before[5] == 0 | ||
assert NO_summary_before[6] == 1000 | ||
assert NO_summary_before[7] == 0 | ||
|
||
# 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}") | ||
|
||
# validate vote events | ||
assert count_vote_items_by_events(vote_tx, contracts.voting) == 2, "Incorrect voting items count" | ||
|
||
metadata = find_metadata_by_vote_id(vote_id) | ||
|
||
assert get_lido_vote_cid_from_str(metadata) == "bafkreiapvuobyrudww3oqhfopbs2fdmtebi6jnvpeb3plxkajnhafw25im" | ||
# 1) | ||
assert staking_router.hasRole(STAKING_MODULE_MANAGE_ROLE, agent.address) == True | ||
|
||
# 2) | ||
NO_summary_after = nor.getNodeOperatorSummary(target_NO_id) | ||
assert NO_summary_after[0] == True | ||
assert NO_summary_after[1] == 0 | ||
assert NO_summary_after[2] == 0 | ||
assert NO_summary_after[3] == 0 | ||
assert NO_summary_after[4] == 0 | ||
assert NO_summary_after[5] == 0 | ||
assert NO_summary_after[6] == 1000 | ||
assert NO_summary_after[7] == 0 | ||
|
||
if bypass_events_decoding or network_name() in ("goerli", "goerli-fork"): | ||
return | ||
|
||
evs = group_voting_events(vote_tx) | ||
|
||
validate_grant_role_event(evs[0], STAKING_MODULE_MANAGE_ROLE, agent.address, agent.address) | ||
|
||
validate_target_validators_count_changed_event(evs[1], target_validators_count_change_request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.