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

change(chain): Refactor the handling of height differences #6330

Merged
merged 22 commits into from
Mar 29, 2023

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Mar 15, 2023

Motivation

Close #6279.

Solution

This PR handles height differences similarly to chrono::DateTime and chrono::Duration.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

@upbqdn upbqdn requested review from a team as code owners March 15, 2023 15:53
@upbqdn upbqdn requested review from arya2 and removed request for a team March 15, 2023 15:53
@github-actions github-actions bot added C-enhancement Category: This is an improvement C-feature Category: New features labels Mar 15, 2023
@upbqdn upbqdn added A-rust Area: Updates to Rust code P-High 🔥 C-audit Category: Issues arising from audit findings and removed C-enhancement Category: This is an improvement C-feature Category: New features labels Mar 15, 2023
@upbqdn upbqdn self-assigned this Mar 15, 2023
@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #6330 (3238412) into main (e982a43) will increase coverage by 0.05%.
The diff coverage is 88.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6330      +/-   ##
==========================================
+ Coverage   77.69%   77.74%   +0.05%     
==========================================
  Files         304      304              
  Lines       39585    39639      +54     
==========================================
+ Hits        30756    30818      +62     
+ Misses       8829     8821       -8     

@arya2 arya2 changed the title change(chain): Unify Sub and Add for Height change(chain): Unify Sub and Add trait impls for Height Mar 15, 2023
@upbqdn
Copy link
Member Author

upbqdn commented Mar 15, 2023

Tests for GBT RPCs are failing. I forgot to run them locally. I'm working on that.

@github-actions github-actions bot added C-enhancement Category: This is an improvement C-feature Category: New features labels Mar 15, 2023
@upbqdn
Copy link
Member Author

upbqdn commented Mar 15, 2023

Tests for GBT RPCs are failing. I forgot to run them locally. I'm working on that.

Fixed.

arya2
arya2 previously approved these changes Mar 16, 2023
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

This looks excellent!

Feel free to ignore the couple trivial suggestions.

zebra-chain/src/chain_tip.rs Outdated Show resolved Hide resolved
zebra-consensus/src/block/subsidy/general.rs Outdated Show resolved Hide resolved
Co-authored-by: Arya <aryasolhi@gmail.com>
arya2
arya2 previously approved these changes Mar 17, 2023
@mpguerra
Copy link
Contributor

@upbqdn is going to be out for this week. Do we want to do anything with this PR in the meantime or should it wait until he gets back?

@teor2345
Copy link
Collaborator

@upbqdn is going to be out for this week. Do we want to do anything with this PR in the meantime or should it wait until he gets back?

@arya2 and I have enough context to finish it off, the remaining comments are mainly tweaks. I think it would be good to finish it to avoid merge conflicts with other work.

@teor2345 teor2345 added C-cleanup Category: This is a cleanup and removed C-enhancement Category: This is an improvement C-feature Category: New features labels Mar 28, 2023
@github-actions github-actions bot added C-enhancement Category: This is an improvement C-feature Category: New features labels Mar 28, 2023
@teor2345
Copy link
Collaborator

It turns out if we make HeightDiff an i64, a whole lot of expect(), as, and other tricky interim checks go away. See a765be4 & 7ac8b89.

(We still have to check at the end of each calculation.)

@teor2345 teor2345 requested a review from arya2 March 28, 2023 23:33
@teor2345
Copy link
Collaborator

@arya2 this is ready for a re-review, the changes were a bit more substantial than I thought, but they helped remove a lot of code that's tricky to review.

I can do a video review if that would help?

Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

This looks great!

I left a couple optional suggestions, feel free to ignore either or both of them.

zebra-chain/src/block/height.rs Show resolved Hide resolved
mergify bot added a commit that referenced this pull request Mar 29, 2023
mergify bot added a commit that referenced this pull request Mar 29, 2023
@mergify mergify bot merged commit 2a48d4c into main Mar 29, 2023
@mergify mergify bot deleted the unify-sub-and-add-for-heights branch March 29, 2023 23:06
@arya2 arya2 mentioned this pull request Apr 18, 2023
36 tasks
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-audit Category: Issues arising from audit findings C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement C-feature Category: New features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NCC-E005955-XVE] zebra-chain: Inconsistent error management in Add and Sub for Height
4 participants