Skip to content
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

p2p: adaptive connections services flags #28170

Merged
merged 6 commits into from
Jan 31, 2024

Commits on Jan 15, 2024

  1. net: store best block tip time inside PeerManager

    And implement 'ApproximateBestBlockDepth()' to estimate
    the distance, in blocks, between the best-known block
    and the network chain tip. Utilizing the best-block time
    and the chainparams blocks spacing to approximate it.
    furszy committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    97df4e3 View commit details
    Browse the repository at this point in the history
  2. net: decouple state independent service flags from desirable ones

    This former one will be moved to the peer manager class in the
    following-up commit.
    furszy committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    f9ac96b View commit details
    Browse the repository at this point in the history
  3. net: move state dependent peer services flags

    No behavior change. Just an intermediate refactoring.
    
    By relocating the peer desirable services flags into the peer
    manager, we allow the connections acceptance process to handle
    post-IBD potential stalling scenarios.
    
    In the follow-up commit(s), the desirable service flags will be
    dynamically adjusted to detect post-IBD stalling scenarios (such
    as a +48-hour inactive node that must prefer full node connections
    instead of limited peer connections because they cannot provide
    historical blocks). Additionally, this encapsulation enable us
    to customize the connections decision-making process based on
    new user's configurations in the future.
    furszy committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    9f36e59 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2024

  1. net: peer manager, dynamically adjust desirable services flag

    Introduces functionality to detect when limited peers connections
    are desirable or not. Ensuring that the new connections desirable
    services flags stay relevant throughout the software's lifecycle.
    (Unlike the previous approach, where once the validation IBD flag
    was set, the desirable services flags remained constant forever).
    
    This will let us recover from stalling scenarios where the node had
    successfully synced, but subsequently dropped connections and remained
    inactive for a duration longer than the limited peers threshold (the
    timeframe within which limited peers can provide blocks). Then, upon
    reconnection to the network, the node may end up only establishing
    connections with limited peers, leading to an inability to synchronize
    the chain.
    
    This also fixes a possible limited peers threshold violation during IBD,
    when the user configures `-maxtipage` further than the BIP159's limits.
    This rule violation could lead to sync delays and, in the worst-case
    scenario, trigger the same post-IBD stalling scenario (mentioned above)
    but during IBD.
    furszy committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    6ed5360 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aff7d92 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    27f260a View commit details
    Browse the repository at this point in the history