Skip to content

fix(protocol): don't panic on startup when initial peer set exceeds channel capacity#5104

Open
damip wants to merge 1 commit into
mainfrom
fix/protocol-initial-peer-enqueue-no-panic
Open

fix(protocol): don't panic on startup when initial peer set exceeds channel capacity#5104
damip wants to merge 1 commit into
mainfrom
fix/protocol-initial-peer-enqueue-no-panic

Conversation

@damip

@damip damip commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

In PeerManagementHandler::new, the initial peer set — the union of locally
configured initial_peers and network-provided bootstrap_peers — is pushed into a
bounded channel with sender_msg.try_send(...).unwrap(), one message per peer.

There is no check that the merged peer count fits
max_size_channel_network_to_peer_handler. If the combined list exceeds the channel
capacity, try_send returns Full, the unwrap() panics, and because this runs on
the node's startup path the node can fail to join the network.

Change

Replace the unwrap() with graceful handling: on a try_send error, log a warning
and skip that peer. Dropping an excess peer at startup is safe — peers are
(re)discovered through normal peer exchange — and it must not abort node startup.

Testing

  • cargo build / cargo clippy clean for massa_protocol_worker.
  • The change is a localized unwrap() → error-logging conversion inside a constructor
    that spawns the peer-management thread; reproducing channel saturation deterministically
    would require a full handler harness, so no dedicated unit test is added.

Risk

Low — the only behavioural change is that an over-capacity initial peer list now logs
and continues instead of panicking. Under normal configuration the channel is not
saturated and behaviour is unchanged.

Tracking: finding F139.

…hannel capacity

PeerManagementHandler::new pushed each merged initial/bootstrap peer into a
bounded channel with try_send(...).unwrap(). An over-capacity peer list made
unwrap() panic on the startup path, potentially preventing the node from
joining the network. Log and skip on send error instead.

Finding F139.

Co-authored-by: Cursor <cursoragent@cursor.com>

@Leo-Besancon Leo-Besancon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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.

3 participants