datahaven/test/cli/handlers/launch/summary.ts
Gonza Montiel 6dae38f587
feat: 🚀 add storage-hub nodes to CLI (#287)
##  Add StorageHub nodes to CLI

This PR adds StorageHub node infrastructure to the CLI and fixes CLI
flag handling and improves the CLI logic a bit.

### Fix: CLI safeguards
- Prevents contract deployment and validator operations when `--ndc`
flag is used
- Skips Kurtosis service display in summary when `--nlk` flag is used

### Feat: Dockerized Storage Hub Nodes
- Adds 5 Docker containers: PostgreSQL, MSP, BSP, Indexer, and Fisherman
nodes
- New CLI flags: `--storagehub` `--no-storagehub` to control StorageHub
nodes launch
- Automatic provider funding and registration (Charleth for MSP and
Dorothy for BSP)
- Exposes nodes on ports 9945-9948 for local development

**TODO**
- [x] MSP & BSP associated pre-funded account.
- [x] Call `forceMspSignUp` and `forceBspSignUp` extrinsics

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
2025-11-22 11:49:14 +01:00

119 lines
3.7 KiB
TypeScript

import invariant from "tiny-invariant";
import { getServiceFromKurtosis, logger, printHeader } from "utils";
import type { LaunchedNetwork } from "../../../launcher/types/launchedNetwork";
import { KURTOSIS_BASE_SERVICES } from "../../../launcher/utils/constants";
import type { LaunchOptions } from ".";
export const performSummaryOperations = async (
options: LaunchOptions,
launchedNetwork: LaunchedNetwork
) => {
printHeader("Service Endpoints");
const servicesToDisplay = options.launchKurtosis ? KURTOSIS_BASE_SERVICES : [];
if (options.blockscout === true) {
servicesToDisplay.push(...["blockscout", "blockscout-frontend"]);
}
if (launchedNetwork.containers.find((c) => c.name === "datahaven-alice")) {
servicesToDisplay.push("datahaven-alice");
}
logger.trace("Services to display", servicesToDisplay);
const displayData: {
service: string;
ports: Record<string, number>;
url: string;
}[] = [];
for (const service of servicesToDisplay) {
logger.debug(`Checking service: ${service}`);
const serviceInfo = service.startsWith("datahaven-")
? undefined
: await getServiceFromKurtosis(service, options.kurtosisEnclaveName);
logger.trace("Service info", serviceInfo);
switch (true) {
case service.startsWith("cl-"): {
invariant(serviceInfo, `❌ Service info for ${service} is not available`);
const httpPort = serviceInfo.public_ports.http.number;
displayData.push({
service,
ports: { http: httpPort },
url: `http://127.0.0.1:${httpPort}`
});
break;
}
case service.startsWith("el-"): {
invariant(serviceInfo, `❌ Service info for ${service} is not available`);
const rpcPort = serviceInfo.public_ports.rpc.number;
const wsPort = serviceInfo.public_ports.ws.number;
displayData.push({
service,
ports: { rpc: rpcPort, ws: wsPort },
url: `http://127.0.0.1:${rpcPort}`
});
break;
}
case service.startsWith("dora"): {
invariant(serviceInfo, `❌ Service info for ${service} is not available`);
const httpPort = serviceInfo.public_ports.http.number;
displayData.push({
service,
ports: { http: httpPort },
url: `http://127.0.0.1:${httpPort}`
});
break;
}
case service === "blockscout": {
invariant(serviceInfo, `❌ Service info for ${service} is not available`);
const httpPort = serviceInfo.public_ports.http.number;
displayData.push({
service,
ports: { http: httpPort },
url: `http://127.0.0.1:${httpPort}`
});
break;
}
case service === "blockscout-frontend": {
invariant(serviceInfo, `❌ Service info for ${service} is not available`);
const httpPort = serviceInfo.public_ports.http.number;
displayData.push({
service,
ports: { http: httpPort },
url: `http://127.0.0.1:${httpPort}`
});
break;
}
case service === "datahaven-alice": {
const port = launchedNetwork.getContainerPort(service);
displayData.push({
service,
ports: { ws: port },
url: `http://127.0.0.1:${port}`
});
break;
}
default: {
logger.error(`Unknown service: ${service}`);
}
}
}
const containers = launchedNetwork.containers.filter((c) => !c.name.startsWith("datahaven-"));
for (const { name, publicPorts } of containers) {
const url = "ws" in publicPorts ? `ws://127.0.0.1:${publicPorts.ws}` : undefined;
if (url) {
displayData.push({ service: name, ports: publicPorts, url });
}
}
console.table(displayData);
};