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

Add support for Aventus chains and allow force decorating relay chainspec (useful for solo chains) #1838

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Node } from "../sharedTypes";

// Aventus genesis node key type
export type GenesisNodeKey = [string, string, { [key: string]: string }];

export function getNodeKey(node: Node, useStash = true): GenesisNodeKey {
const { sr_stash, sr_account, ed_account } = node.accounts;

const address = useStash ? sr_stash.address : sr_account.address;

const key: GenesisNodeKey = [
address,
address,
{
aura: sr_account.address,
grandpa: ed_account.address,
authority_discovery: sr_account.address,
im_online: sr_account.address,
avn: sr_account.address,
},
];

return key;
}

export default {
getNodeKey,
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
GenericEvm = "generic_evm",
LocalV = "local_v",
MainnetLocalV = "mainnet_local_v",
Aventus = "aventus",
}

interface Decorator {
Expand All @@ -31,6 +32,7 @@
import moonbeam from "./moonbeam";
import oak from "./oak";
import generic_evm from "./generic-evm";
import aventus from "./aventus";

function whichChain(chain_name: string, force_decorator?: string): CHAIN {
const chain = force_decorator ? force_decorator : chain_name;
Expand All @@ -47,9 +49,15 @@
if (/local-v/.test(chain)) return CHAIN.LocalV;
if (/mainnet-local-v/.test(chain)) return CHAIN.MainnetLocalV;
if (/generic-evm/.test(chain)) return CHAIN.GenericEvm;
if (/vow-net|avn-chain/.test(chain)) return CHAIN.Aventus;

return CHAIN.Generic;
}
const aventusDecorators: Decorator = Object.keys(aventus).reduce(

Check failure on line 56 in javascript/packages/orchestrator/src/chain-decorators/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `⏎··`

Check failure on line 56 in javascript/packages/orchestrator/src/chain-decorators/index.ts

View workflow job for this annotation

GitHub Actions / build (19.x)

Delete `⏎··`

Check failure on line 56 in javascript/packages/orchestrator/src/chain-decorators/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `⏎··`
(memo, fn) => {
memo[fn] = (aventus as Decorator)[fn];

Check failure on line 58 in javascript/packages/orchestrator/src/chain-decorators/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `··`

Check failure on line 58 in javascript/packages/orchestrator/src/chain-decorators/index.ts

View workflow job for this annotation

GitHub Actions / build (19.x)

Delete `··`

Check failure on line 58 in javascript/packages/orchestrator/src/chain-decorators/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `··`
return memo;
}, Object.create({}));

const moonbeamDecorators: Decorator = Object.keys(moonbeam).reduce(
(memo, fn) => {
Expand Down Expand Up @@ -136,6 +144,7 @@
mainnet_local_v: MainnetLocalVDecorators,
generic: {},
generic_evm: GenericEvmDecorators,
aventus: aventusDecorators,
};

function decorate(chain: CHAIN, fns: Function[]) {
Expand Down
2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/src/chainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@
validatorKeys.push(node.accounts.sr_stash.address);

if (keyType === "session") {
const chain = whichChain(networkSpec.relaychain.chain);
const chain = whichChain(networkSpec.relaychain.chain, networkSpec.relaychain.force_decorator);

Check failure on line 759 in javascript/packages/orchestrator/src/chainSpec.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `networkSpec.relaychain.chain,·networkSpec.relaychain.force_decorator` with `⏎············networkSpec.relaychain.chain,⏎············networkSpec.relaychain.force_decorator,⏎··········`

Check failure on line 759 in javascript/packages/orchestrator/src/chainSpec.ts

View workflow job for this annotation

GitHub Actions / build (19.x)

Replace `networkSpec.relaychain.chain,·networkSpec.relaychain.force_decorator` with `⏎············networkSpec.relaychain.chain,⏎············networkSpec.relaychain.force_decorator,⏎··········`

Check failure on line 759 in javascript/packages/orchestrator/src/chainSpec.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `networkSpec.relaychain.chain,·networkSpec.relaychain.force_decorator` with `⏎············networkSpec.relaychain.chain,⏎············networkSpec.relaychain.force_decorator,⏎··········`
const [decoratedGetNodeKey] = decorate(chain, [getNodeKey]);
const key = decoratedGetNodeKey(node);
await addAuthority(specPath, node, key);
Expand Down
1 change: 1 addition & 0 deletions javascript/packages/orchestrator/src/configGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export async function generateNetworkSpec(
config.relaychain?.max_nominations || DEFAULT_MAX_NOMINATIONS,
nodes: [],
chain: config.relaychain.chain || DEFAULT_CHAIN,
force_decorator: config.relaychain.force_decorator,
overrides: globalOverrides,
defaultResources: config.relaychain.default_resources,
defaultPrometheusPrefix:
Expand Down
2 changes: 2 additions & 0 deletions javascript/packages/orchestrator/src/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface RelayChainConfig {
default_substrate_cli_args_version?: SubstrateCliArgsVersion;
default_keystore_key_types?: string[];
chain: string;
force_decorator?: string;
chain_spec_path?: string;
chain_spec_command?: string;
default_args?: string[];
Expand Down Expand Up @@ -66,6 +67,7 @@ export interface ComputedNetwork {
genesis?: JSON | ObjectJSON;
defaultResources?: Resources;
delayNetworkSettings?: DelayNetworkSettings;
force_decorator?: string;
};
parachains: Parachain[];
types: any;
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nahuseyoum, thanks for the update. Can you remove this file?, the lock file is under javascript dir.
Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you need to bring back the lock file under javascript directory.
Thanks!!

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading