Enable P2P peer scoring in host and add concrete sync request score updates#5014
Open
GheisMohammadi wants to merge 1 commit intodevfrom
Open
Enable P2P peer scoring in host and add concrete sync request score updates#5014GheisMohammadi wants to merge 1 commit intodevfrom
GheisMohammadi wants to merge 1 commit intodevfrom
Conversation
Collaborator
|
Overall looks good, but I have one improvement idea, but I've probably already guess it - we need metrics on that, something like WDYT? |
Collaborator
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Peer scoring in the P2P stack is now fully wired into the host startup path instead of remaining effectively dormant. The change introduces configuration-driven controls for score retention and minimum accepted score, and uses those values during host construction to activate score-based connection gating when enabled. This keeps current behavior unchanged by default, while making scoring an explicit and operationally controllable feature.
On top of the host-level wiring, the sync request/response client path now updates peer scores using concrete runtime outcomes. Successful requests increase the valid-response signal, while transient failures increase an error-response signal. Responses that look malformed or indicate protocol mismatch are treated more strictly and counted as rejected payload behavior. This gives the scoring system meaningful, ongoing input derived from actual protocol interactions rather than static plumbing alone.
The implementation also includes defensive handling for test and mock environments where a full host or peerstore may not be present. In those cases, scoring hooks safely no-op instead of panicking, which preserves test stability and allows the broader suite to run normally. Overall, this PR moves peer scoring from “defined but mostly inactive” to “actively producing signal and enforceable when configured,” with backward-compatible defaults so operators can roll it out deliberately.