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

Stop calculating transaction hashes twice in the checkpoint verifier #2696

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Aug 30, 2021

Motivation

I noticed that we were accidentally calculating transaction hashes twice in the checkpoint verifier.

This could be really inefficient for large blocks and large transactions.

This is unexpected work in sprint 17.

Solution

  • Calculate transaction hashes once for each block
  • Calculate block hashes and heights once for each block
  • Store FinalizedBlocks in the checkpoint verifier
  • Create a new RequestBlock type to simplify a complex method return type

Review

@jvff can review this PR.
It's not urgent at all.

This PR is based on PR #2695, so it might need a rebase after that PR merges.

Reviewer Checklist

  • Code makes sense
  • Existing tests work

@teor2345 teor2345 added A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement C-cleanup Category: This is a cleanup P-Low labels Aug 30, 2021
@teor2345 teor2345 self-assigned this Aug 30, 2021
@teor2345
Copy link
Contributor Author

macOS failed due to a bad set of peers:
https://github.com/ZcashFoundation/zebra/pull/2696/checks?check_run_id=3460265429#step:12:470

I pushed a change anyway, so let's see how CI goes.

jvff
jvff previously approved these changes Aug 30, 2021
Copy link
Contributor

@jvff jvff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. There's only one documentation nit-pick, but feel free to ignore it.

zebra-consensus/src/checkpoint.rs Outdated Show resolved Hide resolved
Base automatically changed from chain-tip-efficient to main August 30, 2021 18:42
@teor2345 teor2345 force-pushed the checkpoint-verifier-efficient branch from 14dde60 to 279b79f Compare August 30, 2021 23:41
@teor2345 teor2345 merged commit 2dac0dd into main Aug 31, 2021
@teor2345 teor2345 deleted the checkpoint-verifier-efficient branch August 31, 2021 00:55
@teor2345
Copy link
Contributor Author

Applied suggestions after approval, and admin-merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants