-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/master' into fix/us…
…e-actual-validator-index # Conflicts: # tests/acceptance/test_veb_negative.py # tests/regression/test_validator_exit_bus_happy_path.py
- Loading branch information
Showing
45 changed files
with
5,646 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
Fallback voting xx/xx/2024. | ||
1. Enable deposits on Optimism L1 Token Bridge | ||
""" | ||
import time | ||
from brownie import interface | ||
from typing import Dict | ||
from brownie.network.transaction import TransactionReceipt | ||
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.agent import agent_forward | ||
from utils.config import ( | ||
get_deployer_account, | ||
get_is_live, | ||
get_priority_fee, | ||
L1_OPTIMISM_TOKENS_BRIDGE, | ||
) | ||
|
||
description = """ | ||
Fallback voting xx/xx/2024. | ||
Enable deposits on Optimism L1 Token Bridge | ||
""" | ||
|
||
|
||
def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: | ||
"""Prepare and run voting.""" | ||
|
||
l1_token_bridge = interface.L1LidoTokensBridge(L1_OPTIMISM_TOKENS_BRIDGE) | ||
|
||
call_script_items = [ | ||
# 1. Enable deposits on Optimism L1 Token Bridge | ||
agent_forward([(l1_token_bridge.address, l1_token_bridge.enableDeposits.encode_input())]), | ||
] | ||
|
||
vote_desc_items = [ | ||
"1) Enable deposits on Optimism L1 Token Bridge", | ||
] | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
""" | ||
Rollback voting if L2 part of the upgrade failed. | ||
TODO | ||
""" | ||
|
||
import time | ||
import eth_abi | ||
from brownie import interface, web3 | ||
from typing import Dict | ||
from brownie.network.transaction import TransactionReceipt | ||
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.agent import agent_forward | ||
from utils.config import ( | ||
get_deployer_account, | ||
get_is_live, | ||
get_priority_fee, | ||
L1_OPTIMISM_CROSS_DOMAIN_MESSENGER, | ||
L1_EMERGENCY_BRAKES_MULTISIG, | ||
LIDO_LOCATOR, | ||
LIDO_LOCATOR_IMPL, | ||
L1_OPTIMISM_TOKENS_BRIDGE, | ||
L1_OPTIMISM_TOKENS_BRIDGE_IMPL, | ||
) | ||
|
||
|
||
DESCRIPTION = """ | ||
Upgrade back L1Bridge, LidoLocator and revokeRole for deposit pause on L1Bridge | ||
""" | ||
|
||
DEPOSITS_ENABLER_ROLE = "0x4b43b36766bde12c5e9cbbc37d15f8d1f769f08f54720ab370faeb4ce893753a" | ||
|
||
def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: | ||
"""Prepare and run voting.""" | ||
|
||
l1_token_bridge_as_proxy = interface.OssifiableProxy(L1_OPTIMISM_TOKENS_BRIDGE) | ||
lido_locator_as_proxy = interface.OssifiableProxy(LIDO_LOCATOR) | ||
l1_token_bridge = interface.L1LidoTokensBridge(L1_OPTIMISM_TOKENS_BRIDGE) | ||
|
||
call_script_items = [ | ||
# 1. L1 TokenBridge upgrade proxy | ||
agent_forward( | ||
[ | ||
( | ||
l1_token_bridge_as_proxy.address, | ||
l1_token_bridge_as_proxy.proxy__upgradeTo.encode_input(L1_OPTIMISM_TOKENS_BRIDGE_IMPL), | ||
) | ||
] | ||
), | ||
# 2. Rollback L1 LidoLocator implementation | ||
agent_forward( | ||
[ | ||
( | ||
lido_locator_as_proxy.address, | ||
lido_locator_as_proxy.proxy__upgradeTo.encode_input(LIDO_LOCATOR_IMPL), | ||
) | ||
] | ||
), | ||
# 3. Revoke DEPOSITS_ENABLER_ROLE for Emergency Brakes Committee multisig | ||
agent_forward( | ||
[ | ||
( | ||
l1_token_bridge.address, | ||
l1_token_bridge.revokeRole.encode_input(DEPOSITS_ENABLER_ROLE, L1_EMERGENCY_BRAKES_MULTISIG), | ||
) | ||
] | ||
), | ||
] | ||
|
||
vote_desc_items = [ | ||
"1) Rollback Optimism L1 Bridge implementation", | ||
"2) Upgrade LidoLocator implementation", | ||
"3) Revoke DEPOSITS_ENABLER_ROLE from Emergency Brakes Committee multisig", | ||
] | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import time | ||
import os | ||
from scripts.upgrade_2024_10_08 import start_vote | ||
from brownie import interface, accounts, network | ||
from tests.conftest import Helpers | ||
from utils.config import ( | ||
contracts, | ||
get_deployer_account, | ||
get_is_live, | ||
get_priority_fee, | ||
network_name, | ||
L1_OPTIMISM_TOKENS_BRIDGE, | ||
AGENT | ||
) | ||
|
||
ENV_OMNIBUS_VOTE_IDS = "OMNIBUS_VOTE_IDS" | ||
|
||
def pause_deposits(): | ||
if not network_name() in ("mainnet-fork",): | ||
return | ||
|
||
network.gas_price("2 gwei") | ||
|
||
accounts[0].transfer(AGENT, "2 ethers") | ||
|
||
l1_token_bridge = interface.L1LidoTokensBridge(L1_OPTIMISM_TOKENS_BRIDGE) | ||
agent = accounts.at(AGENT, force=True) | ||
l1_token_bridge.disableDeposits({"from": agent}) | ||
assert not l1_token_bridge.isDepositsEnabled() | ||
|
||
def resume_deposits(): | ||
if not network_name() in ("mainnet-fork",): | ||
return | ||
|
||
network.gas_price("2 gwei") | ||
|
||
accounts[0].transfer(AGENT, "2 ethers") | ||
|
||
l1_token_bridge = interface.L1LidoTokensBridge(L1_OPTIMISM_TOKENS_BRIDGE) | ||
agent = accounts.at(AGENT, force=True) | ||
l1_token_bridge.enableDeposits({"from": agent}) | ||
assert l1_token_bridge.isDepositsEnabled() | ||
|
||
def start_and_execute_for_fork_upgrade(): | ||
if not network_name() in ("mainnet-fork",): | ||
return | ||
|
||
l1_token_bridge = interface.L1LidoTokensBridge(L1_OPTIMISM_TOKENS_BRIDGE) | ||
if l1_token_bridge.isDepositsEnabled(): | ||
pause_deposits() | ||
|
||
deployerAccount = get_deployer_account() | ||
|
||
# Top up accounts | ||
accounts[0].transfer(AGENT, "2 ethers") | ||
accounts[0].transfer(deployerAccount.address, "2 ethers") | ||
|
||
tx_params = {"from": deployerAccount} | ||
if get_is_live(): | ||
tx_params["priority_fee"] = get_priority_fee() | ||
|
||
if len(vote_ids_from_env()) > 0: | ||
vote_id = vote_ids_from_env()[0] | ||
else: | ||
vote_id, _ = start_vote(tx_params=tx_params, silent=True) | ||
|
||
vote_tx = Helpers.execute_vote(accounts, vote_id, contracts.voting) | ||
|
||
print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") | ||
|
||
vote_id >= 0 and print(f"Vote created: {vote_id}.") | ||
|
||
time.sleep(5) # hack for waiting thread #2. | ||
|
||
def vote_ids_from_env() -> [int]: | ||
if os.getenv(ENV_OMNIBUS_VOTE_IDS): | ||
try: | ||
vote_ids_str = os.getenv(ENV_OMNIBUS_VOTE_IDS) | ||
vote_ids = [int(s) for s in vote_ids_str.split(",")] | ||
print(f"OMNIBUS_VOTE_IDS env var is set, using existing votes {vote_ids}") | ||
return vote_ids | ||
except: | ||
pass | ||
|
||
return [] |
Oops, something went wrong.