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>
107 lines
2.9 KiB
TypeScript
107 lines
2.9 KiB
TypeScript
import { logger, printDivider, printHeader } from "utils";
|
|
import { deployContracts } from "../../../scripts/deploy-contracts";
|
|
import { showDeploymentPlanAndStatus } from "./status";
|
|
import { verifyContracts } from "./verify";
|
|
|
|
export const contractsDeploy = async (options: any, command: any) => {
|
|
// Try to get chain from options or command
|
|
let chain = options.chain;
|
|
if (!chain && command.parent) {
|
|
chain = command.parent.getOptionValue("chain");
|
|
}
|
|
if (!chain) {
|
|
chain = command.getOptionValue("chain");
|
|
}
|
|
|
|
printHeader(`Deploying DataHaven Contracts to ${chain}`);
|
|
|
|
try {
|
|
logger.info("🚀 Starting deployment...");
|
|
logger.info(`📡 Using chain: ${chain}`);
|
|
if (options.rpcUrl) {
|
|
logger.info(`📡 Using RPC URL: ${options.rpcUrl}`);
|
|
}
|
|
|
|
await deployContracts({
|
|
chain: chain,
|
|
rpcUrl: options.rpcUrl,
|
|
privateKey: options.privateKey
|
|
});
|
|
|
|
printDivider();
|
|
} catch (error) {
|
|
logger.error(`❌ Deployment failed: ${error}`);
|
|
}
|
|
};
|
|
|
|
export const contractsCheck = async (options: any, command: any) => {
|
|
// Try to get chain from options or command
|
|
let chain = options.chain;
|
|
if (!chain && command.parent) {
|
|
chain = command.parent.getOptionValue("chain");
|
|
}
|
|
if (!chain) {
|
|
chain = command.getOptionValue("chain");
|
|
}
|
|
|
|
printHeader(`Checking DataHaven ${chain} Configuration and Status`);
|
|
|
|
logger.info("🔍 Showing deployment plan and status");
|
|
|
|
// Use the status function from status.ts
|
|
await showDeploymentPlanAndStatus(chain);
|
|
};
|
|
|
|
export const contractsVerify = async (options: any, command: any) => {
|
|
// Try to get chain from options or command
|
|
let chain = options.chain;
|
|
if (!chain && command.parent) {
|
|
chain = command.parent.getOptionValue("chain");
|
|
}
|
|
if (!chain) {
|
|
chain = command.getOptionValue("chain");
|
|
}
|
|
|
|
printHeader(`Verifying DataHaven Contracts on ${chain} Block Explorer`);
|
|
|
|
if (options.skipVerification) {
|
|
logger.info("⏭️ Skipping verification as requested");
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const verifyOptions = {
|
|
...options,
|
|
chain: chain
|
|
};
|
|
await verifyContracts(verifyOptions);
|
|
printDivider();
|
|
} catch (error) {
|
|
logger.error(`❌ Verification failed: ${error}`);
|
|
}
|
|
};
|
|
|
|
export const contractsPreActionHook = async (thisCommand: any) => {
|
|
let chain = thisCommand.getOptionValue("chain");
|
|
|
|
if (!chain && thisCommand.parent) {
|
|
chain = thisCommand.parent.getOptionValue("chain");
|
|
}
|
|
|
|
const privateKey = thisCommand.getOptionValue("privateKey");
|
|
|
|
if (!chain) {
|
|
logger.error("❌ Chain is required. Use --chain option (hoodi, holesky, mainnet)");
|
|
process.exit(1);
|
|
}
|
|
|
|
const supportedChains = ["hoodi", "holesky", "mainnet"];
|
|
if (!supportedChains.includes(chain)) {
|
|
logger.error(`❌ Unsupported chain: ${chain}. Supported chains: ${supportedChains.join(", ")}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
if (!privateKey) {
|
|
logger.warn("⚠️ Private key not provided. Will use PRIVATE_KEY environment variable");
|
|
}
|
|
};
|