Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[Zombienet] test deregister validator #5718

Merged
merged 18 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
27 changes: 27 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,33 @@ zombienet-tests-malus-dispute-valid:
tags:
- zombienet-polkadot-integration-test

zombienet-tests-deregister-register-validator:
stage: stage3
image: "docker.io/paritytech/zombienet:v1.2.42"
<<: *kubernetes-env
<<: *zombienet-refs
needs:
- job: publish-polkadot-debug-image
pepoviola marked this conversation as resolved.
Show resolved Hide resolved
artifacts: true
variables:
GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke"
before_script:
- echo "Zombie-net Tests Config"
- echo "${ZOMBIENET_IMAGE_NAME}"
- echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}"
- echo "${GH_DIR}"
- export DEBUG=zombie*
- export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG}
- export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG}
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
--github-remote-dir="${GH_DIR}"
--test="0003-deregister-register-validator-smoke.feature"
allow_failure: false
retry: 2
tags:
- zombienet-polkadot-integration-test

#### stage: stage4

publish-rustdoc:
Expand Down
9 changes: 5 additions & 4 deletions node/network/gossip-support/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ impl metrics::Metrics for Metrics {
fn try_register(registry: &Registry) -> Result<Self, PrometheusError> {
let metrics = MetricsInner {
is_authority: prometheus::register(
Gauge::new("polkadot_node_is_authority", "Tracks the node authority status across sessions. \
An authority is any node that is a potential block producer in a session.")?,
Gauge::new("polkadot_node_is_active_validator", "Tracks if the validator is in the active set. \
Updates at session boundary.")?,
registry,
)?,
is_parachain_validator: prometheus::register(
Gauge::new("polkadot_node_is_parachain_validator",
"Tracks the node parachain validator status across sessions. Parachain validators are a \
subset of authorities that perform approval checking of all parachain candidates in a session.")?,
"Tracks if the validator participates in parachain consensus. Parachain validators are a \
subset of the active set validators that perform approval checking of all parachain candidates in a session.\
Updates at session boundary.")?,
registry,
)?,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Description: Deregister / Register Validator Smoke
Network: ./0003-deregister-register-validator-smoke.toml
Creds: config

alice: is up
bob: is up
charlie: is up
dave: is up

# ensure is in the validator set
dave: reports polkadot_node_is_active_validator is 1 within 240 secs

# deregister and check
alice: js-script ./0003-deregister-register-validator.js with "deregister,Dave" return is 0 within 120 secs
dave: reports polkadot_node_is_active_validator is 0 within 240 secs

# register and check
alice: js-script ./0003-deregister-register-validator.js with "register,Dave" return is 0 within 120 secs
dave: reports polkadot_node_is_active_validator is 1 within 240 secs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[settings]
timeout = 1000

[relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local"
command = "polkadot"

[[relaychain.nodes]]
name = "alice"
args = ["-lruntime=debug,parachain=trace" ]

[[relaychain.nodes]]
name = "bob"
args = [ "-lruntime=debug,parachain=trace" ]

[[relaychain.nodes]]
name = "charlie"
args = [ "-lruntime=debug,parachain=trace" ]

[[relaychain.nodes]]
name = "dave"
args = [ "-lruntime=debug,parachain=trace" ]
sandreim marked this conversation as resolved.
Show resolved Hide resolved
42 changes: 42 additions & 0 deletions zombienet_tests/smoke/0003-deregister-register-validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const assert = require("assert");

async function run(nodeName, networkInfo, jsArgs) {
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName];
const api = await zombie.connect(wsUri, userDefinedTypes);
const action = jsArgs[0] === "register" ? "registerValidators" : "deregisterValidators"
const validatorName = jsArgs[1]; // used as seed

await zombie.util.cryptoWaitReady();

// account to submit tx
const keyring = new zombie.Keyring({ type: "sr25519" });
const alice = keyring.addFromUri("//Alice");
const validatorStash = keyring.createFromUri(`${validatorName}//stash`);

await new Promise(async (resolve, reject) => {
const unsub = await api.tx.sudo
.sudo(api.tx.validatorManager[action]([validatorStash.address]))
.signAndSend(alice, (result) => {
console.log(`Current status is ${result.status}`);
if (result.status.isInBlock) {
console.log(
`Transaction included at blockHash ${result.status.asInBlock}`
);
} else if (result.status.isFinalized) {
console.log(
`Transaction finalized at blockHash ${result.status.asFinalized}`
);
unsub();
return resolve();
} else if (result.isError) {
console.log(`Transaction Error`);
unsub();
return reject();
}
});
});

return 0;
}

module.exports = { run }
sandreim marked this conversation as resolved.
Show resolved Hide resolved