-
Notifications
You must be signed in to change notification settings - Fork 9
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
Incorrect usage of bytes constructor #15
Comments
I'm not sure, maybe |
Nice catch! I think That said, it's indeed an easy thing to get wrong, at least for the case when the value is equal to the bytevector length. (since it's checked here: remerkleable/remerkleable/byte_arrays.py Line 81 in 94ed7e2
And for a What do you think? |
I agree with you as it's better to throw an exception as it could be not one byte integer but any size and even if we do conversion back it will be useless two-way conversion with new potential for error by filling leading zeros for example. I think we should go exception way |
From the python spec:
A zero-filled bytes object of a specified length: bytes(10)
https://docs.python.org/3.10/library/stdtypes.html#binaryseq
So when initialized with int or something like
0x01
in https://github.com/protolambda/remerkleable/blob/master/remerkleable/byte_arrays.py#L28 you get00
-filled bytes of input length.Broken usage is, for example, here: https://github.com/ethereum/consensus-specs/blame/dev/specs/eip4844/beacon-chain.md#L58
The text was updated successfully, but these errors were encountered: