Skip to content

Commit 2a6c5e8

Browse files
committed
feat: add tw vote
1 parent 27ba48a commit 2a6c5e8

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

scripts/__init__.py

Whitespace-only changes.

scripts/triggerable_withdrawals/__init__.py

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
TW_DESCRIPTION = "Proposal to use TW in Lido protocol"
2+
3+
## Oracle consensus versions
4+
AO_CONSENSUS_VERSION = 4
5+
VEBO_CONSENSUS_VERSION = 4
6+
7+
VALIDATORS_EXIT_BUS_ORACLE_IMPL = '0x0' # ToDo add deployed address
8+
WITHDRAWAL_VAULT_IMPL = '0x0'
9+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
try:
2+
from brownie import interface, accounts, TransactionReceipt
3+
except ImportError:
4+
print("You're probably running inside Brownie console. Please call:")
5+
print("set_console_globals(interface=interface)")
6+
7+
8+
from typing import Dict, Tuple, Optional
9+
from utils.config import contracts
10+
from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description
11+
from utils.permissions import encode_oz_grant_role
12+
from utils.voting import bake_vote_items, confirm_vote_script, create_vote
13+
14+
from utils.agent import agent_forward
15+
16+
from scripts.triggerable_withdrawals import variables
17+
18+
19+
def encode_proxy_upgrade_to(proxy: interface.Contract, implementation: str) -> Tuple[str, str]:
20+
proxy = interface.OssifiableProxy(proxy)
21+
return proxy.address, proxy.proxy__upgradeTo.encode_input(implementation)
22+
23+
24+
def encode_oracle_upgrade_consensus(proxy: interface.Contract, consensus_version: int) -> Tuple[str, str]:
25+
oracle = interface.BaseOracle(proxy)
26+
return oracle.address, oracle.setConsensusVersion.encode_input(consensus_version)
27+
28+
29+
def create_tw_vote(tx_params: Dict[str, str], silent: bool) -> Tuple[int, Optional[TransactionReceipt]]:
30+
"""
31+
Triggerable withdrawals voting baking and sending.
32+
33+
Contains next steps:
34+
1. Update VEBO implementation
35+
2. Update VEBO consensu version to `4`
36+
# 3. Call finalize upgrade on VEBO # TODO
37+
4. Update WithdrawalVault implementation
38+
5. Grant ADD_FULL_WITHDRAWAL_REQUEST_ROLE to the VEBO in WithdrawalVault
39+
6. Update AO consensus version to `4`
40+
"""
41+
42+
vote_descriptions, call_script_items = zip(
43+
(
44+
"1. Update VEBO implementation",
45+
agent_forward([
46+
encode_proxy_upgrade_to(contracts.validator_exit_bus_oracle, variables.VALIDATORS_EXIT_BUS_ORACLE_IMPL)
47+
])
48+
),
49+
(
50+
"2. Update VEBO consensu version to `4`",
51+
agent_forward([
52+
encode_oracle_upgrade_consensus(contracts.validator_exit_bus_oracle, variables.VEBO_CONSENSUS_VERSION)
53+
])
54+
),
55+
# (
56+
# "3. Call finalize upgrade on VEBO",
57+
# agent_forward([
58+
# TODO
59+
# ])
60+
# ),
61+
(
62+
"4. Update WithdrawalVault implementation",
63+
agent_forward([
64+
encode_proxy_upgrade_to(contracts.withdrawal_vault, variables.WITHDRAWAL_VAULT_IMPL)
65+
])
66+
),
67+
(
68+
"5. Grant ADD_FULL_WITHDRAWAL_REQUEST_ROLE to the VEBO in WithdrawalVault",
69+
agent_forward([
70+
encode_oz_grant_role(
71+
contract=contracts.WithdrawalVault,
72+
role_name="ADD_FULL_WITHDRAWAL_REQUEST_ROLE",
73+
grant_to=contracts.validator_exit_bus_oracle,
74+
)
75+
])
76+
),
77+
(
78+
"6. Update AO consensus version to `4`",
79+
agent_forward([
80+
encode_oracle_upgrade_consensus(contracts.accounting_oracle, variables.AO_CONSENSUS_VERSION)
81+
])
82+
),
83+
)
84+
85+
vote_items = bake_vote_items(list(vote_descriptions), list(call_script_items))
86+
87+
if silent:
88+
desc_ipfs = calculate_vote_ipfs_description(variables.TW_DESCRIPTION)
89+
else:
90+
desc_ipfs = upload_vote_ipfs_description(variables.TW_DESCRIPTION)
91+
92+
assert confirm_vote_script(vote_items, silent, desc_ipfs), 'Vote not confirmed.'
93+
94+
return create_vote(vote_items, tx_params, desc_ipfs=desc_ipfs)

scripts/tw_vote.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from scripts.triggerable_withdrawals.vote_body import create_tw_vote
2+
from utils.config import get_deployer_account, get_priority_fee
3+
4+
5+
def main():
6+
print('Start baking vote.')
7+
8+
tx_params = {
9+
"from": get_deployer_account(),
10+
"priority_fee": get_priority_fee(),
11+
}
12+
13+
vote_id, _ = create_tw_vote(tx_params=tx_params, silent=True)
14+
15+
if vote_id:
16+
print(f'Vote [{vote_id}] created.')
17+

0 commit comments

Comments
 (0)