Skip to content

walletdb: don't reinitialize desc cache with multiple cache entries - #19441

Merged
meshcollider merged 1 commit into
bitcoin:masterfrom
achow101:fix-desc-cache-load
Jul 11, 2020
Merged

walletdb: don't reinitialize desc cache with multiple cache entries#19441
meshcollider merged 1 commit into
bitcoin:masterfrom
achow101:fix-desc-cache-load

Conversation

@achow101

@achow101 achow101 commented Jul 4, 2020

Copy link
Copy Markdown
Member

When loading descriptor caches, we would accidentally reinitialize the descriptor cache when seeing that one already exists. This should have only been initializing the cache when one does not exist. However this code itself is unnecessary as the act of looking up the cache to add to it will initialize it if it didn't already exist.

This issue could be hit by trying to load a wallet that had imported a multisig descriptor. The wallet would fail to load.

A test has been added to wallet_importdescriptors.py to catch this case. Another test case has also been added to check that loading a wallet with only single key descriptors works.

When loading descriptor caches, we would accidentally reinitialize the
descriptor cache when seeing that one already exists. This should have
only been initializing the cache when one does not exist. However this
code itself is unnecessary as the act of looking up the cache to add to
it will initialize it if it didn't already exist.

This issue could be hit by trying to load a wallet that had imported a
multisig descriptor. The wallet would fail to load.

A test has been added to wallet_importdescriptors.py to catch this case.
Another test case has also been added to check that loading a wallet
with only single key descriptors works.
@fanquake fanquake added the Wallet label Jul 4, 2020

@jonatack jonatack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK a66a7a1

Without the change in wallet/walletdb.cpp::595-597 the updated test fails on reloading the wallet at line 383 with the error message from DescriptorScriptPubKeyMan::SetCache Error: Unable to expand wallet descriptor from cache (-4).

@hugohn

hugohn commented Jul 8, 2020

Copy link
Copy Markdown
Contributor

tACK a66a7a1

@meshcollider meshcollider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK a66a7a1

Verified the test fails on master and passes with the code change

@meshcollider
meshcollider merged commit 160800a into bitcoin:master Jul 11, 2020
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Aug 31, 2021
Summary:
> When loading descriptor caches, we would accidentally reinitialize the
> descriptor cache when seeing that one already exists. This should have
> only been initializing the cache when one does not exist. However this
> code itself is unnecessary as the act of looking up the cache to add to
> it will initialize it if it didn't already exist.
>
> This issue could be hit by trying to load a wallet that had imported a
> multisig descriptor. The wallet would fail to load.
>
> A test has been added to wallet_importdescriptors.py to catch this case.
> Another test case has also been added to check that loading a wallet
> with only single key descriptors works.

This is a backport of [[bitcoin/bitcoin#19441 | core#19441]]

Test Plan:
`ninja all check-all`

I confirmed that before the change in walletdb.cpp, the new test fails with an error `Error: Unable to expand wallet descriptor from cache (-4)`. And the change fixes it.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D9991
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants