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
2 changes: 1 addition & 1 deletion javascript/package-lock.json

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

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 @@ enum CHAIN {
GenericEvm = "generic_evm",
LocalV = "local_v",
MainnetLocalV = "mainnet_local_v",
Aventus = "aventus",
}

interface Decorator {
Expand All @@ -31,6 +32,7 @@ import mangata from "./mangata";
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,14 @@ function whichChain(chain_name: string, force_decorator?: string): CHAIN {
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((memo, fn) => {
memo[fn] = (aventus as Decorator)[fn];
return memo;
}, Object.create({}));

const moonbeamDecorators: Decorator = Object.keys(moonbeam).reduce(
(memo, fn) => {
Expand Down Expand Up @@ -136,6 +143,7 @@ const decorators: { [para in CHAIN]: { [fn: string]: Function } } = {
mainnet_local_v: MainnetLocalVDecorators,
generic: {},
generic_evm: GenericEvmDecorators,
aventus: aventusDecorators,
};

function decorate(chain: CHAIN, fns: Function[]) {
Expand Down
5 changes: 4 additions & 1 deletion javascript/packages/orchestrator/src/chainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,10 @@ export async function customizePlainRelayChain(
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,
);
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
Loading