Repository navigation
Conversation
The tracker depends only on bdk_chain, bitcoin, serde and ContractId, but it lived in the `wallet` module, which is gated behind `manager`. A stateless wallet built on `ddk::contract` had to carry its own copy. It moves to `ddk::contract::tracker`; `ddk::wallet::contract_tracker` re-exports it so manager users' imports keep working. Three methods come from that copy: - `expected_spk_txids` lists the txids a sync should still find under the funding scripts. DDK's own tracker sync now passes them, the same way the wallet sync already does, so a replaced or dropped CET is evicted instead of staying canonical in the graph. - `transaction` returns a transaction the tracker has seen. - `staged` borrows the staged changeset, so a persister clears it only once the write is durable. DDK's sync now does that instead of taking the changeset before a write that can fail.
This file contains hidden or 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
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.
Summary
Item 4 of #225.
ContractUtxoTrackerdepends only onbdk_chain,bitcoin,serdeandContractId, but it lived under themanager-onlywalletmodule, so the Lygos wallet carried a 415-line copy. It now lives atddk::contract::tracker, builds withdefault-features = false, and has the three methods the Lygos copy added.Changes
wallet/contract_tracker.rstocontract/tracker.rs.ddk::wallet::contract_trackerstays as a re-export, so manager users' imports don't change.ContractUtxoTracker:expected_spk_txids(&LocalChain) -> Vec<(ScriptBuf, Txid)>transaction(&Txid) -> Option<Arc<Transaction>>staged() -> Option<&ChangeSet>besidetake_stagedexpected_spk_txids, through the same builder call the wallet sync uses. Before this, a replaced or dropped CET stayed canonical in the tracker graph.bdk_chain'sserdefeature directly. It used to come in only throughbdk_wallet.Known edge (not fixed here)
bdk_esplorastamps evictions and sightings in one sync with the samestart_time, andbdk_chainkeeps a transaction canonical only whilelast_evicted < last_seen. If Esplora's script history leaves out a known CET while the outpoint lookup in the same sync reports it, the CET drops out of the canonical view. That needs Esplora to contradict itself within one sync, and it already applies to DDK's wallet sync. If it needs fixing, the fix belongs in the shared sync step (or upstream inbdk_esplora), not in a tracker-only filter.Interaction with the other #225 PRs
The own-broadcast grace PR (item 5) filters evictions in the wallet sync. The tracker only learns transactions from chain sync, never from local broadcast inserts, so the tracker sync doesn't need the grace today.
Testing
dropped_cet_is_evicted_by_a_sync_with_expected_txids: a CET left the mempool, and a sync built fromexpected_spk_txidsevicts it and restores the funding output.staged_changes_stay_until_taken.cargo test -p ddk --lib: 82 passed, including the wallet tests against regtest.cargo test -p ddk --test enumeration -- --ignored: passed. This is the full lifecycle through the tracker sync.contract_tracker_round_tripspasses on sled. The postgres variant couldn't start locally (the embedded postgres needslibxml2.so.2), so CI covers it.cargo fmt --check,cargo clippy -- -D warningsandcargo check -p ddk --no-default-featurespass.