From e0790a5515c98aef5ff802cf2d3c38c25e5014c2 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:37:28 +0200 Subject: [PATCH 1/4] chore: deploy el middleware upgrade --- .../script/holesky/admin/Upgrade.s.sol | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/bolt-contracts/script/holesky/admin/Upgrade.s.sol b/bolt-contracts/script/holesky/admin/Upgrade.s.sol index e549a53d4..0781b56a9 100644 --- a/bolt-contracts/script/holesky/admin/Upgrade.s.sol +++ b/bolt-contracts/script/holesky/admin/Upgrade.s.sol @@ -10,6 +10,7 @@ import {BoltParametersV1} from "../../../src/contracts/BoltParametersV1.sol"; import {BoltValidatorsV1} from "../../../src/contracts/BoltValidatorsV1.sol"; import {BoltManagerV1} from "../../../src/contracts/BoltManagerV1.sol"; import {BoltEigenLayerMiddlewareV1} from "../../../src/contracts/BoltEigenLayerMiddlewareV1.sol"; +import {BoltEigenLayerMiddlewareV2} from "../../../src/contracts/BoltEigenLayerMiddlewareV2.sol"; import {BoltSymbioticMiddlewareV1} from "../../../src/contracts/BoltSymbioticMiddlewareV1.sol"; import {BoltSymbioticMiddlewareV2} from "../../../src/contracts/BoltSymbioticMiddlewareV2.sol"; import {BoltConfig} from "../../../src/lib/Config.sol"; @@ -30,9 +31,9 @@ contract UpgradeBolt is Script { address[] supportedStrategies; } - function run() public { + function upgradeSymbioticMiddleware() public { address admin = msg.sender; - console.log("Upgrading with admin", admin); + console.log("Upgrading Symbiotic middleware with admin", admin); // TODO: Validate upgrades with Upgrades.validateUpgrade Options memory opts; @@ -67,6 +68,46 @@ contract UpgradeBolt is Script { // TODO: Upgrade contracts with Upgrades.upgradeProxy } + function upgradeEigenLayerMiddleware() public { + address admin = msg.sender; + console.log("Upgrading EigenLayer middleware with admin", admin); + // TODO: Validate upgrades with Upgrades.validateUpgrade + + Options memory opts; + opts.unsafeSkipAllChecks = true; + opts.referenceContract = "BoltEigenLayerMiddlewareV1.sol"; + + string memory upgradeTo = "BoltEigenLayerMiddlewareV2.sol"; + + string memory root = vm.projectRoot(); + string memory path = string.concat(root, "/config/holesky/deployments.json"); + string memory json = vm.readFile(path); + + address middlewareV1 = vm.parseJsonAddress(json, ".eigenLayer.middleware"); + + Deployments memory deployments = _readDeployments(); + + bytes memory initEigenLayerMiddleware = abi.encodeCall( + BoltEigenLayerMiddlewareV2.initialize, + ( + admin, + deployments.boltParameters, + deployments.boltManager, + deployments.eigenLayerAVSDirectory, + deployments.eigenLayerDelegationManager, + deployments.eigenLayerStrategyManager + ) + ); + + vm.startBroadcast(admin); + + Upgrades.upgradeProxy(middlewareV1, upgradeTo, initEigenLayerMiddleware, opts); + + vm.stopBroadcast(); + + console.log("BoltSymbioticMiddleware proxy upgraded from %s to %s", opts.referenceContract, upgradeTo); + } + function _readDeployments() public view returns (Deployments memory) { string memory root = vm.projectRoot(); string memory path = string.concat(root, "/config/holesky/deployments.json"); From c66d80a73096e588e16dc7ac49bbc13c499204f4 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:40:28 +0200 Subject: [PATCH 2/4] fix: save el middleware address in deployments --- bolt-contracts/script/holesky/admin/Upgrade.s.sol | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bolt-contracts/script/holesky/admin/Upgrade.s.sol b/bolt-contracts/script/holesky/admin/Upgrade.s.sol index 0781b56a9..3fe6152b0 100644 --- a/bolt-contracts/script/holesky/admin/Upgrade.s.sol +++ b/bolt-contracts/script/holesky/admin/Upgrade.s.sol @@ -28,6 +28,7 @@ contract UpgradeBolt is Script { address eigenLayerAVSDirectory; address eigenLayerDelegationManager; address eigenLayerStrategyManager; + address eigenLayerMiddleware; address[] supportedStrategies; } @@ -79,12 +80,6 @@ contract UpgradeBolt is Script { string memory upgradeTo = "BoltEigenLayerMiddlewareV2.sol"; - string memory root = vm.projectRoot(); - string memory path = string.concat(root, "/config/holesky/deployments.json"); - string memory json = vm.readFile(path); - - address middlewareV1 = vm.parseJsonAddress(json, ".eigenLayer.middleware"); - Deployments memory deployments = _readDeployments(); bytes memory initEigenLayerMiddleware = abi.encodeCall( @@ -101,7 +96,7 @@ contract UpgradeBolt is Script { vm.startBroadcast(admin); - Upgrades.upgradeProxy(middlewareV1, upgradeTo, initEigenLayerMiddleware, opts); + Upgrades.upgradeProxy(deployments.eigenLayerMiddleware, upgradeTo, initEigenLayerMiddleware, opts); vm.stopBroadcast(); @@ -125,6 +120,7 @@ contract UpgradeBolt is Script { eigenLayerAVSDirectory: vm.parseJsonAddress(json, ".eigenLayer.avsDirectory"), eigenLayerDelegationManager: vm.parseJsonAddress(json, ".eigenLayer.delegationManager"), eigenLayerStrategyManager: vm.parseJsonAddress(json, ".eigenLayer.strategyManager"), + eigenLayerMiddleware: vm.parseJsonAddress(json, ".eigenLayer.middleware"), supportedStrategies: vm.parseJsonAddressArray(json, ".eigenLayer.supportedStrategies") }); } From f4b7a308ccd6a1810c0caa592584c4c7dc1d9fd9 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:48:34 +0200 Subject: [PATCH 3/4] fix: initialize v2 --- .../script/holesky/admin/Upgrade.s.sol | 2 +- .../contracts/BoltEigenLayerMiddlewareV2.sol | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bolt-contracts/script/holesky/admin/Upgrade.s.sol b/bolt-contracts/script/holesky/admin/Upgrade.s.sol index 3fe6152b0..9f75f7e08 100644 --- a/bolt-contracts/script/holesky/admin/Upgrade.s.sol +++ b/bolt-contracts/script/holesky/admin/Upgrade.s.sol @@ -83,7 +83,7 @@ contract UpgradeBolt is Script { Deployments memory deployments = _readDeployments(); bytes memory initEigenLayerMiddleware = abi.encodeCall( - BoltEigenLayerMiddlewareV2.initialize, + BoltEigenLayerMiddlewareV2.initializeV2, ( admin, deployments.boltParameters, diff --git a/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol b/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol index 3b3c435fb..0533c9872 100644 --- a/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol +++ b/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol @@ -107,6 +107,25 @@ contract BoltEigenLayerMiddlewareV2 is IBoltMiddlewareV1, IServiceManager, Ownab NAME_HASH = keccak256("EIGENLAYER"); } + function initializeV2( + address _owner, + address _parameters, + address _manager, + address _eigenlayerAVSDirectory, + address _eigenlayerDelegationManager, + address _eigenlayerStrategyManager + ) public reinitializer(2) { + __Ownable_init(_owner); + parameters = IBoltParametersV1(_parameters); + manager = IBoltManagerV1(_manager); + START_TIMESTAMP = Time.timestamp(); + + AVS_DIRECTORY = IAVSDirectory(_eigenlayerAVSDirectory); + DELEGATION_MANAGER = DelegationManagerStorage(_eigenlayerDelegationManager); + STRATEGY_MANAGER = StrategyManagerStorage(_eigenlayerStrategyManager); + NAME_HASH = keccak256("EIGENLAYER"); + } + function _authorizeUpgrade( address newImplementation ) internal override onlyOwner {} From 8df4a6c1c8851d44fd5e4b12c981d84bc0f0e59b Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:51:36 +0200 Subject: [PATCH 4/4] chore: update titles --- bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV1.sol | 2 +- bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV1.sol b/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV1.sol index 750501777..34d4b1b9a 100644 --- a/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV1.sol +++ b/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV1.sol @@ -23,7 +23,7 @@ import {AVSDirectoryStorage} from "@eigenlayer/src/contracts/core/AVSDirectorySt import {DelegationManagerStorage} from "@eigenlayer/src/contracts/core/DelegationManagerStorage.sol"; import {StrategyManagerStorage} from "@eigenlayer/src/contracts/core/StrategyManagerStorage.sol"; -/// @title Bolt Manager +/// @title Bolt EigenLayer Middleware contract. /// @notice This contract is responsible for interfacing with the EigenLayer restaking protocol. /// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades /// with the use of storage gaps. diff --git a/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol b/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol index 0533c9872..a73921f37 100644 --- a/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol +++ b/bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol @@ -24,7 +24,7 @@ import {AVSDirectoryStorage} from "@eigenlayer/src/contracts/core/AVSDirectorySt import {DelegationManagerStorage} from "@eigenlayer/src/contracts/core/DelegationManagerStorage.sol"; import {StrategyManagerStorage} from "@eigenlayer/src/contracts/core/StrategyManagerStorage.sol"; -/// @title Bolt Manager +/// @title Bolt EigenLayer Middleware contract. /// @notice This contract is responsible for interfacing with the EigenLayer restaking protocol. /// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades /// with the use of storage gaps.