-
Notifications
You must be signed in to change notification settings - Fork 120
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 the large block heights required by the spec #1113
Comments
Height
to be like Amount
where we guarantee that heights can never be invalid
I'm going to put this in the first stable release milestone, because it will change our interfaces - so it would be good to make a decision about it before stable. |
Previous discussion: #751 (comment) |
Building on this
The other benefit that came up in the recent review was not needing to always handle the case where the height could be invalid when working with heights. I think we might be able to constrain the need for those checks to just the extra ops traits on |
Marking this as a security issue, because calculations on block heights near the maximum height can panic. |
We might also want to reject blocks with really large heights near u32::MAX, when we parse the coinbase height and expiry height. That way, if we ever accidentally expect or unwrap the results of Height arithmetic, Zebra won't panic. I think the largest height we subtract is 100 (coinbase maturity), and the largest height we add is 1 (or maybe 100). |
Motivation
Zebra limits block heights to 500,000,000 based on the transaction lock time consensus rule. But Zcash has a consensus rule requiring support for larger heights.
Zebra has code that adds
1
to the block height, and panics if the result is over the maximum. So these panics could be triggered by malicious nodes that send fake blocks at the maximum height. But this issue also happens if we increase the limit tou32::MAX
. So we should fix those calculations instead.Scheduling
This ticket is a medium security priority due to panics:
unwrap
andexpect
, and add testsThis ticket is a low priority for the current height fields:
If future changes add or subtract from an expiry height, we'll need to remove the 500 million limit on those calculations. Because an expiry height of
u32::MAX
is valid, and could be committed to the chain right now.Consensus Rule
https://zips.z.cash/protocol/protocol.pdf#blockchain
Solution
u32::MAX
at parse time (and generation time)Optional:
u32::MAX - MIN_TRANSPARENT_COINBASE_MATURITY
(the largest number we use in height calculations). That way, if we accidentally unwrap or expect on Height calculations, Zebra won't panic.Already completed in other tickets:
Rejected Alternatives
This alternative is not allowed by the spec, due to recent spec changes:
We don't have to do it as part of this PR but we should probably change
Height
to be likeAmount
where we guarantee that heights can never be invalid. We'll need to make the inner value of the height private and create newTryFrom
impls and probably fix a bunch of code that this breaks across zebra.Originally posted by @yaahc in #1051 (comment)
The text was updated successfully, but these errors were encountered: