Skip to content

Commit

Permalink
feat: voting tests before pectra
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Jan 20, 2025
1 parent c8501b8 commit 5e411c6
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configs/config_holesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@
CS_GATE_SEAL_ADDRESS = "0x41F2677fae0222cF1f08Cd1c0AAa607B469654Ce"
CS_VERIFIER_ADDRESS = "0xE044427930C166670f5dd84E9154A874c4759310"
CS_ORACLE_EPOCHS_PER_FRAME = 225 * 7 # 7 days
CS_VERIFIER_ADDRESS_OLD = "0x6DcA479178E6Ae41CCEB72a88FfDaa3e10E83CB7"
CS_VERIFIER_ADDRESS_OLD = "0x6FDAA094227CF8E1593f9fB9C1b867C1f846F916"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> Tuple[int, Optional[T
),
),
(
"10. Revoke VERIFIER_ROLE role on CSM from Aragon Agent",
"10. Revoke VERIFIER_ROLE role on CSM from old CS Verifier",
agent_forward(
[
encode_oz_revoke_role(
Expand All @@ -174,7 +174,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> Tuple[int, Optional[T
),
),
(
"11. Grant VERIFIER_ROLE role on CSM to Aragon Agent",
"11. Grant VERIFIER_ROLE role on CSM to new CS Verifier",
agent_forward(
[
encode_oz_grant_role(
Expand Down
170 changes: 170 additions & 0 deletions tests/test_before_pectra_upgrade_holesky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
from scripts.before_pectra_upgrade_holesky import start_vote
from utils.config import LDO_HOLDER_ADDRESS_FOR_TESTS
from brownie import interface
from utils.test.tx_tracing_helpers import *
from utils.test.event_validators.permission import validate_grant_role_event, validate_revoke_role_event
from utils.test.event_validators.common import validate_events_chain

# Contracts
AGENT = "0xE92329EC7ddB11D25e25b3c21eeBf11f15eB325d"
VALIDATORS_EXIT_BUS_ORACLE = "0xffDDF7025410412deaa05E3E1cE68FE53208afcb"
ACCOUNTING_ORACLE = "0x4E97A3972ce8511D87F334dA17a2C332542a5246"
CS_FEE_ORACLE = "0xaF57326C7d513085051b50912D51809ECC5d98Ee"
VOTING = "0xdA7d2573Df555002503F29aA4003e398d28cc00f"
CS_VERIFIER_ADDRESS = "0xE044427930C166670f5dd84E9154A874c4759310"
CS_VERIFIER_ADDRESS_OLD = "0x6FDAA094227CF8E1593f9fB9C1b867C1f846F916"
CSM_ADDRESS = "0x4562c3e63c2e586cD1651B958C22F88135aCAd4f"

# Roles
MANAGE_CONSENSUS_VERSION_ROLE = "0xc31b1e4b732c5173dc51d519dfa432bad95550ecc4b0f9a61c2a558a2a8e4341"
VERIFIER_ROLE = "0x0ce23c3e399818cfee81a7ab0880f714e53d7672b08df0fa62f2843416e1ea09"


# New values

# Accounting oracle
AO_CONSENSUS_VERSION = 3
# Vebo
VEBO_CONSENSUS_VERSION = 3
# CS Fee oracle
CS_FEE_ORACLE_CONSENSUS_VERSION = 2


def get_vebo():
return interface.ValidatorsExitBusOracle(VALIDATORS_EXIT_BUS_ORACLE)


def get_ao():
return interface.AccountingOracle(ACCOUNTING_ORACLE)


def get_cs_fee_oracle():
return interface.CSFeeOracle(CS_FEE_ORACLE)


def get_voting():
return interface.Voting(VOTING)


def get_csm():
return interface.CSModule(CSM_ADDRESS)


def check_aragon_doesnt_have_manage_consensus_role_on_oracle(oracle):
agent_has_manage_consensus_role = oracle.hasRole(MANAGE_CONSENSUS_VERSION_ROLE, AGENT)
assert not agent_has_manage_consensus_role


def test_vote(helpers, accounts, vote_ids_from_env, bypass_events_decoding):
vebo = get_vebo()
ao = get_ao()
cs_fee_oracle = get_cs_fee_oracle()
csm = get_csm()

# Before voting tests
# 1),3) Aragon agent doesnt have MANAGE_CONSENSUS_VERSION_ROLE on AO
check_aragon_doesnt_have_manage_consensus_role_on_oracle(ao)
# 2) Accounting Oracle consensus version equals to 2 before voting
assert ao.getConsensusVersion() == 2
# 4),6) Aragon agent doesnt have MANAGE_CONSENSUS_VERSION_ROLE on Vebo
check_aragon_doesnt_have_manage_consensus_role_on_oracle(vebo)
# 5) Vebo consensus version equals to 2 before voting
assert vebo.getConsensusVersion() == 2
# 7),9) Aragon agent doesnt have MANAGE_CONSENSUS_VERSION_ROLE on CS Fee oracle
check_aragon_doesnt_have_manage_consensus_role_on_oracle(cs_fee_oracle)
# 8) Update vebo consensus version equals to 1
assert cs_fee_oracle.getConsensusVersion() == 1
# 10) Old CS Verifier has VERIFIER_ROLE role on CSM before voting
assert csm.hasRole(VERIFIER_ROLE, CS_VERIFIER_ADDRESS_OLD)
# 11) New CS Verifier doesnt have VERIFIER_ROLE role on CSM before voting
assert not csm.hasRole(VERIFIER_ROLE, CS_VERIFIER_ADDRESS)

# 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)

voting = get_voting()

vote_tx = helpers.execute_vote(accounts, vote_id, voting)

print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}")

# After voting tests
# 1),3) Aragon agent doesnt have MANAGE_CONSENSUS_VERSION_ROLE on AO
check_aragon_doesnt_have_manage_consensus_role_on_oracle(ao)
# 2) Accounting Oracle consensus version equals to 3 after voting
assert ao.getConsensusVersion() == 3
# 4),6) Aragon agent doesnt have MANAGE_CONSENSUS_VERSION_ROLE on Vebo
check_aragon_doesnt_have_manage_consensus_role_on_oracle(vebo)
# 5) Vebo consensus version equals to 3 after voting
assert vebo.getConsensusVersion() == 3
# 7),9) Aragon agent doesnt have MANAGE_CONSENSUS_VERSION_ROLE on CS Fee oracle
check_aragon_doesnt_have_manage_consensus_role_on_oracle(cs_fee_oracle)
# 8) Update vebo consensus version equals to 2 after voting
assert cs_fee_oracle.getConsensusVersion() == 2
# 10) Old CS Verifier has VERIFIER_ROLE role on CSM after voting
assert not csm.hasRole(VERIFIER_ROLE, CS_VERIFIER_ADDRESS_OLD)
# 11) New CS Verifier doesn't have VERIFIER_ROLE role on CSM after voting
assert csm.hasRole(VERIFIER_ROLE, CS_VERIFIER_ADDRESS)

# check verifier epoch

# Events check
display_voting_events(vote_tx)
events = group_voting_events(vote_tx)

assert len(events) == 11

# Validate ao consensus version set
validate_consensus_version_update(events[:3], ACCOUNTING_ORACLE, AO_CONSENSUS_VERSION)

# Validate vebo consensus version set
validate_consensus_version_update(events[3:6], VALIDATORS_EXIT_BUS_ORACLE, VEBO_CONSENSUS_VERSION)

# Validate CS Fee Oracle consensus version set
validate_consensus_version_update(events[6:9], CS_FEE_ORACLE, CS_FEE_ORACLE_CONSENSUS_VERSION)

# Validate VERIFIER_ROLE role revoke from CS_VERIFIER_ADDRESS_OLD
validate_revoke_role_event(
events[9],
VERIFIER_ROLE,
CS_VERIFIER_ADDRESS_OLD,
AGENT,
)

# Validate VERIFIER_ROLE role grant to CS_VERIFIER_ADDRESS_OLD
validate_grant_role_event(
events[10],
VERIFIER_ROLE,
CS_VERIFIER_ADDRESS,
AGENT,
)


# Events check


def validate_consensus_version_update(events: list[EventDict], oracle_address, version):
print(f"events: {events}")
validate_grant_role_event(
events[0],
MANAGE_CONSENSUS_VERSION_ROLE,
AGENT,
AGENT,
)
validate_consensus_version_set(events[1], version)
validate_revoke_role_event(
events[2],
MANAGE_CONSENSUS_VERSION_ROLE,
AGENT,
AGENT,
)


def validate_consensus_version_set(event: EventDict, version):
_events_chain = ["LogScriptCall", "LogScriptCall", "ConsensusVersionSet", "ScriptResult"]
validate_events_chain([e.name for e in event], _events_chain)
assert event["ConsensusVersionSet"]["version"] == version

0 comments on commit 5e411c6

Please sign in to comment.