-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support large block heights #3401
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3401 +/- ##
==========================================
+ Coverage 78.34% 78.67% +0.32%
==========================================
Files 267 273 +6
Lines 31526 32322 +796
==========================================
+ Hits 24698 25428 +730
- Misses 6828 6894 +66 |
Co-authored-by: teor <teor@riseup.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, let's merge!
I'd wait until we merge #3408 into this PR. |
#3408) * Fix some outdated TODO comments * refactor(coinbase expiry): Simplify the code so consensus rule is clear * Fix the formatting of an error message * Remove a redundant comment Co-authored-by: Marek <mail@marek.onl> Co-authored-by: Marek <mail@marek.onl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged in the refactor, re-approving
@teor2345 do you recommend adding any particular tests to this PR? |
I think the existing arithmetic tests cover the new height limit pretty well. But we might want to specifically test that |
I'm currently working on tests that test both valid and invalid lock times and expiration heights in actual transactions. I don't think we have those. |
I added tests for expiry heights in V4 transactions, I don't think we had them. I'm setting the heights manually in the tests, but now I'm thinking it might be better to utilize proptest. @teor2345 would you please let me know if I should rewrite the tests and use proptest instead? I also want to add the same tests for V5 transactions. They will be very similar to V4, so I'd like to have the V4 ones approved first. |
This looks good - a single test vector is enough to test this code. We can always make a proptest later if we're not happy with the coverage. But we should get good coverage from running a full sync to tip.
Go for it! |
I finished the tests. I feel like they're bloated because similar semantics and code repeats in separate tests (which are separate functions), but I didn't come up with a reasonable abstraction to make them more concise. The reason was that the tests differ in various small details. |
Thanks! Good test diagnostics are more important than code re-use here, so you've made a good call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation
Zebra currently supports block heights up to and including 4_999_999 while the spec says "Implementations MUST support block heights up to and including 2^31 −1."
Specifications
This PR also documents the following consensus rules:
Solution
This PR increases the block limit to
u32::MAX / 2 == 2^31 - 1
and adjusts the tests. This change leaves enough room for any offsets in order to perform calculations on the height.This PR will close #1113.
Reviewer Checklist