Skip to content

Commit

Permalink
feat: slashing upgrade scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrower95 committed Dec 6, 2024
1 parent ac57bc1 commit 1d94413
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 1 deletion.
3 changes: 3 additions & 0 deletions script/releases/v1.0.0-slashing/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"solidity.defaultCompiler": "localNodeModule"
}
28 changes: 28 additions & 0 deletions script/releases/v1.0.0-slashing/1-deployContracts.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {EOADeployer} from "zeus-templates/templates/EOADeployer.sol";
import {EigenLabsUpgrade} from "../EigenLabsUpgrade.s.sol";

/**
* Purpose: use an EOA to deploy all of the new contracts for this upgrade.
*/
contract Deploy is EOADeployer {
using EigenLabsUpgrade for *;

function _runAsEOA() internal override {
vm.startBroadcast();

// TODO(alex): deploy all of the slashing contracts, recording the address with `deploySingleton(addr, name)`.
// for `name`, likely use `this.impl(type(Contract).name)`.

vm.stopBroadcast();
}

function testDeploy() public {
_runAsEOA();
Deployment[] memory deploys = deploys();

// TODO(alex): assert on all of our deployments.
}
}
61 changes: 61 additions & 0 deletions script/releases/v1.0.0-slashing/2-queueUpgradeAndUnpause.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {MultisigCall, MultisigCallUtils, MultisigBuilder} from "zeus-templates/templates/MultisigBuilder.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {EigenLabsUpgrade} from "../EigenLabsUpgrade.s.sol";
import {EncGnosisSafe} from "zeus-templates/utils/EncGnosisSafe.sol";
import {MultisigCallUtils, MultisigCall} from "zeus-templates/utils/MultisigCallUtils.sol";
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";

/**
* Purpose:
* * enqueue a multisig transaction which;
* - upgrades all the relevant contracts, and
* - unpauses the system.
* This should be run via the protocol council multisig.
*/
contract Queue is MultisigBuilder {
using MultisigCallUtils for MultisigCall[];
using EigenLabsUpgrade for *;
using EncGnosisSafe for *;
using MultisigCallUtils for *;

MultisigCall[] private _executorCalls;
MultisigCall[] private _opsCalls;

function _getMultisigTransactionCalldata() internal view returns (bytes memory) {
ProxyAdmin pa = ProxyAdmin(this._proxyAdmin());

// TODO(alex): multisig transaction calldata for upgrading all contracts from phase 1.
bytes memory executorMultisigCalldata = new bytes(0);
// for syntax, see rewardsv2 upgrade script

return (executorMultisigCalldata);
}

function _runAsMultisig() internal virtual override {
(bytes memory call) = _getMultisigTransactionCalldata();

TimelockController timelock = TimelockController(payable(this._timelock()));
timelock.schedule(
this._executorMultisig(),
0,
call,
0,
bytes32(0),
timelock.getMinDelay()
);
}

function testDeploy() virtual public {
zSetMultisigContext(this._protocolCouncilMultisig());
execute();

TimelockController timelock = TimelockController(payable(this._timelock()));
bytes memory call = _getMultisigTransactionCalldata();
bytes32 txHash = timelock.hashOperation(this._executorMultisig(), 0, call, 0, 0);
assertEq(timelock.isOperationPending(txHash), true, "Transaction should be queued.");
}
}
35 changes: 35 additions & 0 deletions script/releases/v1.0.0-slashing/3-pause.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {MultisigCall, MultisigCallUtils, MultisigBuilder} from "zeus-templates/templates/MultisigBuilder.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {EigenLabsUpgrade} from "../EigenLabsUpgrade.s.sol";
import {EncGnosisSafe} from "zeus-templates/utils/EncGnosisSafe.sol";
import {MultisigCallUtils, MultisigCall} from "zeus-templates/utils/MultisigCallUtils.sol";

/**
* Purpose: Enqueue a transaction which immediately sets `EigenPodManager.PAUSED_START_CHECKPOINT=true`
*/
contract Pause is MultisigBuilder {
using MultisigCallUtils for MultisigCall[];
using EigenLabsUpgrade for *;
using EncGnosisSafe for *;
using MultisigCallUtils for *;

MultisigCall[] private _executorCalls;
MultisigCall[] private _opsCalls;

function _runAsMultisig() internal virtual override {
// TODO: set:
// EigenPodManager.PAUSED_START_CHECKPOINT = true;
}

function testDeploy() virtual public {
// TODO: this should run from pauser multisig
zSetMultisigContext(this._operationsMultisig());
execute();

// TODO: assert side effects
}
}
1 change: 1 addition & 0 deletions script/releases/v1.0.0-slashing/4-podCleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO(justin): run a binary which completes all checkpoints on the network.
56 changes: 56 additions & 0 deletions script/releases/v1.0.0-slashing/5-executeUpgradeAndUnpause.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {MultisigCall, MultisigCallUtils} from "zeus-templates/templates/MultisigBuilder.sol";
import {SafeTx, SafeTxUtils} from "zeus-templates/utils/SafeTxUtils.sol";
import {Queue} from "./2-queueUpgradeAndUnpause.s.sol";
import {EigenLabsUpgrade} from "../EigenLabsUpgrade.s.sol";
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

contract Execute is Queue {
using MultisigCallUtils for MultisigCall[];
using SafeTxUtils for SafeTx;
using EigenLabsUpgrade for *;

/**
* @dev Overrides the previous _execute function to execute the queued transactions.
*/
function _runAsMultisig() internal override {
bytes memory call = _getMultisigTransactionCalldata();
TimelockController timelock = TimelockController(payable(this._timelock()));
timelock.execute(
this._executorMultisig(),
0,
call,
0,
bytes32(0)
);
}

function testDeploy() override public {}

function testExecute() public {
// 1- run queueing logic
vm.startPrank(this._operationsMultisig());
super._runAsMultisig();
vm.stopPrank();

TimelockController timelock = this._timelock();
bytes memory call = _getMultisigTransactionCalldata();
bytes32 txHash = timelock.hashOperation(this._executorMultisig(), 0, call, 0, 0);
assertEq(timelock.isOperationPending(txHash), true, "Transaction should be queued and pending.");


// 2- warp past delay?
vm.warp(block.timestamp + timelock.getMinDelay()); // 1 tick after ETA
assertEq(timelock.isOperationReady(txHash), true, "Transaction should be executable.");

// 3- execute
zSetMultisigContext(this._protocolCouncilMultisig());
execute();

// 3. TODO: assert that the execute did something
}
}
27 changes: 27 additions & 0 deletions script/releases/v1.0.0-slashing/upgrade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "slashing",
"from": "0.5.2",
"to": "1.0.0",
"phases": [
{
"type": "eoa",
"filename": "1-deployContracts.s.sol"
},
{
"type": "multisig",
"filename": "2-queueUpgradeAndUnpause.s.sol"
},
{
"type": "multisig",
"filename": "3-pause.s.sol"
},
{
"type": "script",
"filename": "4-podCleanup.sh"
},
{
"type": "multisig",
"filename": "5-executeUpgradeAndUnpause.s.sol"
}
]
}

0 comments on commit 1d94413

Please sign in to comment.