Skip to content

Commit

Permalink
fix race condition (#963)
Browse files Browse the repository at this point in the history
* fix race condition

* fmt
  • Loading branch information
pepoviola authored Apr 25, 2023
1 parent c5ece7d commit 33c815b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions javascript/packages/orchestrator/src/paras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export async function generateParachainFiles(
chainSpecFns.addCollatorSelection,
chainSpecFns.writeChainSpec,
]);
const GENESIS_STATE_FILENAME_WITH_ID = `${GENESIS_STATE_FILENAME}-${parachain.id}`;
const GENESIS_WASM_FILENAME_WITH_ID = `${GENESIS_WASM_FILENAME}-${parachain.id}`;

const stateLocalFilePath = `${parachainFilesPath}/${GENESIS_STATE_FILENAME}`;
const wasmLocalFilePath = `${parachainFilesPath}/${GENESIS_WASM_FILENAME}`;
Expand All @@ -57,13 +59,12 @@ export async function generateParachainFiles(
);

let chainSpecFullPath;
const chainSpecFileName = `${parachain.chain ? parachain.chain + "-" : ""}${
const chainName = `${parachain.chain ? parachain.chain + "-" : ""}${
parachain.name
}-${relayChainName}.json`;
}-${relayChainName}`;
const chainSpecFileName = `${chainName}.json`;

const chainSpecFullPathPlain = `${tmpDir}/${
parachain.chain ? parachain.chain + "-" : ""
}${parachain.name}-${relayChainName}-plain.json`;
const chainSpecFullPathPlain = `${tmpDir}/${chainName}-plain.json`;

if (parachain.cumulusBased) {
// need to create the parachain spec
Expand All @@ -89,7 +90,7 @@ export async function generateParachainFiles(
} --disable-default-bootnode`,
defaultImage: parachain.collators[0].image,
},
relayChainName,
chainName,
chainSpecFullPathPlain,
);
}
Expand Down Expand Up @@ -222,7 +223,7 @@ export async function generateParachainFiles(
` --chain ${chainSpecPathInNode} > `,
);
}
commands.push(genesisStateGenerator);
commands.push(`${genesisStateGenerator}-${parachain.id}`);
}
if (parachain.genesisWasmGenerator) {
let genesisWasmGenerator = parachain.genesisWasmGenerator.replace(
Expand All @@ -241,7 +242,7 @@ export async function generateParachainFiles(
` --chain ${chainSpecPathInNode} > `,
);
}
commands.push(genesisWasmGenerator);
commands.push(`${genesisWasmGenerator}-${parachain.id}`);
}

// Native provider doesn't need to wait
Expand Down Expand Up @@ -278,15 +279,15 @@ export async function generateParachainFiles(
if (parachain.genesisStateGenerator) {
await client.copyFileFromPod(
podDef.metadata.name,
`${client.remoteDir}/${GENESIS_STATE_FILENAME}`,
`${client.remoteDir}/${GENESIS_STATE_FILENAME_WITH_ID}`,
stateLocalFilePath,
);
}

if (parachain.genesisWasmGenerator) {
await client.copyFileFromPod(
podDef.metadata.name,
`${client.remoteDir}/${GENESIS_WASM_FILENAME}`,
`${client.remoteDir}/${GENESIS_WASM_FILENAME_WITH_ID}`,
wasmLocalFilePath,
);
}
Expand Down

0 comments on commit 33c815b

Please sign in to comment.