Repository navigation
wollet: skip unchanged blocking scans - #197
ethicnology wants to merge 3 commits into
Conversation
An identical blocking full scan returned Some(Update) whenever no wallet transaction was confirmed at the tip: the tip header was re-downloaded on every scan and every downloaded timestamp counted as a change. Callers persisting and publishing each update did so on every poll. - download a header only when its timestamp is missing or its height is new, take the tip timestamp from the tip header already fetched, and keep only timestamps that differ from the cached ones - compute transaction height additions and deletions before deciding whether to return an update, so a confirmation whose tip was already applied is still reported - treat derivation indices as monotonic, as apply_update does - keep returning an update for UTXO-only scans, which replace the unspent snapshot - expose cached timestamps through WolletState and copy them into WolletConciseState
Regression for the blocking scanner returning an update on identical rescans. The same regtest sequence checks that new transactions, confirmations, new blocks, index expansion, missing or replaced timestamps and a same-height tip replacement still produce one.
agammann
left a comment
There was a problem hiding this comment.
WolletState is a public trait, and this PR adds timestamp(&self, Height) as a required method. Downstream implementations outside this workspace will stop compiling, even though the scanner can conservatively treat an unavailable cached timestamp as None. Could this method have a default implementation returning None, with the built-in states overriding it as they do here? That keeps external implementations source-compatible while still downloading headers when a custom state cannot supply timestamps.
WolletState is public and implemented outside this workspace. Adding timestamp() as a required method broke those implementations, while the scanner can treat an unavailable cached timestamp conservatively. - return None by default: the header is downloaded again and the timestamp counts as changed, as before this optimization - keep the overrides of Wollet and WolletConciseState
|
updated |
agammann
left a comment
There was a problem hiding this comment.
I rechecked head aa1d67c. The default WolletState::timestamp() keeps downstream implementations source-compatible, while the built-in states use cached timestamps for the no-op scan path. The new regtest sequence covers no-op scans, tip and confirmation changes, timestamp repair, and persistence reload. My earlier concern is addressed; I found no further change-specific issue in this diff. I reviewed the code and tests but did not run the regtest suite locally. CI still needs maintainer approval. AI-assisted review.
|
can you please rebase on top of master, we had some related changes touching the same code and conflicting |
Motivation
An identical blocking full-history scan returned another
Updatewhenever no wallet transaction was confirmed at the tip, because the tip header was re-downloaded on every scan and every downloaded timestamp counted as a change. Callers that persist and publish each update (Bull Bitcoin's Liquid wallet) did so after every idle sync.API
BlockchainBackend::full_scan/full_scan_to_indexnow returnNonefor identical rescans. Real changes still returnSome: new, removed or re-heighted transactions, tip changes including a same-height replacement, new scripts, index growth and missing or replaced timestamps.Some, because they replace the unspent snapshot andWolletStateexposes nothing to compare it with.WolletStategainstimestamp(height); it is crate-private in practice (not re-exported), andWolletConciseStatenow carries the cached timestamps. No persistence orUpdateformat change. Asynchronous scanning is unchanged.Tests
test_scan_unchanged(Electrum, regtest) fails on master at the first identical rescan and passes with the fix. The same sequence checks funded and empty wallets, index expansion, a mempool transaction, a confirmation with the tip already applied, timestamp repair and replacement, a same-height tip replacement, a transaction below the tip after a new block, and reload from the legacy store. Alternative states are prepared with the publicUpdateAPI.cargo test -p lwk_wollet --lib: 140 passed, 23 ignored.cargo clippy -p lwk_wollet --all-targets --features electrum,esplora -- -D warningsandcargo fmt --check: clean. Rust 1.91.0, Elements 23.3.3, electrs-liquid 0.4.1.Base: master
7747af34, 2026-11-09.