|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.12; |
| 3 | + |
| 4 | +import {Deploy} from "./1-deployContracts.s.sol"; |
| 5 | +import "../Env.sol"; |
| 6 | + |
| 7 | +import {MultisigBuilder} from "zeus-templates/templates/MultisigBuilder.sol"; |
| 8 | +import "zeus-templates/utils/Encode.sol"; |
| 9 | + |
| 10 | +import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; |
| 11 | + |
| 12 | +/** |
| 13 | + * Purpose: |
| 14 | + * * enqueue a multisig transaction which; |
| 15 | + * - upgrades all the relevant contracts, and |
| 16 | + * - unpauses the system. |
| 17 | + * This should be run via the protocol council multisig. |
| 18 | + */ |
| 19 | +contract QueueAndUnpause is MultisigBuilder, Deploy { |
| 20 | + using Env for *; |
| 21 | + using Encode for *; |
| 22 | + |
| 23 | + function _runAsMultisig() prank(Env.opsMultisig()) internal virtual override { |
| 24 | + bytes memory calldata_to_executor = _getCalldataToExecutor(); |
| 25 | + |
| 26 | + TimelockController timelock = Env.timelockController(); |
| 27 | + timelock.schedule({ |
| 28 | + target: Env.executorMultisig(), |
| 29 | + value: 0, |
| 30 | + data: calldata_to_executor, |
| 31 | + predecessor: 0, |
| 32 | + salt: 0, |
| 33 | + delay: timelock.getMinDelay() |
| 34 | + }); |
| 35 | + } |
| 36 | + |
| 37 | + /// @dev Get the calldata to be sent from the timelock to the executor |
| 38 | + function _getCalldataToExecutor() internal returns (bytes memory) { |
| 39 | + MultisigCall[] storage executorCalls = Encode.newMultisigCalls() |
| 40 | + /// core/ |
| 41 | + .append({ |
| 42 | + to: Env.proxyAdmin(), |
| 43 | + data: Encode.proxyAdmin.upgrade({ |
| 44 | + proxy: address(Env.proxy.avsDirectory()), |
| 45 | + impl: address(Env.impl.avsDirectory()) |
| 46 | + }) |
| 47 | + }) |
| 48 | + .append({ |
| 49 | + to: Env.proxyAdmin(), |
| 50 | + data: Encode.proxyAdmin.upgrade({ |
| 51 | + proxy: address(Env.proxy.delegationManager()), |
| 52 | + impl: address(Env.impl.delegationManager()) |
| 53 | + }) |
| 54 | + }) |
| 55 | + .append({ |
| 56 | + to: Env.proxyAdmin(), |
| 57 | + data: Encode.proxyAdmin.upgrade({ |
| 58 | + proxy: address(Env.proxy.rewardsCoordinator()), |
| 59 | + impl: address(Env.impl.rewardsCoordinator()) |
| 60 | + }) |
| 61 | + }) |
| 62 | + .append({ |
| 63 | + to: Env.proxyAdmin(), |
| 64 | + data: Encode.proxyAdmin.upgrade({ |
| 65 | + proxy: address(Env.proxy.strategyManager()), |
| 66 | + impl: address(Env.impl.strategyManager()) |
| 67 | + }) |
| 68 | + }) |
| 69 | + /// pods/ |
| 70 | + .append({ |
| 71 | + to: address(Env.beacon.eigenPod()), |
| 72 | + data: Encode.upgradeableBeacon.upgradeTo({ |
| 73 | + newImpl: address(Env.impl.eigenPod()) |
| 74 | + }) |
| 75 | + }) |
| 76 | + .append({ |
| 77 | + to: Env.proxyAdmin(), |
| 78 | + data: Encode.proxyAdmin.upgrade({ |
| 79 | + proxy: address(Env.proxy.eigenPodManager()), |
| 80 | + impl: address(Env.impl.eigenPodManager()) |
| 81 | + }) |
| 82 | + }) |
| 83 | + /// strategies/ |
| 84 | + .append({ |
| 85 | + to: Env.proxyAdmin(), |
| 86 | + data: Encode.proxyAdmin.upgrade({ |
| 87 | + proxy: address(Env.proxy.eigenStrategy()), |
| 88 | + impl: address(Env.impl.eigenStrategy()) |
| 89 | + }) |
| 90 | + }) |
| 91 | + .append({ |
| 92 | + to: address(Env.beacon.strategyBase()), |
| 93 | + data: Encode.upgradeableBeacon.upgradeTo({ |
| 94 | + newImpl: address(Env.impl.strategyBase()) |
| 95 | + }) |
| 96 | + }) |
| 97 | + .append({ |
| 98 | + to: Env.proxyAdmin(), |
| 99 | + data: Encode.proxyAdmin.upgrade({ |
| 100 | + proxy: address(Env.proxy.strategyFactory()), |
| 101 | + impl: address(Env.impl.strategyFactory()) |
| 102 | + }) |
| 103 | + }); |
| 104 | + |
| 105 | + /// Add call to upgrade each pre-longtail strategy instance |
| 106 | + uint count = Env.instance.strategyBaseTVLLimits_Count(); |
| 107 | + for (uint i = 0; i < count; i++) { |
| 108 | + address proxyInstance = address(Env.instance.strategyBaseTVLLimits(i)); |
| 109 | + |
| 110 | + executorCalls.append({ |
| 111 | + to: Env.proxyAdmin(), |
| 112 | + data: Encode.proxyAdmin.upgrade({ |
| 113 | + proxy: proxyInstance, |
| 114 | + impl: address(Env.impl.strategyBaseTVLLimits()) |
| 115 | + }) |
| 116 | + }); |
| 117 | + } |
| 118 | + |
| 119 | + // /// Finally, add a call unpausing the EigenPodManager |
| 120 | + // /// We will end up pausing it in step 3, so the unpause will |
| 121 | + // /// go through as part of execution (step 5) |
| 122 | + executorCalls.append({ |
| 123 | + to: address(Env.proxy.eigenPodManager()), |
| 124 | + data: abi.encodeCall(Pausable.unpause, 0) |
| 125 | + }); |
| 126 | + |
| 127 | + return Encode.gnosisSafe.execTransaction({ |
| 128 | + from: address(Env.timelockController()), |
| 129 | + to: Env.multiSendCallOnly(), |
| 130 | + op: Encode.Operation.DelegateCall, |
| 131 | + data: Encode.multiSend(executorCalls) |
| 132 | + }); |
| 133 | + } |
| 134 | + |
| 135 | + function testScript() public virtual override { |
| 136 | + runAsEOA(); |
| 137 | + |
| 138 | + TimelockController timelock = Env.timelockController(); |
| 139 | + bytes memory calldata_to_executor = _getCalldataToExecutor(); |
| 140 | + bytes32 txHash = timelock.hashOperation({ |
| 141 | + target: Env.executorMultisig(), |
| 142 | + value: 0, |
| 143 | + data: calldata_to_executor, |
| 144 | + predecessor: 0, |
| 145 | + salt: 0 |
| 146 | + }); |
| 147 | + |
| 148 | + // Check that the upgrade does not exist in the timelock |
| 149 | + assertFalse(timelock.isOperationPending(txHash), "Transaction should NOT be queued."); |
| 150 | + |
| 151 | + execute(); |
| 152 | + |
| 153 | + // Check that the upgrade has been added to the timelock |
| 154 | + assertTrue(timelock.isOperationPending(txHash), "Transaction should be queued."); |
| 155 | + } |
| 156 | +} |
0 commit comments