-
Notifications
You must be signed in to change notification settings - Fork 106
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
Require minimal height encodings during deserialization #2226
Comments
Oops, this was meant to go in zcash/zips. |
This is a consensus rule, so I've marked it as a medium priority |
It's { 1 .. 5 } in the current spec (which allows block heights ≥ 231). |
Thanks, I've updated the ticket. |
So it currently allows:
|
I just realised the height is little-endian, I've fixed the examples above. Here is an example that don't use the special one-byte script opcodes:
|
Motivation
Zebra accepts non-minimal height encodings when deserializing, but the spec requires minimal encodings.
The serialization should be correct. But the deserialization accepts some encodings that are longer than they need to be. So they are actually invalid.
Consensus Rules
Here's the relevant consensus rule:
https://zips.z.cash/protocol/protocol.pdf#txnconsensus
Related Consensus Rules
Here is a related consensus rule that limits the number of bytes used by a height:
https://zips.z.cash/protocol/protocol.pdf#blockchain
Existing Code
zebra/zebra-chain/src/transparent/serialize.rs
Lines 44 to 53 in 24bf952
Tests
We don't have any proptests for height bytes round-trips (bytes to
Height
to bytes).There are two different encodings we need to test:
We already have height deserialization tests for every mainnet and testnet block test vector.
Context
Comment by @daira in #2225 (comment)
Support the large block heights required by the spec #1113 - out of scope for NU5
The text was updated successfully, but these errors were encountered: