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

fix logic for relay-chain-rpc-url flag #697

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion javascript/packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ async function spawn(
}
}

const options = { monitor, spawnConcurrency, dir, force };
const inCI = process.env.RUN_IN_CONTAINER === "1";
const options = { monitor, spawnConcurrency, dir, force, inCI };
network = await start(creds, config, options);
network.showNetworkInfo(config.settings?.provider);
}
Expand Down
118 changes: 56 additions & 62 deletions javascript/packages/orchestrator/src/cmdGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,73 +124,67 @@ export async function genCumulusCollatorCmd(
}
}

if (
fullCmd.findIndex((thisArg) =>
thisArg.includes("relay-chain-rpc-url"),
) === -1
) {
// Arguments for the relay chain node part of the collator binary.
fullCmd.push(
...[
"--",
"--base-path",
relayDataPath,
"--chain",
`${cfgPath}/${relayChain}.json`,
"--execution wasm",
],
);

if (argsFullNode) {
// Add any additional flags to the CLI
for (const [index, arg] of argsFullNode.entries()) {
if (collatorPorts[arg] >= 0) {
// port passed as argument, we need to ensure is not a default one because it will be
// use by the parachain part.
const selectedPort = parseInt(argsFullNode[index + 1], 10);
if (
[
P2P_PORT,
RPC_HTTP_PORT,
RPC_WS_PORT,
nodeSetup.p2pPort,
nodeSetup.rpcPort,
nodeSetup.wsPort,
].includes(selectedPort)
) {
console.log(
decorators.yellow(
`WARN: default port configured, changing to use a random free port`,
),
);
const randomPort = await getRandomPort();
collatorPorts[arg] = randomPort;
argsFullNode[index + 1] = randomPort.toString();
}
}
}
// Arguments for the relay chain node part of the collator binary.
fullCmd.push(
...[
"--",
"--base-path",
relayDataPath,
"--chain",
`${cfgPath}/${relayChain}.json`,
"--execution wasm",
],
);

// check ports
for (const portArg of Object.keys(collatorPorts)) {
if (collatorPorts[portArg] === 0) {
if (argsFullNode) {
// Add any additional flags to the CLI
for (const [index, arg] of argsFullNode.entries()) {
if (collatorPorts[arg] >= 0) {
// port passed as argument, we need to ensure is not a default one because it will be
// use by the parachain part.
const selectedPort = parseInt(argsFullNode[index + 1], 10);
if (
[
P2P_PORT,
RPC_HTTP_PORT,
RPC_WS_PORT,
nodeSetup.p2pPort,
nodeSetup.rpcPort,
nodeSetup.wsPort,
].includes(selectedPort)
) {
console.log(
decorators.yellow(
`WARN: default port configured, changing to use a random free port`,
),
);
const randomPort = await getRandomPort();
argsFullNode.push(portArg);
argsFullNode.push(randomPort.toString());
debug(`Added ${portArg} with value ${randomPort}`);
collatorPorts[arg] = randomPort;
argsFullNode[index + 1] = randomPort.toString();
}
}
}

// check ports
for (const portArg of Object.keys(collatorPorts)) {
if (collatorPorts[portArg] === 0) {
const randomPort = await getRandomPort();
argsFullNode.push(portArg);
argsFullNode.push(randomPort.toString());
debug(`Added ${portArg} with value ${randomPort}`);
}
}

fullCmd = fullCmd.concat(argsFullNode);
debug(`Added ${argsFullNode} to collator`);
} else {
// ensure ports
for (const portArg of Object.keys(collatorPorts)) {
if (collatorPorts[portArg] === 0) {
const randomPort = await getRandomPort();
fullCmd.push(portArg);
fullCmd.push(randomPort.toString());
debug(`Added ${portArg} with value ${randomPort}`);
}
fullCmd = fullCmd.concat(argsFullNode);
debug(`Added ${argsFullNode} to collator`);
} else {
// ensure ports
for (const portArg of Object.keys(collatorPorts)) {
if (collatorPorts[portArg] === 0) {
const randomPort = await getRandomPort();
fullCmd.push(portArg);
fullCmd.push(randomPort.toString());
debug(`Added ${portArg} with value ${randomPort}`);
}
}
}
Expand Down