Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jul 11, 2020

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Jul 4, 2020

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
Copy link
Contributor

@jonatack jonatack left a comment

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
Copy link
Contributor

hugohn commented Jul 8, 2020

tACK a66a7a1

Copy link
Contributor

@meshcollider meshcollider left a comment

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
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 11, 2020
…tiple cache entries

a66a7a1 walletdb: don't reinitialize desc cache with multiple cache entries (Andrew Chow)

Pull request description:

  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.

ACKs for top commit:
  hugohn:
    tACK [a66a7a1](bitcoin@a66a7a1)
  jonatack:
    ACK a66a7a1
  meshcollider:
    Code review ACK a66a7a1

Tree-SHA512: 3df746421a008708eaa3bbbdd12b9ddd3e2ec111d54625a212dca7414b971cc1f6e2b1757b3232c31a2f637d1b1ef43bf3ffa4ac4216646cf1e92db5f79954f1
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.

None yet

5 participants