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

Adds --insecure-validator-i-know-what-i-do flag and new args version #1570

Merged
merged 4 commits into from
Dec 1, 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
8 changes: 4 additions & 4 deletions docs/src/network-definition-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `chain_spec_path`: (String) Path to the chain spec file, **NOTE** should be the `plain` version to allow customizations.
- `chain_spec_command`: (String) Command to generate the chain spec, **NOTE** can't be used in combination with `chain_spec_path`.
- `default_args`: (Array of strings) An array of arguments to use as default to pass to the `command`.
- `default_substrate_cli_args_version`: (0|1) Allow to set the substrate cli args version (see: https://github.com/paritytech/substrate/pull/13384). By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.
- `default_substrate_cli_args_version`: (0|1|2) Allow to set the substrate cli args version (see: https://github.com/paritytech/substrate/pull/13384). By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.
- `default_overrides`: (Array of objects) An array of overrides to upload to the nodes, objects with:
- `local_path`: string;
- `remote_name`: string;
Expand All @@ -42,7 +42,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `command`: (String) Override default command.
- `command_with_args`: (String) Override default command and args.
- `args`: (Array of strings) Arguments to be passed to the `command`.
- `substrate_cli_args_version`: (0|1) By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.
- `substrate_cli_args_version`: (0|1|2) By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.
- `validator`: (Boolean, default true) Pass the `--validator` flag to the `command`.
- `invulnerable`: (Boolean, default false) If true, the node will be added to `invulnerables` in the chain spec.
- `balance`: (number, default 2000000000000) Balance to set in `balances` for node's account.
Expand Down Expand Up @@ -70,7 +70,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `overrides`: Array of `overrides` definitions.
- `prometheus_prefix`: A parameter for customizing the metric's prefix for the specific node. Will apply to all the nodes of the group; Defaults to 'substrate'.
- `resources`: (Object) **Only** available in `kubernetes`, represent the resources `limits`/`reservations` needed by the node.
- `substrate_cli_args_version`: (0|1) By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.
- `substrate_cli_args_version`: (0|1|2) By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.

## `parachains`

Expand Down Expand Up @@ -108,7 +108,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `env`: Array of env vars Object to set in the container.
- name: (String) name of the `env` var.
- value: (String| number) Value of the env var.
- `substrate_cli_args_version`: (0|1) By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.
- `substrate_cli_args_version`: (0|1|2) By default zombienet will evaluate your binary and set the correct version, but that produces a small overhead that could be skipped if you set directly with this key.

- `onboard_as_parachain`: (Boolean, default true) flag to specify whether the para should be onboarded as a parachain or stay a parathread
- `register_para`: (Boolean, default true) flag to specify whether the para should be registered. The `add_to_genesis` flag **must** be set to false for this flag to have any effect.
Expand Down
10 changes: 9 additions & 1 deletion javascript/packages/orchestrator/src/cmdGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,15 @@ export async function genCmd(
if (jaegerUrl && zombieRole === ZombieRole.Node)
args.push(...["--jaeger-agent", jaegerUrl]);

if (validator && !args.includes("--validator")) args.push("--validator");
if (validator) {
if (!args.includes("--validator")) args.push("--validator");
if (
nodeSetup.substrateCliArgsVersion &&
nodeSetup.substrateCliArgsVersion >= SubstrateCliArgsVersion.V2
) {
args.push("--insecure-validator-i-know-what-i-do");
}
}

if (zombieRole === ZombieRole.Collator && parachainId) {
const parachainIdArgIndex = args.findIndex((arg) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getCliArgsVersion = async (
): Promise<SubstrateCliArgsVersion> => {
const client = getClient() as KubeClient;
// use echo to not finish the pod with error status.
const fullCmd = `${command} --help | grep ws-port || echo "V1"`;
const fullCmd = `${command} --help || echo ""`;
const node = await createTempNodeDef(
"temp",
image,
Expand All @@ -23,7 +23,11 @@ export const getCliArgsVersion = async (
await client.spawnFromDef(podDef);
const logs = await client.getNodeLogs(podName);

return logs.includes("--ws-port <PORT>")
? SubstrateCliArgsVersion.V0
: SubstrateCliArgsVersion.V1;
if (logs.includes("--ws-port <PORT>")) {
return SubstrateCliArgsVersion.V0;
} else if (!logs.includes("--insecure-validator-i-know-what-i-do")) {
return SubstrateCliArgsVersion.V1;
} else {
return SubstrateCliArgsVersion.V2;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ export const getCliArgsVersion = async (
command: string,
): Promise<SubstrateCliArgsVersion> => {
const client = getClient();
const fullCmd = `${command} --help | grep ws-port`;
const fullCmd = `${command} --help`;
const logs = (await client.runCommand(["-c", fullCmd], { allowFail: true }))
.stdout;

return logs.includes("--ws-port <PORT>")
? SubstrateCliArgsVersion.V0
: SubstrateCliArgsVersion.V1;
if (logs.includes("--ws-port <PORT>")) {
return SubstrateCliArgsVersion.V0;
} else if (!logs.includes("--insecure-validator-i-know-what-i-do")) {
return SubstrateCliArgsVersion.V1;
} else {
return SubstrateCliArgsVersion.V2;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getCliArgsVersion = async (
command: string,
): Promise<SubstrateCliArgsVersion> => {
const client = getClient();
const fullCmd = `${command} --help | grep ws-port`;
const fullCmd = `${command} --help`;
const node = await createTempNodeDef(
"temp",
image,
Expand All @@ -20,7 +20,11 @@ export const getCliArgsVersion = async (
await client.spawnFromDef(podDef);
const logs = await client.getNodeLogs(podName);

return logs.includes("--ws-port <PORT>")
? SubstrateCliArgsVersion.V0
: SubstrateCliArgsVersion.V1;
if (logs.includes("--ws-port <PORT>")) {
return SubstrateCliArgsVersion.V0;
} else if (!logs.includes("--insecure-validator-i-know-what-i-do")) {
return SubstrateCliArgsVersion.V1;
} else {
return SubstrateCliArgsVersion.V2;
}
};
2 changes: 2 additions & 0 deletions javascript/packages/orchestrator/src/sharedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { CHAIN } from "./chain-decorators";
export enum SubstrateCliArgsVersion {
V0 = 0,
V1 = 1,
// Includes the --insecure-validator-i-know-what-i-do flag.
V2 = 2,
}

// enums
Expand Down
Loading