Skip to content

Commit 42a61ff

Browse files
AlexandruCihodarualvicsam
authored andcommitted
Rewrite old disputes test with zombienet-sdk (#9257)
Fixes: #9256 --------- Signed-off-by: Alexandru Cihodaru <[email protected]>
1 parent 320c38d commit 42a61ff

File tree

5 files changed

+165
-93
lines changed

5 files changed

+165
-93
lines changed

.github/workflows/zombienet_polkadot.yml

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -200,35 +200,6 @@ jobs:
200200
gh-token: ${{ secrets.GITHUB_TOKEN }}
201201
build-id: ${{ needs.preflight.outputs.BUILD_RUN_ID }}
202202
ref-slug: ${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
203-
204-
#
205-
zombienet-polkadot-functional-0008-dispute-old-finalized:
206-
needs: [preflight]
207-
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-functional-0008-dispute-old-finalized') }}
208-
runs-on: ${{ needs.preflight.outputs.ZOMBIENET_LARGE_RUNNER }}
209-
timeout-minutes: 60
210-
container:
211-
image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }}
212-
options: -v /tmp/zombienet:/tmp/zombienet
213-
env:
214-
ZOMBIENET_INTEGRATION_TEST_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
215-
COL_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/colander:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
216-
MALUS_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/malus:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
217-
DEBUG: ${{ needs.preflight.outputs.DEBUG }}
218-
ZOMBIENET_PROVIDER: ${{ needs.preflight.outputs.ZOMBIENET_PROVIDER }}
219-
steps:
220-
- name: Checkout
221-
uses: actions/checkout@v4
222-
223-
- name: zombienet_test
224-
uses: ./.github/actions/zombienet
225-
with:
226-
test: "0008-dispute-old-finalized.zndsl"
227-
local-dir: "${{ env.LOCAL_DIR }}/functional"
228-
gh-token: ${{ secrets.GITHUB_TOKEN }}
229-
build-id: ${{ needs.preflight.outputs.BUILD_RUN_ID }}
230-
ref-slug: ${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
231-
232203
#
233204
#
234205
zombienet-polkadot-functional-0013-systematic-chunk-recovery:
@@ -1000,7 +971,7 @@ jobs:
1000971
#
1001972
zombienet-polkadot-functional-validator-disabling:
1002973
needs: [preflight]
1003-
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-functional-0010-validator-disabling') }}
974+
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-functional-validator-disabling') }}
1004975
runs-on: ${{ needs.preflight.outputs.ZOMBIENET_LARGE_RUNNER }}
1005976
timeout-minutes: 60
1006977
container:
@@ -1025,6 +996,34 @@ jobs:
1025996
test: "functional::validator_disabling::validator_disabling_test"
1026997
prefix: "polkadot"
1027998

999+
#
1000+
#
1001+
zombienet-polkadot-dispute-old-finalized:
1002+
needs: [preflight]
1003+
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-dispute-old-finalized') }}
1004+
runs-on: ${{ needs.preflight.outputs.ZOMBIENET_LARGE_RUNNER }}
1005+
timeout-minutes: 60
1006+
container:
1007+
image: ${{ needs.preflight.outputs.ZOMBIENET_SDK_IMAGE }}
1008+
env:
1009+
POLKADOT_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
1010+
COL_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/colander:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
1011+
CUMULUS_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-parachain-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
1012+
MALUS_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/malus:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
1013+
RUST_LOG: ${{ needs.preflight.outputs.RUST_LOG }}
1014+
ZOMBIE_PROVIDER: ${{ needs.preflight.outputs.ZOMBIE_PROVIDER }}
1015+
steps:
1016+
- name: Checkout
1017+
uses: actions/checkout@v4
1018+
1019+
- name: zombienet_test
1020+
uses: ./.github/actions/zombienet-sdk
1021+
with:
1022+
gh-token: ${{ secrets.GITHUB_TOKEN }}
1023+
build-id: ${{ needs.preflight.outputs.BUILD_RUN_ID }}
1024+
ref-slug: ${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
1025+
test: "functional::dispute_old_finalized::dispute_old_finalized"
1026+
prefix: "polkadot"
10281027
#
10291028
#
10301029
zombienet-polkadot-shared-core-idle-parachain:
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// Copyright (C) Parity Technologies (UK) Ltd.
2+
// This file is part of Polkadot.
3+
4+
// Polkadot is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Polkadot is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16+
17+
// Test if disputes triggered on finalized blocks out of scope never get to be confirmed and
18+
// concluded.
19+
20+
use anyhow::anyhow;
21+
22+
use cumulus_zombienet_sdk_helpers::assert_para_throughput;
23+
use serde_json::json;
24+
use tokio::time::Duration;
25+
use zombienet_orchestrator::network::node::LogLineCountOptions;
26+
27+
#[tokio::test(flavor = "multi_thread")]
28+
async fn dispute_old_finalized() -> Result<(), anyhow::Error> {
29+
let _ = env_logger::try_init_from_env(
30+
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
31+
);
32+
let images = zombienet_sdk::environment::get_images_from_env();
33+
let config = zombienet_sdk::NetworkConfigBuilder::new()
34+
.with_relaychain(|r| {
35+
let r = r
36+
.with_chain("rococo-local")
37+
.with_default_command("polkadot")
38+
.with_default_image(images.polkadot.as_str())
39+
.with_default_args(vec![("-lparachain=debug").into()])
40+
.with_genesis_overrides(json!({
41+
"patch": {
42+
"configuration" : {
43+
"config": {
44+
"needed_approvals": 1,
45+
"scheduler_params": {
46+
"max_validators_per_core": 1,
47+
}
48+
}
49+
}
50+
}
51+
}))
52+
.with_default_resources(|r| {
53+
r.with_limit_memory("4G")
54+
.with_limit_cpu("2")
55+
.with_request_memory("2G")
56+
.with_request_cpu("1")
57+
});
58+
// Add malus validator
59+
let r = r.with_node(|node| {
60+
node.with_name("malus")
61+
.with_args(vec![
62+
"-lparachain=debug,MALUS=trace".into(),
63+
"--dispute-offset=14".into(),
64+
"--alice".into(),
65+
"--insecure-validator-i-know-what-i-do".into(),
66+
])
67+
.with_image(
68+
std::env::var("MALUS_IMAGE")
69+
.unwrap_or("docker.io/paritypr/malus".to_string())
70+
.as_str(),
71+
)
72+
.with_command("malus")
73+
.with_subcommand("dispute-finalized-candidates")
74+
.invulnerable(false)
75+
});
76+
// Add honest validators
77+
let r = (0..6).fold(r, |acc, i| {
78+
acc.with_node(|node| {
79+
node.with_name(&format!("honest-{i}"))
80+
.with_args(vec!["-lparachain=debug".into()])
81+
})
82+
});
83+
r
84+
})
85+
.with_parachain(|p| {
86+
p.with_id(2000)
87+
.cumulus_based(false)
88+
.with_default_image(
89+
std::env::var("COL_IMAGE")
90+
.unwrap_or("docker.io/paritypr/colander:latest".to_string())
91+
.as_str(),
92+
)
93+
.with_default_command("undying-collator")
94+
.with_default_args(vec!["-lparachain=debug".into()])
95+
.with_collator(|n| n.with_name("collator"))
96+
})
97+
.build()
98+
.map_err(|e| {
99+
let errors = e.into_iter().map(|e| e.to_string()).collect::<Vec<_>>().join(" ");
100+
anyhow!("config errors: {errors}")
101+
})?;
102+
103+
let spawn_fn = zombienet_sdk::environment::get_spawn_fn();
104+
let network = spawn_fn(config).await?;
105+
106+
let honest = network.get_node("honest-0")?;
107+
let relay_client = honest.wait_client().await?;
108+
let malus = network.get_node("malus")?;
109+
110+
log::info!("Waiting for parablocks to be produced");
111+
assert_para_throughput(
112+
&relay_client,
113+
20,
114+
[(polkadot_primitives::Id::from(2000), 10..30)].into_iter().collect(),
115+
)
116+
.await?;
117+
118+
let result = malus
119+
.wait_log_line_count_with_timeout(
120+
"*😈 Disputing candidate with hash:*",
121+
true,
122+
LogLineCountOptions::new(|n| n == 1, Duration::from_secs(180_u64), false),
123+
)
124+
.await?;
125+
assert!(result.success());
126+
let result = honest
127+
.wait_log_line_count_with_timeout(
128+
"*Dispute on candidate concluded*",
129+
true,
130+
LogLineCountOptions::new(|n| n == 0, Duration::from_secs(180_u64), false),
131+
)
132+
.await?;
133+
assert!(result.success());
134+
Ok(())
135+
}

polkadot/zombienet-sdk-tests/tests/functional/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
mod approval_voting_coalescing;
55
mod approved_peer_mixed_validators;
66
mod async_backing_6_seconds_rate;
7+
mod dispute_old_finalized;
78
mod duplicate_collations;
89
mod shared_core_idle_parachain;
910
mod spam_statement_distribution_requests;

polkadot/zombienet_tests/functional/0008-dispute-old-finalized.toml

Lines changed: 0 additions & 42 deletions
This file was deleted.

polkadot/zombienet_tests/functional/0008-dispute-old-finalized.zndsl

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)