Repository navigation
Keep a refill's address reveals out of unrelated wallet persists - #1269
Open
shubhamkmr04 wants to merge 1 commit into
Open
shubhamkmr04 wants to merge 1 commit into
shubhamkmr04 wants to merge 1 commit into
Conversation
A failed pool-record write left the refill's address reveals in the persister's pending change set, which every other persist call flushes. An unrelated persist that succeeded next made them durable while no pool record covered them, so after a restart their indices were never pooled or handed out again, widening the gap a restore from seed must scan across. Stage the refill's reveals in a change set of their own, which only `persist_staged` merges into the pending one, after the refill's record write succeeded. The fix and the persister-level test are the ones proposed in lightningdevkit#1213, adapted to current main. Fixes lightningdevkit#1213. Developed with assistance from Claude Code.
|
I've assigned @tnull as a reviewer! |
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.
Fixes #1213.
When the address pool's refill fails to write the pool record, it keeps the addresses it just revealed with the persister and skips flushing them, so no index becomes durable without record coverage. But it kept them in the pending change set that every other persist call flushes. A sync or transaction persist that succeeded next made them durable anyway, and after a restart those indices were never pooled or handed out again. Repeated with no deposit in between, the gap could grow past the full-scan stop gap, and a restore from seed would miss later funds.
Changes
KVStoreWalletPersistergets a separatestaged_change_set.stage()now merges into it, and onlypersist_staged()moves it into the pending set, which the refill calls only after its record write succeeded.persist_changeset()flushes the pending set alone. This is the approach proposed in Unrelated wallet persists can flush address reveals the pool record does not cover #1213, with its names, adapted to current main.An aborted refill still loses nothing: its reveals stay staged for the next refill, or die with the process and are re-derived to the same indices.
Tests
failed_pool_record_prevents_unrelated_flush_of_reveals(persister): the regression test from Unrelated wallet persists can flush address reveals the pool record does not cover #1213.failed_pool_record_write_keeps_reveals_out_of_unrelated_persists(wallet): a refill whose record write fails, then an unrelated persist and a reload. The persisted external derivation index must not have advanced.Both fail without the fix. The existing pool tests, including
aborting_a_refill_mid_persist_loses_no_revealsandpool_survives_a_crash_at_any_point_during_refill, still pass.No CHANGELOG entry, as the address pool hasn't been released yet.
This change was developed with the assistance of Claude Code.