diff --git a/contracts/script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol b/contracts/script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol index 6fb84b1e4c..581f4292c7 100644 --- a/contracts/script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol +++ b/contracts/script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol @@ -2,24 +2,36 @@ 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, PaymentCoordinator} from "eigenlayer-scripts/utils/ExistingDeploymentParser.sol"; +import { + ExistingDeploymentParser, + PaymentCoordinator, + IPaymentCoordinator, + 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. + * @title ServiceManagerBaseUpgrade for Preprod contracts. * Assumes EOA deploying has permissions to call the proxyAdmin to upgrade. * * * Local Fork: Deploy/Upgrade PaymentCoordinator * anvil --fork-url $RPC_HOLESKY - * forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --verify + * forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.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_PaymentsUpgrade.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_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" payForRange * * Upgrade Holesky testnet: Deploy/Upgrade PaymentCoordinator - * forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast -vvvv --verify + * forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.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_PaymentsUpgrade.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_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" payForRange */ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser { // Hardcode these values to your needs @@ -30,7 +42,7 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser { address registryCoordinator = 0x2c61EA360D6500b58E7f481541A36B443Bc858c6; address stakeRegistry = 0x53668EBf2e28180e38B122c641BC51Ca81088871; - function run() external { + function run(string memory deployArg) external { // 1. Setup and parse existing EigenLayer Holesky preprod contracts _parseInitialDeploymentParams( "script/deploy/holesky/config/eigenlayer_preprod.config.json" @@ -43,10 +55,16 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser { vm.startBroadcast(); emit log_named_address("Deployer Address", msg.sender); - _upgradeServiceManager(); - vm.stopBroadcast(); + 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("payForRange"))) { + _payForRange(); + } + vm.stopBroadcast(); // 3. Sanity Checks _verifyUpgrade(); @@ -77,7 +95,87 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser { ); } - /// @dev + 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, + paymentCoordinator, + 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 payForRange call with the ServiceManager + function _payForRange() internal { + uint256 mockTokenInitialSupply = 1e30; + address stETHStrategy = 0x5C8b55722f421556a2AAfb7A3EA63d4c3e514312; + address rETHStrategy = 0x87f6C7d24b109919eB38295e3F8298425e6331D9; + + IPaymentCoordinator.StrategyAndMultiplier[] memory strategyAndMultipliers = new IPaymentCoordinator.StrategyAndMultiplier[](2); + // Strategy addresses must be in ascending order + strategyAndMultipliers[0] = IPaymentCoordinator.StrategyAndMultiplier({ + strategy: IStrategy(stETHStrategy), + multiplier: 1e18 + }); + strategyAndMultipliers[1] = IPaymentCoordinator.StrategyAndMultiplier({ + strategy: IStrategy(rETHStrategy), + multiplier: 1e18 + }); + + IERC20 token = new ERC20PresetFixedSupply( + "dog wif hat", + "MOCK1", + 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; + + // 2. Create range payment input param + IPaymentCoordinator.RangePayment[] + memory rangePayments = new IPaymentCoordinator.RangePayment[](1); + rangePayments[0] = IPaymentCoordinator.RangePayment({ + strategiesAndMultipliers: strategyAndMultipliers, + token: token, + amount: amount, + startTimestamp: startTimestamp, + duration: duration + }); + + token.approve(serviceManager, amount); + EigenDAServiceManager(serviceManager).payForRange(rangePayments); + } + + /// @dev check implementation address set properly function _verifyUpgrade() internal virtual { // Preprod PaymentCoordinator require(