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

optimize key derivation in the wallet #17991

Merged
merged 1 commit into from May 13, 2024
Merged

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented May 8, 2024

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.

@arvidn arvidn added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label May 8, 2024
…eys for every wallet, derive the keys once and re-use them for the derived puzzle hashes per wallet
@arvidn arvidn marked this pull request as ready for review May 9, 2024 07:28
@arvidn arvidn requested a review from a team as a code owner May 9, 2024 07:28
@arvidn arvidn requested a review from Quexington May 9, 2024 07:28
chia/wallet/wallet_state_manager.py Show resolved Hide resolved
chia/wallet/wallet_state_manager.py Show resolved Hide resolved
chia/wallet/wallet_state_manager.py Show resolved Hide resolved
chia/wallet/wallet_state_manager.py Show resolved Hide resolved
@arvidn arvidn requested a review from Quexington May 9, 2024 20:34
@arvidn arvidn requested a review from emlowe May 10, 2024 10:52
@arvidn arvidn added the ready_to_merge Submitter and reviewers think this is ready label May 10, 2024
@cmmarslender cmmarslender merged commit 41306ad into main May 13, 2024
355 of 356 checks passed
@cmmarslender cmmarslender deleted the wallet-key-derivation branch May 13, 2024 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog ready_to_merge Submitter and reviewers think this is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants