Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

More shred filtering #8975

Merged
merged 1 commit into from
Mar 20, 2020
Merged

More shred filtering #8975

merged 1 commit into from
Mar 20, 2020

Conversation

sakridge
Copy link
Contributor

Problem

Shred replay dos attack can overwhelm shred processing stages downstream of shred fetch.

Summary of Changes

Introduce a filter for shreds at the same slot/index which is cleared periodically. Also, more agressively filter slots which are not relevant like ones below the current root or more than 2 epochs away.

Fixes #8861

aeyakovenko
aeyakovenko previously approved these changes Mar 20, 2020
@mergify mergify bot dismissed aeyakovenko’s stale review March 20, 2020 02:01

Pull request has been modified.

@sakridge sakridge force-pushed the shred-filter branch 3 times, most recently from 275b8cb to 758578e Compare March 20, 2020 02:40
@carllin
Copy link
Contributor

carllin commented Mar 20, 2020

tests to show filtering?

if let Ok(index) = limited_deserialize::<u32>(&p.data[index_start..index_end]) {
if index < MAX_DATA_SHREDS_PER_SLOT as u32 {
if let Some((slot, index)) = Self::get_slot_index(p, &mut index_overrun) {
if slot > last_root && slot < (last_slot + 2 * slots_per_epoch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment for why we picked 2 * slots_per_epoch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed like a reasonable number :)


pub struct ShredFetchStage {
thread_hdls: Vec<JoinHandle<()>>,
}

impl ShredFetchStage {
fn get_slot_index(p: &Packet, index_overrun: &mut usize) -> Option<(u64, u32)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a small test for this so we don't change shred format without breaking this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a utility function in the shreds module?

let slot_received = shreds_received.entry(slot).or_insert_with(|| {
BitVec::new_fill(false, MAX_DATA_SHREDS_PER_SLOT as u64)
});
if !slot_received.get(index.into()) {
p.meta.discard = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the discard flag false by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ah missed that, coooooo

@sakridge
Copy link
Contributor Author

tests to show filtering?

This file has no tests.. why start now? ... /s

Thread bank_forks into shred fetch
@sakridge sakridge merged commit 453f5ce into solana-labs:master Mar 20, 2020
@sakridge sakridge deleted the shred-filter branch March 20, 2020 14:49
@sakridge sakridge added the v1.0 label Mar 20, 2020
mergify bot pushed a commit that referenced this pull request Mar 20, 2020
Thread bank_forks into shred fetch

(cherry picked from commit 453f5ce)

# Conflicts:
#	core/src/shred_fetch_stage.rs
sakridge added a commit to sakridge/solana that referenced this pull request Mar 20, 2020
Thread bank_forks into shred fetch
sakridge added a commit to sakridge/solana that referenced this pull request Mar 20, 2020
Thread bank_forks into shred fetch and filter by slot.
sakridge added a commit that referenced this pull request Mar 20, 2020
Thread bank_forks into shred fetch and filter by slot.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

High rate of tvu ingress traffic causes delinquency
3 participants