Skip to content

Commit

Permalink
Mild refactoring + adding in utils file + commenting out code
Browse files Browse the repository at this point in the history
  • Loading branch information
nadir-akhtar committed Oct 3, 2024
1 parent d1381bd commit 26861fc
Show file tree
Hide file tree
Showing 8 changed files with 724 additions and 521 deletions.
520 changes: 260 additions & 260 deletions script/Release.s.sol

Large diffs are not rendered by default.

37 changes: 33 additions & 4 deletions script/Release_Template.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.12;

import "script/utils/ConfigParser.sol";
import "script/utils/EncodeSafeMultisendMainnet.sol";
import {EncGnosisSafe} from "script/utils/Encoders.sol";

/// @notice Deployment data struct
Expand All @@ -19,9 +20,10 @@ struct Transaction {
EncGnosisSafe.Operation op;
}

/// TODO: break all abstract contracts out into their own file in a `template` directory

/// @notice template for an EOA script
abstract contract EOABuilder is ConfigParser {
Deployment[] internal deployments;

function deploy(string memory envPath) public returns (Deployment[] memory) {
(
Expand All @@ -37,8 +39,30 @@ abstract contract EOABuilder is ConfigParser {
}

/// @notice template for a Multisig script
abstract contract MultisigBuilder is ConfigParser {
abstract contract MultisigBuilder is ConfigParser, EncodeSafeTransactionMainnet {

/// @return a Transaction object for a Gnosis Safe to ingest
function execute(string memory envPath) public returns (bytes memory) {
(
Addresses memory addrs,
Environment memory env,
Params memory params
) = _readConfigFile(envPath);

Tx[] memory txs = _execute(addrs, env, params);

return encodeMultisendTxs(txs);
}

/// @notice to be implemented by inheriting contract
function _execute(Addresses memory addrs, Environment memory env, Params memory params) internal virtual returns (Tx[] memory);
}

abstract contract NestedMultisigBuilder is ConfigParser {

/// @return a Transaction object for a Gnosis Safe to ingest
/// @dev this object is intended to hold calldata to be sent to *yet another* Safe
/// which will contain the actual relevant calldata
function execute(string memory envPath) public returns (Transaction memory) {
(
Addresses memory addrs,
Expand All @@ -53,11 +77,16 @@ abstract contract MultisigBuilder is ConfigParser {
function _execute(Addresses memory addrs, Environment memory env, Params memory params) internal virtual returns (Transaction memory);
}


/// @notice template for an OpsMultisig script that goes through the timelock
abstract contract OpsTimelockBuilder is MultisigBuilder {
abstract contract OpsTimelockBuilder is NestedMultisigBuilder {

/// @return a Transaction object for a Gnosis Safe to ingest
function queue(string memory envPath) public returns (Transaction memory) {
// TODO

// get response from _queue()
// encode for Timelock
// return encoded call for Ops Multisig
}
function _queue(Addresses memory addrs, Environment memory env, Params memory params) internal virtual returns (Transaction memory);

Expand Down
150 changes: 75 additions & 75 deletions script/ScriptTest.t.sol
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "./Release_Template.s.sol";

// zeus new "pepe" opsmultisig

contract PEPE_Upgrade is OpsTimelockBuilder {

struct TimelockData {
address target;
uint value;
string signature;
bytes data;
uint eta;
}

function _makeTimelockData(
Addresses memory addrs,
Environment memory env,
Params memory params
) internal override returns (TimelockData memory) {
TimelockData data = _newTimelockData();
data.eta = env.isMainnet() ? 12351235 : 0;

data.appendCall({
to: addrs.eigenPod.beacon,
data: EncBeacon.upgradeTo(addrs.eigenPod.getPending())
});

data.appendCall({
to: addrs.proxyAdmin,
data: EncProxyAdmin.upgrade(addrs.eigenPodManager.proxy, addrs.eigenPodManager.getPending())
});

return data.encode();
}
function _queue(
Addresses memory addrs,
Environment memory env,
Params memory params
) internal override returns (Calls[] memory) {
TimelockData memory data = _makeTimelockData(addrs, env, params);

return opsMultisig.queue(txns);
}
function _execute(
Addresses memory addrs,
Environment memory env,
Params memory params
) internal override returns (Calls[]) {
TimelockTxn[] memory txns = _makeTimelockTxns(addrs, env, params);

Calls[] memory final = opsMultsig.execute(txns)
.append({
to: awfe
data: awef
});

return final;
}
}

contract PEPE_Deploy is EOABuilder {

function _deploy(
Addresses memory addrs,
Environment memory env,
Params memory params
) internal override returns (Deployment[]) {
}
}
// // SPDX-License-Identifier: BUSL-1.1
// pragma solidity ^0.8.12;

// import "./Release_Template.s.sol";

// // zeus new "pepe" opsmultisig

// contract PEPE_Upgrade is OpsTimelockBuilder {

// struct TimelockData {
// address target;
// uint value;
// string signature;
// bytes data;
// uint eta;
// }

// function _makeTimelockData(
// Addresses memory addrs,
// Environment memory env,
// Params memory params
// ) internal override returns (TimelockData memory) {
// TimelockData data = _newTimelockData();
// data.eta = env.isMainnet() ? 12351235 : 0;

// data.appendCall({
// to: addrs.eigenPod.beacon,
// data: EncBeacon.upgradeTo(addrs.eigenPod.getPending())
// });

// data.appendCall({
// to: addrs.proxyAdmin,
// data: EncProxyAdmin.upgrade(addrs.eigenPodManager.proxy, addrs.eigenPodManager.getPending())
// });

// return data.encode();
// }

// function _queue(
// Addresses memory addrs,
// Environment memory env,
// Params memory params
// ) internal override returns (Transaction memory) {
// TimelockData memory data = _makeTimelockData(addrs, env, params);

// return opsMultisig.queue(txns);
// }

// function _execute(
// Addresses memory addrs,
// Environment memory env,
// Params memory params
// ) internal override returns (Transaction memory) {
// TimelockTxn[] memory txns = _makeTimelockTxns(addrs, env, params);

// Calls[] memory result = opsMultsig.execute(txns)
// .append({
// to: awfe,
// data: awef
// });

// return result;
// }
// }

// contract PEPE_Deploy is EOABuilder {

// function _deploy(
// Addresses memory addrs,
// Environment memory env,
// Params memory params
// ) internal override returns (Deployment[]) {

// }
// }
5 changes: 4 additions & 1 deletion script/releases/v0.1-eigenpod/DeployEigenPod.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
pragma solidity ^0.8.12;

import "script/Release_Template.s.sol";
import "src/contracts/pods/EigenPod.sol";

contract DeployEigenPod is EOABuilder {
Deployment[] internal deployments;

function _deploy(Addresses memory addrs, Environment memory env, Params memory params) internal override returns (Deployment[] memory) {
/// @notice deploys an EigenPod and returns the deployed address
function _deploy(Addresses memory addrs, Environment memory, Params memory params) internal override returns (Deployment[] memory) {

deployments.push(Deployment({
name: type(EigenPod).name,
Expand Down
26 changes: 22 additions & 4 deletions script/releases/v0.1-eigenpod/UpgradeEigenPod.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,32 @@ import "script/Release_Template.s.sol";

contract UpgradeCounter is MultisigBuilder {

function _execute(Addresses memory addrs, Environment memory env, Params memory params) internal override returns (Transaction memory) {
function _execute(Addresses memory addrs, Environment memory env, Params memory params) internal override returns (Tx[] memory) {
Tx[] memory txs = new Tx[](2);

bytes memory calldata_to_executor;
return Transaction({
to: addrs.timelock,
// txs[0] = Tx({
// to: eigenPodBeacon,
// value: 0,
// data: abi.encodeWithSelector(
// IUpgradeableBeacon.upgradeTo.selector, newEigenPodImpl
// )
// });

// txs[1] = Tx({
// to: eigenLayerProxyAdmin,
// value: 0,
// data: abi.encodeWithSelector(ProxyAdmin.upgrade.selector, eigenPodManager, newEigenPodManagerImpl)
// });

bytes memory calldata_to_executor; // upgrade data

Transaction({
to: addrs.proxyAdmin,
value: 0,
data: calldata_to_executor,
op: EncGnosisSafe.Operation.DelegateCall
});

return txs;
}
}
36 changes: 18 additions & 18 deletions script/releases/v0.4.2-pepe/Script.s.sol
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;
// // SPDX-License-Identifier: BUSL-1.1
// pragma solidity ^0.8.12;

import "./utils/Releasoor.s.sol";
// import "./../../utils/Releasoor.s.sol";

contract v0_4_2_ is Releasoor {
// contract v0_4_2_ is Releasoor {

using TxBuilder for *;
using AddressUtils for *;
// using TxBuilder for *;
// using AddressUtils for *;

function deploy(Addresses memory addrs) internal override {
// If you're deploying contracts, do that here
}
// function deploy(Addresses memory addrs) internal override {
// // If you're deploying contracts, do that here
// }

function queueUpgrade(Addresses memory addrs) internal override returns (Tx[] memory executorTxns, uint eta) {
// If you're queueing an upgrade via the timelock, you can
// define and encode those transactions here
}
// function queueUpgrade(Addresses memory addrs) internal override returns (Tx[] memory executorTxns, uint eta) {
// // If you're queueing an upgrade via the timelock, you can
// // define and encode those transactions here
// }

function executeUpgrade(Addresses memory addrs) internal override {
// Whether you are using the timelock or just making transactions
// from the ops multisig, you can define/encode those transactions here
}
}
// function executeUpgrade(Addresses memory addrs) internal override {
// // Whether you are using the timelock or just making transactions
// // from the ops multisig, you can define/encode those transactions here
// }
// }
Loading

0 comments on commit 26861fc

Please sign in to comment.