Skip to content

[Fix] Prune old validator candidates#4317

Merged
vicsn merged 4 commits into
stagingfrom
fix/prune_old_validator_candidates
Jun 24, 2026
Merged

[Fix] Prune old validator candidates#4317
vicsn merged 4 commits into
stagingfrom
fix/prune_old_validator_candidates

Conversation

@ljedrz

@ljedrz ljedrz commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

This PR extends the CandidatePeer with the last known Aleo address field, which is then used to prune the peer pool of outdated validator entries during the handshake, so that we don't attempt to reconnect to them again.

Small drive-bys:

  • fix a Reconnnecting spelling error in a log (which may be an annoyance in debugging)
  • moved a test block from the beginning of a module to its end (it threw me off when I was working on these changes)

Supersedes #4229.

Fixes #4228.

ljedrz added 4 commits June 11, 2026 15:21
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>

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 improves peer pool hygiene by tracking a candidate peer’s last known Aleo address and using it during handshake to prune outdated validator candidate entries, reducing repeated reconnect attempts to stale IPs (related to #4228).

Changes:

  • Extend CandidatePeer to include last_known_aleo_addr (carried over when a peer is downgraded from Connected → Candidate).
  • Prune outdated candidate entries during Gateway handshake when the same Aleo address is observed from a different listening address.
  • Small drive-bys: fix “Reconnnecting” log typo and move peering.rs tests to the end of the module.

Reviewed changes

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

File Description
node/router/src/heartbeat.rs Updates connection helper signature to use the now-generic CandidatePeer<N>.
node/network/src/peering.rs Adjusts candidate-peer getters for CandidatePeer<N> and relocates the tests block.
node/network/src/peer.rs Makes CandidatePeer network-generic and adds last_known_aleo_addr, populated on downgrade.
node/bft/src/gateway.rs Fixes reconnect log typo and prunes outdated candidate entries during handshake using last_known_aleo_addr.

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

Comment thread node/network/src/peer.rs
Comment thread node/bft/src/gateway.rs
Comment thread node/bft/src/gateway.rs
@vicsn

vicsn commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

FYI I didn't merge due to the open copilot comments

@ljedrz

ljedrz commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

@vicsn I replied to the leftover comments, feel free to proceed with merging if you agree.

@vicsn vicsn merged commit 48d4025 into staging Jun 24, 2026
5 checks passed
@vicsn vicsn deleted the fix/prune_old_validator_candidates branch June 24, 2026 14:57
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.

[Bug] Connections to lots of already connected validators

3 participants