Skip to content

Commit bbe01fe

Browse files
committed
reject empty manifests
1 parent b67c19f commit bbe01fe

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

polkadot/node/network/protocol/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,12 @@ pub mod v2 {
637637
}
638638
}
639639

640+
/// Returns `true` if the filter consists of zeroes.
641+
pub fn is_blank(&self) -> bool {
642+
self.seconded_in_group.leading_zeros() == self.seconded_in_group.len() &&
643+
self.validated_in_group.leading_zeros() == self.validated_in_group.len()
644+
}
645+
640646
/// Whether the filter has a specific expected length, consistent across both
641647
/// bitfields.
642648
pub fn has_len(&self, len: usize) -> bool {

polkadot/node/network/statement-distribution/src/v2/requests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,11 @@ fn validate_complete_response(
788788
return invalid_candidate_output()
789789
}
790790

791+
// If we filtered out all statements, the response is invalid.
792+
if received_filter.is_blank() {
793+
return invalid_candidate_output()
794+
}
795+
791796
statements
792797
};
793798

polkadot/node/network/statement-distribution/src/v2/tests/requests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ fn peer_reported_for_providing_statement_from_disabled_validator() {
12421242
assert_matches!(
12431243
overseer.recv().await,
12441244
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::ReportPeer(ReportPeerMessage::Single(p, r)))
1245-
if p == peer_b && r == BENEFIT_VALID_RESPONSE.into() => { }
1245+
if p == peer_b && r == COST_INVALID_RESPONSE.into() => { }
12461246
);
12471247

12481248
assert_matches!(

0 commit comments

Comments
 (0)