Skip to content

Add gossip ban and rate limit policy#1263

Open
jjyr wants to merge 50 commits intonervosnetwork:developfrom
jjyr:fnn-gossip-ban-rate-limit
Open

Add gossip ban and rate limit policy#1263
jjyr wants to merge 50 commits intonervosnetwork:developfrom
jjyr:fnn-gossip-ban-rate-limit

Conversation

@jjyr
Copy link
Copy Markdown
Collaborator

@jjyr jjyr commented Apr 9, 2026

This PR require #1217

Summary

This PR adds a gossip policy that temporarily bans misbehaving non-channel peers and rate-
limits gossip traffic to reduce spam, protect sync, and limit abuse.

Changes

  • add GossipPolicyConfig under FiberConfig as gossip_policy
  • add in-memory gossip scoring and 10-minute temporary bans for non-channel peers
  • add outbound gossip rate limiting at both global and per-peer levels
  • add inbound channel update rate limiting
  • add delayed outbound gossip delivery with per-peer queues
  • add tests for ban tracking, rate limiting, delayed sends, and related gossip flows

View diff

jjyr added 30 commits March 11, 2026 09:24
@jjyr jjyr requested review from chenyukang, doitian and quake April 9, 2026 13:04
@jjyr jjyr marked this pull request as ready for review April 9, 2026 13:05
))),
_ => Err(Error::InvalidParameter(format!(
"Channel announcement transaction {:?} not found or not confirmed, the reason is unknown",
Ok(response) => Err(Error::InvalidParameter(format!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CkbRpcClient::get_transaction returns a successful response with tx_status Unknown, Pending, or Proposed when the funding tx is not committed yet. This branch still maps those statuses to InvalidParameter, so an honest peer can be scored or banned whenever our local chain view lags behind theirs. The defer path only handles transport errors; non-committed statuses should be deferred too.


ExtendedGossipMessageStoreMessage::SaveMessages(peer, messages) => {
let now_ms = now_timestamp_as_millis_u64();
for message in messages {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for BroadcastMessage like ChannelUpdate, seems save latest message is more meanningful than old ones.
here when we reached a limit, we drop those new ones?
maybe it's not a big issue, since we add limit here for extreme scenarios....

Copy link
Copy Markdown
Collaborator Author

@jjyr jjyr Apr 10, 2026

Choose a reason for hiding this comment

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

Right, it is for preventing the milicious attack, the regular gossip message shouldn't reach the limitation.

Comment thread crates/fiber-lib/src/fiber/config.rs
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.

2 participants