|
| 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) |
0 commit comments