Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: edasm upgrade scripts for rewards #612

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions contracts/script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,21 @@ import {EigenDAServiceManager} from "../../../src/core/EigenDAServiceManager.sol
*/
contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
// Hardcode these values to your needs
address public serviceManager = 0x54A03db2784E3D0aCC08344D05385d0b62d4F432;
address public serviceManagerImplementation = 0xFe779fB43280A92cd85466312E2AE8A4F1A48007;
ProxyAdmin public avsProxyAdmin = ProxyAdmin(0x9Fd7E279f5bD692Dc04792151E14Ad814FC60eC1);
address public serviceManager = 0xD4A7E1Bd8015057293f0D0A557088c286942e84b;
address public serviceManagerImplementation = 0xdBFd6C8582b58590C4AFF40BdF15488A086bC672;

ProxyAdmin public avsProxyAdmin = ProxyAdmin(0xB043055dd967A382577c2f5261fA6428f2905c15);
address deployerAddress = 0xDA29BB71669f46F2a779b4b62f03644A84eE3479;
address registryCoordinator = 0x2c61EA360D6500b58E7f481541A36B443Bc858c6;
address stakeRegistry = 0x53668EBf2e28180e38B122c641BC51Ca81088871;
address registryCoordinator = 0x53012C69A189cfA2D9d29eb6F19B32e0A2EA3490;
address stakeRegistry = 0xBDACD5998989Eec814ac7A0f0f6596088AA2a270;

function run(string memory deployArg) external {
// 1. Setup and parse existing EigenLayer Holesky preprod contracts
_parseInitialDeploymentParams(
"script/deploy/holesky/config/eigenlayer_preprod.config.json"
"script/deploy/holesky/config/eigenlayer.config.json"
);
_parseDeployedContracts(
"script/deploy/holesky/config/eigenlayer_preprod_addresses.config.json"
"script/deploy/holesky/config/eigenlayer_addresses.config.json"
);

// 2. broadcast deployment
Expand Down Expand Up @@ -96,8 +97,8 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
}

function _deployServiceManager() internal virtual {
IPauserRegistry pauserRegistry = IPauserRegistry(0x9Ab2FEAf0465f0eD51Fc2b663eF228B418c9Dad1);
address emptyContract = 0xc08b788d587F927b49665b90ab35D5224965f3d9;
IPauserRegistry pauserRegistry = IPauserRegistry(0x85Ef7299F8311B25642679edBF02B62FA2212F06);
address emptyContract = 0x9690d52B1Ce155DB2ec5eCbF5a262ccCc7B3A6D2;
uint256 initialPausedStatus = 0;
address initialOwner = deployerAddress;
address[] memory batchConfirmers;
Expand Down Expand Up @@ -132,35 +133,41 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {

/// @notice Example createAVSRewardsSubmission call with the ServiceManager
function _createAVSRewardsSubmission() internal {

uint256 mockTokenInitialSupply = 1e30;
address stETHStrategy = 0x5C8b55722f421556a2AAfb7A3EA63d4c3e514312;
address rETHStrategy = 0x87f6C7d24b109919eB38295e3F8298425e6331D9;
// actual strategy addresses
address stETHStrategy = 0x7D704507b76571a51d9caE8AdDAbBFd0ba0e63d3;
address rETHStrategy = 0x3A8fBdf9e77DFc25d09741f51d3E181b25d0c4E0;

IRewardsCoordinator.StrategyAndMultiplier[] memory strategyAndMultipliers = new IRewardsCoordinator.StrategyAndMultiplier[](2);
// Strategy addresses must be in ascending order
strategyAndMultipliers[0] = IRewardsCoordinator.StrategyAndMultiplier({
strategy: IStrategy(stETHStrategy),
strategy: IStrategy(rETHStrategy),
multiplier: 1e18
});
strategyAndMultipliers[1] = IRewardsCoordinator.StrategyAndMultiplier({
strategy: IStrategy(rETHStrategy),
strategy: IStrategy(stETHStrategy),
multiplier: 1e18
});

IERC20 token = new ERC20PresetFixedSupply(
"dog wif hat",
"MOCK1",
mockTokenInitialSupply,
msg.sender
);
// IERC20 token = new ERC20PresetFixedSupply(
// "HARRYPOTTEROBAMASONIC10INU",
// "BITCOIN",
// mockTokenInitialSupply,
// msg.sender
// );

IERC20 token = IERC20(0x3B78576F7D6837500bA3De27A60c7f594934027E);


// must be in multiples of weeks i.e startTimestamp % 604800 == 0
uint32 startTimestamp = 1714608000;
uint32 startTimestamp = 1714608000 + 8 weeks;
// must be in multiples of weeks i.e duration % 604800 == 0
uint32 duration = 1 weeks;
uint32 duration = 10 weeks;
// amount <= 1e38 - 1
uint256 amount = 100e18;
uint256 amount = 5000000e18;

// 2. Create RewardsSubmission input param
// Create RewardsSubmission input param
IRewardsCoordinator.RewardsSubmission[]
memory rewardsSubmissions = new IRewardsCoordinator.RewardsSubmission[](1);
rewardsSubmissions[0] = IRewardsCoordinator.RewardsSubmission({
Expand All @@ -171,6 +178,9 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
duration: duration
});

// Set rewardsInitiator
// EigenDAServiceManager(serviceManager).setRewardsInitiator(msg.sender);

token.approve(serviceManager, amount);
EigenDAServiceManager(serviceManager).createAVSRewardsSubmission(rewardsSubmissions);
}
Expand All @@ -179,7 +189,7 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
function _verifyUpgrade() internal virtual {
// Preprod RewardsCoordinator
require(
address(rewardsCoordinator) == 0xb22Ef643e1E067c994019A4C19e403253C05c2B0,
address(rewardsCoordinator) == 0xAcc1fb458a1317E886dB376Fc8141540537E68fE,
"ServiceManagerBaseUpgrade: RewardsCoordinator address is incorrect"
);
require(
Expand Down
202 changes: 202 additions & 0 deletions contracts/script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {ERC20PresetFixedSupply} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {
ExistingDeploymentParser,
RewardsCoordinator,
IRewardsCoordinator,
IPauserRegistry,
IStrategy,
IERC20
} from "eigenlayer-scripts/utils/ExistingDeploymentParser.sol";
import {IRegistryCoordinator} from "eigenlayer-middleware/interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";

import {EigenDAServiceManager} from "../../../src/core/EigenDAServiceManager.sol";

/**
* @title ServiceManagerBaseUpgrade for Preprod contracts.
* Assumes EOA deploying has permissions to call the proxyAdmin to upgrade.
*
*
* Local Fork: Deploy/Upgrade RewardsCoordinator
* anvil --fork-url $RPC_HOLESKY
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" upgrade
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" deploy
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" createAVSRewardsSubmission
*
* Upgrade Holesky testnet: Deploy/Upgrade RewardsCoordinator
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" upgrade
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" deploy
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade_preprod.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" createAVSRewardsSubmission
*/
contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
// Hardcode these values to your needs
address public serviceManager = 0x54A03db2784E3D0aCC08344D05385d0b62d4F432;
address public serviceManagerImplementation = 0x798c05C4002Fb0769c5A79f34052c7c2ef322532;

ProxyAdmin public avsProxyAdmin = ProxyAdmin(0x9Fd7E279f5bD692Dc04792151E14Ad814FC60eC1);
address deployerAddress = 0xDA29BB71669f46F2a779b4b62f03644A84eE3479;
address registryCoordinator = 0x2c61EA360D6500b58E7f481541A36B443Bc858c6;
address stakeRegistry = 0x53668EBf2e28180e38B122c641BC51Ca81088871;

function run(string memory deployArg) external {
// 1. Setup and parse existing EigenLayer Holesky preprod contracts
_parseInitialDeploymentParams(
"script/deploy/holesky/config/eigenlayer_preprod.config.json"
);
_parseDeployedContracts(
"script/deploy/holesky/config/eigenlayer_preprod_addresses.config.json"
);

// 2. broadcast deployment
vm.startBroadcast();

emit log_named_address("Deployer Address", msg.sender);

if (keccak256(abi.encode(deployArg)) == keccak256(abi.encode("upgrade"))) {
_upgradeServiceManager();
} else if (keccak256(abi.encode(deployArg)) == keccak256(abi.encode("deploy"))) {
_deployServiceManager();
} else if (keccak256(abi.encode(deployArg)) == keccak256(abi.encode("createAVSRewardsSubmission"))) {
_createAVSRewardsSubmission();
}

vm.stopBroadcast();

// 3. Sanity Checks
_verifyUpgrade();

// Verify Eigenlayer contracts parsed from config
_verifyContractPointers();
_verifyImplementations();
_verifyContractsInitialized({isInitialDeployment: false});
_verifyInitializationParams();
}

/// @dev Should override this to change to your specific upgrade needs
function _upgradeServiceManager() internal virtual {
// 1. Deploy new ServiceManager implementation contract
serviceManagerImplementation = address(
new EigenDAServiceManager(
avsDirectory,
rewardsCoordinator,
IRegistryCoordinator(registryCoordinator),
IStakeRegistry(stakeRegistry)
)
);

// 2. Upgrade the ServiceManager proxy to the new implementation
avsProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(serviceManager))),
address(serviceManagerImplementation)
);
}

function _deployServiceManager() internal virtual {
IPauserRegistry pauserRegistry = IPauserRegistry(0x9Ab2FEAf0465f0eD51Fc2b663eF228B418c9Dad1);
address emptyContract = 0xc08b788d587F927b49665b90ab35D5224965f3d9;
uint256 initialPausedStatus = 0;
address initialOwner = deployerAddress;
address[] memory batchConfirmers;

// 1. Deploy new ServiceManager implementation contract
serviceManagerImplementation = address(
new EigenDAServiceManager(
avsDirectory,
rewardsCoordinator,
IRegistryCoordinator(registryCoordinator),
IStakeRegistry(stakeRegistry)
)
);

// 2. Deploy new TUPS and initialize
serviceManager = address(
new TransparentUpgradeableProxy(emptyContract, address(avsProxyAdmin), "")
);

avsProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(serviceManager))),
address(serviceManagerImplementation),
abi.encodeWithSelector(
EigenDAServiceManager.initialize.selector,
eigenLayerPauserReg,
initialPausedStatus,
initialOwner,
batchConfirmers
)
);
}

/// @notice Example createAVSRewardsSubmission call with the ServiceManager
function _createAVSRewardsSubmission() internal {

uint256 mockTokenInitialSupply = 1e30;
// actual strategy addresses
address stETHStrategy = 0x5C8b55722f421556a2AAfb7A3EA63d4c3e514312;
address rETHStrategy = 0x87f6C7d24b109919eB38295e3F8298425e6331D9;

IRewardsCoordinator.StrategyAndMultiplier[] memory strategyAndMultipliers = new IRewardsCoordinator.StrategyAndMultiplier[](2);
// Strategy addresses must be in ascending order
strategyAndMultipliers[0] = IRewardsCoordinator.StrategyAndMultiplier({
strategy: IStrategy(stETHStrategy),
multiplier: 1e18
});
strategyAndMultipliers[1] = IRewardsCoordinator.StrategyAndMultiplier({
strategy: IStrategy(rETHStrategy),
multiplier: 1e18
});

IERC20 token = new ERC20PresetFixedSupply(
"HARRYPOTTEROBAMASONIC10INU",
"BITCOIN",
mockTokenInitialSupply,
msg.sender
);
// must be in multiples of weeks i.e startTimestamp % 604800 == 0
uint32 startTimestamp = 1714608000;
// must be in multiples of weeks i.e duration % 604800 == 0
uint32 duration = 1 weeks;
// amount <= 1e38 - 1
uint256 amount = 100e18;

// Create RewardsSubmission input param
IRewardsCoordinator.RewardsSubmission[]
memory rewardsSubmissions = new IRewardsCoordinator.RewardsSubmission[](1);
rewardsSubmissions[0] = IRewardsCoordinator.RewardsSubmission({
strategiesAndMultipliers: strategyAndMultipliers,
token: token,
amount: amount,
startTimestamp: startTimestamp,
duration: duration
});

// Set rewardsInitiator
// EigenDAServiceManager(serviceManager).setRewardsInitiator(msg.sender);

token.approve(serviceManager, amount);
EigenDAServiceManager(serviceManager).createAVSRewardsSubmission(rewardsSubmissions);
}

/// @dev check implementation address set properly
function _verifyUpgrade() internal virtual {
// Preprod RewardsCoordinator
require(
address(rewardsCoordinator) == 0xb22Ef643e1E067c994019A4C19e403253C05c2B0,
"ServiceManagerBaseUpgrade: RewardsCoordinator address is incorrect"
);
require(
avsProxyAdmin.getProxyImplementation(
TransparentUpgradeableProxy(payable(serviceManager))
) == serviceManagerImplementation,
"ServiceManagerBaseUpgrade: ServiceMananger implementation initially set incorrectly"
);
require(
msg.sender == deployerAddress,
"ServiceManagerBaseUpgrade: deployer address is incorrect"
);
}
}
58 changes: 58 additions & 0 deletions contracts/script/deploy/holesky/config/eigenlayer.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"chainInfo": {
"chainId": 17000
},
"multisig_addresses": {
"pauserMultisig": "0x53410249ec7d3a3F9F1ba3912D50D6A3Df6d10A7",
"communityMultisig": "0xCb8d2f9e55Bc7B1FA9d089f9aC80C583D2BDD5F7",
"operationsMultisig": "0xfaEF7338b7490b9E272d80A1a39f4657cAf2b97d",
"executorMultisig": "0x28Ade60640fdBDb2609D8d8734D1b5cBeFc0C348",
"timelock": "0xcF19CE0561052a7A7Ff21156730285997B350A7D"
},
"strategies": {
"numStrategies": 0,
"MAX_PER_DEPOSIT": 115792089237316195423570985008687907853269984665640564039457584007913129639935,
"MAX_TOTAL_DEPOSITS": 115792089237316195423570985008687907853269984665640564039457584007913129639935,
"strategiesToDeploy": []
},
"strategyManager": {
"init_strategy_whitelister": "0x28Ade60640fdBDb2609D8d8734D1b5cBeFc0C348",
"init_paused_status": 0
},
"delegationManager": {
"init_paused_status": 0,
"init_minWithdrawalDelayBlocks": 10
},
"rewardsCoordinator": {
"init_paused_status": 0,
"CALCULATION_INTERVAL_SECONDS": 604800,
"MAX_REWARDS_DURATION": 6048000,
"MAX_RETROACTIVE_LENGTH": 7776000,
"MAX_FUTURE_LENGTH": 2592000,
"GENESIS_REWARDS_TIMESTAMP": 1710979200,
"rewards_updater_address": "0xBda666E84f5354358edC1Cd24c062bd831818C5A",
"activation_delay": 7200,
"calculation_interval_seconds": 604800,
"global_operator_commission_bips": 1000
},
"avsDirectory": {
"init_paused_status": 0
},
"slasher": {
"init_paused_status": 0
},
"eigenPod": {
"MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR": 32000000000,
"GENESIS_TIME": 1695902400
},
"eigenPodManager": {
"init_paused_status": 0,
"deneb_fork_timestamp": "1707305664"
},
"delayedWithdrawalRouter": {
"init_paused_status": 0,
"init_withdrawalDelayBlocks": 10
},
"ethPOSDepositAddress": "0x4242424242424242424242424242424242424242",
"beaconOracleAddress": "0x4C116BB629bff7A8373c2378bBd919f8349B8f25"
}
Loading
Loading