Skip to content

Commit

Permalink
fix(orchestrator): use tmp dir when we create paras artifacts (#1638)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
pepoviola and pepoviola authored Jan 2, 2024
1 parent 35b2811 commit 80224c3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 58 deletions.
2 changes: 1 addition & 1 deletion flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
...
}: let
# this change on each change of dependencies, unfortunately this hash not yet automatically updated from SRI of package.lock
npmDepsHash = "sha256-PK1YPfUkLWwzpAQ00S7j5VbfLA8G+zxHaDN4Bjwz7lc=";
npmDepsHash = "sha256-FMIJ+cCwnskUaqrKVgs8klsQVCwEt9q4FvjhqEg9B28=";
####

# there is officia polkadot on nixpkgs, but it has no local rococo wasm to run
Expand Down
57 changes: 1 addition & 56 deletions javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@polkadot/keyring": "^12.6.2",
"@polkadot/util-crypto": "^12.6.1",
"@zombienet/utils": "^0.0.24",
"chai": "^5.0.0",
"chai": "^4.3.10",
"debug": "^4.3.4",
"execa": "^5.1.1",
"fs-extra": "^11.2.0",
Expand Down
27 changes: 27 additions & 0 deletions javascript/packages/orchestrator/src/paras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ export async function generateParachainFiles(
chainSpecPathInNode!,
);
}

if (client.providerName === "native") {
// inject a tmp base-path to prevent the use of a pre-existing un-purged data directory.
// see https://github.com/paritytech/zombienet/issues/1519
// NOTE: this is only needed in native provider since un k8s/podman the fs is always fresh
const exportGenesisStateCustomPath = `${client.tmpDir}/export-genesis-state/${parachain.id}`;
await fs.promises.mkdir(exportGenesisStateCustomPath, {
recursive: true,
});
genesisStateGenerator = injectBasePathInCmd(
genesisStateGenerator,
exportGenesisStateCustomPath,
);
}

commands.push(`${genesisStateGenerator}-${parachain.id}`);
}
if (parachain.genesisWasmGenerator) {
Expand Down Expand Up @@ -359,3 +374,15 @@ function injectChainInCmd(cmd: string, chain: string): string {
parts.splice(index, 0, `--chain ${chain}`);
return parts.join(" ");
}

// Inject the base-path (e.g. --base-path <path> or -d <path>)
// IFF is not present
function injectBasePathInCmd(cmd: string, path: string): string {
const parts = cmd.split(" ").filter(Boolean);
// IFF is present don't modify the cmd
if (parts.includes("-d") || parts.includes("--base-path")) return cmd;

// inject just after the subcommand
parts.splice(2, 0, `-d ${path}`);
return parts.join(" ");
}

0 comments on commit 80224c3

Please sign in to comment.