Skip to content

fix(network): allow Disconnect message on T3 connections#15405

Merged
darioush merged 6 commits into
near:masterfrom
darioush:network/fix-t3-disconnect-2
Mar 18, 2026
Merged

fix(network): allow Disconnect message on T3 connections#15405
darioush merged 6 commits into
near:masterfrom
darioush:network/fix-t3-disconnect-2

Conversation

@darioush

@darioush darioush commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Disconnect was only allowed on T2 in is_allowed_receive, but PeerActor::stopping (peer_actor.rs) sends it unconditionally on all tiers when a peer connection closes. This caused every T3 connection closure to log a spurious warning and forcibly drop the connection as DisallowedMessage instead of processing the disconnect cleanly.

  • Allow Disconnect on all tiers (like HandshakeFailure and LastEdge)
  • Emit ConnectionClosed test event for non-T2 tiers in unregister so tests can observe T3 connection lifecycle
  • Add t3_disconnect test that sends a Disconnect over T3 and asserts it's not rejected

@darioush darioush changed the title Network/fix t3 disconnect 2 fix(network): allow Disconnect message on T3 connections Mar 18, 2026
@darioush darioush marked this pull request as ready for review March 18, 2026 02:16
@darioush darioush requested a review from a team as a code owner March 18, 2026 02:16

Copilot AI 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.

Pull request overview

This PR fixes a tier-mismatch in the networking layer where Disconnect messages were rejected on T3 connections, even though PeerActor::stop_actor sends Disconnect on shutdown for all tiers. It also improves test observability of non-T2 connection lifecycles.

Changes:

  • Allow PeerMessage::Disconnect to be received on all TCP tiers in tcp::Tier::is_allowed_receive.
  • Ensure NetworkState::unregister emits the ConnectionClosed test event for all tiers (by avoiding the early return for non-T2).
  • Add a regression test that sends Disconnect over a T3 connection and asserts it is handled cleanly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
chain/network/src/peer_manager/connection/mod.rs Updates tier message-allowlist to accept Disconnect on any tier.
chain/network/src/peer_manager/network_state/mod.rs Refactors unregister to keep T2-only routing/store logic gated while still emitting ConnectionClosed test events for all tiers.
chain/network/src/peer_manager/tests/connection_pool.rs Adds t3_disconnect regression test validating T3 Disconnect is accepted and produces the expected closing reason.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Mar 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.01%. Comparing base (734d7d8) to head (9a5f89c).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...hain/network/src/peer_manager/network_state/mod.rs 91.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15405      +/-   ##
==========================================
- Coverage   69.02%   69.01%   -0.02%     
==========================================
  Files         934      934              
  Lines      209214   209873     +659     
  Branches   209214   209873     +659     
==========================================
+ Hits       144405   144834     +429     
- Misses      58823    59049     +226     
- Partials     5986     5990       +4     
Flag Coverage Δ
pytests-nightly 1.16% <0.00%> (-0.01%) ⬇️
unittests 68.35% <91.66%> (+0.09%) ⬆️
unittests-nightly 68.55% <91.66%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@darioush darioush added this pull request to the merge queue Mar 18, 2026
Merged via the queue into near:master with commit 2e28773 Mar 18, 2026
63 of 65 checks passed
@darioush darioush deleted the network/fix-t3-disconnect-2 branch March 18, 2026 15:01
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