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

Start disconnecting from outdated peers a few days before network upgrade activation #4545

Open
teor2345 opened this issue May 31, 2022 · 1 comment
Labels
A-network Area: Network protocol updates or fixes C-security Category: Security issues I-remote-node-overload Zebra can overload other nodes on the network NU-6 Network Upgrade: NU6 specific tasks
Milestone

Comments

@teor2345
Copy link
Contributor

teor2345 commented May 31, 2022

Motivation

To avoid Zcash peer connection storms, we want to start disconnecting from outdated peers before network upgrade activation.

Specifications

Here is what zcashd does:
https://zips.z.cash/zip-0201#network-coalescence

Designs

  1. If Zebra is close to a network upgrade, at regular intervals, randomly choose an outdated peer, and disconnect from it. This will make Zebra automatically reconnect to another peer in its address book.
  2. Zebra attempts new peer connections in a fixed, predictable order #1875 might be needed to make sure we don't just reconnect to the same peer
  3. We might be able to re-use the ChangePeerConnections request from Tracking: security: Limit ability of synthetic nodes to take up connection slots. Credit: Ziggurat Team  #7822, but add an "outdated peers only" filter to it.

Possible Implementation

Launch a peer set background task that waits until the block height has changed, checks if it is near a network upgrade, then sends a ChangePeerConnections { disconnect_outdated: true } request.

Then sleep until the next request could be sent, whether a request was sent or not. This avoids locking the state watch channel too much.

Out of Scope

optional changes
  1. When connecting to peers, randomly choose a peer from reconnection_peers, rather than always choosing the first one. To prefer peers that are more likely to reconnect, randomly select two peer indexes using sample, then return the peer at the lower index.

Compatibility

Here are the zcashd parameters:

  • close means height >= (activation_height - NETWORK_UPGRADE_PEER_PREFERENCE_BLOCK_PERIOD)
  • NETWORK_UPGRADE_PEER_PREFERENCE_BLOCK_PERIOD is 1728, or 1.5 days
  • the regular intervals are whenever there is a new connection
  • an outdated peer is a peer that would be disconnected after the upcoming network upgrade

For Zebra, we could use:

  • a regular interval of 5 minutes, but only if we have more than 2 peers, and
  • the same parameters as zcashd

This makes the number of disconnections 2-6 times the peer set size. (The peer limits are 75 outbound and 125 inbound peers.) So if half the peers on the network are upgraded, Zebra should be connected to 75% - 98% upgraded peers when the network upgrade activates.

@teor2345 teor2345 added S-needs-triage Status: A bug report needs triage P-Medium ⚡ C-security Category: Security issues I-remote-node-overload Zebra can overload other nodes on the network A-network Area: Network protocol updates or fixes NU-6 Network Upgrade: NU6 specific tasks labels May 31, 2022
@mpguerra
Copy link
Contributor

@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Mar 16, 2023
@teor2345 teor2345 changed the title Start disconnecting from outdated peers before network upgrade activation Start disconnecting from outdated peers a few days before network upgrade activation Oct 30, 2023
@mpguerra mpguerra modified the milestone: NU6 Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes C-security Category: Security issues I-remote-node-overload Zebra can overload other nodes on the network NU-6 Network Upgrade: NU6 specific tasks
Projects
Status: New
Development

No branches or pull requests

2 participants