Skip to content

Commit

Permalink
refactor: deployment scripts (#79)
Browse files Browse the repository at this point in the history
* chore: update eigenlayer contract address

* refactor: deployment script
  • Loading branch information
renlulu authored Apr 4, 2024
1 parent d7c0eb0 commit a058f98
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 62 deletions.
111 changes: 69 additions & 42 deletions contracts/script/MachServiceManagerDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,35 @@ contract MachServiceManagerDeployer is Script {
AVSDirectory avsDirectory;
DelegationManager delegationManager;
StrategyManager strategyManager;
StrategyBaseTVLLimits strategyBaseTVLLimits;
address stETH;
address rETH;
address LsETH;
address sfrxETH;
address ETHx;
address osETH;
address cbETH;
address mETH;
address ankrETH;
address WETH;
address beaconETH;
}

struct AddressConfig {
struct DeploymentConfig {
// from team
address machAVSCommunityMultisig;
address machAVSPauser;
address churner;
address ejector;
address confirmer;
uint256 chainId;
uint256 numStrategies;
uint256 maxOperatorCount;
// from eigenlayer contracts
address avsDirectory;
address delegationManager;
}

function run() external {
uint8 numStrategies = 1;
uint256 maxOperatorCount = 10;

EigenLayerContracts memory eigenLayerContracts;

{
Expand All @@ -75,9 +84,6 @@ contract MachServiceManagerDeployer is Script {

bytes memory deployedStrategyManagerData = vm.parseJson(deployedEigenLayerAddresses, ".strategyManager");
address deployedStrategyManager = abi.decode(deployedStrategyManagerData, (address));
bytes memory deployedStrategyBaseTVLLimitsData =
vm.parseJson(deployedEigenLayerAddresses, ".strategyBaseTVLLimits");
address deployedStrategyBaseTVLLimits = abi.decode(deployedStrategyBaseTVLLimitsData, (address));
bytes memory deployedAvsDirectoryData = vm.parseJson(deployedEigenLayerAddresses, ".avsDirectory");
address deployedAvsDirectory = abi.decode(deployedAvsDirectoryData, (address));
bytes memory deployedDelegationManagerData = vm.parseJson(deployedEigenLayerAddresses, ".delegationManager");
Expand All @@ -86,36 +92,59 @@ contract MachServiceManagerDeployer is Script {
eigenLayerContracts.avsDirectory = AVSDirectory(deployedAvsDirectory);
eigenLayerContracts.strategyManager = StrategyManager(deployedStrategyManager);
eigenLayerContracts.delegationManager = DelegationManager(deployedDelegationManager);
eigenLayerContracts.strategyBaseTVLLimits = StrategyBaseTVLLimits(deployedStrategyBaseTVLLimits);
eigenLayerContracts.stETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".stETH"), (address));
eigenLayerContracts.rETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".rETH"), (address));
eigenLayerContracts.LsETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".LsETH"), (address));
eigenLayerContracts.sfrxETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".sfrxETH"), (address));
eigenLayerContracts.ETHx = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".ETHx"), (address));
eigenLayerContracts.osETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".osETH"), (address));
eigenLayerContracts.cbETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".cbETH"), (address));
eigenLayerContracts.mETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".mETH"), (address));
eigenLayerContracts.ankrETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".ankrETH"), (address));
eigenLayerContracts.WETH = abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".WETH"), (address));
eigenLayerContracts.beaconETH =
abi.decode(vm.parseJson(deployedEigenLayerAddresses, ".beaconETH"), (address));
}

DeploymentConfig memory deploymentConfig;
deploymentConfig.machAVSCommunityMultisig = msg.sender;
deploymentConfig.machAVSPauser = msg.sender;
deploymentConfig.churner = msg.sender;
deploymentConfig.ejector = msg.sender;
deploymentConfig.confirmer = msg.sender;
deploymentConfig.chainId = 1;
deploymentConfig.numStrategies = 11;
deploymentConfig.maxOperatorCount = 30;
deploymentConfig.avsDirectory = address(eigenLayerContracts.avsDirectory);
deploymentConfig.delegationManager = address(eigenLayerContracts.delegationManager);

// strategies deployed
StrategyBaseTVLLimits[] memory deployedStrategyArray = new StrategyBaseTVLLimits[](1);
deployedStrategyArray[0] = StrategyBaseTVLLimits(address(eigenLayerContracts.strategyBaseTVLLimits));
address[] memory deployedStrategyArray = new address[](11);
deployedStrategyArray[0] = eigenLayerContracts.stETH;
deployedStrategyArray[1] = eigenLayerContracts.rETH;
deployedStrategyArray[2] = eigenLayerContracts.LsETH;
deployedStrategyArray[3] = eigenLayerContracts.sfrxETH;
deployedStrategyArray[4] = eigenLayerContracts.ETHx;
deployedStrategyArray[5] = eigenLayerContracts.osETH;
deployedStrategyArray[6] = eigenLayerContracts.cbETH;
deployedStrategyArray[7] = eigenLayerContracts.mETH;
deployedStrategyArray[8] = eigenLayerContracts.ankrETH;
deployedStrategyArray[9] = eigenLayerContracts.WETH;
deployedStrategyArray[10] = eigenLayerContracts.beaconETH;

vm.startBroadcast();
// deploy proxy admin for ability to upgrade proxy contracts
ProxyAdmin machAVSProxyAdmin = new ProxyAdmin();
EmptyContract emptyContract = new EmptyContract();

AddressConfig memory addressConfig;
addressConfig.machAVSCommunityMultisig = msg.sender;
addressConfig.machAVSPauser = msg.sender;
addressConfig.churner = msg.sender;
addressConfig.ejector = msg.sender;
addressConfig.confirmer = msg.sender;
addressConfig.chainId = 1;
addressConfig.avsDirectory = address(eigenLayerContracts.avsDirectory);
addressConfig.delegationManager = address(eigenLayerContracts.delegationManager);

PauserRegistry pauserRegistry;

// deploy pauser registry
{
address[] memory pausers = new address[](2);
pausers[0] = addressConfig.machAVSPauser;
pausers[1] = addressConfig.machAVSCommunityMultisig;
pauserRegistry = new PauserRegistry(pausers, addressConfig.machAVSCommunityMultisig);
pausers[0] = deploymentConfig.machAVSPauser;
pausers[1] = deploymentConfig.machAVSCommunityMultisig;
pauserRegistry = new PauserRegistry(pausers, deploymentConfig.machAVSCommunityMultisig);
}

MachServiceContract memory machServiceContract;
Expand Down Expand Up @@ -148,7 +177,7 @@ contract MachServiceManagerDeployer is Script {
);

machServiceContract.stakeRegistryImplementation = new StakeRegistry(
machServiceContract.registryCoordinator, IDelegationManager(addressConfig.delegationManager)
machServiceContract.registryCoordinator, IDelegationManager(deploymentConfig.delegationManager)
);
machAVSProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(machServiceContract.stakeRegistry))),
Expand All @@ -170,33 +199,31 @@ contract MachServiceManagerDeployer is Script {

{
IRegistryCoordinator.OperatorSetParam[] memory operatorSetParams =
new IRegistryCoordinator.OperatorSetParam[](numStrategies);
for (uint256 i = 0; i < numStrategies; i++) {
new IRegistryCoordinator.OperatorSetParam[](deploymentConfig.numStrategies);
for (uint256 i = 0; i < deploymentConfig.numStrategies; i++) {
// hard code these for now
operatorSetParams[i] = IRegistryCoordinator.OperatorSetParam({
maxOperatorCount: uint32(maxOperatorCount),
maxOperatorCount: uint32(deploymentConfig.maxOperatorCount),
kickBIPsOfOperatorStake: 11000, // an operator needs to have kickBIPsOfOperatorStake / 10000 times the stake of the operator with the least stake to kick them out
kickBIPsOfTotalStake: 1001 // an operator needs to have less than kickBIPsOfTotalStake / 10000 of the total stake to be kicked out
});
}
uint96[] memory minimumStakeForQuourm = new uint96[](numStrategies);
uint96[] memory minimumStakeForQuourm = new uint96[](deploymentConfig.numStrategies);
IStakeRegistry.StrategyParams[][] memory strategyAndWeightingMultipliers =
new IStakeRegistry.StrategyParams[][](numStrategies);
for (uint256 i = 0; i < numStrategies; i++) {
new IStakeRegistry.StrategyParams[][](deploymentConfig.numStrategies);
for (uint256 i = 0; i < deploymentConfig.numStrategies; i++) {
strategyAndWeightingMultipliers[i] = new IStakeRegistry.StrategyParams[](1);
strategyAndWeightingMultipliers[i][0] = IStakeRegistry.StrategyParams({
strategy: IStrategy(address(deployedStrategyArray[i])),
multiplier: 1 ether
});
strategyAndWeightingMultipliers[i][0] =
IStakeRegistry.StrategyParams({strategy: IStrategy(deployedStrategyArray[i]), multiplier: 1 ether});
}
machAVSProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(machServiceContract.registryCoordinator))),
address(machServiceContract.registryCoordinatorImplementation),
abi.encodeWithSelector(
RegistryCoordinator.initialize.selector,
addressConfig.machAVSCommunityMultisig,
addressConfig.churner,
addressConfig.ejector,
deploymentConfig.machAVSCommunityMultisig,
deploymentConfig.churner,
deploymentConfig.ejector,
IPauserRegistry(pauserRegistry),
0, // initial paused status is nothing paused
operatorSetParams,
Expand All @@ -206,10 +233,10 @@ contract MachServiceManagerDeployer is Script {
);
}
machServiceContract.machServiceManagerImplementation = new MachServiceManager(
IAVSDirectory(addressConfig.avsDirectory),
IAVSDirectory(deploymentConfig.avsDirectory),
machServiceContract.registryCoordinator,
machServiceContract.stakeRegistry,
addressConfig.chainId
deploymentConfig.chainId
);
// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
machAVSProxyAdmin.upgradeAndCall(
Expand All @@ -219,8 +246,8 @@ contract MachServiceManagerDeployer is Script {
MachServiceManager.initialize.selector,
IPauserRegistry(pauserRegistry),
0,
addressConfig.machAVSCommunityMultisig,
addressConfig.machAVSCommunityMultisig
deploymentConfig.machAVSCommunityMultisig,
deploymentConfig.machAVSCommunityMultisig
)
);
vm.stopBroadcast();
Expand Down
34 changes: 14 additions & 20 deletions contracts/script/output/eigenlayer_deploy_output.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
{
"avsDirectory": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"avsDirectoryImplementation": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"baseStrategyImplementation": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
"delayedWithdrawalRouter": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
"delayedWithdrawalRouterImplementation": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"delegationManager": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"delegationManagerImplementation": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
"eigenLayerPauserRegistry": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"eigenLayerProxyAdmin": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"eigenPodBeacon": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
"eigenPodImplementation": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
"eigenPodManager": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"eigenPodManagerImplementation": "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
"object": "eigenlayer contracts deployment output",
"slasher": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"slasherImplementation": "0x9A676e781A523b5d0C0e43731313A708CB607508",
"strategyBaseTVLLimits": "0x4A679253410272dd5232B3Ff7cF5dbB88f295319",
"strategyManager": "0x0165878A594ca255338adfa4d48449f69242Eb8F",
"strategyManagerImplementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"underlayingToken": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44"
"strategyManager": "0xdfB5f6CE42aAA7830E94ECFCcAd411beF4d4D5b6",
"avsDirectory": "0x055733000064333CaDDbC92763c58BF0192fFeBf",
"delegationManager": "0xA44151489861Fe9e3055d95adC98FbD462B948e7",
"stETH": "0x7D704507b76571a51d9caE8AdDAbBFd0ba0e63d3",
"rETH": "0x3A8fBdf9e77DFc25d09741f51d3E181b25d0c4E0",
"LsETH": "0x05037A81BD7B4C9E0F7B430f1F2A22c31a2FD943",
"sfrxETH": "0x9281ff96637710Cd9A5CAcce9c6FAD8C9F54631c",
"ETHx": "0x31B6F59e1627cEfC9fA174aD03859fC337666af7",
"osETH": "0x46281E3B7fDcACdBa44CADf069a94a588Fd4C6Ef",
"cbETH": "0x70EB4D3c164a6B4A5f908D4FBb5a9cAfFb66bAB6",
"mETH": "0xaccc5A86732BE85b5012e8614AF237801636F8e5",
"ankrETH": "0x7673a47463F80c6a3553Db9E54c8cDcd5313d0ac",
"WETH": "0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9",
"beaconETH": "0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0"
}

0 comments on commit a058f98

Please sign in to comment.