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

spv: Implement per-peer increasing backoffs #2466

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jrick
Copy link
Member

@jrick jrick commented Jan 27, 2025

Backoff for discovered peers begins at 5s and adds an exponentially-decaying
increase before maxing out at 90s. Persistent peers use a smaller scaled
backoff curve starting at 1s and maxing out at 18s).

All backoffs include a small amount of random jitter to avoid reconnection
storms at syncer startup.

Backoffs are reset if network connection is established to the peer.

Rebased over #2465.

@jrick
Copy link
Member Author

jrick commented Jan 27, 2025

I'm going to also add last attempt tracking, so that when we return to a discovered peer at a later point which already had a backoff chosen, we won't wait for the full backoff duration at the point the peer is chosen again, but only the remaining time (if any).

Copy link

@norwnd norwnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions

chain/sync.go Show resolved Hide resolved
chain/sync.go Show resolved Hide resolved
chain/sync.go Show resolved Hide resolved
chain/sync.go Show resolved Hide resolved
spv/sync.go Outdated Show resolved Hide resolved
@jrick jrick force-pushed the spvbackoff branch 2 times, most recently from 8d278b7 to 2d7ec6d Compare January 27, 2025 20:18
Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I use the internet trick to lose all peers, they never come back and sync stops forever with these changes.

@jrick
Copy link
Member Author

jrick commented Jan 28, 2025

Unsure if it's the exact same case you saw, but when I kill my connections while it is in the middle of the rescan, it never errors out of it, and that seems to hang the whole thing. Will take a closer look in the morning.

@jrick
Copy link
Member Author

jrick commented Jan 28, 2025

Fixed. It wasn't actually hung, just sleeping for a stupidly long timeout.

jrick added 4 commits January 28, 2025 15:02
During clean shutdown, signal the mixing client to shutdown first, waiting for
it to finish running, before closing the RPC and SPV syncers.

Updates the mixing module to a version that supports continuing active mixes
before terminating the mixing client.
Recreate a new syncer in the SPV reconnect loop in main.  This will allow
initial sync logic to be reperformed if peers can be connected later.

This also adds a forced 5s backoff before peers connection attempts are made
again, matching the backoff behavior for RPC syncing.
Backoff for discovered peers begins at 5s and adds an exponentially-decaying
increase before maxing out at 90s.  Persistent peers use a smaller scaled
backoff curve starting at 1s and maxing out at 18s).

All backoffs include a small amount of random jitter to avoid reconnection
storms at syncer startup.

Backoffs are reset if network connection is established to the peer.
Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants