Skip to content

Commit

Permalink
Merge pull request #314 from chainbound/nico/chore/el-upgrade
Browse files Browse the repository at this point in the history
chore: deploy EL middleware upgrade script
  • Loading branch information
merklefruit authored Oct 24, 2024
2 parents 8a5831d + 8df4a6c commit 650628a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
41 changes: 39 additions & 2 deletions bolt-contracts/script/holesky/admin/Upgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -27,12 +28,13 @@ contract UpgradeBolt is Script {
address eigenLayerAVSDirectory;
address eigenLayerDelegationManager;
address eigenLayerStrategyManager;
address eigenLayerMiddleware;
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;
Expand Down Expand Up @@ -67,6 +69,40 @@ 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";

Deployments memory deployments = _readDeployments();

bytes memory initEigenLayerMiddleware = abi.encodeCall(
BoltEigenLayerMiddlewareV2.initializeV2,
(
admin,
deployments.boltParameters,
deployments.boltManager,
deployments.eigenLayerAVSDirectory,
deployments.eigenLayerDelegationManager,
deployments.eigenLayerStrategyManager
)
);

vm.startBroadcast(admin);

Upgrades.upgradeProxy(deployments.eigenLayerMiddleware, 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");
Expand All @@ -84,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")
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 20 additions & 1 deletion bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {}
Expand Down

0 comments on commit 650628a

Please sign in to comment.