Skip to content

Sync to specific block #1818

Open
Open
@Ash-L2L

Description

@Ash-L2L

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionThere's still a discussion ongoingnew featureNew feature or request

    Type

    No type

    Projects

    Status

    Discussion

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions