Skip to content

Commit

Permalink
Merge branch 'main' into nik-automerge-dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod authored Sep 27, 2023
2 parents b32d4a2 + 3b87796 commit 5f9a62e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
24 changes: 24 additions & 0 deletions docs/src/network-definition-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `rpc_port`: (number) RPC port to use;
- `prometheus_port`: (number) Prometheus port to use;
- `prometheus_prefix`: A parameter for customizing the metric's prefix for the specific node. Will apply only to this node; Defaults to 'substrate'.
- `keystore_key_types`: Defines which keystore keys should be created, for more details checkout details below.
- `node_groups`:
- `*name`: (String) Group name, used for naming the nodes (e.g name-1)
- `*count` (Number), Number of `nodes` to launch for this group.
Expand Down Expand Up @@ -94,6 +95,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.
- `keystore_key_types`: Defines which keystore keys should be created, for more details checkout details below.

- `collator_groups`:

Expand Down Expand Up @@ -121,3 +123,25 @@ The network config can be provided both in `json` or `toml` format and each sect
## `types`

- Object to use as `user defined types` with the js api.

## `keystore_key_types`

- There are 2 ways to specify key, values that don't respect below format will be ignored:
- short: `audi` - creates `audi` key type that defaults to predefined schema, it predefined schema for given key type doesn't exist it is ignored
- long: `audi_sr` - creates `audi` key type with `sr` schema

- Schemas: `ed`, `ec`, `sr`

- Predefined key type schemas:
- `aura` - `sr` if statemint or asset hub polkadot parachain, otherwise `ed`
- `babe` - `sr`
- `imon` - `sr`
- `gran` - `ed`
- `audi` - `sr`
- `asgn` - `sr`
- `para` - `sr`
- `beef` - `ec`
- `nmbs` - `sr`
- `rand` - `sr`
- `rate` - `ed`
- `acco` - `sr`
24 changes: 20 additions & 4 deletions javascript/packages/orchestrator/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "@polkadot/util-crypto";
import { makeDir } from "@zombienet/utils";
import fs from "fs";
import { DEFAULT_KEYSTORE_KEY_TYPES } from "./constants";
import { Node } from "./sharedTypes";

function nameCase(string: string) {
Expand Down Expand Up @@ -92,9 +91,26 @@ export async function generateKeystoreFiles(
rate: node.accounts.ed_account.publicKey, // Equilibrium rate module
};

node.keystoreKeyTypes?.forEach((key_type: string) => {
if (DEFAULT_KEYSTORE_KEY_TYPES.includes(key_type))
keystore_key_types[key_type] = default_keystore_key_types[key_type];
// 2 ways keys can be defined:
node.keystoreKeyTypes?.forEach((key_spec) => {
// short: by only 4 letter key type with defaulted scheme e.g. "audi", if default scheme doesn't exist it is "ed"
if (key_spec.length === 4) {
keystore_key_types[key_spec] =
default_keystore_key_types[key_spec] ||
node.accounts.sr_account.publicKey;
}

// long: 4 letter key type with scheme separated by underscore e.g. "audi_sr"
const [key_type, key_scheme] = key_spec.split("_");
if (key_type.length === 4) {
if (key_scheme === "ed") {
keystore_key_types[key_type] = node.accounts.ed_account.publicKey;
} else if (key_scheme === "ec") {
keystore_key_types[key_type] = node.accounts.ec_account.publicKey;
} else if (key_scheme === "sr") {
keystore_key_types[key_type] = node.accounts.sr_account.publicKey;
}
}
});

if (Object.keys(keystore_key_types).length === 0)
Expand Down

0 comments on commit 5f9a62e

Please sign in to comment.