Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nahuseyoum authored Jan 31, 2025
2 parents e213308 + 236781b commit c487b2b
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ Below can be found some of the projects that are currently using Zombienet as in
- [Composable](https://github.com/ComposableFi/composable) via `nix run "composable#devnet-picasso"`
- [Gossamer](https://github.com/ChainSafe/gossamer/issues/2843)
- [Oak/Turing/Neumann](https://github.com/OAK-Foundation/OAK-blockchain/tree/master/zombienets)
- [Hydradx](https://github.com/galacticcouncil/HydraDX-node/tree/master/rococo-local)
- [Hydradx](https://github.com/galacticcouncil/HydraDX-node/tree/master/launch-configs/zombienet)
- [InvArch](https://github.com/InvArch/InvArch-Node/blob/34a6e2216bc79c9bcee2f2f4c0cd8243fe4dfc93/zombienet/rococo-and-tinkernet+basilisk.toml)
- [Mangata](https://github.com/mangata-finance/mangata-node/tree/develop/devops/zombienet)
- [Manta/Phala](https://github.com/Manta-Network/manta-indexer/pull/30)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Below can be found some of the projects that are currently using Zombienet as in
- [Acurast](https://github.com/Acurast/acurast-substrate/blob/10c3160a297ae6c3092ee692e6d3b632896fca65/Makefile)
- [Gossamer](https://github.com/ChainSafe/gossamer/issues/2843)
- [Oak/Turing/Neumann](https://github.com/OAK-Foundation/OAK-blockchain/tree/master/zombienets)
- [Hydradx](https://github.com/galacticcouncil/HydraDX-node/tree/master/rococo-local)
- [Hydradx](https://github.com/galacticcouncil/HydraDX-node/tree/master/launch-configs/zombienet)
- [InvArch](https://github.com/InvArch/InvArch-Node/blob/34a6e2216bc79c9bcee2f2f4c0cd8243fe4dfc93/zombienet/rococo-and-tinkernet+basilisk.toml)
- [Mangata](https://github.com/mangata-finance/mangata-node/tree/develop/devops/zombienet)
- [Manta/Phala](https://github.com/Manta-Network/manta-indexer/pull/30)
Expand Down
6 changes: 3 additions & 3 deletions javascript/packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zombienet/cli",
"version": "1.3.117",
"version": "1.3.119",
"description": "ZombieNet aim to be a testing framework for substrate based blockchains, providing a simple cli tool that allow users to spawn and test ephemeral Substrate based networks",
"main": "dist/index.js",
"scripts": {
Expand Down Expand Up @@ -56,8 +56,8 @@
},
"dependencies": {
"@zombienet/dsl-parser-wrapper": "^0.1.11",
"@zombienet/orchestrator": "^0.0.97",
"@zombienet/utils": "^0.0.25",
"@zombienet/orchestrator": "^0.0.98",
"@zombienet/utils": "^0.0.26",
"cli-progress": "^3.12.0",
"commander": "^11.1.0",
"debug": "^4.3.4",
Expand Down
91 changes: 53 additions & 38 deletions javascript/packages/cli/src/actions/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const options: OptIf = {};
* @returns
*/
export async function setup(params: any, opts?: any) {
// If the platform is MacOS then the repos needs to be cloned and run locally by the user
// If the platform is MacOS (intel) then the repos needs to be cloned and run locally by the user
// as polkadot and/or polkadot-parachain do not release a valid binaries for MacOS
if (process.platform === "darwin") {
if (process.platform === "darwin" && process.arch !== "arm64") {
console.log(
`${decorators.red(
"\n\n------------------------------------------------------------------------\n\nNote: ",
)} You are using MacOS. Please, clone Polkadot SDK from ` +
)} You are using MacOS (intel). Please, clone Polkadot SDK from ` +
decorators.cyan("https://github.com/paritytech/polkadot-sdk") +
` \n in order to build the polkadot and/or polkadot-parachain locally.\n At the moment there is no binaries for MacOs as releases.` +
decorators.red(
Expand All @@ -42,16 +42,18 @@ export async function setup(params: any, opts?: any) {
}

console.log(decorators.green("\n\n🧟🧟🧟 ZombieNet Setup 🧟🧟🧟\n\n"));
if (!["linux"].includes(process.platform)) {
if (!isValidHost()) {
console.log(
"Zombienet setup currently supports only linux. \n Alternative, you can use k8s or podman. For more read here: https://github.com/paritytech/zombienet#requirements-by-provider",
"Zombienet setup currently supports only linux(x64) and MacOS (arm64). \n Alternative, you can use k8s or podman. For more read here: https://github.com/paritytech/zombienet#requirements-by-provider",
);
return;
}

console.log(decorators.green("Gathering latest releases' versions...\n"));
const arch_sufix = process.arch === "arm64" ? "aarch64-apple-darwin" : "";

await new Promise<void>((resolve) => {
latestPolkadotReleaseURL(POLKADOT_SDK, POLKADOT).then(
latestPolkadotReleaseURL(POLKADOT_SDK, `${POLKADOT}-${arch_sufix}`).then(
(res: [string, string]) => {
options[POLKADOT] = {
name: POLKADOT,
Expand All @@ -64,46 +66,47 @@ export async function setup(params: any, opts?: any) {
});

await new Promise<void>((resolve) => {
latestPolkadotReleaseURL(POLKADOT_SDK, POLKADOT_PREPARE_WORKER).then(
(res: [string, string]) => {
options[POLKADOT_PREPARE_WORKER] = {
name: POLKADOT_PREPARE_WORKER,
url: res[0],
size: res[1],
};
resolve();
},
);
latestPolkadotReleaseURL(
POLKADOT_SDK,
`${POLKADOT_PREPARE_WORKER}-${arch_sufix}`,
).then((res: [string, string]) => {
options[POLKADOT_PREPARE_WORKER] = {
name: POLKADOT_PREPARE_WORKER,
url: res[0],
size: res[1],
};
resolve();
});
});

await new Promise<void>((resolve) => {
latestPolkadotReleaseURL(POLKADOT_SDK, POLKADOT_EXECUTE_WORKER).then(
(res: [string, string]) => {
options[POLKADOT_EXECUTE_WORKER] = {
name: POLKADOT_EXECUTE_WORKER,
url: res[0],
size: res[1],
};
resolve();
},
);
latestPolkadotReleaseURL(
POLKADOT_SDK,
`${POLKADOT_EXECUTE_WORKER}-${arch_sufix}`,
).then((res: [string, string]) => {
options[POLKADOT_EXECUTE_WORKER] = {
name: POLKADOT_EXECUTE_WORKER,
url: res[0],
size: res[1],
};
resolve();
});
});

await new Promise<void>((resolve) => {
latestPolkadotReleaseURL(POLKADOT_SDK, POLKADOT_PARACHAIN).then(
(res: [string, string]) => {
options[POLKADOT_PARACHAIN] = {
name: POLKADOT_PARACHAIN,
url: res[0],
size: res[1],
};
resolve();
},
);
latestPolkadotReleaseURL(
POLKADOT_SDK,
`${POLKADOT_PARACHAIN}-${arch_sufix}`,
).then((res: [string, string]) => {
options[POLKADOT_PARACHAIN] = {
name: POLKADOT_PARACHAIN,
url: res[0],
size: res[1],
};
resolve();
});
});

// If the platform is MacOS then the polkadot repo needs to be cloned and run locally by the user
// as polkadot do not release a binary for MacOS
if (params[0] === "all") {
params = [POLKADOT, POLKADOT_PARACHAIN];
}
Expand Down Expand Up @@ -165,6 +168,18 @@ export async function setup(params: any, opts?: any) {
}

// helper fns

// Check if the host is a valid platform/arch
const isValidHost = (): boolean => {
const isValid =
process.platform === "linux" && process.arch === "x64"
? true
: process.platform === "darwin" && process.arch === "arm64"
? true
: false;

return isValid;
};
// Download the binaries
const downloadBinaries = async (binaries: string[]): Promise<void> => {
try {
Expand Down
4 changes: 2 additions & 2 deletions javascript/packages/orchestrator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zombienet/orchestrator",
"version": "0.0.97",
"version": "0.0.98",
"description": "ZombieNet aim to be a testing framework for substrate based blockchains, providing a simple cli tool that allow users to spawn and test ephemeral Substrate based networks",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -40,7 +40,7 @@
"@polkadot/api": "^14.0.1",
"@polkadot/keyring": "^13.1.1",
"@polkadot/util-crypto": "^13.1.1",
"@zombienet/utils": "^0.0.25",
"@zombienet/utils": "^0.0.26",
"chai": "^4.3.10",
"debug": "^4.3.4",
"execa": "^5.1.1",
Expand Down
6 changes: 2 additions & 4 deletions javascript/packages/orchestrator/src/chainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,12 @@ export async function addBalances(specPath: string, nodes: Node[]) {
const balanceToAdd = stakingBond
? node.validator && node.balance > stakingBond
? node.balance
: stakingBond! + BigInt(1)
: stakingBond! * BigInt(2) // Double the balance we use for stake
: node.balance;

balanceMap[stashKey] = balanceToAdd;

const logLine = `👤 Added Balance ${
node.balance
} for ${decorators.green(node.name)} - ${decorators.magenta(stashKey)}`;
const logLine = `👤 Added Balance ${balanceToAdd} for ${decorators.green(node.name)} - ${decorators.magenta(stashKey)}`;
new CreateLogTable({
colWidths: [120],
doubleBorder: true,
Expand Down
15 changes: 9 additions & 6 deletions javascript/packages/orchestrator/src/test-runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ export async function run(

suite.afterAll("teardown", async function () {
this.timeout(180 * 1000);
// report metric
const testEnd = performance.now();
const elapsedSecs = Math.round((testEnd - testStart) / 1000);
debug(`\t 🕰 [Test] elapsed time: ${elapsedSecs} secs`);
let success: boolean = false;
if (network && !network.wasRunning) {
// report metric
const testEnd = performance.now();
const elapsedSecs = Math.round((testEnd - testStart) / 1000);
debug(`\t 🕰 [Test] elapsed time: ${elapsedSecs} secs`);
if (inCI) await registerTotalElapsedTimeSecs(elapsedSecs);

let logsPath;
try {
logsPath = await network.dumpLogs(false);
Expand All @@ -157,6 +156,8 @@ export async function run(
console.log(
`\n\n\t${decorators.red("❌ One or more of your test failed...")}`,
);
} else {
success = true;
}

// All test passed, just remove the network
Expand Down Expand Up @@ -227,6 +228,8 @@ export async function run(
}
}
}
// submit metric
if (inCI) await registerTotalElapsedTimeSecs(elapsedSecs, success);
return;
});

Expand Down
2 changes: 1 addition & 1 deletion javascript/packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zombienet/utils",
"version": "0.0.25",
"version": "0.0.26",
"description": "Useful utilities for ZombieNet Framework",
"main": "dist/index.js",
"author": "Parity Technologies <admin@parity.io>",
Expand Down
8 changes: 6 additions & 2 deletions javascript/packages/utils/src/zombieMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export async function registerSpawnElapsedTimeSecs(elapsed: number) {
}
}

export async function registerTotalElapsedTimeSecs(elapsed: number) {
export async function registerTotalElapsedTimeSecs(
elapsed: number,
success: boolean,
) {
if (canSend()) {
const status = success ? "pass" : "fail";
const [jobId, jobName, projectName, pushGatewayUrl] = getFromCI();
const metricName = "zombie_test_complete_secs";
const help = `# HELP ${metricName} Elapsed time to complete the test job in seconds (including spawning, but not teardown)`;
const type = `# TYPE ${metricName} gauge`;
const metricString = `${metricName}{job_id="${jobId}", job_name="${jobName}", project_name="${projectName}"} ${elapsed}`;
const metricString = `${metricName}{job_id="${jobId}", job_name="${jobName}", project_name="${projectName}"}, status="${status}" ${elapsed}`;
const body = [help, type, metricString, "\n"].join("\n");
await fetch(pushGatewayUrl!, {
method: "POST",
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/docker/zombienet_injected.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RUN mkdir -p /etc/zombie-net
# USER nonroot

# install rust
ENV RUST_VERSION=1.80.0
ENV RUST_VERSION=1.81.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_VERSION -y
ENV PATH $PATH:/home/nonroot/.cargo/bin
# install nextest
Expand Down
4 changes: 2 additions & 2 deletions tests/scale-net/0001-scale-net.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ chain = "rococo-local"

[[relaychain.node_groups]]
name = "a"
count = 1
count = 2
{% include("./a-group.toml")%}

[[relaychain.node_groups]]
name = "b"
count = 1
count = 2
{% include("./b-group.toml")%}

{% for id in [100,200] %}
Expand Down

0 comments on commit c487b2b

Please sign in to comment.