Skip to content

Commit 80224c3

Browse files
authored
fix(orchestrator): use tmp dir when we create paras artifacts (#1638)
* fix(orchestrator): use tmp dir when we create paras artifacts * Fix nix hash * lint * typo * downgrade chai to 4.x * Fix nix hash * fix lock file * Fix nix hash --------- Co-authored-by: pepoviola <pepoviola@users.noreply.github.com>
1 parent 35b2811 commit 80224c3

File tree

4 files changed

+30
-58
lines changed

4 files changed

+30
-58
lines changed

flake-module.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
...
99
}: let
1010
# this change on each change of dependencies, unfortunately this hash not yet automatically updated from SRI of package.lock
11-
npmDepsHash = "sha256-PK1YPfUkLWwzpAQ00S7j5VbfLA8G+zxHaDN4Bjwz7lc=";
11+
npmDepsHash = "sha256-FMIJ+cCwnskUaqrKVgs8klsQVCwEt9q4FvjhqEg9B28=";
1212
####
1313

1414
# there is officia polkadot on nixpkgs, but it has no local rococo wasm to run

javascript/package-lock.json

Lines changed: 1 addition & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/packages/orchestrator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@polkadot/keyring": "^12.6.2",
4242
"@polkadot/util-crypto": "^12.6.1",
4343
"@zombienet/utils": "^0.0.24",
44-
"chai": "^5.0.0",
44+
"chai": "^4.3.10",
4545
"debug": "^4.3.4",
4646
"execa": "^5.1.1",
4747
"fs-extra": "^11.2.0",

javascript/packages/orchestrator/src/paras.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ export async function generateParachainFiles(
241241
chainSpecPathInNode!,
242242
);
243243
}
244+
245+
if (client.providerName === "native") {
246+
// inject a tmp base-path to prevent the use of a pre-existing un-purged data directory.
247+
// see https://github.com/paritytech/zombienet/issues/1519
248+
// NOTE: this is only needed in native provider since un k8s/podman the fs is always fresh
249+
const exportGenesisStateCustomPath = `${client.tmpDir}/export-genesis-state/${parachain.id}`;
250+
await fs.promises.mkdir(exportGenesisStateCustomPath, {
251+
recursive: true,
252+
});
253+
genesisStateGenerator = injectBasePathInCmd(
254+
genesisStateGenerator,
255+
exportGenesisStateCustomPath,
256+
);
257+
}
258+
244259
commands.push(`${genesisStateGenerator}-${parachain.id}`);
245260
}
246261
if (parachain.genesisWasmGenerator) {
@@ -359,3 +374,15 @@ function injectChainInCmd(cmd: string, chain: string): string {
359374
parts.splice(index, 0, `--chain ${chain}`);
360375
return parts.join(" ");
361376
}
377+
378+
// Inject the base-path (e.g. --base-path <path> or -d <path>)
379+
// IFF is not present
380+
function injectBasePathInCmd(cmd: string, path: string): string {
381+
const parts = cmd.split(" ").filter(Boolean);
382+
// IFF is present don't modify the cmd
383+
if (parts.includes("-d") || parts.includes("--base-path")) return cmd;
384+
385+
// inject just after the subcommand
386+
parts.splice(2, 0, `-d ${path}`);
387+
return parts.join(" ");
388+
}

0 commit comments

Comments
 (0)