Repository navigation
net: exempt manual peers from the hybrid fallback, fix its state - #250
Merged
Merged
Conversation
Found in review of #233. - Manual peers never fall back. An attacker on the path can make an endpoint's hybrid handshakes fail without any keys (damage the peer's confirmation, reset the connection, drop its traffic), and three failures put it in the fallback set, repeatably. Failures of MANUAL connections (addnode, -connect) no longer count toward a streak, and a manual connection always negotiates, even to an endpoint in the fallback set. Counters, rings, log lines and the local-fault warning still see them. Automatic connections keep the fallback. - The success set is capped at 1,000 endpoints, the least recently confirmed evicted first: feelers to advertised endpoints grew it without bound. A separate flag keeps "a handshake succeeded since startup" for the local-fault warning. - ObservePQ() no longer re-reads fNetworkActive. Events from the peer's bytes, a verified confirmation included, are always accounted; DisconnectNodes() passes the snapshot it closed connections with, so closes caused by switching the network off are never derived as abandoned or closed_after_switch. - A fallback window also ends once its length has passed on the steady clock, so a wall clock step back can't stretch it; the stats keep their wall clock times. - The local-fault warning counts only failures this node's own ML-KEM code can cause: ek_modulus, length, tag, and closed_after_switch with eof or reset. ek_length, not_decoy and timeout are the peer's or the path's. - getnetworkinfo counts connections_pq from the connection manager's node list, without CopyStats() and a cs_main lock per peer. Every node in the list is one getpeerinfo lists, so the result is the same. - A backward step of the mocked steady clock restarts load shedding's current second and quiet run, so shedding can't latch. - net_pq_tests restores CreateSock with an RAII guard in pq_config. - The rpc fuzz target mocks the steady clock too, as getpqtransportinfo now reads it. - The specification's downgrade note, the operator guide (fallback, local_fault, abandoned), the RPC delta reference and the release note say what the code does. The fallback functional tests use automatic connections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
4 tasks done
7 of 30 tasks
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.
Fixes from review of #233. The main one is that manual peers never fall back.
MANUALconnections (addnode,-connect) no longer count toward a streak.ObservePQ()no longer re-readsfNetworkActive.DisconnectNodes()passes its snapshot, so closes caused by switching the network off are never recorded as peer outcomes.ek_modulus,length,tag, andclosed_after_switchwitheoforreset. It used to count peer-format failures such asek_lengthtoo.getnetworkinfocountsconnections_pqthroughCConnman::GetPQNodeCount(). It no longer copies every peer's stats or takescs_mainper peer, and the result is unchanged.CreateSockinnet_pq_tests;rpcfuzz target now mocks the steady clock, becausegetpqtransportinforeads it and the target aborted on real system time.addconnection), since manual ones no longer fall back.Verification:
net_pq_testscases. Each one fails when its fix is reverted.net_pq_tests,net_testsandbip324_testspass.p2p_v2_pq,p2p_v2_pq_fallback,p2p_v2_pq_misbehaving,rpc_pqtransport,rpc_net,feature_pq_quickstartandtool_pq_canarypass.lint-pq-doc-tokens.pyand the vectors check pass.-Wthread-safetygives no warnings.rpc(withgetpqtransportinfo,getnetworkinfo,getpeerinfo, and unlimited),connman,net,process_message(s),p2p_handshake,p2p_headers_presync,p2p_v2_pq_malicious_peerandp2p_transport_serialization.Since #245, pull requests into
feature/pq-transportdon't run CI. #233's full CI covers this change once it merges.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.