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

Reputation penalty for sending empty block response #5814

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Changes from all commits
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
7 changes: 7 additions & 0 deletions client/network/src/protocol/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ mod rep {
/// Reputation change for peers which send us a known bad block.
pub const BAD_BLOCK: Rep = Rep::new(-(1 << 29), "Bad block");

/// Peer did not provide us with advertised block data.
pub const NO_BLOCK: Rep = Rep::new(-(1 << 29), "No requested block data");

/// Reputation change for peers which send us a known block.
pub const KNOWN_BLOCK: Rep = Rep::new(-(1 << 29), "Duplicate block");

Expand Down Expand Up @@ -696,6 +699,10 @@ impl<B: BlockT> ChainSync<B> {
}
PeerSyncState::DownloadingStale(_) => {
peer.state = PeerSyncState::Available;
if blocks.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

Why are we not doing this for the other states as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

When doing full sync it is not that critical, as we'll get new blocks from other peers eventually.

debug!(target: "sync", "Empty block response from {}", who);
return Err(BadPeer(who, rep::NO_BLOCK));
}
blocks.into_iter().map(|b| {
IncomingBlock {
hash: b.hash,
Expand Down