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

Commit

Permalink
Add scaffolding to be able to test aggression works
Browse files Browse the repository at this point in the history
... add option to malus nodes that witholds messages sent by
approval-distribution to simulate approvals couldn't be sent to some of
the peers and test finality is not lagging

Signed-off-by: Alexandru Gheorghe <[email protected]>
  • Loading branch information
alexggh committed Jul 20, 2023
1 parent 2af3525 commit 8abed2a
Show file tree
Hide file tree
Showing 11 changed files with 485 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions node/malus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ polkadot-node-core-pvf-execute-worker = { path = "../core/pvf/execute-worker" }
polkadot-node-core-pvf-prepare-worker = { path = "../core/pvf/prepare-worker" }
polkadot-node-primitives = { path = "../primitives" }
polkadot-primitives = { path = "../../primitives" }
polkadot-node-network-protocol = { path = "../network/protocol" }

color-eyre = { version = "0.6.1", default-features = false }
assert_matches = "1.5"
async-trait = "0.1.57"
Expand Down
2 changes: 1 addition & 1 deletion node/malus/src/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
/// For non-trivial cases, the `sender` can be used to send
/// multiple messages after doing some additional processing.
fn intercept_incoming(
&self,
&mut self,
_sender: &mut Sender,
msg: FromOrchestra<Self::Message>,
) -> Option<FromOrchestra<Self::Message>> {
Expand Down
12 changes: 12 additions & 0 deletions node/malus/src/malus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum NemesisVariant {
BackGarbageCandidate(BackGarbageCandidateOptions),
/// Delayed disputing of ancestors that are perfectly fine.
DisputeAncestor(DisputeAncestorOptions),
/// Do not distribute approvals to all nodes
WitholdApprovalsDistribution(WitholdApprovalsDistributionOptions),

#[allow(missing_docs)]
#[command(name = "prepare-worker", hide = true)]
Expand All @@ -59,6 +61,7 @@ impl MalusCli {
/// Launch a malus node.
fn launch(self) -> eyre::Result<()> {
let finality_delay = self.finality_delay;

match self.variant {
NemesisVariant::BackGarbageCandidate(opts) => {
let BackGarbageCandidateOptions { percentage, cli } = opts;
Expand Down Expand Up @@ -88,6 +91,15 @@ impl MalusCli {
finality_delay,
)?
},
NemesisVariant::WitholdApprovalsDistribution(WitholdApprovalsDistributionOptions {
num_network_groups,
assigned_network_group,
cli,
}) => polkadot_cli::run_node(
cli,
WitholdApprovalsDistribution { num_network_groups, assigned_network_group },
finality_delay,
)?,
NemesisVariant::PvfPrepareWorker(cmd) => {
#[cfg(target_os = "android")]
{
Expand Down
2 changes: 1 addition & 1 deletion node/malus/src/variants/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ where

// Capture all (approval and backing) candidate validation requests and depending on configuration fail them.
fn intercept_incoming(
&self,
&mut self,
subsystem_sender: &mut Sender,
msg: FromOrchestra<Self::Message>,
) -> Option<FromOrchestra<Self::Message>> {
Expand Down
4 changes: 4 additions & 0 deletions node/malus/src/variants/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ mod back_garbage_candidate;
mod common;
mod dispute_valid_candidates;
mod suggest_garbage_candidate;
mod withold_approvals_distribution;

pub(crate) use self::{
back_garbage_candidate::{BackGarbageCandidateOptions, BackGarbageCandidates},
dispute_valid_candidates::{DisputeAncestorOptions, DisputeValidCandidates},
suggest_garbage_candidate::{SuggestGarbageCandidateOptions, SuggestGarbageCandidates},
withold_approvals_distribution::{
WitholdApprovalsDistribution, WitholdApprovalsDistributionOptions,
},
};
pub(crate) use common::*;
2 changes: 1 addition & 1 deletion node/malus/src/variants/suggest_garbage_candidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where

/// Intercept incoming `Second` requests from the `collator-protocol` subsystem.
fn intercept_incoming(
&self,
&mut self,
subsystem_sender: &mut Sender,
msg: FromOrchestra<Self::Message>,
) -> Option<FromOrchestra<Self::Message>> {
Expand Down
Loading

0 comments on commit 8abed2a

Please sign in to comment.