mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-30 11:55:42 +00:00
statement-distribution: fix filtering of statements for elastic parachains (#3879)
fixes https://github.com/paritytech/polkadot-sdk/issues/3775 Additionally moves the claim queue fetch utilities into `subsystem-util`. TODO: - [x] fix tests - [x] add elastic scaling tests --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -312,6 +312,66 @@ fn useful_cluster_statement_from_non_cluster_peer_rejected() {
|
||||
});
|
||||
}
|
||||
|
||||
// Both validators in the test are part of backing groups assigned to same parachain
|
||||
#[test]
|
||||
fn elastic_scaling_useful_cluster_statement_from_non_cluster_peer_rejected() {
|
||||
let config = TestConfig {
|
||||
validator_count: 20,
|
||||
group_size: 3,
|
||||
local_validator: LocalRole::Validator,
|
||||
async_backing_params: None,
|
||||
};
|
||||
|
||||
let relay_parent = Hash::repeat_byte(1);
|
||||
let peer_a = PeerId::random();
|
||||
|
||||
test_harness(config, |state, mut overseer| async move {
|
||||
let candidate_hash = CandidateHash(Hash::repeat_byte(42));
|
||||
|
||||
let test_leaf = state.make_dummy_leaf_with_multiple_cores_per_para(relay_parent, 3);
|
||||
|
||||
// Peer A is not in our group, but its group is assigned to same para as we are.
|
||||
let not_our_group = GroupIndex(1);
|
||||
|
||||
let that_group_validators = state.group_validators(not_our_group, false);
|
||||
let v_non = that_group_validators[0];
|
||||
|
||||
connect_peer(
|
||||
&mut overseer,
|
||||
peer_a.clone(),
|
||||
Some(vec![state.discovery_id(v_non)].into_iter().collect()),
|
||||
)
|
||||
.await;
|
||||
|
||||
send_peer_view_change(&mut overseer, peer_a.clone(), view![relay_parent]).await;
|
||||
activate_leaf(&mut overseer, &test_leaf, &state, true, vec![]).await;
|
||||
|
||||
let statement = state
|
||||
.sign_statement(
|
||||
v_non,
|
||||
CompactStatement::Seconded(candidate_hash),
|
||||
&SigningContext { parent_hash: relay_parent, session_index: 1 },
|
||||
)
|
||||
.as_unchecked()
|
||||
.clone();
|
||||
|
||||
send_peer_message(
|
||||
&mut overseer,
|
||||
peer_a.clone(),
|
||||
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_matches!(
|
||||
overseer.recv().await,
|
||||
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::ReportPeer(ReportPeerMessage::Single(p, r)))
|
||||
if p == peer_a && r == COST_UNEXPECTED_STATEMENT_INVALID_SENDER.into() => { }
|
||||
);
|
||||
|
||||
overseer
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn statement_from_non_cluster_originator_unexpected() {
|
||||
let config = TestConfig {
|
||||
|
||||
@@ -1829,9 +1829,7 @@ fn advertisement_not_re_sent_when_peer_re_enters_view() {
|
||||
});
|
||||
}
|
||||
|
||||
// Grid statements imported to backing once candidate enters hypothetical frontier.
|
||||
#[test]
|
||||
fn grid_statements_imported_to_backing() {
|
||||
fn inner_grid_statements_imported_to_backing(groups_for_first_para: usize) {
|
||||
let validator_count = 6;
|
||||
let group_size = 3;
|
||||
let config = TestConfig {
|
||||
@@ -1851,9 +1849,12 @@ fn grid_statements_imported_to_backing() {
|
||||
let local_group_index = local_validator.group_index.unwrap();
|
||||
|
||||
let other_group = next_group_index(local_group_index, validator_count, group_size);
|
||||
let other_para = ParaId::from(other_group.0);
|
||||
|
||||
let test_leaf = state.make_dummy_leaf(relay_parent);
|
||||
// Other para is same para for elastic scaling test (groups_for_first_para > 1)
|
||||
let other_para = ParaId::from((groups_for_first_para == 1) as u32);
|
||||
|
||||
let test_leaf =
|
||||
state.make_dummy_leaf_with_multiple_cores_per_para(relay_parent, groups_for_first_para);
|
||||
|
||||
let (candidate, pvd) = make_candidate(
|
||||
relay_parent,
|
||||
@@ -2018,6 +2019,18 @@ fn grid_statements_imported_to_backing() {
|
||||
overseer
|
||||
});
|
||||
}
|
||||
// Grid statements imported to backing once candidate enters hypothetical frontier.
|
||||
#[test]
|
||||
fn grid_statements_imported_to_backing() {
|
||||
inner_grid_statements_imported_to_backing(1);
|
||||
}
|
||||
|
||||
// Grid statements imported to backing once candidate enters hypothetical frontier.
|
||||
// All statements are for candidates of the same parachain but from different backing groups.
|
||||
#[test]
|
||||
fn elastic_scaling_grid_statements_imported_to_backing() {
|
||||
inner_grid_statements_imported_to_backing(2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn advertisements_rejected_from_incorrect_peers() {
|
||||
|
||||
@@ -177,20 +177,39 @@ impl TestState {
|
||||
}
|
||||
|
||||
fn make_dummy_leaf(&self, relay_parent: Hash) -> TestLeaf {
|
||||
self.make_dummy_leaf_with_multiple_cores_per_para(relay_parent, 1)
|
||||
}
|
||||
|
||||
fn make_dummy_leaf_with_multiple_cores_per_para(
|
||||
&self,
|
||||
relay_parent: Hash,
|
||||
groups_for_first_para: usize,
|
||||
) -> TestLeaf {
|
||||
TestLeaf {
|
||||
number: 1,
|
||||
hash: relay_parent,
|
||||
parent_hash: Hash::repeat_byte(0),
|
||||
session: 1,
|
||||
availability_cores: self.make_availability_cores(|i| {
|
||||
CoreState::Scheduled(ScheduledCore {
|
||||
para_id: ParaId::from(i as u32),
|
||||
collator: None,
|
||||
})
|
||||
let para_id = if i < groups_for_first_para {
|
||||
ParaId::from(0u32)
|
||||
} else {
|
||||
ParaId::from(i as u32)
|
||||
};
|
||||
|
||||
CoreState::Scheduled(ScheduledCore { para_id, collator: None })
|
||||
}),
|
||||
disabled_validators: Default::default(),
|
||||
para_data: (0..self.session_info.validator_groups.len())
|
||||
.map(|i| (ParaId::from(i as u32), PerParaData::new(1, vec![1, 2, 3].into())))
|
||||
.map(|i| {
|
||||
let para_id = if i < groups_for_first_para {
|
||||
ParaId::from(0u32)
|
||||
} else {
|
||||
ParaId::from(i as u32)
|
||||
};
|
||||
|
||||
(para_id, PerParaData::new(1, vec![1, 2, 3].into()))
|
||||
})
|
||||
.collect(),
|
||||
minimum_backing_votes: 2,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user