You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dash-spv: peers sending invalid headers or CFHeaders are never banned #1290
A peer that sends block headers failing proof-of-work or difficulty validation, or filter headers that do not chain, is never banned or penalized. The client logs the failure and asks again, possibly from the same peer.
Evidence (on dev)
Block headers:BlockHeadersManager::handle_headers_pipeline (dash-spv/src/sync/block_headers/manager.rs) bans the peer only when HeadersPipeline::receive_headers errors. That covers a checkpoint hash mismatch only. Continuity, PoW and difficulty are checked later, in store_headers via BlockHeaderValidator::validate, when a completed segment is stored from store_ready_batches. By then the segment no longer records which peer sent its headers. The error goes up to the sync loop in dash-spv/src/sync/sync_manager.rs, which only logs it and emits SyncEvent::ManagerError, and nothing bans a peer for it.
Filter headers: in FilterHeadersManager::handle_message (dash-spv/src/sync/filter_headers/sync_manager.rs), a SyncError::Validation from process_cfheaders logs Rejected CFHeaders batch at …, requesting it again and calls pipeline.requeue_rejected. The peer argument is unused (_peer), so the sender is never banned.
A peer serving bad data therefore costs us a full re-download each time, and nothing stops the broker from routing the retry back to it.
Fix
Record the sending peer with the headers a segment buffers, and with each CFHeaders response. Then call network.ban_peer(peer) when BlockHeaderValidator::validate fails or process_cfheaders returns SyncError::Validation. Only ban for failures that prove the data itself is bad: PoW, difficulty, broken continuity, and a filter header chain that doesn't match the stored one. Don't ban for failures that could come from our own state.
Spotted while reviewing #921. Its backfill paths inherit the same behaviour.
Activity