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

WIP: Lets improve deployment #685

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ script/output/M1_deployment_data.json
/docs/docgen/

script/misc
script/output

test.sh

Expand Down
88 changes: 87 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,93 @@ surya mdreport surya_report.md ./src/contracts/**/*.sol
make bindings
```

## Deployments
## Deploy EigenLayer Contracts

### Deploy to Anvil

1\. Start `anvil`

```bash
$ anvil --host 0.0.0.0 --accounts 1 --balance 100
```

2\. Make a note of your RPC_URL

```bash
$ RPC_URL=http://localhost:8545
```

3\. Make a note of your account and private key

```bash
$ PUBLIC_KEY=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
$ PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
```

4\. check your connection

```bash
$ cast balance ${PUBLIC_KEY} --rpc-url ${RPC_URL}
```

5\. Deploy M2 Contracts

```bash
$ forge script script/deploy/devnet/M2_Deploy_From_Scratch.s.sol --rpc-url ${RPC_URL} \
--private-key ${PRIVATE_KEY} --broadcast \
--sig "run(string)" -- M2_deploy_from_scratch.anvil.config.json
```

6\. Upgrade M2 Contracts

```bash
$ forge script script/deploy/devnet/M2_Deploy_From_Scratch.s.sol --rpc-url ${RPC_URL} \
--private-key ${PRIVATE_KEY} --broadcast \
--sig "upgrade(string,string)" -- M2_deploy_from_scratch.anvil.config.json M2_deploy_from_scratch_deployment_data.json
```


Contracts deployment information is saved in `script/output/devnet/M2_from_scratch_deployment_data.json`

### Deploy to DevNet

Devnet can be started locally or contact the protocol team for a public url

1\. Make a note of the devnet `RPC_URL`

```bash
$ RPC_URL=http://devnet...:8545
```

2. Make a note of the deployer account and private key

```bash
$ PUBLIC_KEY=0x4a3Ee341f8ceEdB790F511A18899fBC1fdEb35af
$ PRIVATE_KEY=...
```

4\. check your connection

```bash
$ cast balance ${PUBLIC_KEY} --rpc-url ${RPC_URL}
```

5\. Deploy M2 Contracts

```bash
$ forge script script/deploy/devnet/M2_Deploy_From_Scratch.s.sol --rpc-url ${RPC_URL} \
--private-key ${PRIVATE_KEY} --broadcast \
--sig "run(string)" -- M2_deploy_from_scratch.devnet.config.json
```

6\. Upgrade Contracts
```bash
$ forge script script/deploy/devnet/M2_Deploy_From_Scratch.s.sol --rpc-url ${RPC_URL} \
--private-key ${PRIVATE_KEY} --broadcast \
--sig "upgrade(string,string)" -- M2_deploy_from_scratch.devnet.config.json M2_deploy_from_scratch.devnet.config.json
```

Contracts deployment information is saved in `script/output/devnet/M2_from_scratch_deployment_data.json`

### Current Mainnet Deployment

Expand Down
44 changes: 44 additions & 0 deletions script/configs/devnet/M2_deploy_from_scratch.devnet.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"maintainer": "[email protected]",
"multisig_addresses": {
"operationsMultisig": "0x4a3Ee341f8ceEdB790F511A18899fBC1fdEb35af",
"pauserMultisig": "0x4a3Ee341f8ceEdB790F511A18899fBC1fdEb35af",
"executorMultisig": "0x4a3Ee341f8ceEdB790F511A18899fBC1fdEb35af"
},
"strategies": [],
"strategyManager": {
"init_paused_status": 0,
"init_withdrawal_delay_blocks": 1
},
"eigenPod": {
"PARTIAL_WITHDRAWAL_FRAUD_PROOF_PERIOD_BLOCKS": 1,
"MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR": "32000000000"
},
"eigenPodManager": {
"init_paused_status": 30
},
"delayedWithdrawalRouter": {
"init_paused_status": 0,
"init_withdrawal_delay_blocks": 1
},
"slasher": {
"init_paused_status": 0
},
"delegation": {
"init_paused_status": 0,
"init_withdrawal_delay_blocks": 1
},
"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": "0x18a0f92Ad9645385E8A8f3db7d0f6CF7aBBb0aD4",
"activation_delay": 7200,
"calculation_interval_seconds": 604800,
"global_operator_commission_bips": 1000
},
"ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
}
152 changes: 152 additions & 0 deletions script/deploy/devnet/DeploymentDetails.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.12;
// solhint-disable no-console

import {stdJson} from "forge-std/StdJson.sol";
import {console2} from "forge-std/console2.sol";
import {VmSafe} from "forge-std/Vm.sol";

struct ContractDeployment {
address avsDirectory;
address avsDirectoryImplementation;
address baseStrategyImplementation;
address delegationManager;
address delegationManagerImplementation;
address eigenPodBeacon;
address eigenPodImplementation;
address eigenPodManager;
address eigenPodManagerImplementation;
address emptyContract;
address pauserRegistry;
address proxyAdmin;
address rewardsCoordinator;
address rewardsCoordinatorImplementation;
address slasher;
address slasherImplementation;
address strategyManager;
address strategyManagerImplementation;
address ethDepositAddress;
}

library DeploymentDetails {
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));

function write(
ContractDeployment calldata deploymentDetails,
address executorMultisig,
address operationsMultisig,
address nilContract
) external {
// WRITE JSON DATA
string memory parentObject = "parent object";

string memory deployedAddresses = "address";
vm.serializeAddress(deployedAddresses, "proxyAdmin", deploymentDetails.proxyAdmin);
vm.serializeAddress(deployedAddresses, "pauserRegistry", deploymentDetails.pauserRegistry);
vm.serializeAddress(deployedAddresses, "slasher", deploymentDetails.slasher);
vm.serializeAddress(deployedAddresses, "slasherImplementation", deploymentDetails.slasherImplementation);
vm.serializeAddress(deployedAddresses, "delegationManager", deploymentDetails.delegationManager);
vm.serializeAddress(
deployedAddresses,
"delegationManagerImplementation",
deploymentDetails.delegationManagerImplementation
);
vm.serializeAddress(deployedAddresses, "avsDirectory", deploymentDetails.avsDirectory);
vm.serializeAddress(
deployedAddresses,
"avsDirectoryImplementation",
deploymentDetails.avsDirectoryImplementation
);
vm.serializeAddress(deployedAddresses, "strategyManager", deploymentDetails.strategyManager);
vm.serializeAddress(
deployedAddresses,
"strategyManagerImplementation",
deploymentDetails.strategyManagerImplementation
);
vm.serializeAddress(deployedAddresses, "eigenPodManager", deploymentDetails.eigenPodManager);
vm.serializeAddress(
deployedAddresses,
"eigenPodManagerImplementation",
deploymentDetails.eigenPodManagerImplementation
);
vm.serializeAddress(deployedAddresses, "rewardsCoordinator", deploymentDetails.rewardsCoordinator);
vm.serializeAddress(
deployedAddresses,
"rewardsCoordinatorImplementation",
deploymentDetails.rewardsCoordinatorImplementation
);
vm.serializeAddress(deployedAddresses, "eigenPodBeacon", deploymentDetails.eigenPodBeacon);
vm.serializeAddress(deployedAddresses, "eigenPodImplementation", deploymentDetails.eigenPodImplementation);
vm.serializeAddress(
deployedAddresses,
"baseStrategyImplementation",
deploymentDetails.baseStrategyImplementation
);
vm.serializeAddress(deployedAddresses, "emptyContract", nilContract);
vm.serializeAddress(deployedAddresses, "ethDepositAddress", deploymentDetails.ethDepositAddress);

string memory deployedAddressesOutput = vm.serializeString(deployedAddresses, "strategies", "");

string memory parameters = "parameters";
vm.serializeAddress(parameters, "executorMultisig", executorMultisig);
string memory parametersOutput = vm.serializeAddress(parameters, "operationsMultisig", operationsMultisig);

string memory chainInfo = "chainInfo";
vm.serializeUint(chainInfo, "deploymentBlock", block.number);
string memory chainInfo_output = vm.serializeUint(chainInfo, "chainId", block.chainid);

// serialize all the data
vm.serializeString(parentObject, deployedAddresses, deployedAddressesOutput);
vm.serializeString(parentObject, chainInfo, chainInfo_output);
string memory finalJson = vm.serializeString(parentObject, parameters, parametersOutput);
// TODO: should output to different file depending on configFile passed to run()
// so that we don't override mainnet output by deploying to goerli for eg.
vm.writeJson(finalJson, "script/output/devnet/M2_deploy_from_scratch_deployment_data.json");
console2.log("Deployment data written to script/output/devnet/M2_deploy_from_scratch_deployment_data.json");
}

function read(string memory deploymentFileName) external returns (ContractDeployment memory) {
string memory deployDetailsPath = string(bytes(string.concat("script/output/devnet/", deploymentFileName)));
string memory deployData = vm.readFile(deployDetailsPath);
ContractDeployment memory deploymentDetails;
deploymentDetails.avsDirectory = stdJson.readAddress(deployData, ".address.avsDirectory");
deploymentDetails.avsDirectoryImplementation = stdJson.readAddress(
deployData,
".address.avsDirectoryImplementation"
);
deploymentDetails.baseStrategyImplementation = stdJson.readAddress(
deployData,
".address.baseStrategyImplementation"
);
deploymentDetails.delegationManager = stdJson.readAddress(deployData, ".address.delegationManager");
deploymentDetails.delegationManagerImplementation = stdJson.readAddress(
deployData,
".address.delegationManagerImplementation"
);
deploymentDetails.eigenPodBeacon = stdJson.readAddress(deployData, ".address.eigenPodBeacon");
deploymentDetails.eigenPodImplementation = stdJson.readAddress(deployData, ".address.eigenPodImplementation");
deploymentDetails.eigenPodManager = stdJson.readAddress(deployData, ".address.eigenPodManager");
deploymentDetails.eigenPodManagerImplementation = stdJson.readAddress(
deployData,
".address.eigenPodManagerImplementation"
);
deploymentDetails.emptyContract = stdJson.readAddress(deployData, ".address.emptyContract");
deploymentDetails.pauserRegistry = stdJson.readAddress(deployData, ".address.pauserRegistry");
deploymentDetails.proxyAdmin = stdJson.readAddress(deployData, ".address.proxyAdmin");
deploymentDetails.rewardsCoordinator = stdJson.readAddress(deployData, ".address.rewardsCoordinator");
deploymentDetails.rewardsCoordinatorImplementation = stdJson.readAddress(
deployData,
".address.rewardsCoordinatorImplementation"
);
deploymentDetails.slasher = stdJson.readAddress(deployData, ".address.slasher");
deploymentDetails.slasherImplementation = stdJson.readAddress(deployData, ".address.slasherImplementation");
deploymentDetails.strategyManager = stdJson.readAddress(deployData, ".address.strategyManager");
deploymentDetails.strategyManagerImplementation = stdJson.readAddress(
deployData,
".address.strategyManagerImplementation"
);
deploymentDetails.ethDepositAddress = stdJson.readAddress(deployData, ".address.ethDepositAddress");

return deploymentDetails;
}
}
Loading
Loading