Skip to content

Cleanup gossip peer outbound state on disconnect#1534

Open
quake wants to merge 1 commit into
developfrom
fix/gossip-peer-state-cleanup
Open

Cleanup gossip peer outbound state on disconnect#1534
quake wants to merge 1 commit into
developfrom
fix/gossip-peer-state-cleanup

Conversation

@quake

@quake quake commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

  • remove per-peer outbound token bucket on peer disconnect
  • replace state clone in estimate_outbound_message_delay with non-mutating peek
  • prevents unbounded peer_outbound HashMap growth

Tests

  • cargo check -p fnn --features sqlite
  • cargo fmt --all -- --check
  • git diff --check

@quake
quake requested review from chenyukang and jjyr July 7, 2026 03:54
}
GossipActorMessage::PeerDisconnected(pubkey, _session) => {
state.peer_states.remove(&pubkey);
state.policy.remove_outbound_peer(&pubkey);

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.

here removes the peer outbound bucket before dropping delayed outbound messages, but drop_delayed_outbound_messages_for_peer refunds each queued message, and refund_outbound_message recreates the same peer bucket via peer_outbound.entry(...).or_insert_with(...). So any disconnected peer with delayed gossip payloads still leaves an outbound bucket behind, which means this PR does not actually clean up the peer state in the case most relevant to queue/backpressure cleanup. Move remove_outbound_peer after the delayed-message refund/drop, or add a refund path that does not recreate per-peer state during disconnect cleanup.

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