From e72f4f73bc96937a192e992158c867f8ca88faa3 Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Wed, 16 Aug 2023 09:38:44 -0300 Subject: [PATCH] fix(orchestrator): set undying/adder collators not validators by default (#1247) * fix(orchestrator): set undying/adder collators not validators by default * fmt * fix cmd generator for undying/adder collators * fmt cmdGenerator * better comments about ternary --- javascript/packages/orchestrator/src/cmdGenerator.ts | 2 +- .../packages/orchestrator/src/configGenerator.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/javascript/packages/orchestrator/src/cmdGenerator.ts b/javascript/packages/orchestrator/src/cmdGenerator.ts index 3d445a94f..7913a21c4 100644 --- a/javascript/packages/orchestrator/src/cmdGenerator.ts +++ b/javascript/packages/orchestrator/src/cmdGenerator.ts @@ -270,7 +270,7 @@ export async function genCmd( const parachainIdArgIndex = args.findIndex((arg) => arg.includes("--parachain-id"), ); - args.splice(parachainIdArgIndex, 1); + if (parachainIdArgIndex >= 0) args.splice(parachainIdArgIndex, 1); args.push(`--parachain-id ${parachainId}`); } diff --git a/javascript/packages/orchestrator/src/configGenerator.ts b/javascript/packages/orchestrator/src/configGenerator.ts index 82adc0594..7f5145f79 100644 --- a/javascript/packages/orchestrator/src/configGenerator.ts +++ b/javascript/packages/orchestrator/src/configGenerator.ts @@ -529,11 +529,21 @@ async function getCollatorNodeFromConfig( const ports = await getPorts(provider, collatorConfig); const externalPorts = await getExternalPorts(provider, ports, collatorConfig); + // IFF the collator have explicit set the validator field we use that value, + // if not we set by default cumulus collators as `validators`, this implies that we will + // run those with this flag `--collator`. + const isValidator = + collatorConfig.validator !== undefined + ? collatorConfig.validator + : cumulusBased + ? true + : false; + const node: Node = { name: collatorName, key: getSha256(collatorName), accounts: accountsForNode, - validator: collatorConfig.validator !== false ? true : false, // --collator and --force-authoring by default + validator: isValidator, invulnerable: collatorConfig.invulnerable, balance: collatorConfig.balance, image: collatorConfig.image || DEFAULT_COLLATOR_IMAGE,