-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rewrite validator disabling test with zombienet-sdk #9128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexandruCihodaru
merged 14 commits into
master
from
acihodaru/9085-validator-disabling-to-zombienet-sdk
Jul 21, 2025
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d1ba0d
[tests]: Rewrite validator disabling test with zombienet-sdk
AlexandruCihodaru 9410d01
Fix formatting and add prdoc
AlexandruCihodaru ff548e8
Fix clippy issues
AlexandruCihodaru b2bfdbf
Fix prdoc format
AlexandruCihodaru b76566e
Fix github workflow
AlexandruCihodaru 954e369
Make malus validator vulnerable
AlexandruCihodaru 6b3125e
add the id of the para in the error message
AlexandruCihodaru fae576a
Merge branch 'master' into acihodaru/9085-validator-disabling-to-zomb…
AlexandruCihodaru 22aa406
Assert that the disabled validator is malus
AlexandruCihodaru 9aa3c60
Merge branch 'master' into acihodaru/9085-validator-disabling-to-zomb…
AlexandruCihodaru d83d7b0
Merge branch 'master' into acihodaru/9085-validator-disabling-to-zomb…
AlexandruCihodaru 3860df8
implement review feedback
AlexandruCihodaru 0ca5341
make clippy happy
AlexandruCihodaru a793c13
Merge branch 'master' into acihodaru/9085-validator-disabling-to-zomb…
AlexandruCihodaru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
polkadot/zombienet-sdk-tests/tests/functional/validator_disabling.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Test checks that misbehaving validators disabled. | ||
|
|
||
| use anyhow::anyhow; | ||
|
|
||
| use cumulus_zombienet_sdk_helpers::assert_finalized_para_throughput; | ||
| use polkadot_primitives::{BlockNumber, CandidateHash, DisputeState, SessionIndex}; | ||
| use serde_json::json; | ||
| use tokio::time::Duration; | ||
| use zombienet_orchestrator::network::node::LogLineCountOptions; | ||
| use zombienet_sdk::{ | ||
| subxt::{OnlineClient, PolkadotConfig}, | ||
| NetworkConfigBuilder, | ||
| }; | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| async fn validator_disabling_test() -> Result<(), anyhow::Error> { | ||
| let _ = env_logger::try_init_from_env( | ||
| env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), | ||
| ); | ||
| let images = zombienet_sdk::environment::get_images_from_env(); | ||
| let config_builder = NetworkConfigBuilder::new() | ||
| .with_relaychain(|r| { | ||
| let r = r | ||
| .with_chain("westend-local") // Use westend-local so the disabling can take effect. | ||
| .with_default_command("polkadot") | ||
| .with_default_image(images.polkadot.as_str()) | ||
| .with_default_args(vec![("-lparachain=debug").into()]) | ||
| .with_genesis_overrides(json!({ | ||
| "configuration": { | ||
| "config": { | ||
| "scheduler_params": { | ||
| "group_rotation_frequency": 10, | ||
| "max_validators_per_core": 1 | ||
| }, | ||
| "needed_approvals": 2, | ||
| } | ||
| } | ||
| })) | ||
| // Adding malicious validator. | ||
| .with_node(|node| { | ||
| node.with_name("malus-validator") | ||
| .with_image( | ||
| std::env::var("MALUS_IMAGE") | ||
| .unwrap_or("docker.io/paritypr/malus".to_string()) | ||
| .as_str(), | ||
| ) | ||
| .with_command("malus") | ||
| .with_subcommand("suggest-garbage-candidate") | ||
| .with_args(vec![ | ||
| "-lMALUS=trace".into(), | ||
| // Without this the malus validator won't run on macOS. | ||
| "--insecure-validator-i-know-what-i-do".into(), | ||
| ]) | ||
| // Make it vulenrable so disabling really happens | ||
| .invulnerable(false) | ||
| }); | ||
| // Also honest validators. | ||
| let r = (0..3).fold(r, |acc, i| { | ||
| acc.with_node(|node| { | ||
| node.with_name(&format!("honest-validator-{i}")) | ||
| .with_args(vec![("-lparachain=debug,runtime::staking=debug".into())]) | ||
| }) | ||
| }); | ||
| r | ||
| }) | ||
| .with_parachain(|p| { | ||
| p.with_id(1000) | ||
| .with_default_command("adder-collator") | ||
| .cumulus_based(false) | ||
| .with_default_image(images.cumulus.as_str()) | ||
| .with_default_args(vec!["-lparachain=debug".into()]) | ||
| .with_collator(|n| n.with_name("alice")) | ||
| }) | ||
| .build() | ||
| .map_err(|e| { | ||
| let errors = e.into_iter().map(|e| e.to_string()).collect::<Vec<_>>().join(" "); | ||
| anyhow!("config errors: {errors}") | ||
| })?; | ||
|
|
||
| let spawn_fn = zombienet_sdk::environment::get_spawn_fn(); | ||
| log::info!("Spawning network"); | ||
| let network = spawn_fn(config_builder).await?; | ||
|
|
||
| log::info!("Waiting for parablocks to be produced"); | ||
| let honest_validator = network.get_node("honest-validator-0")?; | ||
| let relay_client: OnlineClient<PolkadotConfig> = honest_validator.wait_client().await?; | ||
|
|
||
| assert_finalized_para_throughput( | ||
| &relay_client, | ||
| 20, | ||
| [(polkadot_primitives::Id::from(1000), 10..30)].into_iter().collect(), | ||
| ) | ||
| .await?; | ||
|
|
||
| log::info!("Wait for a dispute to be initialized."); | ||
| let mut best_blocks = relay_client.blocks().subscribe_best().await?; | ||
| let mut dispute_session: u32 = u32::MAX; | ||
| // Check next new block from the current best fork | ||
| while let Some(block) = best_blocks.next().await { | ||
| let disputes = relay_client | ||
| .runtime_api() | ||
| .at(block?.hash()) | ||
| .call_raw::<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>>( | ||
| "ParachainHost_disputes", | ||
| None, | ||
| ) | ||
| .await?; | ||
| if let Some((session, _, _)) = disputes.first() { | ||
| dispute_session = *session; | ||
| break; | ||
| } | ||
| } | ||
| assert_ne!(dispute_session, u32::MAX); | ||
| log::info!("Dispute initiated."); | ||
|
|
||
| let concluded_dispute_metric = | ||
| "polkadot_parachain_candidate_dispute_concluded{validity=\"invalid\"}"; | ||
| let parachain_candidate_dispute_metric = "parachain_candidate_disputes_total"; | ||
| // honest-validator-1: reports parachain_candidate_disputes_total is at least 1 within 600 | ||
AlexandruCihodaru marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // seconds | ||
| honest_validator | ||
| .wait_metric_with_timeout(parachain_candidate_dispute_metric, |d| d >= 1.0, 600_u64) | ||
| .await?; | ||
| // honest-validator: reports polkadot_parachain_candidate_dispute_concluded{validity="invalid"} | ||
| // is at least 1 within 200 seconds | ||
| honest_validator | ||
| .wait_metric_with_timeout(concluded_dispute_metric, |d| d >= 1.0, 200_u64) | ||
| .await?; | ||
| // honest-validator: log line contains "Disabled validators detected" within 180 seconds | ||
| let result = honest_validator | ||
| .wait_log_line_count_with_timeout( | ||
|
||
| "*Disabled validators detected*", | ||
AlexandruCihodaru marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| true, | ||
| LogLineCountOptions::new(|n| n == 1, Duration::from_secs(180_u64), false), | ||
| ) | ||
| .await?; | ||
| assert!(result.success()); | ||
| Ok(()) | ||
| } | ||
41 changes: 0 additions & 41 deletions
41
polkadot/zombienet_tests/functional/0010-validator-disabling.toml
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
polkadot/zombienet_tests/functional/0010-validator-disabling.zndsl
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| title: Rewrite validator disabling test with zombienet-sdk | ||
|
|
||
| doc: | ||
| - audience: Node Dev | ||
| description: |- | ||
| Migrate validator disabling test to the new version of zombienet | ||
|
|
||
| crates: [] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.