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

Retry failed RPC calls on error #741

Closed

Conversation

evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Sep 1, 2022

This PR replaces #707 (which attempted to fix #650), but is based on top of work done in #740.

Description

Refer to #707 and #740

I don't think we can ever fix #650 fully, however the work done in this PR seems to reduce the failure rate.

In addition to the work done by @afilini in #707, this PR introduces logic that catches error code -4 during descriptor/scriptPubKey import, and treats it like a successful import (so we continue syncing as usual). The caveat of this is that some sync cycles will miss out on importing some scriptPubKeys/descriptors, but is this better than a complete failure?

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

* [ ] This pull request breaks the existing API
* [ ] I've added tests to reproduce the issue which are now passing

  • I'm linking the issue being fixed by this PR

evanlinjin and others added 5 commits September 1, 2022 11:15
`RpcImportParams` keeps track of the scriptPubKey derivation index to
start from for the next call to `importdescripts`/`importmulti`, thus
avoiding re-importing into Bitcoin Core.
* Add `RpcSyncParams::page_size` that restricts req/resp array count
  for various RPC calls.
* Add `pagenated_import` function.
Whenever the transport errors with "WouldBlock" we wait a bit and retry
the call.

Related to bitcoindevkit#650, should at least fix the errors with RPC
@evanlinjin evanlinjin force-pushed the fix/rpc-retry-on-error branch 4 times, most recently from cafd917 to 9d8cc0c Compare September 1, 2022 16:09
Bitcoin Core returns code -4 during scriptPubKey/descriptor import
when it is still rescanning the wallet. This PR waits until the
rescan completes before continuing sync as if it was a successful
import.

The caveat of this approach is that a sync cycle may miss out on
importing some scriptPubKeys. Also, re-import logic is not ideal as
network interruptions or parallel requests will result in strange
behavior.

TODO: This may not be this best solution.
@evanlinjin
Copy link
Member Author

@afilini do you think this is still worth working on?

@evanlinjin evanlinjin closed this Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

CI: blockchain::esplora::bdk_blockchain_tests::test_sync_stop_gap_20 occationally fails
2 participants