Skip to content

Commit a4fea49

Browse files
committed
Enhance substrate CLI args version handling in network configuration
- Added `defaultSubstrateCliArgsVersion` to `ComputedNetwork` interface. - Updated `generateNetworkSpec` to utilize the new default substrate CLI args version. - Improved `setSubstrateCliArgsVersion` to detect and log nodes and collators missing the version configuration.
1 parent df56c37 commit a4fea49

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

javascript/packages/orchestrator/src/configGenerator.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export async function generateNetworkSpec(
132132
defaultPrometheusPrefix:
133133
config.relaychain.default_prometheus_prefix ||
134134
DEFAULT_PROMETHEUS_PREFIX,
135+
defaultSubstrateCliArgsVersion:
136+
config.relaychain.default_substrate_cli_args_version,
135137
delayNetworkSettings:
136138
config.relaychain.default_delay_network_settings ||
137139
config.settings?.global_delay_network_global_settings,
@@ -226,7 +228,7 @@ export async function generateNetworkSpec(
226228
networkSpec.relaychain.defaultPrometheusPrefix,
227229
substrate_cli_args_version:
228230
nodeGroup.substrate_cli_args_version ||
229-
networkSpec.relaychain.default_substrate_cli_args_version,
231+
networkSpec.relaychain.defaultSubstrateCliArgsVersion,
230232
};
231233

232234
const nodeSetup = await getNodeFromConfig(
@@ -419,6 +421,8 @@ export async function generateNetworkSpec(
419421
para,
420422
cumulusBased: isCumulusBased,
421423
defaultArgs: parachain.default_args || [],
424+
defaultSubstrateCliArgsVersion:
425+
parachain.default_substrate_cli_args_version,
422426
addToGenesis:
423427
parachain.add_to_genesis === undefined
424428
? true
@@ -644,6 +648,16 @@ async function getCollatorNodeFromConfig(
644648
};
645649

646650
if (group) node.group = group;
651+
652+
if (
653+
collatorConfig.substrate_cli_args_version ||
654+
parachain.default_substrate_cli_args_version
655+
)
656+
node.substrateCliArgsVersion =
657+
collatorConfig.substrate_cli_args_version ||
658+
parachain.default_substrate_cli_args_version ||
659+
undefined; // will be detected as part of the bootstrap process
660+
647661
return node;
648662
}
649663

@@ -740,11 +754,12 @@ async function getNodeFromConfig(
740754
if (dbSnapshot) nodeSetup.dbSnapshot = dbSnapshot;
741755
if (
742756
node.substrate_cli_args_version ||
743-
networkSpec.default_substrate_cli_args_version
757+
networkSpec.relaychain.defaultSubstrateCliArgsVersion
744758
)
745759
nodeSetup.substrateCliArgsVersion =
746760
node.substrate_cli_args_version ||
747-
networkSpec.default_substrate_cli_args_version;
761+
networkSpec.relaychain.defaultSubstrateCliArgsVersion ||
762+
undefined; // will be detected as part of the bootstrap process
748763
return nodeSetup;
749764
}
750765

javascript/packages/orchestrator/src/configTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface ComputedNetwork {
5757
defaultArgs: string[];
5858
defaultDbSnapshot?: string;
5959
defaultPrometheusPrefix: string;
60+
defaultSubstrateCliArgsVersion?: SubstrateCliArgsVersion;
6061
chain: string;
6162
chainSpecPath?: string;
6263
chainSpecCommand?: string;
@@ -124,6 +125,7 @@ export interface ParachainConfig extends CommonParachainConfig {
124125
cumulus_based?: boolean;
125126
bootnodes?: string[];
126127
prometheus_prefix?: string;
128+
default_substrate_cli_args_version?: SubstrateCliArgsVersion;
127129
// backward compatibility
128130
collator?: NodeConfig;
129131
collators?: NodeConfig[];

javascript/packages/orchestrator/src/orchestrator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ export async function start(
245245

246246
// Set substrate client argument version, needed from breaking change.
247247
// see https://github.com/paritytech/substrate/pull/13384
248+
// This will only spawn detection processes for nodes that don't have
249+
// substrate_cli_args_version configured via default_substrate_cli_args_version
250+
// or individual node substrate_cli_args_version settings
248251
await setSubstrateCliArgsVersion(networkSpec, client);
249252

250253
const random_suffix_to_isolate = networkSpec.settings.isolate_env

javascript/packages/orchestrator/src/sharedTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface Parachain extends CommonParachainConfig {
5454
statePath?: string;
5555
collators: Node[];
5656
defaultArgs: string[];
57+
defaultSubstrateCliArgsVersion?: SubstrateCliArgsVersion;
5758
}
5859

5960
export interface Node extends NodeCommonTypes, Ports {

javascript/packages/orchestrator/src/substrateCliArgsHelper.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ export const setSubstrateCliArgsVersion = async (
1111
network: ComputedNetwork,
1212
client: Client,
1313
) => {
14+
const nodesNeedingVersion = network.relaychain.nodes.filter(
15+
(node) => !node.substrateCliArgsVersion,
16+
);
17+
const collatorsNeedingVersion = network.parachains.flatMap((parachain) =>
18+
parachain.collators.filter((collator) => !collator.substrateCliArgsVersion),
19+
);
20+
21+
if (
22+
nodesNeedingVersion.length === 0 &&
23+
collatorsNeedingVersion.length === 0
24+
) {
25+
debug(
26+
"All nodes already have substrate_cli_args_version configured, skipping detection",
27+
);
28+
return;
29+
}
30+
1431
const { getCliArgsHelp } = getProvider(client.providerName);
1532
// Calculate substrate cli version for each node
1633
// and set in the node to use later when we build the cmd.

0 commit comments

Comments
 (0)