fix: reject mismatched HD chain wallet records#7383
Conversation
|
@coderabbitai review |
✅ Action performedReview finished.
|
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughIn Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
✅ Review complete (commit 8fbae2b) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Small, well-scoped fix that converts an assert over the HD chain record-type invariant into a graceful wallet load error. strType is the branch discriminator so it is set before the early return, and WalletBatch::IsKeyType() already covers HDCHAIN/CRYPTED_HDCHAIN so the loader surfaces DBErrors::CORRUPT instead of aborting. New unit tests exercise both mismatch directions; all four agents converged on zero findings.
Note: GitHub does not allow me to approve my own PR, so this is posted as a COMMENT while preserving the clean exact-SHA review.
Replace the assert in ReadKeyValue that compared the DB record's key type against CHDChain::IsCrypted() with a wallet load error. A wallet whose record type and payload disagree is corrupt, not a programmer bug, and should not abort the process. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e85b88f to
8fbae2b
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Single-commit fix replacing an aborting assert in ReadKeyValue with a graceful wallet-load error on HD chain type/payload mismatch. Verified: strType is HDCHAIN/CRYPTED_HDCHAIN at the return-false point, both are in IsKeyType(), so LoadWallet classifies the failure as DBErrors::CORRUPT — matching the surrounding HDPUBKEY corrupt pattern. Latest delta only consolidates the new tests into the existing walletdb_tests suite by promoting it to WalletTestingSetup, which does not affect the pre-existing stream-deserialization test. Prior review at e85b88f was clean and no findings carry forward (prior_findings_status: []).
Note: GitHub does not allow me to approve my own PR, so this is posted as a COMMENT while preserving the clean exact-SHA review.
|
CI scope check for the current red jobs on This PR only changes: The That test is already tracked as intermittent in #7310; I added this run as new evidence there. There is also a current The PR fix remains proper as-is: the branch touches only local wallet record loading/tests, while both red checks are pre-existing functional-test timing/sync flakes outside the PR diff. |
Issue being fixed or feature implemented
Malformed wallet database records can currently trip a process assertion while
loading HD chain state. A wallet database whose HD chain key type disagrees with
the serialized chain encryption flag is corrupt input and should be reported as
a wallet load error instead of aborting the process.
What was done?
Changed
ReadKeyValueto validateHDCHAIN/CRYPTED_HDCHAINrecords with anormal conditional check. When the key type and serialized
CHDChainstate donot match, wallet loading now returns a descriptive database error.
Added focused unit coverage for both mismatch directions.
How Has This Been Tested?
Ran:
git diff --check upstream/develop...HEAD src/test/test_dash --run_test=walletdb_hdchain_tests code-review dashpay/dash upstream/develop e85b88f74882b2ecf437cbce56441177e1955e11 "Reject mismatched HDCHAIN/CRYPTED_HDCHAIN wallet records gracefully instead of asserting during wallet load"The pre-PR review gate returned
ship.Breaking Changes
None.
Checklist: