Skip to content

Commit

Permalink
feat: pectra devnet4 voting script
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Dec 19, 2024
1 parent 0aa3f1a commit df1c4a7
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 4 deletions.
5 changes: 2 additions & 3 deletions brownie-config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
dependencies:
# we're using 4.0.0 since we don't need proxy beacon logic from 4.1.0
- OpenZeppelin/[email protected]

networks:
default: mainnet-fork
default: devnet4
development:
priority_fee: auto
live:
Expand All @@ -12,4 +11,4 @@ networks:
autofetch_sources: true

hypothesis:
max_examples: 10
max_examples: 10
12 changes: 12 additions & 0 deletions network-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ development:
timeout: 360
# https://github.com/mds1/multicall#multicall2-contract-addresses
multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696"

- cmd: ./ganache.sh
cmd_settings:
accounts: 10
chain_id: 32382
gas_limit: 30000000
mnemonic: brownie
port: 56136
host: http://127.0.0.1
id: devnet4
name: Devnet4
timeout: 360
311 changes: 311 additions & 0 deletions scripts/pectra_upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
"""
Pectra upgrade
1. Grant role `EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE` role to Aragon Agent on `OracleReportSanityChecker` contract
2. Set `exitedValidatorsPerDayLimit` sanity checker parameter to 1800
3. Grant role `APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE` role to Aragon Agent on `OracleReportSanityChecker` contract
4. Set `appearedValidatorsPerDayLimit` sanity checker parameter to 1800
5. Grant role `INITIAL_SLASHING_AND_PENALTIES_MANAGER_ROLE` role to Aragon Agent on `OracleReportSanityChecker` contract
6. Set `initialSlashingAmountPWei` sanity checker parameter to 8
7. Grant MANAGE_CONSENSUS_VERSION_ROLE role on Accounting Oracle to Aragon Agent
8. Update Accounting Oracle consensus version to 3
9. Revoke MANAGE_CONSENSUS_VERSION_ROLE role on Accounting Oracle from Aragon Agent
10. Grant MANAGE_CONSENSUS_VERSION_ROLE role on Validator Exit Bus Oracle to Aragon Agent
11. Update Validator Exit Bus Oracle consensus version to 3
12. Revoke MANAGE_CONSENSUS_VERSION_ROLE role on Validator Exit Bus Oracle from Aragon Agent
13. Grant MANAGE_CONSENSUS_VERSION_ROLE role on CSFeeOracle to Aragon Agent
14. Update CSFeeOracle consensus version to 2
15. Revoke MANAGE_CONSENSUS_VERSION_ROLE role on CSFeeOracle from Aragon Agent
16. Revoke VERIFIER_ROLE role on CSM from old CS Verifier
17. Grant VERIFIER_ROLE role on CSM to new CS Verifier
"""

import time

try:
from brownie import interface, accounts
except ImportError:
print("You're probably running inside Brownie console. Please call:")
print("set_console_globals(interface=interface)")


from typing import Dict, Tuple, Optional
from utils.config import (
get_deployer_account,
get_is_live,
get_priority_fee,
contracts,
AO_CONSENSUS_VERSION,
VEBO_CONSENSUS_VERSION,
)
from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description
from utils.permissions import encode_oz_grant_role, encode_oz_revoke_role
from utils.voting import bake_vote_items, confirm_vote_script, create_vote

from brownie.network.transaction import TransactionReceipt
from utils.agent import agent_forward
from utils.mainnet_fork import pass_and_exec_dao_vote

# Oracle sanity checker params

NEW_INITIAL_SLASHING_AMOUNT_PWEI = 8
UNCHANGED_INACTIVITY_PENATIES_AMOUNT_PWEI = 101
NEW_EXITED_VALIDATORS_PER_DAY_LIMIT = 1800
NEW_APPEARED_VALIDATORS_PER_DAY_LIMIT = 1800

# Consensus version

AO_CONSENSUS_VERSION = 3
VEBO_CONSENSUS_VERSION = 3
CS_FEE_ORACLE_CONSENSUS_VERSION = 2

# CSM

CS_VERIFIER_OLD = ""

description = """
Release Pectra updates
"""


def encode_ao_set_consensus_version() -> Tuple[str, str]:
proxy = contracts.accounting_oracle
return proxy.address, proxy.setConsensusVersion.encode_input(AO_CONSENSUS_VERSION)


def encode_vebo_set_consensus_version() -> Tuple[str, str]:
proxy = contracts.validators_exit_bus_oracle
return proxy.address, proxy.setConsensusVersion.encode_input(VEBO_CONSENSUS_VERSION)


def encode_cs_fee_oracle_set_consensus_version() -> Tuple[str, str]:
proxy = contracts.cs_fee_oracle
return proxy.address, proxy.setConsensusVersion.encode_input(CS_FEE_ORACLE_CONSENSUS_VERSION)


def start_vote(tx_params: Dict[str, str], silent: bool) -> Tuple[int, Optional[TransactionReceipt]]:
"""Prepare and run voting."""

vote_desc_items, call_script_items = zip(
(
"1) Grant role `EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE` role to Aragon Agent on `OracleReportSanityChecker` contract",
agent_forward(
[
encode_oz_grant_role(
contract=contracts.oracle_report_sanity_checker,
role_name="EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE",
grant_to=contracts.agent,
)
]
),
),
(
"2) Set `exitedValidatorsPerDayLimit` sanity checker parameter to 1800",
agent_forward(
[
(
contracts.oracle_report_sanity_checker.address,
contracts.oracle_report_sanity_checker.setExitedValidatorsPerDayLimit.encode_input(
NEW_EXITED_VALIDATORS_PER_DAY_LIMIT
),
),
]
),
),
(
"3) Grant role `APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE` role to Aragon Agent on `OracleReportSanityChecker` contract",
agent_forward(
[
encode_oz_grant_role(
contract=contracts.oracle_report_sanity_checker,
role_name="APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE",
grant_to=contracts.agent,
)
]
),
),
(
"4) Set `appearedValidatorsPerDayLimit` sanity checker parameter to 1800",
agent_forward(
[
(
contracts.oracle_report_sanity_checker.address,
contracts.oracle_report_sanity_checker.setAppearedValidatorsPerDayLimit.encode_input(
NEW_APPEARED_VALIDATORS_PER_DAY_LIMIT
),
),
]
),
),
(
"5) Grant role `INITIAL_SLASHING_AND_PENALTIES_MANAGER_ROLE` role to Aragon Agent on `OracleReportSanityChecker` contract",
agent_forward(
[
encode_oz_grant_role(
contract=contracts.oracle_report_sanity_checker,
role_name="INITIAL_SLASHING_AND_PENALTIES_MANAGER_ROLE",
grant_to=contracts.agent,
)
]
),
),
(
"6) Set `initialSlashingAmountPWei` sanity checker parameter to 8",
agent_forward(
[
(
contracts.oracle_report_sanity_checker.address,
contracts.oracle_report_sanity_checker.setInitialSlashingAndPenaltiesAmount.encode_input(
NEW_INITIAL_SLASHING_AMOUNT_PWEI,
UNCHANGED_INACTIVITY_PENATIES_AMOUNT_PWEI,
),
),
]
),
),
(
"7. Grant MANAGE_CONSENSUS_VERSION_ROLE role on Accounting Oracle to Aragon Agent",
agent_forward(
[
encode_oz_grant_role(
contract=contracts.accounting_oracle,
role_name="MANAGE_CONSENSUS_VERSION_ROLE",
grant_to=contracts.agent,
)
]
),
),
(
"8. Update Accounting Oracle consensus version to 3",
agent_forward([encode_ao_set_consensus_version()]),
),
(
"9. Revoke MANAGE_CONSENSUS_VERSION_ROLE role on Accounting Oracle from Aragon Agent",
agent_forward(
[
encode_oz_revoke_role(
contract=contracts.accounting_oracle,
role_name="MANAGE_CONSENSUS_VERSION_ROLE",
revoke_from=contracts.agent,
)
]
),
),
(
"10. Grant MANAGE_CONSENSUS_VERSION_ROLE role on Validator Exit Bus Oracle to Aragon Agent",
agent_forward(
[
encode_oz_grant_role(
contract=contracts.validators_exit_bus_oracle,
role_name="MANAGE_CONSENSUS_VERSION_ROLE",
grant_to=contracts.agent,
)
]
),
),
(
"11. Update Validator Exit Bus Oracle consensus version to 3",
agent_forward([encode_vebo_set_consensus_version()]),
),
(
"12. Revoke MANAGE_CONSENSUS_VERSION_ROLE role on Validator Exit Bus Oracle from Aragon Agent",
agent_forward(
[
encode_oz_revoke_role(
contract=contracts.validators_exit_bus_oracle,
role_name="MANAGE_CONSENSUS_VERSION_ROLE",
revoke_from=contracts.agent,
)
]
),
),
(
"13. Grant MANAGE_CONSENSUS_VERSION_ROLE role on CSFeeOracle to Aragon Agent",
agent_forward(
[
encode_oz_grant_role(
contract=contracts.cs_fee_oracle,
role_name="MANAGE_CONSENSUS_VERSION_ROLE",
grant_to=contracts.agent,
)
]
),
),
(
"14. Update CSFeeOracle consensus version to 3",
agent_forward([encode_cs_fee_oracle_set_consensus_version()]),
),
(
"15. Revoke MANAGE_CONSENSUS_VERSION_ROLE role on Validator Exit Bus Oracle from Aragon Agent",
agent_forward(
[
encode_oz_revoke_role(
contract=contracts.cs_fee_oracle,
role_name="MANAGE_CONSENSUS_VERSION_ROLE",
revoke_from=contracts.agent,
)
]
),
),
# (
# "16. Revoke VERIFIER_ROLE role on CSM from Aragon Agent",
# agent_forward(
# [
# encode_oz_revoke_role(
# contract=contracts.csm,
# role_name="VERIFIER_ROLE",
# revoke_from=CS_VERIFIER_OLD,
# )
# ]
# ),
# ),
# (
# "17. Grant VERIFIER_ROLE role on CSM to Aragon Agent",
# agent_forward(
# [
# encode_oz_grant_role(
# contract=contracts.csm,
# role_name="VERIFIER_ROLE",
# grant_to=contracts.cs_verifier,
# )
# ]
# ),
# ),
)

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.


def start_and_execute_vote_on_fork():
if get_is_live():
raise Exception("This script is for local testing only.")

tx_params = {"from": get_deployer_account()}
vote_id, _ = start_vote(tx_params=tx_params, silent=True)

time.sleep(5) # hack for waiting thread #2.

print(f"Vote created: {vote_id}.")
pass_and_exec_dao_vote(int(vote_id))
9 changes: 8 additions & 1 deletion utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def network_name() -> Optional[str]:
elif network_name() in ("sepolia", "sepolia-fork"):
print(f'Using {color("yellow")}config_sepolia.py{color} addresses')
from configs.config_sepolia import *
elif network_name() in ("devnet4"):
print(f'Using {color("yellow")}config_devnet4.py{color} addresses')
from configs.config_devnet4 import *
else:
print(f'Using {color("magenta")}config_mainnet.py{color} addresses')
from configs.config_mainnet import *
Expand All @@ -61,21 +64,24 @@ def get_priority_fee() -> str:
else:
return "2 gwei"


def get_max_fee() -> str:
if "OMNIBUS_MAX_FEE" in os.environ:
return os.environ["OMNIBUS_MAX_FEE"]
else:
return "300 gwei"


def local_deployer() -> LocalAccount:
"""
Local deployer can ONLY be used for the local run.
"""
deployer = accounts[4]
agent = accounts.at(AGENT, force=True)

if web3.eth.get_balance(agent.address) < 10 * 10 ** 18:
if web3.eth.get_balance(agent.address) < 10 * 10**18:
from utils.balance import set_balance

set_balance(agent.address, 10)

interface.MiniMeToken(LDO_TOKEN).transfer(deployer, 10**18, {"from": agent})
Expand Down Expand Up @@ -391,6 +397,7 @@ def trp_escrow_factory(self) -> interface.VestingEscrowFactory:
def token_rate_notifier(self) -> interface.TokenRateNotifier:
return interface.TokenRateNotifier(L1_TOKEN_RATE_NOTIFIER)


def __getattr__(name: str) -> Any:
if name == "contracts":
return ContractsLazyLoader()
Expand Down

0 comments on commit df1c4a7

Please sign in to comment.