-
Notifications
You must be signed in to change notification settings - Fork 349
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
Introduce evicted-at
/last-evicted
timestamps
#1839
Open
evanlinjin
wants to merge
6
commits into
bitcoindevkit:master
Choose a base branch
from
evanlinjin:evicted_at
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6dc26c4
to
0fcc097
Compare
540a83f
to
5107b3a
Compare
5718a3e
to
07903a8
Compare
evicted-at
/last-evicted
timestamps
8 tasks
This is a set of evicted txs from the mempool.
The evicted-at and last-evicted timestamp informs the `TxGraph` when the transaction was last deemed as missing (evicted) from the mempool. The canonicalization algorithm is changed to disregard transactions with a last-evicted timestamp greater or equal to it's last-seen timestamp. The exception is when we have a canonical descendant due to rules of transitivity. Update rusqlite_impl to persist `last_evicted`. Also update docs: * Remove duplicate paragraphs about `ChangeSet`s. * Add "Canonicalization" section which expands on methods that require canonicalization and the associated data types used in the canonicalization algorithm.
The spk history returned from Electrum should have these txs present. Any missing tx will be considered evicted from the mempool.
* `TxGraph::try_list_expected_spk_txids` * `TxGraph::list_expected_spk_txids` * `IndexedTxGraph::try_list_expected_spk_txids` * `IndexedTxGraph::list_expected_spk_txids` Co-authored-by: valued mammal <valuedmammal@protonmail.com> Co-authored-by: Wei Chen <wzc110@gmail.com>
Co-authored-by: Wei Chen <wzc110@gmail.com>
Co-authored-by: Wei Chen <wzc110@gmail.com>
07903a8
to
9d6c795
Compare
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially Fixes #1740.
Replaces #1765.
Replaces #1811.
Description
This PR allows the receiving structures (
bdk_chain
,bdk_wallet
) to detect and evict incoming transactions that are double spent (cancelled).We add a new field to
TxUpdate
(TxUpdate::evicted_ats
), which in turn, updates thelast_evicted
timestamps that are tracked/persisted byTxGraph
. This is similar to howTxUpdate::seen_ats
update thelast_seen
timestamp inTxGraph
. Transactions with alast_evicted
timestamp higher than theirlast_seen
timestamp are considered evicted.SpkWithExpectedTxids
is introduced inSpkClient
to track expectedTxid
s for eachspk
. During a sync, if anyTxid
s fromSpkWithExpectedTxids
are not in the current history of anspk
obtained from the chain source, thoseTxid
s are considered missing. Support forSpkWithExpectedTxids
has been added to bothbdk_electrum
andbdk_esplora
chain source crates.The canonicalization algorithm is updated to disregard transactions with a
last_evicted
timestamp greater than or equal to theirlast_seen
timestamp, except in cases where transitivity rules apply.Notes to the reviewers
This PR does not fix #1740 for block-by-block chain source (such as
bdk_bitcoind_rpc
). This work is done in a separate PR (#1857).Changelog notice
TxUpdate::evicted_ats
which tracks transactions that have been replaced and are no longer present in mempool.TxGraph
to tracklast_evicted
timestamps. This is when a transaction is last marked as missing from the mempool.last_evicted
timestamp greater than or equal to it'slast_seen
timestamp, except when a canonical descendant exists due to rules of transitivity.SpkWithExpectedTxids
inspk_client
which keeps track of expectedTxid
s for eachspk
.bdk_electrum
andbdk_esplora
to understandSpkWithExpectedTxids
.SyncRequestBuilder::expected_txids_of_spk
method which adds an association betweentxid
s andspk
s.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: