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: After losing all peers synced is never true. #2464

Open
JoeGruffins opened this issue Jan 27, 2025 · 4 comments
Open

spv: After losing all peers synced is never true. #2464

JoeGruffins opened this issue Jan 27, 2025 · 4 comments

Comments

@JoeGruffins
Copy link
Member

JoeGruffins commented Jan 27, 2025

After losing all peers, even if you get them back, synced from the rpc command syncstatus never becomes true.

Can be seen on mainnet:

  1. Start up an spv wallet on mainnet.
  2. After syncstatus returns true for synced turn off your internet.
  3. Wait for getpeerinfo to return an empty list.
  4. Start your internet again.
  5. Check syncstatus after getting peers back and waiting a bit.

Also, if you have logs on trace when turning off peers, you will see the spinning described in #2433

@davecgh
Copy link
Member

davecgh commented Jan 27, 2025

I'm sure @jrick will know better since he's far more familiar with this code and works on it, but I imagine it has to wait for a new block to know it's synced again.

Did you wait long enough to know if that's the case or not?

@JoeGruffins
Copy link
Member Author

Yes. I have waited a few blocks. The change in block number is reflected in getinfo but synced stays false.

@JoeGruffins JoeGruffins changed the title spv: After loosing all peers synced is never true. spv: After losing all peers synced is never true. Jan 27, 2025
@jrick
Copy link
Member

jrick commented Jan 27, 2025

Yeah, I can see how this is occurring. The SPV syncer never does complete teardown (where the main package could recreate the syncer all over again in a loop) when all peers are lost.

This is indicative of a larger issue in this design: we almost certainly want to treat reconnection after all peers drop the same as initial sync, but we only perform initial sync once per syncer instance. I think tearing down the entire syncer (with Run() returning an error) is the best way to work around this problem.

@jrick
Copy link
Member

jrick commented Jan 27, 2025

Please test #2465 to see if it fixes this issue.

I believe this should also fix the cpu spinning as 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

No branches or pull requests

3 participants