optimize key derivation in the wallet #17991
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of deriving the same keys for every wallet, derive the keys once and re-use them for the derived puzzle hashes per wallet.
Since a large block was de-dented, reviewing with white space ignored is highly recommended:
https://github.com/Chia-Network/chia-blockchain/pull/17991/files?diff=split&w=1
Purpose:
Deriving keys is not a cheap operation. Right now, we perform the work of deriving new keys redundantly. We derive the same key for every wallet.
This patch factors out the key derivation to outside of the loop over the wallets. The wallets then use the keys to compute their puzzle hashes, which are what we end up subscribing to.
Current Behavior:
Derive the keys multiple times, once for every wallet.
New Behavior:
Derive the keys once, and re-use them for each wallet.