-
Notifications
You must be signed in to change notification settings - Fork 997
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
Use custom types in data structures #667
Comments
Agreed this improves readability! We can even define a |
Cool! I can take care of PR then.
|
I'm not sure if I like it or not. Some notes:
|
What's left 'raw'
(some may be outdated or missing since we didn't yet migrate from Spec v0.1)
|
This draft PR try to fix a longstanding wart (see #196, #371, #667) regarding bitfields. We define bitfields as lists or vectors of `bool`s, as opposed to `bytes`. Benefits: * Remove ugly-as-hell helper function `verify_bitfield` * No more bit manipulation with `justification_bitfield` * Merkleisation-friendly `justification_bitfield` (i.e. `justification_bitfield` does not change unless a new epoch is justified). * Easy parametrisation of the number of bits in `justification_bitfield` (can be more or fewer than 64—more may be useful for dApps and light clients) * Semantically cleaner typing This requires a minor SSZ change (Merkleisation not affected) where lists and vectors of `bool`s should be packed, similar to packing of `uintN`. We could alias `bool` to `uint1` so that the packing logic only needs to be defined once for `uintN`.
Closing in favour of #1156 :) Sorry it too this long @Nashatyrev. Feel free to review that PR. |
As soon as there are strict custom types for helper functions may be it makes sense to use them appropriately for data structures members like below.
In our Java implementation we already converted the structures members (like this) and constants (like this) to custom types (where applicable) which significantly improved readability and type safety.
The text was updated successfully, but these errors were encountered: