Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganise the types #1255

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/packages/cli/src/actions/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Network, start } from "@zombienet/orchestrator";
import { LaunchConfig } from "@zombienet/orchestrator/dist/types";
import { LaunchConfig } from "@zombienet/orchestrator/dist/configTypes";
import {
decorators,
getCredsFilePath,
Expand Down
4 changes: 3 additions & 1 deletion javascript/packages/orchestrator/src/chainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
import crypto from "crypto";
import fs from "fs";
import { generateKeyFromSeed } from "./keys";
import { ChainSpec, ComputedNetwork, HrmpChannelsConfig, Node } from "./types";
import { ChainSpec } from "./types";
import { HrmpChannelsConfig, Node } from "./sharedTypes";
import { ComputedNetwork } from "./configTypes";
const JSONbig = require("json-bigint")({ useNativeBigInt: true });
const debug = require("debug")("zombie::chain-spec");

Expand Down
2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/src/cmdGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RPC_HTTP_PORT,
RPC_WS_PORT,
} from "./constants";
import { Node, SubstrateCliArgsVersion, ZombieRole } from "./types";
import { Node, ZombieRole, SubstrateCliArgsVersion } from "./sharedTypes";

const debug = require("debug")("zombie::cmdGenerator");

Expand Down
10 changes: 4 additions & 6 deletions javascript/packages/orchestrator/src/configGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ import {
} from "./constants";
import { generateKeyForNode } from "./keys";
import { PARA, decorate, whichPara } from "./paras-decorators";
import { ComputedNetwork, LaunchConfig, ParachainConfig } from "./configTypes";
import {
ComputedNetwork,
LaunchConfig,
Node,
NodeConfig,
Override,
Parachain,
ParachainConfig,
ZombieRole,
envVars,
} from "./types";
Node,
ZombieRole,
} from "./sharedTypes";

const debug = require("debug")("zombie::config-manager");

Expand Down
122 changes: 122 additions & 0 deletions javascript/packages/orchestrator/src/configTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import {
CommonParachainConfig,
HrmpChannelsConfig,
NodeCommonTypes,
NodeConfig,
ObjectJSON,
Override,
Parachain,
Resources,
SubstrateCliArgsVersion,
Node,
} from "./sharedTypes";

// network config to spawn.
export interface LaunchConfig extends PolkadotLaunchConfig {
config: { provider: string };
settings: Settings;
configBasePath: string;
}

export interface PolkadotLaunchConfig {
relaychain: RelayChainConfig;
parachains: ParachainConfig[];
types: any;
hrmp_channels?: HrmpChannelsConfig[];
}

export interface RelayChainConfig {
default_command?: string;
default_image?: string;
default_resources?: Resources;
default_db_snapshot?: string;
default_prometheus_prefix?: string;
default_substrate_cli_args_version?: SubstrateCliArgsVersion;
chain: string;
chain_spec_path?: string;
chain_spec_command?: string;
default_args?: string[];
default_overrides?: Override[];
random_nominators_count?: number;
max_nominations?: number;
nodes?: NodeConfig[];
node_groups?: NodeGroupConfig[];
total_node_in_groups?: number;
genesis?: JSON | ObjectJSON;
}

export interface ComputedNetwork {
settings: Settings;
relaychain: {
defaultImage: string;
defaultCommand: string;
defaultArgs: string[];
defaultDbSnapshot?: string;
defaultPrometheusPrefix: string;
chain: string;
chainSpecPath?: string;
chainSpecCommand?: string;
randomNominatorsCount: number;
maxNominations: number;
nodes: Node[];
overrides: Override[];
genesis?: JSON | ObjectJSON;
defaultResources?: Resources;
};
parachains: Parachain[];
types: any;
hrmp_channels?: HrmpChannelsConfig[];
configBasePath: string;
seed: string;
}

export interface Settings {
global_volumes?: GlobalVolume[];
bootnode?: boolean;
bootnode_domain?: string;
timeout: number;
node_spawn_timeout?: number;
grafana?: boolean;
telemetry?: boolean;
prometheus?: boolean;
jaeger_agent?: string; // agent or collator
tracing_collator_url?: string; // collator query url
tracing_collator_service_name?: string; // only used by k8s provider and if not set the `url`
tracing_collator_service_namespace?: string; // only used by k8s provider and if not set the `url`
tracing_collator_service_port?: number; // only used by k8s provider and if not set the `url`
enable_tracing?: boolean;
provider: string;
polkadot_introspector?: boolean;
backchannel?: boolean; // only used in k8s at the moment, spawn a backchannel instance
image_pull_policy?: "IfNotPresent" | "Never" | "Always";
local_ip?: string; // ip used for expose local services (rpc/metrics/monitors)
}

export interface GlobalVolume {
name: string;
fs_type: string;
mount_path: string;
}

export interface ParachainConfig extends CommonParachainConfig {
add_to_genesis?: boolean;
register_para?: boolean;
onboard_as_parachain?: boolean;
genesis_wasm_path?: string;
genesis_wasm_generator?: string;
genesis_state_path?: string;
genesis_state_generator?: string;
chain_spec_path?: string;
cumulus_based?: boolean;
bootnodes?: string[];
prometheus_prefix?: string;
// backward compatibility
collator?: NodeConfig;
collators?: NodeConfig[];
collator_groups?: NodeGroupConfig[];
}

export interface NodeGroupConfig extends NodeCommonTypes {
image?: string;
count: string | number;
}
10 changes: 4 additions & 6 deletions javascript/packages/orchestrator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ export { Network } from "./network";
export { start, test } from "./orchestrator";
export { Providers } from "./providers";
export { run } from "./test-runner";
export { TestDefinition } from "./types";
export {
HrmpChannelsConfig,
PolkadotLaunchConfig,
LaunchConfig,
NodeConfig,
ObjectJSON,
ParachainConfig,
PolkadotLaunchConfig,
TestDefinition,
} from "./types";
} from "./configTypes";
export { HrmpChannelsConfig, ObjectJSON, NodeConfig } from "./sharedTypes";
2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@polkadot/util-crypto";
import { makeDir } from "@zombienet/utils";
import fs from "fs";
import { Node } from "./types";
import { Node } from "./sharedTypes";

function nameCase(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Network } from "../network";
import { Client } from "../providers/client";
import { PodmanClient } from "../providers/podman/podmanClient";
import { ComputedNetwork } from "../types";
import { ComputedNetwork } from "../configTypes";

export async function setTracingCollatorConfig(
networkSpec: ComputedNetwork,
Expand Down
10 changes: 3 additions & 7 deletions javascript/packages/orchestrator/src/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ import { registerParachain } from "./jsapi-helpers";
import { Network, Scope } from "./network";
import { generateParachainFiles } from "./paras";
import { getProvider } from "./providers/";
import {
ComputedNetwork,
LaunchConfig,
Node,
Parachain,
fileMap,
} from "./types";
import { fileMap } from "./types";

import { spawnIntrospector } from "./network-helpers/instrospector";
import { setTracingCollatorConfig } from "./network-helpers/tracing-collator";
Expand All @@ -52,6 +46,8 @@ import { Client } from "./providers/client";
import { KubeClient } from "./providers/k8s/kubeClient";
import { spawnNode } from "./spawner";
import { setSubstrateCliArgsVersion } from "./substrateCliArgsHelper";
import { ComputedNetwork, LaunchConfig } from "./configTypes";
import { Node, Parachain } from "./sharedTypes";

const debug = require("debug")("zombie");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Acala genesis node key type
export type GenesisNodeKey = [string, string, { [key: string]: string }];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GenesisNodeKey, getNodeKey as _getNodeKey } from "../chainSpec";
import { Node } from "../types";
import { Node } from "../sharedTypes";

export function getNodeKey(node: Node, useStash = true): GenesisNodeKey {
const { ed_account } = node.accounts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Astar genesis node key type
export type GenesisNodeKey = [string, string, { [key: string]: string }];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Bifrost genesis node key type
export type GenesisNodeKey = [string, string, { [key: string]: string }];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Efinity genesis node key type
export type GenesisNodeKey = [string, string, { [key: string]: string }];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
readAndParseChainSpec,
writeChainSpec,
} from "../chainSpec";
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Acala genesis node key type
export type GenesisNodeKey = [string, string, { [key: string]: string }];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
writeChainSpec,
} from "../chainSpec";
import { generateKeyForNode as _generateKeyForNode } from "../keys";
import { Node } from "../types";
import { Node } from "../sharedTypes";

async function generateKeyForNode(nodeName?: string): Promise<any> {
const keys = await _generateKeyForNode(nodeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
readAndParseChainSpec,
writeChainSpec,
} from "../chainSpec";
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Track 1st staking bond as default
let paraStakingBond: number | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
writeChainSpec,
} from "../chainSpec";
import { generateKeyForNode as _generateKeyForNode } from "../keys";
import { ChainSpec, Node } from "../types";
import { ChainSpec } from "../types";
import { Node } from "../sharedTypes";

// track 1st staking as default;
let paraStakingBond: bigint | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
readAndParseChainSpec,
writeChainSpec,
} from "../chainSpec";
import { Node } from "../types";
import { Node } from "../sharedTypes";

// Track 1st staking bond as default
let paraStakingBond: number | undefined;
Expand Down
3 changes: 2 additions & 1 deletion javascript/packages/orchestrator/src/paras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
import { decorate } from "./paras-decorators";
import { Providers } from "./providers";
import { getClient } from "./providers/client";
import { Node, Parachain, ZombieRole, fileMap } from "./types";
import { fileMap } from "./types";
import { Node, ZombieRole, Parachain } from "./sharedTypes";

const debug = require("debug")("zombie::paras");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getRandomPort, getSha256 } from "@zombienet/utils";
import { getUniqueName } from "../../configGenerator";
import { TMP_DONE, WAIT_UNTIL_SCRIPT_SUFIX } from "../../constants";
import { Network } from "../../network";
import { Node, ZombieRole } from "../../types";
import { Node, ZombieRole } from "../../sharedTypes";
import { BootNodeResource, NodeResource, ServiceResource } from "./resources";
import { PodSpec, ServiceSpec } from "./resources/types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
TRANSFER_CONTAINER_NAME,
TRANSFER_CONTAINER_WAIT_LOG,
} from "../../constants";
import { fileMap, ZombieRole } from "../../types";
import { fileMap } from "../../types";
import { ZombieRole } from "../../sharedTypes";
import {
Client,
RunCommandOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node, ZombieRole } from "../../../types";
import { Node, ZombieRole } from "../../../sharedTypes";
import { NodeResource } from "./nodeResource";
import { Container, PodSpec, Volume } from "./types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TRANSFER_CONTAINER_NAME,
TRANSFER_CONTAINER_WAIT_LOG,
} from "../../../constants";
import { Node, ZombieRole, ZombieRoleLabel } from "../../../types";
import { Node, ZombieRole, ZombieRoleLabel } from "../../../sharedTypes";
import {
Container,
ContainerPort,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { envVars, Resources, ZombieRoleLabel } from "../../../types";
import { envVars, Resources, ZombieRoleLabel } from "../../../sharedTypes";

type ContainerResource = Resources["resources"];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubstrateCliArgsVersion } from "../../types";
import { SubstrateCliArgsVersion } from "../../sharedTypes";
import { getClient } from "../client";
import { createTempNodeDef, genNodeDef } from "./dynResourceDefinition";
import { KubeClient } from "./kubeClient";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getRandomPort } from "@zombienet/utils";
import { getUniqueName } from "../../configGenerator";
import { Network } from "../../network";
import { Node, ZombieRole } from "../../types";
import { Node, ZombieRole } from "../../sharedTypes";
import { getClient } from "../client";
import { BootNodeResource, NodeResource } from "./resources";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
LOCALHOST,
P2P_PORT,
} from "../../constants";
import { ZombieRole, fileMap } from "../../types";
import { fileMap } from "../../types";
import { ZombieRole } from "../../sharedTypes";
import {
Client,
RunCommandOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makeDir } from "@zombienet/utils";
import { genCmd } from "../../../cmdGenerator";
import { ZombieRole, ZombieRoleLabel } from "../../../types";
import { ZombieRole, ZombieRoleLabel } from "../../../sharedTypes";
import { NodeResource } from "./nodeResource";
import { NodeSpec, Port, ProcessEnvironment } from "./types";

Expand Down
Loading
Loading