Skip to content

Commit

Permalink
fix: upgrades must be made from gov timelock
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Mar 4, 2021
1 parent e6bae91 commit 4c1ef96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
14 changes: 1 addition & 13 deletions scripts/deploy/upgrade.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from brownie.network.contract import ProjectContract

from helpers.gnosis_safe import GnosisSafe, MultisigTxMetadata


# try all the methods in priority order
VERSION_METHODS = [
Expand Down Expand Up @@ -29,17 +27,7 @@ def upgrade_versioned_proxy(
):
return

multi = GnosisSafe(badger.devMultisig)

multi.execute(
MultisigTxMetadata(description="Upgrade versioned proxy contract with new logic version",),
{
"to": badger.devProxyAdmin.address,
"data": badger.devProxyAdmin.upgrade.encode_input(
proxy, logic
),
},
)
badger.devProxyAdmin.upgrade(proxy, logic, {"from": badger.governanceTimelock})


def _get_version(contract: ProjectContract) -> float:
Expand Down
4 changes: 4 additions & 0 deletions scripts/systems/badger_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def connect_badger(
badger.connect_honeypot_meme(badger_deploy["honeypotMeme"])
badger.connect_community_pool(badger_deploy["communityPool"])
badger.connect_dao_badger_timelock(badger_deploy["daoBadgerTimelock"])
badger.connect_governance_timelock(badger_deploy["timelock"])
badger.connect_rewards_manager(badger_deploy["badgerRewardsManager"])
badger.connect_unlock_scheduler(badger_deploy["unlockScheduler"])

Expand Down Expand Up @@ -950,6 +951,9 @@ def connect_dao_badger_timelock(self, address):
self.daoBadgerTimelock = SimpleTimelock.at(address)
self.upgrade.track_contract_upgradeable("daoBadgerTimelock", self.daoBadgerTimelock)

def connect_governance_timelock(self, address):
self.governanceTimelock = GovernanceTimelock.at(address)

def connect_rewards_manager(self, address):
self.badgerRewardsManager = BadgerRewardsManager.at(address)
self.upgrade.track_contract_upgradeable(
Expand Down
9 changes: 7 additions & 2 deletions scripts/systems/upgrade_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ def snapshot(self, contract: ProjectContract) -> None:
def validate(self) -> bool:
prev = self.snapshots[0]
for snapshot in self.snapshots[1:]:
if snapshot != prev:
return False
# Snapshots should be the same length.
for idx in range(0, len(snapshot)):
# If field unimpl in last version, skip comparison.
if prev[idx] is None:
continue
if snapshot[idx] != prev[idx]:
return False
prev = snapshot
return True

Expand Down

0 comments on commit 4c1ef96

Please sign in to comment.