Skip to content

Commit

Permalink
feat(contracts): deploy with OZ Upgrades library
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 9, 2024
1 parent f91a941 commit eb5c531
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
2 changes: 1 addition & 1 deletion bolt-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ remappings = [
"@eigenlayer/=lib/eigenlayer-contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin-upgrades/=lib/openzeppelin-foundry-upgrades/",
"@openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/",

# Symbiotic remappings contexts
"lib/core/:forge-std/=lib/core/lib/forge-std/src/",
Expand Down
34 changes: 9 additions & 25 deletions bolt-contracts/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.25;
import {Script, console} from "forge-std/Script.sol";

import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Upgrades} from "@openzeppelin-upgrades/src/Upgrades.sol";
import {Upgrades} from "@openzeppelin-foundry-upgrades/src/Upgrades.sol";

import {BoltValidators} from "../src/contracts/BoltValidators.sol";
import {BoltManager} from "../src/contracts/BoltManager.sol";
Expand All @@ -28,41 +28,24 @@ contract DeployBolt is Script {
// on the contract implementations, as well as upgrade the contracts.
address admin = msg.sender;

// TODO: IMPORTANT: Use a different account for the proxy admin!
// Otherwise we will not be able to access the adminOnly functions
// on the underlying implementations through the proxy.
// We can however call them directly if needed.

address validatorsImplementation = address(new BoltValidators());
console.log("BoltValidators implementation deployed at", validatorsImplementation);

bytes memory initValidators = abi.encodeCall(BoltValidators.initialize, admin);
address validatorsProxy = address(new ERC1967Proxy(validatorsImplementation, initValidators));
// Upgrades.deployUUPSProxy();
// Generate the `initialize` call data for the contract.
bytes memory initValidators = abi.encodeCall(BoltValidators.initialize, (admin));
// Deploy the UUPSProxy through the `Upgrades` library, with the correct `initialize` call data.
address validatorsProxy = Upgrades.deployUUPSProxy("BoltValidators.sol", initValidators);
console.log("BoltValidators proxy deployed at", validatorsProxy);

address managerImplementation = address(new BoltManager());
console.log("BoltManager implementation deployed at", managerImplementation);

bytes memory initManager = abi.encodeCall(BoltManager.initialize, (admin, validatorsProxy));
address managerProxy = address(new ERC1967Proxy(managerImplementation, initManager));
address managerProxy = Upgrades.deployUUPSProxy("BoltManager.sol", initManager);
console.log("BoltManager proxy deployed at", managerProxy);

address eigenLayerMiddlewareImplementation = address(new BoltEigenLayerMiddleware());

console.log("BoltEigenLayerMiddleware implementation deployed at", eigenLayerMiddlewareImplementation);

bytes memory initEigenLayerMiddleware = abi.encodeCall(
BoltEigenLayerMiddleware.initialize,
(admin, managerProxy, eigenlayerAVSDirectory, eigenlayerDelegationManager, eigenlayerStrategyManager)
);
address eigenLayerMiddlewareProxy =
address(new ERC1967Proxy(eigenLayerMiddlewareImplementation, initEigenLayerMiddleware));
Upgrades.deployUUPSProxy("BoltEigenLayerMiddleware.sol", initEigenLayerMiddleware);
console.log("BoltEigenLayerMiddleware proxy deployed at", eigenLayerMiddlewareProxy);

address symbioticMiddleware = address(new BoltSymbioticMiddleware());
console.log("BoltSymbioticMiddleware deployed at", address(symbioticMiddleware));

bytes memory initSymbioticMiddleware = abi.encodeCall(
BoltSymbioticMiddleware.initialize,
(
Expand All @@ -74,7 +57,8 @@ contract DeployBolt is Script {
symbioticVaultRegistry
)
);
address symbioticMiddlewareProxy = address(new ERC1967Proxy(symbioticMiddleware, initSymbioticMiddleware));
address symbioticMiddlewareProxy =
Upgrades.deployUUPSProxy("BoltSymbioticMiddleware.sol", initSymbioticMiddleware);
console.log("BoltSymbioticMiddleware proxy deployed at", address(symbioticMiddlewareProxy));

vm.stopBroadcast();
Expand Down

0 comments on commit eb5c531

Please sign in to comment.