|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.12; |
| 3 | + |
| 4 | +import {MultisigCall, MultisigCallUtils, MultisigBuilder} from "zeus-templates/templates/MultisigBuilder.sol"; |
| 5 | +import {SafeTx, SafeTxUtils} from "zeus-templates/utils/SafeTxUtils.sol"; |
| 6 | +import {Queue} from "./2-multisig.s.sol"; |
| 7 | +import {EigenLabsUpgrade} from "../EigenLabsUpgrade.s.sol"; |
| 8 | +import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; |
| 9 | +import {RewardsCoordinator} from "src/contracts/core/RewardsCoordinator.sol"; |
| 10 | +import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; |
| 11 | +import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; |
| 12 | +import {IPauserRegistry} from "src/contracts/interfaces/IPauserRegistry.sol"; |
| 13 | +import {DelegationManager} from "src/contracts/core/DelegationManager.sol"; |
| 14 | +import {StrategyManager} from "src/contracts/core/StrategyManager.sol"; |
| 15 | +import {console} from "forge-std/console.sol"; |
| 16 | + |
| 17 | +contract Execute is Queue { |
| 18 | + using MultisigCallUtils for MultisigCall[]; |
| 19 | + using SafeTxUtils for SafeTx; |
| 20 | + using EigenLabsUpgrade for *; |
| 21 | + |
| 22 | + event Upgraded(address indexed implementation); |
| 23 | + |
| 24 | + function options() internal view override returns (MultisigOptions memory) { |
| 25 | + return MultisigOptions(this._protocolCouncilMultisig(), Operation.Call); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * @dev Overrides the previous _execute function to execute the queued transactions. |
| 30 | + */ |
| 31 | + function runAsMultisig() internal override { |
| 32 | + bytes memory executorMultisigCalldata = _getMultisigTransactionCalldata(); |
| 33 | + TimelockController timelock = TimelockController(payable(this._timelock())); |
| 34 | + timelock.execute( |
| 35 | + this._executorMultisig(), |
| 36 | + 0 /* value */, |
| 37 | + executorMultisigCalldata, |
| 38 | + 0 /* predecessor */, |
| 39 | + bytes32(0) /* salt */ |
| 40 | + ); |
| 41 | + } |
| 42 | + |
| 43 | + function testDeploy() public override { |
| 44 | + // save the previous implementation address to assert its change later |
| 45 | + address prevRewardsCoordinator = zDeployedImpl(type(RewardsCoordinator).name); |
| 46 | + |
| 47 | + // 0. Deploy the Implementation contract. |
| 48 | + runAsEOA(); |
| 49 | + |
| 50 | + // 1. run the queue script. |
| 51 | + vm.startPrank(this._operationsMultisig()); |
| 52 | + super.runAsMultisig(); |
| 53 | + vm.stopPrank(); |
| 54 | + |
| 55 | + RewardsCoordinator rewardsCoordinatorProxy = RewardsCoordinator(zDeployedProxy(type(RewardsCoordinator).name)); |
| 56 | + uint256 pausedStatusBefore = rewardsCoordinatorProxy.paused(); |
| 57 | + TimelockController timelock = this._timelock(); |
| 58 | + |
| 59 | + // 2. run the execute script above. |
| 60 | + bytes memory multisigTxnData = _getMultisigTransactionCalldata(); |
| 61 | + bytes32 txHash = timelock.hashOperation(this._executorMultisig(), 0, multisigTxnData, 0, 0); |
| 62 | + |
| 63 | + assertEq(timelock.isOperationPending(txHash), true, "Transaction should be queued and pending."); |
| 64 | + vm.warp(block.timestamp + timelock.getMinDelay()); // 1 tick after ETA. |
| 65 | + |
| 66 | + assertEq(timelock.isOperationReady(txHash), true, "Transaction should be executable."); |
| 67 | + |
| 68 | + vm.expectEmit(true, true, true, true, address(rewardsCoordinatorProxy)); |
| 69 | + emit Upgraded(zDeployedImpl(type(RewardsCoordinator).name)); |
| 70 | + execute(); |
| 71 | + |
| 72 | + // 3. assert that the execute did something |
| 73 | + assertEq(timelock.isOperationDone(txHash), true, "Transaction should be executed."); |
| 74 | + |
| 75 | + // assert that the proxy implementation was updated. |
| 76 | + ProxyAdmin admin = ProxyAdmin(this._proxyAdmin()); |
| 77 | + address rewardsCoordinatorImpl = admin.getProxyImplementation( |
| 78 | + TransparentUpgradeableProxy(payable(zDeployedProxy(type(RewardsCoordinator).name))) |
| 79 | + ); |
| 80 | + assertEq(rewardsCoordinatorImpl, zDeployedImpl(type(RewardsCoordinator).name)); |
| 81 | + assertNotEq(prevRewardsCoordinator, rewardsCoordinatorImpl, "expected rewardsCoordinatorImpl to be different"); |
| 82 | + |
| 83 | + uint256 pausedStatusAfter = rewardsCoordinatorProxy.paused(); |
| 84 | + address owner = this._operationsMultisig(); |
| 85 | + IPauserRegistry pauserRegistry = IPauserRegistry(this._pauserRegistry()); |
| 86 | + uint64 initPausedStatus = zUint64("REWARDS_COORDINATOR_INIT_PAUSED_STATUS"); |
| 87 | + address rewardsUpdater = zAddress("REWARDS_COORDINATOR_UPDATER"); |
| 88 | + uint32 activationDelay = zUint32("REWARDS_COORDINATOR_ACTIVATION_DELAY"); |
| 89 | + uint16 defaultOperatorSplitBips = zUint16("REWARDS_COORDINATOR_DEFAULT_OPERATOR_SPLIT_BIPS"); |
| 90 | + |
| 91 | + // Ensure that the proxy contract cannot be re-initialized. |
| 92 | + vm.expectRevert("Initializable: contract is already initialized"); |
| 93 | + rewardsCoordinatorProxy.initialize( |
| 94 | + owner, |
| 95 | + pauserRegistry, |
| 96 | + initPausedStatus, |
| 97 | + rewardsUpdater, |
| 98 | + activationDelay, |
| 99 | + defaultOperatorSplitBips |
| 100 | + ); |
| 101 | + |
| 102 | + // Assert Immutables and State Variables set through initialize |
| 103 | + assertEq(rewardsCoordinatorProxy.owner(), owner, "expected owner"); |
| 104 | + assertEq(address(rewardsCoordinatorProxy.pauserRegistry()), address(pauserRegistry), "expected pauserRegistry"); |
| 105 | + assertEq(address(rewardsCoordinatorProxy.rewardsUpdater()), rewardsUpdater, "expected rewardsUpdater"); |
| 106 | + assertEq(rewardsCoordinatorProxy.activationDelay(), activationDelay, "expected activationDelay"); |
| 107 | + assertEq( |
| 108 | + rewardsCoordinatorProxy.defaultOperatorSplitBips(), |
| 109 | + defaultOperatorSplitBips, |
| 110 | + "expected defaultOperatorSplitBips" |
| 111 | + ); |
| 112 | + assertEq( |
| 113 | + pausedStatusBefore, |
| 114 | + pausedStatusAfter, |
| 115 | + "expected paused status to be the same before and after initialization" |
| 116 | + ); |
| 117 | + assertEq( |
| 118 | + address(rewardsCoordinatorProxy.delegationManager()), |
| 119 | + zDeployedProxy(type(DelegationManager).name), |
| 120 | + "expected delegationManager" |
| 121 | + ); |
| 122 | + assertEq( |
| 123 | + address(rewardsCoordinatorProxy.strategyManager()), |
| 124 | + zDeployedProxy(type(StrategyManager).name), |
| 125 | + "expected strategyManager" |
| 126 | + ); |
| 127 | + |
| 128 | + assertEq( |
| 129 | + rewardsCoordinatorProxy.CALCULATION_INTERVAL_SECONDS(), |
| 130 | + zUint32("REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS"), |
| 131 | + "expected REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS" |
| 132 | + ); |
| 133 | + assertEq( |
| 134 | + rewardsCoordinatorProxy.CALCULATION_INTERVAL_SECONDS(), |
| 135 | + 1 days, |
| 136 | + "expected REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS" |
| 137 | + ); |
| 138 | + assertGt( |
| 139 | + rewardsCoordinatorProxy.CALCULATION_INTERVAL_SECONDS(), |
| 140 | + 0, |
| 141 | + "expected non-zero REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS" |
| 142 | + ); |
| 143 | + |
| 144 | + assertEq(rewardsCoordinatorProxy.MAX_REWARDS_DURATION(), zUint32("REWARDS_COORDINATOR_MAX_REWARDS_DURATION")); |
| 145 | + assertGt(rewardsCoordinatorProxy.MAX_REWARDS_DURATION(), 0); |
| 146 | + |
| 147 | + assertEq( |
| 148 | + rewardsCoordinatorProxy.MAX_RETROACTIVE_LENGTH(), |
| 149 | + zUint32("REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH") |
| 150 | + ); |
| 151 | + assertGt(rewardsCoordinatorProxy.MAX_RETROACTIVE_LENGTH(), 0); |
| 152 | + |
| 153 | + assertEq(rewardsCoordinatorProxy.MAX_FUTURE_LENGTH(), zUint32("REWARDS_COORDINATOR_MAX_FUTURE_LENGTH")); |
| 154 | + assertGt(rewardsCoordinatorProxy.MAX_FUTURE_LENGTH(), 0); |
| 155 | + |
| 156 | + assertEq( |
| 157 | + rewardsCoordinatorProxy.GENESIS_REWARDS_TIMESTAMP(), |
| 158 | + zUint32("REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP") |
| 159 | + ); |
| 160 | + assertGt(rewardsCoordinatorProxy.GENESIS_REWARDS_TIMESTAMP(), 0); |
| 161 | + } |
| 162 | +} |
0 commit comments