Skip to content

feat: handle DoS node by sending block#475

Merged
yiweichi merged 17 commits into
mainfrom
feat-penalize-peer-on-duplicate-block
Feb 2, 2026
Merged

feat: handle DoS node by sending block#475
yiweichi merged 17 commits into
mainfrom
feat-penalize-peer-on-duplicate-block

Conversation

@yiweichi

@yiweichi yiweichi commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Problem

Malicious peers can DoS the node by sending old blocks.

Solution

Two-layer defense:

  1. Finalized Block Protection
    if block_number <= finalized_height { penalize(peer); // Immediately reject}
  2. Duplicate Block Detection
    // Cache recent blocks per peerif peer_already_sent_this_block { penalize(peer); // DoS detected }

Fixes #307

@codspeed-hq

codspeed-hq Bot commented Jan 12, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing feat-penalize-peer-on-duplicate-block (624e663) with main (b77ae04)

Open in CodSpeed

@yiweichi yiweichi changed the title feat: penalize peer on duplicate block feat: handle DoS node by sending block Jan 19, 2026
@yiweichi yiweichi requested a review from frisitano January 19, 2026 08:46

@frisitano frisitano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Added a few comments inline. Can you add some test cases, please?

I'm also wondering if we can simplify the logic a bit. The idea would be that if we have a connection with a peer over scroll-wire, then we should only gossip on scroll-wire. If we don't have a scroll-wire connection, then we use eth-wire. I think this should allow us to consolidate the block cache per peer into a single cache.

Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/scroll-wire/src/manager.rs Outdated
@yiweichi yiweichi requested a review from frisitano January 30, 2026 07:52

@frisitano frisitano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Addeed some comments inline.

Comment thread crates/network/src/manager.rs
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
Comment thread crates/network/src/manager.rs Outdated
@yiweichi yiweichi requested a review from frisitano January 30, 2026 13:11
Comment thread crates/network/src/manager.rs Outdated
frisitano
frisitano previously approved these changes Jan 30, 2026
@yiweichi

Copy link
Copy Markdown
Contributor Author

I'm planing to build a v1.0.7-rc0 image and deploy it on sepolia reth-rpc-0, then keep an eyes on the connected peer of it, do you think that make sense? @frisitano

@yiweichi yiweichi requested a review from frisitano January 30, 2026 14:05
@yiweichi yiweichi merged commit 0330e50 into main Feb 2, 2026
21 of 22 checks passed
@yiweichi yiweichi deleted the feat-penalize-peer-on-duplicate-block branch February 2, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Network] Penalize peer if they send us duplicate block

2 participants