mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## Summary This PR introduces support for deploying Datahaven contracts to different chains (hoodi, holesky, mainnet), as well as a new cli command to manage this deployment separately from the regular deployment, while maintaining compatibility with it. #### New CLI command - **`bun cli contracts deploy`** - Deploy contracts to supported chains (Hoodi, Holesky, Mainnet) - **`bun cli contracts status`** - Check deployment configuration and status - **`bun cli contracts verify`** - Verify contracts on block explorers - Commands need the chain parameter: `--chain <hoodi | holesky | mainnet>` - Right now only `hoodi` and `holesky` are supported ### Deployment #### Hoodi & Holesky Network Support - Added **DeployBase.s.sol** as common ground for **DeployTestnet.s.sol** (also new) and **DeployLocal.s.sol** (existing). - **Hoodi configuration** (`contracts/config/hoodi.json`) with deployed EigenLayer contract addresses to reference. - **Holesky configuration** (`contracts/config/hoodi.json`) with deployed EigenLayer contract addresses to reference. #### Contracts being deployed - **DataHaven**: ServiceManager, VetoableSlasher, RewardsRegistry - **Snowbridge**: BeefyClient, AgentExecutor, Gateway, RewardsAgent - **EigenLayer**: References existing deployed contracts (not re-deployed) #### Deployment files When the deployment is done, a new file under `contracts/deployments` is generated with the addresses of the deployed contracts, for each chain (it will be overriden per chain if run multiple times). So we would have one `anvil.json`, `hoodi.json`, `holesky.json`, etc, with the addresses of the deployed contracts for reference and for later verification. #### Todo - [x] Test compatibility with existing `bun cli launch` and `bun cli deploy` commands #### For follow-up PRs - Fix verification issue with `foundry verify-contracts` when specifying the `chain` or `chain-id` parameter, needed for hoodi (https://github.com/foundry-rs/foundry/issues/7466). - Add `redeploy` feature to only override implementation contract and leave the proxy address untouched ## Usage Examples ```bash # Deploy to Hoodi network bun cli contracts deploy --chain hoodi # Check deployment status bun cli contracts status --chain hoodi # Verify contracts on block explorer bun cli contracts verify --chain hoodi ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added deployment and configuration support for new networks "hoodi" and "holesky", including new configuration and deployment files. * Introduced a CLI tool for managing contract deployments, status checks, and verification across supported chains. * Added example environment configuration and comprehensive deployment documentation. * Enabled contract verification and status reporting via the CLI with support for block explorer integration. * **Improvements** * Refactored deployment scripts for modularity, supporting both local and testnet environments. * Centralized and extended configuration loading to support additional contract addresses and network parameters. * Enhanced deployment utilities and typings to support multi-network deployments. * **Bug Fixes** * Improved input validation and error handling in CLI commands and deployment scripts. * Added explicit handling for zero address in operator strategy retrieval. * **Chores** * Updated documentation and configuration templates for easier onboarding and deployment management. * Improved logging and output formatting for deployment and verification processes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
143 lines
5 KiB
TypeScript
143 lines
5 KiB
TypeScript
import { logger, printDivider } from "utils";
|
|
import { getChainDeploymentParams, loadChainConfig } from "../../../configs/contracts/config";
|
|
import { checkContractVerification } from "./verify";
|
|
|
|
/**
|
|
* Shows the status of chain deployment and verification
|
|
*/
|
|
export const showDeploymentPlanAndStatus = async (chain: string) => {
|
|
try {
|
|
const config = await loadChainConfig(chain);
|
|
const deploymentParams = getChainDeploymentParams(chain);
|
|
|
|
const displayData = {
|
|
Network: `${deploymentParams.network} (Chain ID: ${deploymentParams.chainId})`,
|
|
"RPC URL": deploymentParams.rpcUrl,
|
|
"Block Explorer": deploymentParams.blockExplorer,
|
|
"Genesis Time": new Date(deploymentParams.genesisTime * 1000).toISOString(),
|
|
"AVS Owner": `${config.avs.avsOwner.slice(0, 10)}...${config.avs.avsOwner.slice(-8)}`,
|
|
"Rewards Initiator": `${config.avs.rewardsInitiator.slice(0, 10)}...${config.avs.rewardsInitiator.slice(-8)}`,
|
|
"Veto Committee Member": `${config.avs.vetoCommitteeMember.slice(0, 10)}...${config.avs.vetoCommitteeMember.slice(-8)}`
|
|
};
|
|
console.table(displayData);
|
|
|
|
await showDatahavenContractStatus(chain, deploymentParams.rpcUrl);
|
|
await showEigenLayerContractStatus(
|
|
config,
|
|
deploymentParams.chainId.toString(),
|
|
deploymentParams.rpcUrl
|
|
);
|
|
|
|
printDivider();
|
|
} catch (error) {
|
|
logger.error(`❌ Failed to load ${chain} configuration: ${error}`);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Common function to print contract status (deployment + verification)
|
|
*/
|
|
const printContractStatus = async (
|
|
contract: { name: string; address: string },
|
|
etherscanApiKey?: string,
|
|
chainId?: string,
|
|
rpcUrl?: string
|
|
) => {
|
|
if (!contract.address || contract.address === "0x0000000000000000000000000000000000000000") {
|
|
logger.info(`❌ ${contract.name}: Not deployed`);
|
|
} else if (!etherscanApiKey) {
|
|
logger.info(`⚠️ ${contract.name}: Deployed (${contract.address}) - verification unknown`);
|
|
} else {
|
|
try {
|
|
const isVerified = await checkContractVerification(contract.address, chainId, rpcUrl);
|
|
if (isVerified) {
|
|
logger.info(`✅ ${contract.name}: Deployed and verified`);
|
|
} else {
|
|
logger.warn(`⚠️ ${contract.name}: Deployed but not verified`);
|
|
}
|
|
} catch (error) {
|
|
logger.warn(
|
|
`⚠️ ${contract.name}: Deployed but verification check failed with error: ${error}`
|
|
);
|
|
}
|
|
|
|
// Add small delay to respect rate limits
|
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Shows the status of all contracts (deployment + verification)
|
|
*/
|
|
const showDatahavenContractStatus = async (chain: string, rpcUrl: string) => {
|
|
try {
|
|
const contracts = [
|
|
{ name: "DataHavenServiceManager", key: "ServiceManagerImplementation" },
|
|
{ name: "VetoableSlasher", key: "VetoableSlasher" },
|
|
{ name: "RewardsRegistry", key: "RewardsRegistry" },
|
|
{ name: "Snowbridge BeefyClient", key: "BeefyClient" },
|
|
{ name: "Snowbridge AgentExecutor", key: "AgentExecutor" },
|
|
{ name: "Snowbridge Gateway", key: "Gateway" },
|
|
{ name: "Snowbridge Agent", key: "RewardsAgent" }
|
|
];
|
|
|
|
logger.info("DataHaven contracts");
|
|
|
|
const deploymentsPath = `../contracts/deployments/${chain}.json`;
|
|
const deploymentsFile = Bun.file(deploymentsPath);
|
|
const exists = await deploymentsFile.exists();
|
|
|
|
if (!exists) {
|
|
contracts.forEach(({ name }) => logger.info(` ❌ ${name}: Not deployed`));
|
|
return;
|
|
}
|
|
|
|
const deployments = await deploymentsFile.json();
|
|
const etherscanApiKey = process.env.ETHERSCAN_API_KEY;
|
|
|
|
for (const contract of contracts) {
|
|
const address = deployments[contract.key];
|
|
await printContractStatus({ name: contract.name, address }, etherscanApiKey, chain, rpcUrl);
|
|
}
|
|
} catch (error) {
|
|
logger.warn(`⚠️ Could not check contract status: ${error}`);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Shows the status of EigenLayer contracts (verification only)
|
|
*/
|
|
const showEigenLayerContractStatus = async (config: any, chainId: string, rpcUrl: string) => {
|
|
try {
|
|
const contracts = [
|
|
{
|
|
name: "DelegationManager",
|
|
address: config.eigenLayer.delegationManager
|
|
},
|
|
{ name: "StrategyManager", address: config.eigenLayer.strategyManager },
|
|
{ name: "EigenPodManager", address: config.eigenLayer.eigenPodManager },
|
|
{ name: "AVSDirectory", address: config.eigenLayer.avsDirectory },
|
|
{
|
|
name: "RewardsCoordinator",
|
|
address: config.eigenLayer.rewardsCoordinator
|
|
},
|
|
{
|
|
name: "AllocationManager",
|
|
address: config.eigenLayer.allocationManager
|
|
},
|
|
{
|
|
name: "PermissionController",
|
|
address: config.eigenLayer.permissionController
|
|
}
|
|
];
|
|
|
|
logger.info("EigenLayer contracts status:");
|
|
const etherscanApiKey = process.env.ETHERSCAN_API_KEY;
|
|
|
|
for (const contract of contracts) {
|
|
await printContractStatus(contract, etherscanApiKey, chainId, rpcUrl);
|
|
}
|
|
} catch (error) {
|
|
logger.warn(`⚠️ Could not check EigenLayer contract status: ${error}`);
|
|
}
|
|
};
|