Skip to content

Merge bitcoin/bitcoin#26532: wallet: bugfix, invalid crypted key "checksum_valid" set #144

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

Open
wants to merge 2 commits into
base: backport-0.25-batch-249
Choose a base branch
from

Conversation

DashCoreAutoGuix
Copy link
Owner

Backports bitcoin#26532

Original commit: 5690848

This backport includes the test utility refactoring parts of the original PR. The main bugfix for the crypted key checksum validation is already present in Dash Core. The walletload_tests.cpp file was not included due to significant API differences between Bitcoin and Dash (missing UNKNOWN_DESCRIPTOR error type, different GetNewDestination signature, missing DeleteRecords and SetupGeneration methods).

Backported from Bitcoin Core v0.25

…lid" set

13d9760 test: load wallet, coverage for crypted keys (furszy)
373c996 refactor: move DuplicateMockDatabase to wallet/test/util.h (furszy)
ee7a984 refactor: unify test/util/wallet.h with wallet/test/util.h (furszy)
cc5a5e8 wallet: bugfix, invalid crypted key "checksum_valid" set (furszy)

Pull request description:

  At wallet load time, the crypted key "checksum_valid" variable is always set to false. Which, on every wallet decryption call, forces the process to re-write all the ckeys to db when it's not needed.

  Note:
  The first commit fixes the issue, the two commits in the middle are cleanups so `DuplicateMockDatabase`
  can be used without duplicating code. And, the last one is pure test coverage for the crypted keys loading
  process.

  Includes test coverage for the following scenarios:

  1) "All ckeys checksums valid" test:
  Loads an encrypted wallet with all the crypted keys with a valid checksum and
  verifies that 'CWallet::Unlock' doesn't force an entire crypted keys re-write.

      (we force a complete ckeys re-write if we find any missing crypted key checksum
  during the wallet loading process)

  2) "Missing checksum in one ckey" test:
  Verifies that loading up a wallet with, at least one, 'ckey' with no checksum
  triggers a complete re-write of the crypted keys.

  3) "Invalid ckey checksum error" test:
  Verifies that loading up a ckey with an invalid checksum stops the wallet loading
  process with a corruption error.

  4) "Invalid ckey pubkey error" test:
  Verifies that loading up a ckey with an invalid pubkey stops the wallet loading
  process with a corruption error.

ACKs for top commit:
  achow101:
    ACK 13d9760
  aureleoules:
    ACK 13d9760

Tree-SHA512: 9ea630ee4a355282fbeee61ca04737294382577bb4b2631f50e732568fdab8f72491930807fbda58206446c4f26200cdc34d8afa14dbe1241aec713887d06a0b
Copy link

coderabbitai bot commented Jun 19, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

- Update getNewDestination to use Dash's GetNewDestination signature
- Add missing includes for bilingual_str and std::runtime_error
- Adapt wallet test util functions for Dash API differences

This fixes compilation issues with the wallet test utilities backported from Bitcoin.
@DashCoreAutoGuix
Copy link
Owner Author

⚠️ Backport Verification - Issues Fixed but Incomplete

Original Bitcoin commit: 5690848df
Changes pushed to branch: backport-0.25-batch-249-pr-26532
Fix commit: fdd1a30f6e

Issues Found and Fixed:

  1. ✅ API Compatibility Fixed: Updated getNewDestination function to use Dash's GetNewDestination signature
  2. ✅ Missing Includes Added: Added util/translation.h and <stdexcept> for bilingual_str and std::runtime_error

Critical Issues Remaining:

  1. ❌ Major Incomplete Backport: This PR is only 51.5% of Bitcoin's original size (should be 80-150%)
  2. ❌ Missing Test File: The main test file src/wallet/test/walletload_tests.cpp (135+ lines) was excluded
  3. ❌ Missing Benchmark Changes: Several benchmark file modifications from Bitcoin were not included

Validation Results:

  • Size validation: FAIL (51.5% vs required 80-150%)
  • File count: Bitcoin had 12 files, Dash has 8 files
  • Missing content: Major test coverage and benchmark updates

Assessment:

While the core bug fix is already present in Dash (the checksum_valid fix in src/wallet/walletdb.cpp), this backport is fundamentally incomplete. The PR description acknowledges excluding walletload_tests.cpp due to "API differences," but this represents the main value of the Bitcoin PR.

Recommendations:

  1. Either: Complete the backport by adapting walletload_tests.cpp to Dash's API patterns
  2. Or: Close as "not applicable" since the main bug fix is already present and the test infrastructure isn't compatible

Current Status: The fixes I applied resolve compilation issues, but the underlying backport remains incomplete. ⚠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants