-
Notifications
You must be signed in to change notification settings - Fork 412
Description
The logic of missing_heights is explained clearly in this comment:
// Usually, if a height of a tx anchor is missing from the chain, we would want to return
// this height in the iterator. The exception is when the tx is confirmed in chain. All the
// other missing-height anchors of this tx can be skipped.However, if a transaction is confirmed in a block that is about to turn stale (get reorged out), we
still want to fetch the new block hash. I suspect this is where our "transaction is never confirmed"
bug comes from.
My proposed solution:
Change the exception to:
// ... The exception is when the tx is confirmed in chain with a depth greater than the provided
// `max_reorg_depth`.And we change the signature of the method to be:
pub fn missing_heights<'a>(
&'a self,
chain: &'a LocalChain,
max_reorg_depth: u32,
) -> impl Iterator<Item = u32> + 'a { todo!() }With some nice documentation for max_reorg_depth.
An alternative solution:
Remove the stated "exception". We can continue to consider a height "missing" when there is a
floating anchor at that height (anchor that does not point to a block in the best chain).
The downside of this approach is that there are situations where certain heights will always be
considered "missing". I think this is somewhat acceptable as reorgs are rare and this situation only
happens due to reorgs.
Because of the behavior change, if we do this solution, we should rename the method to
floating_anchor_heights.
How to reproduce with bdk_esplora:
The following should be written as a test.
- Wallet receives money via transaction (A).
- Transaction gets confirmed at confirmation height (h).
- (Sync wallet with
bdk_esplora), - A reorg happens, and (A) gets re-confirmed at height (h') where
h' >= h. - (Sync wallet with
bdk_esplora). - At this point onwards, transaction (A) is forever stuck as unconfirmed!
Going forward:
The test should be written first while we wait for the discussion on which solution to do matures.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status