Skip to content

Commit

Permalink
fix tests for correct events when forward agent node renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalgek committed Oct 31, 2023
1 parent 36dc722 commit 616b3b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 40 deletions.
37 changes: 12 additions & 25 deletions scripts/vote_2023_10_31.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand All @@ -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
Expand All @@ -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]:
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 4 additions & 14 deletions tests/test_2023_10_31.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/test/event_validators/node_operators_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 616b3b3

Please sign in to comment.