Skip to content

fix view key corruption - #436

Open
auruya wants to merge 1 commit into
seraphis-migration:fcmp++-beta-stressnetfrom
auruya:fix-wallet-scan
Open

fix view key corruption#436
auruya wants to merge 1 commit into
seraphis-migration:fcmp++-beta-stressnetfrom
auruya:fix-wallet-scan

Conversation

@auruya

@auruya auruya commented Jul 14, 2026

Copy link
Copy Markdown

Since the output scanning is done in parallel to key image calculation now, we sometimes get a scrambled view key due to a race condition where view key gets read by scan job between the time we encrypt view key before decrypting all keys. This PR adds a couple of new functions to account_keys that excludes view key encryption/decryption directly instead of encrypting/decrypting it each time.

@jeffro256

Copy link
Copy Markdown
Collaborator

This is the job of the wallet2::m_encrypt_keys_after_refresh. If the view-key is being mangled during refresh, then the lifetime of m_encrypt_keys_after_refresh isn't correct. That's where the fix should be IMO

@auruya

auruya commented Jul 15, 2026

Copy link
Copy Markdown
Author

@jeffro256 yes that can be another way to solve it. If that is preferred, I think this scan_key_image call

scan_key_image(*enote_scan_infos.at(i), /*pool=*/false, output_key_images[i], password_failure);
should be moved after
if (!scan_blocks_waiter.wait())
this waiter so that we know no thread is using the view key. Of course this will impact the performance but to reduce the impact we can still do the scan_key_image in parallel.

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