Skip to content

Commit

Permalink
Add Holesky and rollup deployment scripts (#82)
Browse files Browse the repository at this point in the history
* refactor: Move scripts to specific network directories and move similar methods to Utils

* chore: Add Holesky deployment addresses

* feat: Add rollup deployment scripts

* chore: Add rollup deployment addresses
  • Loading branch information
Hyodar authored Apr 17, 2024
1 parent 5c136f7 commit 4e45714
Show file tree
Hide file tree
Showing 10 changed files with 652 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ import {IndexRegistry} from "eigenlayer-middleware/src/IndexRegistry.sol";
import {StakeRegistry} from "eigenlayer-middleware/src/StakeRegistry.sol";
import {OperatorStateRetriever} from "eigenlayer-middleware/src/OperatorStateRetriever.sol";

import {RegistryCoordinator} from "../src/external/RegistryCoordinator.sol";
import {SFFLServiceManager} from "../src/eth/SFFLServiceManager.sol";
import {SFFLTaskManager} from "../src/eth/SFFLTaskManager.sol";
import {SFFLRegistryCoordinator} from "../src/eth/SFFLRegistryCoordinator.sol";
import {SFFLOperatorSetUpdateRegistry} from "../src/eth/SFFLOperatorSetUpdateRegistry.sol";
import {ERC20Mock, IERC20} from "../test/mock/ERC20Mock.sol";
import {RegistryCoordinator} from "../../../src/external/RegistryCoordinator.sol";
import {SFFLServiceManager} from "../../../src/eth/SFFLServiceManager.sol";
import {SFFLTaskManager} from "../../../src/eth/SFFLTaskManager.sol";
import {SFFLRegistryCoordinator} from "../../../src/eth/SFFLRegistryCoordinator.sol";
import {SFFLOperatorSetUpdateRegistry} from "../../../src/eth/SFFLOperatorSetUpdateRegistry.sol";
import {ERC20Mock, IERC20} from "../../../test/mock/ERC20Mock.sol";

import {Utils} from "./utils/Utils.sol";
import {Utils} from "../../utils/Utils.sol";

import "forge-std/Test.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/console.sol";

// forge script script/SFFLDeployer.s.sol:SFFLDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv
contract SFFLDeployer is Script, Utils {
uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 100;
uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30;
Expand Down Expand Up @@ -197,6 +196,7 @@ contract SFFLDeployer is Script, Utils {
/**
* @dev Deploys the SFFL contracts.
* @param delegationManager The delegation manager.
* @param avsDirectory The AVS directory.
* @param strat The deployed strategy.
* @param sfflCommunityMultisig The community multisig.
* @param sfflPauser The pauser.
Expand All @@ -219,25 +219,25 @@ contract SFFLDeployer is Script, Utils {

sfflPauserReg = new PauserRegistry(pausers, sfflCommunityMultisig);

sfflServiceManagerProxy = _deployEmptyProxy(sfflProxyAdmin);
sfflServiceManagerProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
sfflServiceManager = SFFLServiceManager(address(sfflServiceManagerProxy));

sfflTaskManagerProxy = _deployEmptyProxy(sfflProxyAdmin);
sfflTaskManagerProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
sfflTaskManager = SFFLTaskManager(address(sfflTaskManagerProxy));

registryCoordinatorProxy = _deployEmptyProxy(sfflProxyAdmin);
registryCoordinatorProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
registryCoordinator = SFFLRegistryCoordinator(address(registryCoordinatorProxy));

blsApkRegistryProxy = _deployEmptyProxy(sfflProxyAdmin);
blsApkRegistryProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
blsApkRegistry = BLSApkRegistry(address(blsApkRegistryProxy));

indexRegistryProxy = _deployEmptyProxy(sfflProxyAdmin);
indexRegistryProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
indexRegistry = IndexRegistry(address(indexRegistryProxy));

operatorSetUpdateRegistryProxy = _deployEmptyProxy(sfflProxyAdmin);
operatorSetUpdateRegistryProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
operatorSetUpdateRegistry = SFFLOperatorSetUpdateRegistry(address(operatorSetUpdateRegistryProxy));

stakeRegistryProxy = _deployEmptyProxy(sfflProxyAdmin);
stakeRegistryProxy = _deployEmptyProxy(sfflProxyAdmin, address(emptyContract));
stakeRegistry = StakeRegistry(address(stakeRegistryProxy));

operatorStateRetriever = new OperatorStateRetriever();
Expand Down Expand Up @@ -332,53 +332,6 @@ contract SFFLDeployer is Script, Utils {
_serializeSFFLDeployedContracts();
}

/**
* @dev Deploys a new proxy contract using the given implementation and initialization data.
* @param _impl Address of the implementation contract.
* @param _admin Proxy admin.
* @param _initCode Initialization code.
*/
function _deployProxy(ProxyAdmin _admin, address _impl, bytes memory _initCode)
internal
returns (TransparentUpgradeableProxy)
{
return new TransparentUpgradeableProxy(_impl, address(_admin), _initCode);
}

/**
* @dev Deploys an empty proxy - i.e. a zero implementation and with no init code
* @param _admin Proxy admin.
*/
function _deployEmptyProxy(ProxyAdmin _admin) internal returns (TransparentUpgradeableProxy) {
return new TransparentUpgradeableProxy(address(emptyContract), address(_admin), "");
}

/**
* @dev Upgrades a proxy to a new implementation.
* @param _admin Proxy admin.
* @param _proxy The proxy to upgrade.
* @param _impl The new implementation to upgrade to.
*/
function _upgradeProxy(ProxyAdmin _admin, TransparentUpgradeableProxy _proxy, address _impl) internal {
_admin.upgrade(_proxy, _impl);
}

/**
* @dev Upgrades a proxy to a new impl and calls a function on the implementation.
* @param _admin Proxy admin.
* @param _proxy The proxy to upgrade.
* @param _impl The new impl to upgrade to.
* @param _data The encoded calldata to use in the call after upgrading.
*/
function _upgradeProxyAndCall(
ProxyAdmin _admin,
TransparentUpgradeableProxy _proxy,
address _impl,
bytes memory _data
) internal {
_admin.upgradeAndCall(_proxy, _impl, _data);
}

/**
* @dev Serializes the SFFL deployed contracts to the forge output.
*/
Expand Down
82 changes: 82 additions & 0 deletions contracts/evm/script/deploy/devnet/SFFLDeployerRollup.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import {ProxyAdmin, TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

import {PauserRegistry} from "@eigenlayer/contracts/permissions/PauserRegistry.sol";

import {SFFLRegistryRollup} from "../../../src/rollup/SFFLRegistryRollup.sol";

import {Utils} from "../../utils/Utils.sol";

import "forge-std/Test.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/console.sol";

contract SFFLDeployerRollup is Script, Utils {
uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 66;
address public constant AGGREGATOR_ADDR = 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720;

ProxyAdmin public sfflProxyAdmin;
PauserRegistry public sfflPauserReg;

SFFLRegistryRollup public sfflRegistryRollup;
TransparentUpgradeableProxy public sfflRegistryRollupProxy;
address public sfflRegistryRollupImpl;

string public constant SFFL_DEPLOYMENT_FILE = "sffl_rollup_deployment_output";

function run() external {
address sfflCommunityMultisig = msg.sender;
address sfflPauser = msg.sender;

vm.startBroadcast();

sfflProxyAdmin = new ProxyAdmin();

address[] memory pausers = new address[](2);
pausers[0] = sfflPauser;
pausers[1] = sfflCommunityMultisig;

sfflPauserReg = new PauserRegistry(pausers, sfflCommunityMultisig);

sfflRegistryRollupImpl = address(new SFFLRegistryRollup());
sfflRegistryRollupProxy = _deployProxy(
sfflProxyAdmin,
sfflRegistryRollupImpl,
abi.encodeWithSelector(
SFFLRegistryRollup.initialize.selector,
QUORUM_THRESHOLD_PERCENTAGE,
sfflCommunityMultisig,
AGGREGATOR_ADDR,
sfflPauserReg
)
);
sfflRegistryRollup = SFFLRegistryRollup(address(sfflRegistryRollupProxy));

_serializeSFFLDeployedContracts();

vm.stopBroadcast();
}

/**
* @dev Serializes the SFFL deployed contracts to the forge output.
*/
function _serializeSFFLDeployedContracts() internal {
string memory parent_object = "parent object";
string memory addresses = "addresses";

string memory output;

output = vm.serializeAddress(addresses, "deployer", address(msg.sender));
output = vm.serializeAddress(addresses, "sfflProxyAdmin", address(sfflProxyAdmin));
output = vm.serializeAddress(addresses, "sfflPauserReg", address(sfflPauserReg));
output = vm.serializeAddress(addresses, "sfflRegistryRollup", address(sfflRegistryRollup));
output = vm.serializeAddress(addresses, "sfflRegistryRollupImpl", address(sfflRegistryRollupImpl));

string memory finalJson = vm.serializeString(parent_object, addresses, output);

writeOutput(finalJson, SFFL_DEPLOYMENT_FILE);
}
}
Loading

0 comments on commit 4e45714

Please sign in to comment.