Repository navigation
Conversation
|
👋 Thanks for assigning @tankyleo as a reviewer! |
tankyleo
left a comment
There was a problem hiding this comment.
Could we persist the checkpoint as part of the first write of the wallet? I had codex generate this commit here for illustration: tankyleo@6afa6af
This would avoid persisting an intermediate genesis-only wallet when we intend to start from a later checkpoint. Otherwise, a crash or failed write between wallet creation and checkpoint persistence can leave the wallet starting from genesis on the next build.
When creating a new on-chain wallet, we first persisted it at genesis and only then inserted the checkpoint acting as its birthday, which was never persisted explicitly. It only reached the store because filling the address pool later in the build happens to flush the wallet's staged changes. A crash or failed write in between left a persisted wallet that reloads at genesis and tries to rescan the whole chain, which never succeeds against a pruned bitcoind. We now apply the checkpoint before the wallet is first persisted, so that its initial state always includes the birthday. As BDK can't turn a wallet created in memory into a persisted one, we write that state ourselves and load the wallet back from the persister. Reported-by: vnprclanker Co-Authored-By: HAL 9000
Nothing covered that a node restarted between its first build and its first wallet sync keeps the wallet birthday rather than rescanning from genesis, nor that a rejected build leaves no wallet behind. We add an integration test that builds a fresh node against bitcoind, drops it before it syncs, and checks that the wallet's chain state was written exactly once and that the rebuilt node doesn't pick up a payment confirmed before its birthday. It covers the RPC and REST chain sources, with and without an explicit rescan height. Co-Authored-By: HAL 9000
1eaaa38 to
58941dd
Compare
Alright, adopted that approach. |
When creating a new on-chain wallet, we insert a first checkpoint as
its birthday, but never persisted it explicitly. It only reached the
store because filling the address pool later in the build happens to
flush the wallet's staged changes. Without that side effect, a node
restarted before its first sync would reload the wallet at genesis and
try to rescan the whole chain, which never succeeds against a pruned
bitcoind.
We now persist the wallet right after applying the checkpoint, failing
the build if that doesn't succeed, so the birthday no longer depends
on unrelated wallet persistence.