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

fix: reduce cost of signer key-search algorithm with pre-compute table #129

Merged
merged 8 commits into from
Jun 28, 2022

Conversation

bhgomes
Copy link
Contributor

@bhgomes bhgomes commented Jun 22, 2022

Signed-off-by: Brandon H. Gomes bhgomes@pm.me

Before this PR, the signer key-search algorithm would re-compute every viewing key within the search range on every insertion of a UTXO. Now, we use a dynamic program that replaces the viewing key computation with a lookup if the key has already been computed. To prevent run-away growth of this table we have a max capacity set to 16 times the GAP_LIMIT (currently set to 20), a very unlikely limit to be reached except for implementation errors or purposeful memory attacks.

This PR also adds some utility functions for B-Trees.

Focus Files:

  • manta-accounting/src/wallet/signer.rs
  • manta-accounting/src/key.rs

Before we can merge this PR, please make sure that all the following items have been checked off:

  • Linked to an issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Added one line describing your change in CHANGELOG.md and added the appropriate changelog label to the PR.
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Checked that changes and commits conform to the standards outlined in CONTRIBUTING.md.

Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
@bhgomes bhgomes added this to the v0.5.2 milestone Jun 22, 2022
@bhgomes bhgomes requested review from BoyuanFeng, stechu, Kevingislason and a user June 22, 2022 19:26
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
@bhgomes bhgomes marked this pull request as ready for review June 22, 2022 19:29
@bhgomes bhgomes added changelog:fixed Changelog: add these changes to the `fixed` section of the changelog norelease labels Jun 22, 2022
@ghost
Copy link

ghost commented Jun 23, 2022

out

manta-accounting/src/key.rs Outdated Show resolved Hide resolved
manta-accounting/src/key.rs Show resolved Hide resolved
manta-accounting/src/wallet/signer.rs Show resolved Hide resolved
@bhgomes bhgomes merged commit 128c55c into main Jun 28, 2022
@bhgomes bhgomes deleted the fix/reduce-key-rederivations branch June 28, 2022 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:fixed Changelog: add these changes to the `fixed` section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants