2025-04-03 17:06:32 +00:00
|
|
|
// SPDX-License-Identifier: UNLICENSED
|
|
|
|
|
pragma solidity ^0.8.27;
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
// Testing imports
|
2025-04-03 17:06:32 +00:00
|
|
|
import {Script} from "forge-std/Script.sol";
|
|
|
|
|
import {console} from "forge-std/console.sol";
|
|
|
|
|
import {DeployParams} from "./DeployParams.s.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {Logging} from "../utils/Logging.sol";
|
|
|
|
|
import {Accounts} from "../utils/Accounts.sol";
|
|
|
|
|
// Snowbridge imports
|
2025-04-03 17:06:32 +00:00
|
|
|
import {Gateway} from "snowbridge/src/Gateway.sol";
|
|
|
|
|
import {IGatewayV2} from "snowbridge/src/v2/IGateway.sol";
|
|
|
|
|
import {GatewayProxy} from "snowbridge/src/GatewayProxy.sol";
|
|
|
|
|
import {AgentExecutor} from "snowbridge/src/AgentExecutor.sol";
|
|
|
|
|
import {Agent} from "snowbridge/src/Agent.sol";
|
|
|
|
|
import {Initializer} from "snowbridge/src/Initializer.sol";
|
|
|
|
|
import {OperatingMode} from "snowbridge/src/types/Common.sol";
|
|
|
|
|
import {ud60x18} from "snowbridge/lib/prb-math/src/UD60x18.sol";
|
|
|
|
|
import {BeefyClient} from "snowbridge/src/BeefyClient.sol";
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
// OpenZeppelin imports
|
|
|
|
|
import {ERC20PresetFixedSupply} from
|
|
|
|
|
"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol";
|
|
|
|
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
2025-04-03 17:06:32 +00:00
|
|
|
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {ITransparentUpgradeableProxy} from
|
|
|
|
|
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
|
2025-04-03 17:06:32 +00:00
|
|
|
import {TransparentUpgradeableProxy} from
|
|
|
|
|
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
|
|
|
|
|
|
|
|
|
|
// EigenLayer imports
|
2025-04-03 17:06:32 +00:00
|
|
|
import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {AVSDirectory} from "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol";
|
|
|
|
|
import {DelegationManager} from "eigenlayer-contracts/src/contracts/core/DelegationManager.sol";
|
|
|
|
|
import {RewardsCoordinator} from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol";
|
|
|
|
|
import {StrategyManager} from "eigenlayer-contracts/src/contracts/core/StrategyManager.sol";
|
|
|
|
|
import {IAllocationManagerTypes} from
|
|
|
|
|
"eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
|
|
|
|
|
import {IETHPOSDeposit} from "eigenlayer-contracts/src/contracts/interfaces/IETHPOSDeposit.sol";
|
2025-04-03 17:06:32 +00:00
|
|
|
import {
|
|
|
|
|
IRewardsCoordinator,
|
|
|
|
|
IRewardsCoordinatorTypes
|
|
|
|
|
} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol";
|
|
|
|
|
import {PermissionController} from
|
|
|
|
|
"eigenlayer-contracts/src/contracts/permissions/PermissionController.sol";
|
|
|
|
|
import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol";
|
2025-04-03 17:06:32 +00:00
|
|
|
import {EigenPod} from "eigenlayer-contracts/src/contracts/pods/EigenPod.sol";
|
|
|
|
|
import {EigenPodManager} from "eigenlayer-contracts/src/contracts/pods/EigenPodManager.sol";
|
|
|
|
|
import {StrategyBaseTVLLimits} from
|
|
|
|
|
"eigenlayer-contracts/src/contracts/strategies/StrategyBaseTVLLimits.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol";
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
// DataHaven imports
|
2025-04-03 17:06:32 +00:00
|
|
|
import {DataHavenServiceManager} from "../../src/DataHavenServiceManager.sol";
|
2025-04-11 23:54:20 +00:00
|
|
|
import {MerkleUtils} from "../../src/libraries/MerkleUtils.sol";
|
2025-04-03 17:06:32 +00:00
|
|
|
import {VetoableSlasher} from "../../src/middleware/VetoableSlasher.sol";
|
|
|
|
|
import {RewardsRegistry} from "../../src/middleware/RewardsRegistry.sol";
|
|
|
|
|
|
2025-04-16 15:49:35 +00:00
|
|
|
struct ServiceManagerInitParams {
|
|
|
|
|
address avsOwner;
|
|
|
|
|
address rewardsInitiator;
|
|
|
|
|
address[] validatorsStrategies;
|
|
|
|
|
address[] bspsStrategies;
|
|
|
|
|
address[] mspsStrategies;
|
|
|
|
|
address gateway;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-22 19:49:51 +00:00
|
|
|
// Struct to store more detailed strategy information
|
|
|
|
|
struct StrategyInfo {
|
|
|
|
|
address address_;
|
|
|
|
|
address underlyingToken;
|
|
|
|
|
address tokenCreator;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
contract Deploy is Script, DeployParams, Accounts {
|
2025-04-03 17:06:32 +00:00
|
|
|
// Progress indicator
|
2025-04-11 23:54:20 +00:00
|
|
|
uint16 public deploymentStep = 0;
|
|
|
|
|
uint16 public totalSteps = 4; // Total major deployment steps
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// EigenLayer Contract declarations
|
2025-04-11 23:54:20 +00:00
|
|
|
EmptyContract public emptyContract;
|
|
|
|
|
RewardsCoordinator public rewardsCoordinator;
|
|
|
|
|
RewardsCoordinator public rewardsCoordinatorImplementation;
|
|
|
|
|
PermissionController public permissionController;
|
|
|
|
|
PermissionController public permissionControllerImplementation;
|
|
|
|
|
AllocationManager public allocationManager;
|
|
|
|
|
AllocationManager public allocationManagerImplementation;
|
|
|
|
|
DelegationManager public delegation;
|
|
|
|
|
DelegationManager public delegationImplementation;
|
|
|
|
|
StrategyManager public strategyManager;
|
|
|
|
|
StrategyManager public strategyManagerImplementation;
|
|
|
|
|
AVSDirectory public avsDirectory;
|
|
|
|
|
AVSDirectory public avsDirectoryImplementation;
|
|
|
|
|
EigenPodManager public eigenPodManager;
|
|
|
|
|
EigenPodManager public eigenPodManagerImplementation;
|
|
|
|
|
UpgradeableBeacon public eigenPodBeacon;
|
|
|
|
|
EigenPod public eigenPodImplementation;
|
|
|
|
|
StrategyBaseTVLLimits public baseStrategyImplementation;
|
2025-04-22 19:49:51 +00:00
|
|
|
StrategyInfo[] public deployedStrategies;
|
2025-04-11 23:54:20 +00:00
|
|
|
IETHPOSDeposit public ethPOSDeposit;
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// EigenLayer required semver
|
2025-04-11 23:54:20 +00:00
|
|
|
string public constant SEMVER = "v1.0.0";
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _logProgress() internal {
|
2025-04-03 17:06:32 +00:00
|
|
|
deploymentStep++;
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logProgress(deploymentStep, totalSteps);
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function run() public {
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logHeader("DATAHAVEN DEPLOYMENT SCRIPT");
|
2025-04-03 17:06:32 +00:00
|
|
|
console.log("| Network: %s", vm.envOr("NETWORK", string("anvil")));
|
|
|
|
|
console.log("| Timestamp: %s", vm.toString(block.timestamp));
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logFooter();
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Load configurations
|
|
|
|
|
SnowbridgeConfig memory snowbridgeConfig = getSnowbridgeConfig();
|
|
|
|
|
AVSConfig memory avsConfig = getAVSConfig();
|
|
|
|
|
EigenLayerConfig memory eigenLayerConfig = getEigenLayerConfig();
|
|
|
|
|
|
|
|
|
|
// Deploy EigenLayer core contracts
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logHeader("EIGENLAYER CORE CONTRACTS DEPLOYMENT");
|
|
|
|
|
Logging.logInfo("Deploying core infrastructure contracts");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy proxy admin for ability to upgrade proxy contracts
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
ProxyAdmin proxyAdmin = new ProxyAdmin();
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("ProxyAdmin", address(proxyAdmin));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy pauser registry
|
2025-04-11 23:54:20 +00:00
|
|
|
PauserRegistry pauserRegistry = _deployPauserRegistry(eigenLayerConfig);
|
|
|
|
|
Logging.logContractDeployed("PauserRegistry", address(pauserRegistry));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy empty contract to use as initial implementation for proxies
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
emptyContract = new EmptyContract();
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("EmptyContract", address(emptyContract));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy proxies that will point to implementations
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logSection("Deploying Proxy Contracts");
|
|
|
|
|
_deployProxies(proxyAdmin);
|
|
|
|
|
Logging.logStep("Initial proxies deployed successfully");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Setup ETH2 deposit contract for EigenPod functionality
|
|
|
|
|
ethPOSDeposit = IETHPOSDeposit(getETHPOSDepositAddress());
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("ETHPOSDeposit", address(ethPOSDeposit));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy EigenPod implementation and beacon
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
eigenPodImplementation = new EigenPod(
|
|
|
|
|
ethPOSDeposit, eigenPodManager, eigenLayerConfig.beaconChainGenesisTimestamp, SEMVER
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
eigenPodBeacon = new UpgradeableBeacon(address(eigenPodImplementation));
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("EigenPod Implementation", address(eigenPodImplementation));
|
|
|
|
|
Logging.logContractDeployed("EigenPod Beacon", address(eigenPodBeacon));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy implementation contracts
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logSection("Deploying Implementation Contracts");
|
|
|
|
|
_deployImplementations(eigenLayerConfig, pauserRegistry);
|
|
|
|
|
Logging.logStep("Implementation contracts deployed successfully");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-16 15:49:35 +00:00
|
|
|
// Upgrade proxies to point to implementations and initialise
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logSection("Initializing Contracts");
|
|
|
|
|
_upgradeAndInitializeProxies(eigenLayerConfig, proxyAdmin);
|
|
|
|
|
Logging.logStep("Proxies upgraded and initialized successfully");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy strategy implementation and create strategy proxies
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logSection("Deploying Strategy Contracts");
|
|
|
|
|
_deployStrategies(pauserRegistry, proxyAdmin);
|
|
|
|
|
Logging.logStep("Strategy contracts deployed successfully");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Transfer ownership of core contracts
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.transferOwnership(eigenLayerConfig.executorMultisig);
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
eigenPodBeacon.transferOwnership(eigenLayerConfig.executorMultisig);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("Ownership transferred to multisig");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logFooter();
|
|
|
|
|
_logProgress();
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy Snowbridge and configure Agent
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logHeader("SNOWBRIDGE DEPLOYMENT");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
(
|
|
|
|
|
BeefyClient beefyClient,
|
|
|
|
|
AgentExecutor agentExecutor,
|
|
|
|
|
IGatewayV2 gateway,
|
|
|
|
|
address payable rewardsAgentAddress
|
2025-04-11 23:54:20 +00:00
|
|
|
) = _deploySnowbridge(snowbridgeConfig);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logFooter();
|
|
|
|
|
_logProgress();
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-16 15:49:35 +00:00
|
|
|
// Deploy DataHaven custom contracts
|
|
|
|
|
(
|
|
|
|
|
DataHavenServiceManager serviceManager,
|
|
|
|
|
VetoableSlasher vetoableSlasher,
|
|
|
|
|
RewardsRegistry rewardsRegistry
|
|
|
|
|
) = _deployDataHavenContracts(avsConfig, proxyAdmin, gateway);
|
|
|
|
|
|
|
|
|
|
Logging.logFooter();
|
|
|
|
|
_logProgress();
|
|
|
|
|
|
2025-04-03 17:06:32 +00:00
|
|
|
// Set the Agent in the RewardsRegistry
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logHeader("FINAL CONFIGURATION");
|
|
|
|
|
// This needs to be executed by the AVS owner
|
|
|
|
|
vm.broadcast(_avsOwnerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
serviceManager.setRewardsAgent(0, address(rewardsAgentAddress));
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("Agent set in RewardsRegistry");
|
|
|
|
|
Logging.logContractDeployed("Agent Address", rewardsAgentAddress);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logFooter();
|
|
|
|
|
_logProgress();
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Output all deployed contract addresses
|
2025-04-11 23:54:20 +00:00
|
|
|
_outputDeployedAddresses(
|
2025-04-03 17:06:32 +00:00
|
|
|
beefyClient,
|
|
|
|
|
agentExecutor,
|
|
|
|
|
gateway,
|
|
|
|
|
serviceManager,
|
|
|
|
|
vetoableSlasher,
|
|
|
|
|
rewardsRegistry,
|
|
|
|
|
rewardsAgentAddress
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deploySnowbridge(
|
2025-04-03 17:06:32 +00:00
|
|
|
SnowbridgeConfig memory config
|
|
|
|
|
) internal returns (BeefyClient, AgentExecutor, IGatewayV2, address payable) {
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logSection("Deploying Snowbridge Core Components");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
BeefyClient beefyClient = _deployBeefyClient(config);
|
|
|
|
|
Logging.logContractDeployed("BeefyClient", address(beefyClient));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
AgentExecutor agentExecutor = new AgentExecutor();
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("AgentExecutor", address(agentExecutor));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
Gateway gatewayImplementation = new Gateway(address(beefyClient), address(agentExecutor));
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("Gateway Implementation", address(gatewayImplementation));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Configure and deploy Gateway proxy
|
|
|
|
|
OperatingMode defaultOperatingMode = OperatingMode.Normal;
|
|
|
|
|
Initializer.Config memory gatewayConfig = Initializer.Config({
|
|
|
|
|
mode: defaultOperatingMode,
|
|
|
|
|
deliveryCost: 1,
|
|
|
|
|
registerTokenFee: 1,
|
|
|
|
|
assetHubCreateAssetFee: 1,
|
|
|
|
|
assetHubReserveTransferFee: 1,
|
|
|
|
|
exchangeRate: ud60x18(1),
|
|
|
|
|
multiplier: ud60x18(1),
|
|
|
|
|
foreignTokenDecimals: 18,
|
|
|
|
|
maxDestinationFee: 1
|
|
|
|
|
});
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
IGatewayV2 gateway = IGatewayV2(
|
|
|
|
|
address(new GatewayProxy(address(gatewayImplementation), abi.encode(gatewayConfig)))
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("Gateway Proxy", address(gateway));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Create Agent
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logSection("Creating Snowbridge Agent");
|
|
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
gateway.v2_createAgent(config.rewardsMessageOrigin);
|
|
|
|
|
address payable rewardsAgentAddress = payable(gateway.agentOf(config.rewardsMessageOrigin));
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("Rewards Agent", rewardsAgentAddress);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
return (beefyClient, agentExecutor, gateway, rewardsAgentAddress);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deployProxies(
|
2025-04-03 17:06:32 +00:00
|
|
|
ProxyAdmin proxyAdmin
|
|
|
|
|
) internal {
|
|
|
|
|
// Deploy proxies with empty implementation initially
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
delegation = DelegationManager(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("DelegationManager Proxy", address(delegation));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
strategyManager = StrategyManager(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("StrategyManager Proxy", address(strategyManager));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
avsDirectory = AVSDirectory(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("AVSDirectory Proxy", address(avsDirectory));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
eigenPodManager = EigenPodManager(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("EigenPodManager Proxy", address(eigenPodManager));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
rewardsCoordinator = RewardsCoordinator(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("RewardsCoordinator Proxy", address(rewardsCoordinator));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
allocationManager = AllocationManager(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("AllocationManager Proxy", address(allocationManager));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
permissionController = PermissionController(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("PermissionController Proxy", address(permissionController));
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deployImplementations(
|
2025-04-03 17:06:32 +00:00
|
|
|
EigenLayerConfig memory config,
|
|
|
|
|
PauserRegistry pauserRegistry
|
|
|
|
|
) internal {
|
|
|
|
|
// Deploy implementation contracts
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
delegationImplementation = new DelegationManager(
|
|
|
|
|
strategyManager,
|
|
|
|
|
eigenPodManager,
|
|
|
|
|
allocationManager,
|
|
|
|
|
pauserRegistry,
|
|
|
|
|
permissionController,
|
|
|
|
|
config.minWithdrawalDelayBlocks,
|
|
|
|
|
SEMVER
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
|
|
|
|
"DelegationManager Implementation", address(delegationImplementation)
|
|
|
|
|
);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
strategyManagerImplementation = new StrategyManager(delegation, pauserRegistry, SEMVER);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
2025-04-03 17:06:32 +00:00
|
|
|
"StrategyManager Implementation", address(strategyManagerImplementation)
|
|
|
|
|
);
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
avsDirectoryImplementation = new AVSDirectory(delegation, pauserRegistry, SEMVER);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
|
|
|
|
"AVSDirectory Implementation", address(avsDirectoryImplementation)
|
|
|
|
|
);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
eigenPodManagerImplementation =
|
|
|
|
|
new EigenPodManager(ethPOSDeposit, eigenPodBeacon, delegation, pauserRegistry, SEMVER);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
2025-04-03 17:06:32 +00:00
|
|
|
"EigenPodManager Implementation", address(eigenPodManagerImplementation)
|
|
|
|
|
);
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
rewardsCoordinatorImplementation = new RewardsCoordinator(
|
|
|
|
|
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams(
|
|
|
|
|
delegation,
|
|
|
|
|
strategyManager,
|
|
|
|
|
allocationManager,
|
|
|
|
|
pauserRegistry,
|
|
|
|
|
permissionController,
|
|
|
|
|
config.calculationIntervalSeconds,
|
|
|
|
|
config.maxRewardsDuration,
|
|
|
|
|
config.maxRetroactiveLength,
|
|
|
|
|
config.maxFutureLength,
|
|
|
|
|
config.genesisRewardsTimestamp,
|
|
|
|
|
SEMVER
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
2025-04-03 17:06:32 +00:00
|
|
|
"RewardsCoordinator Implementation", address(rewardsCoordinatorImplementation)
|
|
|
|
|
);
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
allocationManagerImplementation = new AllocationManager(
|
|
|
|
|
delegation,
|
|
|
|
|
pauserRegistry,
|
|
|
|
|
permissionController,
|
|
|
|
|
config.deallocationDelay,
|
|
|
|
|
config.allocationConfigurationDelay,
|
|
|
|
|
SEMVER
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
2025-04-03 17:06:32 +00:00
|
|
|
"AllocationManager Implementation", address(allocationManagerImplementation)
|
|
|
|
|
);
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
permissionControllerImplementation = new PermissionController(SEMVER);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed(
|
2025-04-03 17:06:32 +00:00
|
|
|
"PermissionController Implementation", address(permissionControllerImplementation)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _upgradeAndInitializeProxies(
|
2025-04-03 17:06:32 +00:00
|
|
|
EigenLayerConfig memory config,
|
|
|
|
|
ProxyAdmin proxyAdmin
|
|
|
|
|
) internal {
|
|
|
|
|
// Initialize DelegationManager
|
|
|
|
|
{
|
|
|
|
|
IStrategy[] memory strategies;
|
|
|
|
|
uint256[] memory withdrawalDelayBlocks;
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(delegation))),
|
|
|
|
|
address(delegationImplementation),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
DelegationManager.initialize.selector,
|
|
|
|
|
config.executorMultisig,
|
|
|
|
|
config.delegationInitPausedStatus,
|
|
|
|
|
config.delegationWithdrawalDelayBlocks,
|
|
|
|
|
strategies,
|
|
|
|
|
withdrawalDelayBlocks
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("DelegationManager initialized");
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize StrategyManager
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(strategyManager))),
|
|
|
|
|
address(strategyManagerImplementation),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
StrategyManager.initialize.selector,
|
|
|
|
|
config.executorMultisig,
|
|
|
|
|
config.operationsMultisig,
|
|
|
|
|
config.strategyManagerInitPausedStatus
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("StrategyManager initialized");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Initialize AVSDirectory
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(avsDirectory))),
|
|
|
|
|
address(avsDirectoryImplementation),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
AVSDirectory.initialize.selector,
|
|
|
|
|
config.executorMultisig,
|
|
|
|
|
0 // Initial paused status
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("AVSDirectory initialized");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Initialize EigenPodManager
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(eigenPodManager))),
|
|
|
|
|
address(eigenPodManagerImplementation),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
EigenPodManager.initialize.selector,
|
|
|
|
|
config.executorMultisig,
|
|
|
|
|
config.eigenPodManagerInitPausedStatus
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("EigenPodManager initialized");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Initialize RewardsCoordinator
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(rewardsCoordinator))),
|
|
|
|
|
address(rewardsCoordinatorImplementation),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
RewardsCoordinator.initialize.selector,
|
|
|
|
|
config.executorMultisig,
|
|
|
|
|
config.rewardsCoordinatorInitPausedStatus,
|
|
|
|
|
config.rewardsUpdater,
|
|
|
|
|
config.activationDelay,
|
|
|
|
|
config.globalCommissionBips
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("RewardsCoordinator initialized");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Initialize AllocationManager
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(allocationManager))),
|
|
|
|
|
address(allocationManagerImplementation),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
AllocationManager.initialize.selector,
|
|
|
|
|
config.executorMultisig,
|
|
|
|
|
config.allocationManagerInitPausedStatus
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("AllocationManager initialized");
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Initialize PermissionController (no initialization function)
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
proxyAdmin.upgrade(
|
|
|
|
|
ITransparentUpgradeableProxy(payable(address(permissionController))),
|
|
|
|
|
address(permissionControllerImplementation)
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logStep("PermissionController upgraded");
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deployStrategies(PauserRegistry pauserRegistry, ProxyAdmin proxyAdmin) internal {
|
2025-04-03 17:06:32 +00:00
|
|
|
// Deploy base strategy implementation
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
baseStrategyImplementation =
|
|
|
|
|
new StrategyBaseTVLLimits(strategyManager, pauserRegistry, SEMVER);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("Strategy Implementation", address(baseStrategyImplementation));
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Create default test token and strategy if needed
|
2025-04-11 23:54:20 +00:00
|
|
|
// In a production environment, this would be replaced with actual token addresses.
|
2025-04-03 17:06:32 +00:00
|
|
|
if (block.chainid != 1) {
|
2025-04-11 23:54:20 +00:00
|
|
|
// We mint tokens to the operator account so that it then has a balance to deposit as stake.
|
|
|
|
|
vm.broadcast(_deployerPrivateKey);
|
|
|
|
|
address testToken =
|
|
|
|
|
address(new ERC20PresetFixedSupply("TestToken", "TEST", 1000000 ether, _operator));
|
|
|
|
|
Logging.logContractDeployed("TestToken", testToken);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Create strategy for test token
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
StrategyBaseTVLLimits strategy = StrategyBaseTVLLimits(
|
|
|
|
|
address(
|
|
|
|
|
new TransparentUpgradeableProxy(
|
|
|
|
|
address(baseStrategyImplementation),
|
|
|
|
|
address(proxyAdmin),
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
StrategyBaseTVLLimits.initialize.selector,
|
|
|
|
|
1000000 ether, // maxPerDeposit
|
|
|
|
|
10000000 ether, // maxDeposits
|
|
|
|
|
IERC20(testToken)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2025-04-22 19:49:51 +00:00
|
|
|
// Store the strategy with its token information
|
|
|
|
|
deployedStrategies.push(
|
|
|
|
|
StrategyInfo({
|
|
|
|
|
address_: address(strategy),
|
|
|
|
|
underlyingToken: testToken,
|
|
|
|
|
tokenCreator: _operator
|
|
|
|
|
})
|
|
|
|
|
);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logContractDeployed("Test Strategy", address(strategy));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Whitelist strategies in the strategy manager
|
|
|
|
|
IStrategy[] memory strategies = new IStrategy[](deployedStrategies.length);
|
|
|
|
|
for (uint256 i = 0; i < deployedStrategies.length; i++) {
|
2025-04-22 19:49:51 +00:00
|
|
|
strategies[i] = IStrategy(deployedStrategies[i].address_);
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_operationsMultisigPrivateKey);
|
|
|
|
|
strategyManager.addStrategiesToDepositWhitelist(strategies);
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deployProxyAdmin() internal returns (ProxyAdmin) {
|
2025-04-03 17:06:32 +00:00
|
|
|
ProxyAdmin proxyAdmin = new ProxyAdmin();
|
|
|
|
|
return proxyAdmin;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deployPauserRegistry(
|
2025-04-03 17:06:32 +00:00
|
|
|
EigenLayerConfig memory config
|
|
|
|
|
) internal returns (PauserRegistry) {
|
|
|
|
|
// Use the array of pauser addresses directly from the config
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
return new PauserRegistry(config.pauserAddresses, config.unpauserAddress);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _buildValidatorSet(
|
2025-04-03 17:06:32 +00:00
|
|
|
uint128 id,
|
|
|
|
|
bytes32[] memory validators
|
|
|
|
|
) internal pure returns (BeefyClient.ValidatorSet memory) {
|
|
|
|
|
// Calculate the merkle root from the validators array using the shared library
|
|
|
|
|
bytes32 merkleRoot = MerkleUtils.calculateMerkleRoot(validators);
|
|
|
|
|
|
|
|
|
|
// Create and return the validator set with the calculated merkle root
|
|
|
|
|
return
|
|
|
|
|
BeefyClient.ValidatorSet({id: id, length: uint128(validators.length), root: merkleRoot});
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _deployBeefyClient(
|
2025-04-03 17:06:32 +00:00
|
|
|
SnowbridgeConfig memory config
|
|
|
|
|
) internal returns (BeefyClient) {
|
|
|
|
|
// Create validator sets using the MerkleUtils library
|
|
|
|
|
BeefyClient.ValidatorSet memory validatorSet =
|
2025-04-11 23:54:20 +00:00
|
|
|
_buildValidatorSet(0, config.initialValidators);
|
2025-04-03 17:06:32 +00:00
|
|
|
BeefyClient.ValidatorSet memory nextValidatorSet =
|
2025-04-11 23:54:20 +00:00
|
|
|
_buildValidatorSet(1, config.nextValidators);
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Deploy BeefyClient
|
2025-04-11 23:54:20 +00:00
|
|
|
vm.broadcast(_deployerPrivateKey);
|
2025-04-03 17:06:32 +00:00
|
|
|
return new BeefyClient(
|
|
|
|
|
config.randaoCommitDelay,
|
|
|
|
|
config.randaoCommitExpiration,
|
|
|
|
|
config.minNumRequiredSignatures,
|
|
|
|
|
config.startBlock,
|
|
|
|
|
validatorSet,
|
|
|
|
|
nextValidatorSet
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 23:54:20 +00:00
|
|
|
function _outputDeployedAddresses(
|
2025-04-03 17:06:32 +00:00
|
|
|
BeefyClient beefyClient,
|
|
|
|
|
AgentExecutor agentExecutor,
|
|
|
|
|
IGatewayV2 gateway,
|
|
|
|
|
DataHavenServiceManager serviceManager,
|
|
|
|
|
VetoableSlasher vetoableSlasher,
|
|
|
|
|
RewardsRegistry rewardsRegistry,
|
|
|
|
|
address agent
|
|
|
|
|
) internal {
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logHeader("DEPLOYMENT SUMMARY");
|
|
|
|
|
|
|
|
|
|
Logging.logSection("Snowbridge Contracts");
|
|
|
|
|
Logging.logContractDeployed("BeefyClient", address(beefyClient));
|
|
|
|
|
Logging.logContractDeployed("AgentExecutor", address(agentExecutor));
|
|
|
|
|
Logging.logContractDeployed("Gateway", address(gateway));
|
|
|
|
|
Logging.logContractDeployed("Agent", agent);
|
|
|
|
|
|
|
|
|
|
Logging.logSection("DataHaven Contracts");
|
|
|
|
|
Logging.logContractDeployed("ServiceManager", address(serviceManager));
|
|
|
|
|
Logging.logContractDeployed("VetoableSlasher", address(vetoableSlasher));
|
|
|
|
|
Logging.logContractDeployed("RewardsRegistry", address(rewardsRegistry));
|
|
|
|
|
|
|
|
|
|
Logging.logSection("EigenLayer Core Contracts");
|
|
|
|
|
Logging.logContractDeployed("DelegationManager", address(delegation));
|
|
|
|
|
Logging.logContractDeployed("StrategyManager", address(strategyManager));
|
|
|
|
|
Logging.logContractDeployed("AVSDirectory", address(avsDirectory));
|
|
|
|
|
Logging.logContractDeployed("EigenPodManager", address(eigenPodManager));
|
|
|
|
|
Logging.logContractDeployed("EigenPodBeacon", address(eigenPodBeacon));
|
|
|
|
|
Logging.logContractDeployed("RewardsCoordinator", address(rewardsCoordinator));
|
|
|
|
|
Logging.logContractDeployed("AllocationManager", address(allocationManager));
|
|
|
|
|
Logging.logContractDeployed("PermissionController", address(permissionController));
|
|
|
|
|
Logging.logContractDeployed("ETHPOSDeposit", address(ethPOSDeposit));
|
|
|
|
|
|
|
|
|
|
Logging.logSection("Strategy Contracts");
|
|
|
|
|
Logging.logContractDeployed(
|
|
|
|
|
"BaseStrategyImplementation", address(baseStrategyImplementation)
|
|
|
|
|
);
|
|
|
|
|
for (uint256 i = 0; i < deployedStrategies.length; i++) {
|
|
|
|
|
Logging.logContractDeployed(
|
2025-04-22 19:49:51 +00:00
|
|
|
string.concat("DeployedStrategy", vm.toString(i)), deployedStrategies[i].address_
|
2025-04-11 23:54:20 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logging.logFooter();
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
// Write to deployment file for future reference
|
|
|
|
|
string memory network = vm.envOr("NETWORK", string("anvil"));
|
|
|
|
|
string memory deploymentPath =
|
|
|
|
|
string.concat(vm.projectRoot(), "/deployments/", network, ".json");
|
|
|
|
|
|
|
|
|
|
// Create directory if it doesn't exist
|
|
|
|
|
vm.createDir(string.concat(vm.projectRoot(), "/deployments"), true);
|
|
|
|
|
|
|
|
|
|
// Create JSON with deployed addresses
|
|
|
|
|
string memory json = "{";
|
|
|
|
|
json = string.concat(json, '"network": "', network, '",');
|
|
|
|
|
|
|
|
|
|
// Snowbridge contracts
|
|
|
|
|
json = string.concat(json, '"BeefyClient": "', vm.toString(address(beefyClient)), '",');
|
|
|
|
|
json = string.concat(json, '"AgentExecutor": "', vm.toString(address(agentExecutor)), '",');
|
|
|
|
|
json = string.concat(json, '"Gateway": "', vm.toString(address(gateway)), '",');
|
|
|
|
|
json =
|
|
|
|
|
string.concat(json, '"ServiceManager": "', vm.toString(address(serviceManager)), '",');
|
|
|
|
|
json =
|
|
|
|
|
string.concat(json, '"VetoableSlasher": "', vm.toString(address(vetoableSlasher)), '",');
|
|
|
|
|
json =
|
|
|
|
|
string.concat(json, '"RewardsRegistry": "', vm.toString(address(rewardsRegistry)), '",');
|
|
|
|
|
json = string.concat(json, '"Agent": "', vm.toString(agent), '",');
|
|
|
|
|
|
|
|
|
|
// EigenLayer contracts
|
|
|
|
|
json = string.concat(json, '"DelegationManager": "', vm.toString(address(delegation)), '",');
|
|
|
|
|
json =
|
|
|
|
|
string.concat(json, '"StrategyManager": "', vm.toString(address(strategyManager)), '",');
|
|
|
|
|
json = string.concat(json, '"AVSDirectory": "', vm.toString(address(avsDirectory)), '",');
|
|
|
|
|
json =
|
|
|
|
|
string.concat(json, '"EigenPodManager": "', vm.toString(address(eigenPodManager)), '",');
|
|
|
|
|
json =
|
|
|
|
|
string.concat(json, '"EigenPodBeacon": "', vm.toString(address(eigenPodBeacon)), '",');
|
|
|
|
|
json = string.concat(
|
|
|
|
|
json, '"RewardsCoordinator": "', vm.toString(address(rewardsCoordinator)), '",'
|
|
|
|
|
);
|
|
|
|
|
json = string.concat(
|
|
|
|
|
json, '"AllocationManager": "', vm.toString(address(allocationManager)), '",'
|
|
|
|
|
);
|
|
|
|
|
json = string.concat(
|
2025-04-11 23:54:20 +00:00
|
|
|
json, '"PermissionController": "', vm.toString(address(permissionController)), '",'
|
|
|
|
|
);
|
|
|
|
|
json = string.concat(json, '"ETHPOSDeposit": "', vm.toString(address(ethPOSDeposit)), '",');
|
|
|
|
|
json = string.concat(
|
|
|
|
|
json,
|
|
|
|
|
'"BaseStrategyImplementation": "',
|
|
|
|
|
vm.toString(address(baseStrategyImplementation)),
|
|
|
|
|
'"'
|
2025-04-03 17:06:32 +00:00
|
|
|
);
|
2025-04-22 19:49:51 +00:00
|
|
|
|
|
|
|
|
// Add strategies with token information
|
2025-04-11 23:54:20 +00:00
|
|
|
if (deployedStrategies.length > 0) {
|
|
|
|
|
json = string.concat(json, ",");
|
|
|
|
|
json = string.concat(json, '"DeployedStrategies": [');
|
|
|
|
|
|
|
|
|
|
for (uint256 i = 0; i < deployedStrategies.length; i++) {
|
2025-04-22 19:49:51 +00:00
|
|
|
json = string.concat(json, "{");
|
|
|
|
|
json = string.concat(
|
|
|
|
|
json, '"address": "', vm.toString(deployedStrategies[i].address_), '",'
|
|
|
|
|
);
|
|
|
|
|
json = string.concat(
|
|
|
|
|
json,
|
|
|
|
|
'"underlyingToken": "',
|
|
|
|
|
vm.toString(deployedStrategies[i].underlyingToken),
|
|
|
|
|
'",'
|
|
|
|
|
);
|
|
|
|
|
json = string.concat(
|
|
|
|
|
json, '"tokenCreator": "', vm.toString(deployedStrategies[i].tokenCreator), '"'
|
|
|
|
|
);
|
|
|
|
|
json = string.concat(json, "}");
|
2025-04-11 23:54:20 +00:00
|
|
|
|
|
|
|
|
// Add comma if not the last element
|
|
|
|
|
if (i < deployedStrategies.length - 1) {
|
|
|
|
|
json = string.concat(json, ",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json = string.concat(json, "]");
|
|
|
|
|
}
|
2025-04-03 17:06:32 +00:00
|
|
|
|
|
|
|
|
json = string.concat(json, "}");
|
|
|
|
|
|
|
|
|
|
// Write to file
|
|
|
|
|
vm.writeFile(deploymentPath, json);
|
2025-04-11 23:54:20 +00:00
|
|
|
Logging.logInfo(string.concat("Deployment info saved to: ", deploymentPath));
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|
2025-04-16 15:49:35 +00:00
|
|
|
|
|
|
|
|
function _deployDataHavenContracts(
|
|
|
|
|
AVSConfig memory avsConfig,
|
|
|
|
|
ProxyAdmin proxyAdmin,
|
|
|
|
|
IGatewayV2 gateway
|
|
|
|
|
) internal returns (DataHavenServiceManager, VetoableSlasher, RewardsRegistry) {
|
|
|
|
|
Logging.logHeader("DATAHAVEN CUSTOM CONTRACTS DEPLOYMENT");
|
|
|
|
|
|
|
|
|
|
// Deploy the Service Manager
|
|
|
|
|
vm.broadcast(_deployerPrivateKey);
|
|
|
|
|
DataHavenServiceManager serviceManagerImplementation =
|
|
|
|
|
new DataHavenServiceManager(rewardsCoordinator, permissionController, allocationManager);
|
|
|
|
|
Logging.logContractDeployed(
|
|
|
|
|
"ServiceManager Implementation", address(serviceManagerImplementation)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Extract strategies logic to a helper function to reduce local variables
|
|
|
|
|
_prepareStrategiesForServiceManager(avsConfig, deployedStrategies);
|
|
|
|
|
|
|
|
|
|
// Create service manager initialisation parameters struct to reduce stack variables
|
|
|
|
|
ServiceManagerInitParams memory initParams = ServiceManagerInitParams({
|
|
|
|
|
avsOwner: avsConfig.avsOwner,
|
|
|
|
|
rewardsInitiator: avsConfig.rewardsInitiator,
|
|
|
|
|
validatorsStrategies: avsConfig.validatorsStrategies,
|
|
|
|
|
bspsStrategies: avsConfig.bspsStrategies,
|
|
|
|
|
mspsStrategies: avsConfig.mspsStrategies,
|
|
|
|
|
gateway: address(gateway)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Create the service manager proxy
|
|
|
|
|
DataHavenServiceManager serviceManager =
|
|
|
|
|
_createServiceManagerProxy(serviceManagerImplementation, proxyAdmin, initParams);
|
|
|
|
|
Logging.logContractDeployed("ServiceManager Proxy", address(serviceManager));
|
|
|
|
|
|
|
|
|
|
// Deploy VetoableSlasher
|
|
|
|
|
vm.broadcast(_deployerPrivateKey);
|
|
|
|
|
VetoableSlasher vetoableSlasher = new VetoableSlasher(
|
|
|
|
|
allocationManager,
|
|
|
|
|
serviceManager,
|
|
|
|
|
avsConfig.vetoCommitteeMember,
|
|
|
|
|
avsConfig.vetoWindowBlocks
|
|
|
|
|
);
|
|
|
|
|
Logging.logContractDeployed("VetoableSlasher", address(vetoableSlasher));
|
|
|
|
|
|
|
|
|
|
// Deploy RewardsRegistry
|
|
|
|
|
vm.broadcast(_deployerPrivateKey);
|
|
|
|
|
RewardsRegistry rewardsRegistry = new RewardsRegistry(
|
|
|
|
|
address(serviceManager),
|
|
|
|
|
address(0) // Will be set to the Agent address after creation
|
|
|
|
|
);
|
|
|
|
|
Logging.logContractDeployed("RewardsRegistry", address(rewardsRegistry));
|
|
|
|
|
|
|
|
|
|
Logging.logSection("Configuring Service Manager");
|
|
|
|
|
|
|
|
|
|
// Register the DataHaven service in the AllocationManager
|
|
|
|
|
vm.broadcast(_avsOwnerPrivateKey);
|
|
|
|
|
serviceManager.updateAVSMetadataURI("");
|
|
|
|
|
Logging.logStep("DataHaven service registered in AllocationManager");
|
|
|
|
|
|
|
|
|
|
// Set the slasher in the ServiceManager
|
|
|
|
|
vm.broadcast(_avsOwnerPrivateKey);
|
|
|
|
|
serviceManager.setSlasher(vetoableSlasher);
|
|
|
|
|
Logging.logStep("Slasher set in ServiceManager");
|
|
|
|
|
|
|
|
|
|
// Set the RewardsRegistry in the ServiceManager
|
|
|
|
|
uint32 validatorsSetId = serviceManager.VALIDATORS_SET_ID();
|
|
|
|
|
vm.broadcast(_avsOwnerPrivateKey);
|
|
|
|
|
serviceManager.setRewardsRegistry(validatorsSetId, rewardsRegistry);
|
|
|
|
|
Logging.logStep("RewardsRegistry set in ServiceManager");
|
|
|
|
|
|
|
|
|
|
return (serviceManager, vetoableSlasher, rewardsRegistry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _createServiceManagerProxy(
|
|
|
|
|
DataHavenServiceManager implementation,
|
|
|
|
|
ProxyAdmin proxyAdmin,
|
|
|
|
|
ServiceManagerInitParams memory params
|
|
|
|
|
) internal returns (DataHavenServiceManager) {
|
|
|
|
|
vm.broadcast(_deployerPrivateKey);
|
|
|
|
|
bytes memory initData = abi.encodeWithSelector(
|
|
|
|
|
DataHavenServiceManager.initialise.selector,
|
|
|
|
|
params.avsOwner,
|
|
|
|
|
params.rewardsInitiator,
|
|
|
|
|
params.validatorsStrategies,
|
|
|
|
|
params.bspsStrategies,
|
|
|
|
|
params.mspsStrategies,
|
|
|
|
|
params.gateway
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
TransparentUpgradeableProxy proxy =
|
|
|
|
|
new TransparentUpgradeableProxy(address(implementation), address(proxyAdmin), initData);
|
|
|
|
|
|
|
|
|
|
return DataHavenServiceManager(address(proxy));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _prepareStrategiesForServiceManager(
|
|
|
|
|
AVSConfig memory config,
|
2025-04-22 19:49:51 +00:00
|
|
|
StrategyInfo[] memory strategies
|
2025-04-16 15:49:35 +00:00
|
|
|
) internal pure {
|
|
|
|
|
if (config.validatorsStrategies.length == 0) {
|
|
|
|
|
config.validatorsStrategies = new address[](strategies.length);
|
|
|
|
|
config.bspsStrategies = new address[](strategies.length);
|
|
|
|
|
config.mspsStrategies = new address[](strategies.length);
|
|
|
|
|
for (uint256 i = 0; i < strategies.length; i++) {
|
2025-04-22 19:49:51 +00:00
|
|
|
config.validatorsStrategies[i] = strategies[i].address_;
|
|
|
|
|
config.bspsStrategies[i] = strategies[i].address_;
|
|
|
|
|
config.mspsStrategies[i] = strategies[i].address_;
|
2025-04-16 15:49:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-03 17:06:32 +00:00
|
|
|
}
|