-
Notifications
You must be signed in to change notification settings - Fork 38.8k
doc: Clarify scope of eviction protection of outbound block-relay peers #19871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: Clarify scope of eviction protection of outbound block-relay peers #19871
Conversation
sdaftuar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments above the definition of ChainSyncTimeoutState in net_processing.cpp should also be updated.
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
// Note that outbound block-relay peers are excluded from this protection, and thus always subject to eviction under the bad/lagging chain logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you may want to consider adding a comment that explains how m_protect is used by stale-tip-based eviction as well. In particular, the stale-tip -> extra full outbound peer logic could cause an existing full outbound to be evicted, but peers with m_protect set will not be chosen for eviction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Also added a commit on scope of m_protect w.r.t to both eviction logics.
b94ebc3 to
6ce273b
Compare
|
Updated at 6ce273b. I guess we could split up |
Block-relay-only peers were introduced by bitcoin#15759. According to its author, it was intented to make them only immune to outbound peer rotation-based eviction and not from all eviction as modified comment leans to think of. Clearly indicate that outbound block-relay peers aren't protected from eviction by the bad/lagging chain logic.
6ce273b to
706f1f0
Compare
706f1f0 to
b55f979
Compare
|
Thanks @naumenkogs, took your last suggestion at b55f979 |
|
ACK b55f9790194746ce0180fc9fc5e085bdb118432c |
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b55f9790 suggestions
- /** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logics.
+ /** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic.
*
* Both are only in effect for outbound, non-manual, non-protected connections.
* Any peer protected (m_protect = true) is not chosen for eviction. A peer is
- * marked as protected if :
+ * marked as protected if all of these are true:
* - its connection type is IsBlockOnlyConn() == false
* - it gave us a valid connecting header
- * - it has a better chain than we have
* - we haven't reached MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT yet
+ * - it has a better chain than we have
+ * - it is not already marked as protectedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'm going to leave it as it is. It's a bit confusing saying that something is "marked as protected if it is not already marked as protected".
Note, actually CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL are two different logics, thus the plural.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware. Logic is most often used as an uncountable noun, but it's not an issue.
While rewriting this, I think it would be good to clarify that the list of conditions is "if all of these" and not "if any of these".
The reordering suggestion is to follow the order of the actual checks.
I verified that the proposed documentation corresponds to the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the noun suggestion. Took it, also the re-ordering. But not the "it is not already marked as protected" it's a tautology IMO (it would false future triggering of protection if we don't due to g_outbound_peers_with_protect_from_disconnect is incremented in same conditional, but technically the state transition is defined without)
… logics The field m_protect is used to protect from eviction both by bad/lagging chain and extra outbound peers logics. Outbound block-relay peers are always excluded from this protection.
b55f979 to
d769254
Compare
|
ACK d769254 |
| /** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic. | ||
| * | ||
| * Both are only in effect for outbound, non-manual, non-protected connections. | ||
| * Any peer protected (m_protect = true) is not chosen for eviction. A peer is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this explanation actually belongs to the declaration of m_protect better, but I don't care enough to ask for this... Consider this if you gonna update it.
…bound block-relay peers d769254 [doc] Clarify semantic of peer's m_protect w.r.t to outbound eviction logics (Antoine Riard) ac71fe9 [doc] Clarify scope of eviction protection of outbound block-relay peers (Antoine Riard) Pull request description: Block-relay-only peers were introduced by bitcoin#15759. According to its author, it was intented to make them only immune to outbound peer rotation-based eviction and not from all eviction as modified comment leans to think of. Clearly indicate that outbound block-relay peers aren't protected from eviction by the bad/lagging chain logic. Fix bitcoin#19863 ACKs for top commit: naumenkogs: ACK d769254 jonatack: ACK d769254 Tree-SHA512: 597fbd62838a6e39276024165b11514cad20a2e9d33cf9202d261cbadcb62b2df427c858e0cb57e585840d4c1d4600104aa53916bb868541f2580e4eed9b4b52
| * - its connection type is IsBlockOnlyConn() == false | ||
| * - it gave us a valid connecting header | ||
| * - we haven't reached MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT yet | ||
| * - it has a better chain than we have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is quite right?
the relevant part of the check in ProcessHeadersMessage checks nodestate->pindexBestKnownBlock->nChainWork >= ::ChainActive().Tip()->nChainWork, aka would set m_protect to true if they have the same chain tip as we do.
I think saying the peer "has a better chain" is misleading, because then I'd expect a long-running node to usually not have protected peers. Based on the logic I see, I'd expect a long-running node to usually have MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT.
what do you think?
Summary: > [doc] Clarify scope of eviction protection of outbound block-relay peers > > Block-relay-only peers were introduced by #15759. According to its > author, it was intented to make them only immune to outbound peer > rotation-based eviction and not from all eviction as modified comment > leans to think of. > > Clearly indicate that outbound block-relay peers aren't protected > from eviction by the bad/lagging chain logic. > [doc] Clarify semantic of peer's m_protect w.r.t to outbound eviction logics > > The field m_protect is used to protect from eviction both by bad/lagging > chain and extra outbound peers logics. Outbound block-relay peers are > always excluded from this protection. This is a backport of [[bitcoin/bitcoin#19871 | core#19871]] Test Plan: proofreading Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D10420
Block-relay-only peers were introduced by #15759. According to its
author, it was intented to make them only immune to outbound peer
rotation-based eviction and not from all eviction as modified comment
leans to think of.
Clearly indicate that outbound block-relay peers aren't protected
from eviction by the bad/lagging chain logic.
Fix #19863