Skip to content

Sync to specific block #1818

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

Open
Ash-L2L opened this issue Feb 2, 2025 · 0 comments
Open

Sync to specific block #1818

Ash-L2L opened this issue Feb 2, 2025 · 0 comments
Labels
discussion There's still a discussion ongoing new feature New feature or request

Comments

@Ash-L2L
Copy link

Ash-L2L commented Feb 2, 2025

Describe the enhancement
Currently, there is no way to sync a Wallet to a specific block (and no further).
One can specify an initial chain tip in a sync request, but there is no way to specify a target chain tip. A sync always ends with the current best tip.
There is no way to disconnect a wallet tip either, so syncing to current best tip and then disconnecting blocks is not possible (#1271, #1655).

It should be possible to either:

Use case
In an application that needs to keep a wallet in sync with some other component that updates on each new tip (eg. a mempool), an initial sync process is quite awkward:

  1. Load wallet
  2. Subscribe to sequence/rawblock/hashblock
  3. Sync wallet
  4. Sync other component to wallet tip
  5. Persist wallet
  6. Ignore tip updates older than wallet tip
  7. For each new tip, apply block to wallet and other component, and persist wallet

In particular, the requirement to sync a wallet to the current tip before anything else is a constraint on application architecture - it is more complex to perform initial sync concurrently, since a wallet may sync to a different tip than another component. If that other component also does not support disconnecting blocks, one needs to repeatedly attempt to sync each to the same block.

If specifying a target chain tip for sync was possible, an initial sync process could look like

  1. Load wallet
  2. Subscribe to sequence/rawblock/hashblock
  3. Get current best tip
  4. Sync & persist wallet, sync other component to best tip
  5. Ignore tip updates older than wallet tip
  6. For each new tip, apply block to wallet and other component, and persist wallet

If disconnecting blocks was possible, an initial sync process could look like

  1. Load wallet
  2. Subscribe to sequence/rawblock/hashblock
  3. Get current best tip
  4. Sync wallet, sync other component to best tip
  5. If wallet tip is behind best tip, connect blocks; If wallet tip is ahead, disconnect blocks
  6. Persist wallet
  7. Ignore tip updates older than shared tip
  8. For each new tip, apply block to wallet and other component, and persist wallet
@oleonardolima oleonardolima added new feature New feature or request discussion There's still a discussion ongoing labels Feb 2, 2025
@notmandatory notmandatory moved this to Discussion in BDK Chain Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion There's still a discussion ongoing new feature New feature or request
Projects
Status: Discussion
Development

No branches or pull requests

2 participants