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 the multiaddress for bootnodes string #774

Merged
merged 3 commits into from
Mar 8, 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
18 changes: 15 additions & 3 deletions javascript/packages/orchestrator/src/bootnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ import PeerId from "peer-id";

export async function generateBootnodeString(
key: string,
args: string[],
ip: string,
port: number,
useWs: boolean = true,
): Promise<string> {
let multiaddress;
let pair = await libp2pKeys.generateKeyPairFromSeed(
"Ed25519",
hexToU8a(hexAddPrefix(key)),
1024,
);
let peerId: PeerId = await PeerId.createFromPrivKey(pair.bytes);
const multiaddress = `/ip4/${ip}/tcp/${port}/${
useWs ? "ws/" : "/"
}p2p/${peerId.toB58String()}`;

const listenIndex = args.findIndex((arg) => arg === "--listen-addr");
if (listenIndex >= 0) {
let listenAddrParts = args[listenIndex + 1].split("/");
listenAddrParts[2] = ip;
listenAddrParts[4] = port.toString();
multiaddress = `${listenAddrParts.join("/")}/p2p/${peerId.toB58String()}`;
} else {
multiaddress = `/ip4/${ip}/tcp/${port}/${
useWs ? "ws/" : "/"
}p2p/${peerId.toB58String()}`;
}

return multiaddress;
}
2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/src/cmdGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export async function genCmd(
args[listenIndex + 1] = listenAddr;
} else {
// no --listen-add args
args.push(...[`--listen-addr /ip4/0.0.0.0/tcp/${nodeSetup.p2pPort}/ws`]);
args.push(...["--listen-addr", `/ip4/0.0.0.0/tcp/${nodeSetup.p2pPort}/ws`]);
}

// set our base path
Expand Down
9 changes: 8 additions & 1 deletion javascript/packages/orchestrator/src/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ export async function start(
const [nodeIp, nodePort] = await client.getNodeInfo(podDef.metadata.name);
const nodeMultiAddress = await generateBootnodeString(
node.key!,
node.args,
nodeIp,
nodePort,
);
Expand Down Expand Up @@ -655,7 +656,12 @@ export async function start(
const [nodeIp, nodePort] = await client.getNodeInfo(firstNode.name);

bootnodes.push(
await generateBootnodeString(firstNode.key!, nodeIp, nodePort),
await generateBootnodeString(
firstNode.key!,
firstNode.args,
nodeIp,
nodePort,
),
);
// add bootnodes to chain spec
await addBootNodes(chainSpecFullPath, bootnodes);
Expand Down Expand Up @@ -712,6 +718,7 @@ export async function start(
await addBootNodes(parachain.specPath!, [
await generateBootnodeString(
firstCollatorNode.key!,
firstCollatorNode.args,
nodeIp,
nodePort,
),
Expand Down