Skip to content

p2p: fix dial scheduler and multichannel dial cleanup - #1035

Open
yoomee1313 wants to merge 3 commits into
kaiachain:devfrom
yoomee1313:p2p-dial-fix
Open

p2p: fix dial scheduler and multichannel dial cleanup#1035
yoomee1313 wants to merge 3 commits into
kaiachain:devfrom
yoomee1313:p2p-dial-fix

Conversation

@yoomee1313

Copy link
Copy Markdown
Contributor

Proposed changes

This PR addresses p2p dial issues introduced by the DialSched refactor.

It contains three fixes:

063bb72 p2p: serialize dial candidate collection

  • Fixes a dial scheduler race where getCandidates read scheduler bookkeeping across inconsistent lock snapshots.
  • Keeps candidate demand calculation, static peer snapshot, dynamic queue refill, and CN allowlist filtering under one scheduler lock.
  • This makes each dial candidate batch reflect one consistent view of connected/dialing/static/CN peer state.

b0690b2 p2p: preserve connected peers on dial failure

  • Fixes a simultaneous dial case where outbound dial failure could remove bookkeeping for an already live inbound peer.
  • markDialFailure now returns early when the peer is already present in connectedAll.
  • This prevents failed outbound attempts from tearing down live peer accounting.

7fb2656 p2p: clean up incomplete multichannel dials

  • Fixes partial multichannel dial cleanup when some channels succeed but the full peer is never assembled.
  • dialMulti now verifies peer assembly after all channels, cleans only outbound pending candidates, and preserves inbound candidates from simultaneous dials.
  • Incomplete multichannel dials no longer remove static peers, and the warning log includes expected/dialed/cleaned channel counts.

One known limitation remains: multichannel candidate assembly is still keyed only by peer ID, so inbound and outbound candidate state can share the same candidate set. This is an existing design limitation rather than a regression introduced by this PR, so it is left out of scope.

Types of changes

  • 🐛 Bug fix
  • ✨ Non-hardfork changes (node upgrade not required)
  • 💥 Hardfork / consensus-breaking changes
  • 🧪 Test improvements
  • 🧰 CI / build tool
  • ♻️ Chore / Refactor / Non-functional changes

Checklist

  • 📖 I have read the CONTRIBUTING GUIDELINES doc
  • 📝 I have signed in the PR comment I have read the CLA Document and I hereby sign the CLA in first time contribute after having read CLA
  • 🟢 Lint and unit tests pass locally with my changes ($ make test)

Related issues

Further comments

@yoomee1313 yoomee1313 self-assigned this Aug 12, 2026
@ian0371 ian0371 added the do not merge Do not merge just yet label Aug 12, 2026
@yoomee1313 yoomee1313 closed this Aug 13, 2026
@yoomee1313
yoomee1313 deleted the p2p-dial-fix branch August 13, 2026 05:28
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 2026
@yoomee1313
yoomee1313 restored the p2p-dial-fix branch August 13, 2026 12:03
@yoomee1313 yoomee1313 reopened this Aug 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

do not merge Do not merge just yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants