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 · 3 comments
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-7 Network Upgrade: NU7 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.

Optional:

  1. 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
  2. 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 mpguerra moved this to 🆕 New in Zebra Sep 22, 2022
@mpguerra mpguerra added this to Zebra Sep 22, 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
@mpguerra mpguerra moved this from New to Sprint Backlog in Zebra Jul 15, 2024
@mpguerra
Copy link
Contributor

We might be able to defer this issue until after testnet activation, although we might also want to test it first on testnet...

@oxarbitrage oxarbitrage self-assigned this Jul 17, 2024
@oxarbitrage oxarbitrage added NU-7 Network Upgrade: NU7 specific tasks and removed NU-6 Network Upgrade: NU6 specific tasks labels Jul 19, 2024
@oxarbitrage
Copy link
Contributor

After internal discussions and feedback from @str4d, we have concluded the following:

  • Both zebrad and zcashd have end-of-support logic. When configured correctly, EOS acts as a first barrier against incompatible peers.
  • zcashd includes logic for star disconnecting peers as we approach a Network Upgrade, which is what we aim to implement in this ticket for Zebra.
  • zcashd will remain the main node for NU6.
  • Introducing this disconnect logic now carries a risk due to insufficient time for testing.
  • This feature will be more crucial for NU7.

Therefore, we have decided to implement this feature, but it is not critical for NU6 development.

@oxarbitrage oxarbitrage removed their assignment Jul 19, 2024
@mpguerra mpguerra removed this from the NU6 milestone Jul 22, 2024
@mpguerra mpguerra moved this from Sprint Backlog to Product Backlog in Zebra Jul 22, 2024
@mpguerra mpguerra added this to the NU7 milestone Sep 5, 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-7 Network Upgrade: NU7 specific tasks
Projects
Status: Product Backlog
Development

No branches or pull requests

3 participants