Skip to content

fix(protocol): consume default outbound slot on dial success, not failure#5102

Open
damip wants to merge 1 commit into
mainfrom
fix/protocol-default-outbound-slot-accounting
Open

fix(protocol): consume default outbound slot on dial success, not failure#5102
damip wants to merge 1 commit into
mainfrom
fix/protocol-default-outbound-slot-accounting

Conversation

@damip

@damip damip commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

In start_connectivity_thread's outbound dialing loop, the default-category
branch consumed a connection slot and recorded the address as connected on
try_connect_peer(...).is_err() — i.e. on failure — which is inverted.

Compare the special-category branch just above, which (correctly) consumes the slot
and records the address on .is_ok().

Because of the inversion, for uncategorized peers:

  • a failed dial wrongly consumed a slot and marked the peer connected, so the
    node could stop dialing while still under-connected;
  • a successful dial did not consume a slot, so the node could exceed the intended
    outbound target for the default category.

Change

Consume the default-category slot and record the address on success (.is_ok()),
mirroring the special-category branch.

Testing

  • cargo build / cargo clippy clean for massa_protocol_worker.
  • The fix is a one-token control-flow correction inside the connectivity thread's
    select! loop; exercising it in isolation would require a full network-controller
    mock and connectivity-thread harness, so no dedicated unit test is added. The change
    is verified by direct comparison with the adjacent, correct special-category branch.

Risk

Low — it aligns the default-category accounting with the already-correct
special-category accounting.

Tracking: finding F140.

…lure

The default-category branch in start_connectivity_thread consumed a slot
and recorded the address as connected on try_connect_peer(...).is_err()
instead of .is_ok(), inverted relative to the special-category branch.
This could leave the node under-connected after failed dials or exceed the
outbound target after successful dials. Consume the slot on success.

Finding F140.

Co-authored-by: Cursor <cursoragent@cursor.com>
@damip
damip requested review from Leo-Besancon and removed request for Leo-Besancon July 21, 2026 14:42

@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.

2 participants