Skip to content
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

Migrate 0009-approval-voting-coalescing.zndsl to zombienet-sdk #7666

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 16 additions & 8 deletions .gitlab/pipeline/zombienet/polkadot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ zombienet-polkadot-functional-0008-dispute-old-finalized:
--local-dir="${LOCAL_DIR}/functional"
--test="0008-dispute-old-finalized.zndsl"

zombienet-polkadot-functional-0009-approval-voting-coalescing:
extends:
- .zombienet-polkadot-common
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}/functional"
--test="0009-approval-voting-coalescing.zndsl"

zombienet-polkadot-functional-0010-validator-disabling:
extends:
- .zombienet-polkadot-common
Expand Down Expand Up @@ -449,6 +441,22 @@ zombienet-polkadot-functional-async-backing-6-seconds-rate:
- unset NEXTEST_SUCCESS_OUTPUT
- cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- functional::async_backing_6_seconds_rate::async_backing_6_seconds_rate_test

zombienet-polkadot-functional-approval-voting-coalescing::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can move this test to gha as part of this migration, since we need to move to gha at some point to shutdown gitlab. I can push those changes here @alexggh if you are agree?
Thx!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely, we don't want to migrate twice, so feel free to push here whatever needs pushing.

extends:
- .zombienet-polkadot-common
needs:
- job: build-polkadot-zombienet-tests
artifacts: true
before_script:
- !reference [".zombienet-polkadot-common", "before_script"]
- export POLKADOT_IMAGE="${ZOMBIENET_INTEGRATION_TEST_IMAGE}"
- export X_INFRA_INSTANCE=spot # use spot by default
script:
# we want to use `--no-capture` in zombienet tests.
- unset NEXTEST_FAILURE_OUTPUT
- unset NEXTEST_SUCCESS_OUTPUT
- cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- functional::approval_voting_coalescing::approval_voting_coalescing_test

zombienet-polkadot-functional-duplicate-collations:
extends:
- .zombienet-polkadot-common
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Test that checks approval voting coalescing does not lag finality.

use anyhow::anyhow;

use crate::helpers::{
assert_finality_lag_less_than, assert_finalized_block_height, assert_para_throughput,
};
use polkadot_primitives::Id as ParaId;
use serde_json::json;
use subxt::{OnlineClient, PolkadotConfig};
use zombienet_sdk::NetworkConfigBuilder;

#[tokio::test(flavor = "multi_thread")]
async fn approval_voting_coalescing_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 no_show_slots = 4;
let config = NetworkConfigBuilder::new()
.with_relaychain(|r| {
let r = r
.with_chain("rococo-local")
.with_default_command("polkadot")
.with_default_image(images.polkadot.as_str())
.with_default_args(vec![("-lparachain=debug,runtime=debug").into()])
.with_genesis_overrides(json!({
"configuration": {
"config": {
"needed_approvals": 4,
"relay_vrf_modulo_samples": 6,
"no_show_slots": no_show_slots,
"approval_voting_params": {
"max_approval_coalesce_count": 5
}
}
}
}))
.with_node(|node| node.with_name("validator-0"));

(1..12)
.fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}"))))
})
.with_parachain(|p| {
p.with_id(2000)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2000"))
})
.with_parachain(|p| {
p.with_id(2001)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2001"))
})
.with_parachain(|p| {
p.with_id(2002)
.with_default_command("undying-collator")
.with_default_image(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we dedup ? Feels weird to just copy paste all of these para config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of copy-pasted from other tests @pepoviola is there a more elegant way to express all this identical parachains where just the id differs ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D never mind, I was lazy it is easy to avoid duplication :D

std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2002"))
})
.with_parachain(|p| {
p.with_id(2003)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2003"))
})
.with_parachain(|p| {
p.with_id(2004)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2004"))
})
.with_parachain(|p| {
p.with_id(2005)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2005"))
})
.with_parachain(|p| {
p.with_id(2006)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2006"))
})
.with_parachain(|p| {
p.with_id(2007)
.with_default_command("undying-collator")
.with_default_image(
std::env::var("COL_IMAGE")
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
.as_str(),
)
.cumulus_based(false)
.with_default_args(vec![("-lparachain=debug").into()])
.with_collator(|n| n.with_name("collator-undying-2007"))
})
.build()
.map_err(|e| {
let errs = e.into_iter().map(|e| e.to_string()).collect::<Vec<_>>().join(" ");
anyhow!("config errs: {errs}")
})?;

let spawn_fn = zombienet_sdk::environment::get_spawn_fn();

log::info!("Spawning network");
let network = spawn_fn(config).await?;

log::info!("Waiting for network to initialize");
let relay_node = network.get_node("validator-0")?;
let para_node_2001 = network.get_node("collator-undying-2000")?;

let relay_client: OnlineClient<PolkadotConfig> = relay_node.wait_client().await?;

log::info!("Waiting for parachains to advance to block 15");
assert_para_throughput(
&relay_client,
15,
[
(ParaId::from(2000), 11..16),
(ParaId::from(2001), 11..16),
(ParaId::from(2002), 11..16),
(ParaId::from(2003), 11..16),
(ParaId::from(2004), 11..16),
(ParaId::from(2005), 11..16),
(ParaId::from(2006), 11..16),
(ParaId::from(2007), 11..16),
]
.into_iter()
.collect(),
)
.await?;

log::info!("Checking finality does not log and no-shows are within range");
for node in network.nodes() {
assert_finality_lag_less_than(&node.wait_client().await?, no_show_slots).await?;
assert!(
node.reports("polkadot_parachain_approvals_no_shows_total").await.unwrap() < 3.1,
"No-shows should be less than 3"
);
}

log::info!("Test finished successfully");

Ok(())
}
1 change: 1 addition & 0 deletions polkadot/zombienet-sdk-tests/tests/functional/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
mod async_backing_6_seconds_rate;
mod duplicate_collations;
mod sync_backing;
mod approval_voting_coalescing;
14 changes: 14 additions & 0 deletions polkadot/zombienet-sdk-tests/tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ pub async fn assert_finalized_block_height(
Ok(())
}

// Helper function for asserting that the finality lag is less than a given value.
pub async fn assert_finality_lag_less_than(
client: &OnlineClient<PolkadotConfig>,
lag: u32,
) -> Result<(), anyhow::Error> {
if let Some(best_block) = client.blocks().subscribe_best().await?.next().await {
let height = best_block?.number();
assert_finalized_block_height(client, height - lag..height).await?;
} else {
assert!(false, "No best block received");
}
Ok(())
}

/// Assert that finality has not stalled.
pub async fn assert_blocks_are_being_finalized(
client: &OnlineClient<PolkadotConfig>,
Expand Down
Loading