-
Notifications
You must be signed in to change notification settings - Fork 36
Bug. Decoding 0x80 / Encoding and decoding of 0 #28
Comments
It seems like in the tests, 0 is treated as a null value. This goes against the spec from what I understand. Can I submit a PR fixing this? |
Yes please! Can you also give a reference to the part in the spec (Yellow Paper) to ease the reviewers job. |
Awesome, will do. |
Just as a note here for reference: there are also 0-issues in These have to be addressed and might be connected to the issue here. |
(as an on-top note: the issues in ethereumjs-tx for me seems to be so grave that I am totally puzzled why this hasn't been discovered before) |
Found wiki here: https://github.com/ethereum/wiki/wiki/RLP |
when using rlp, we need two level ser/der protocol:
The RLP spec most describe the latter one, leaving the high level protocol to decide how to convert the high level objects to rlp objects. The exception is that how the unsigned integer as a high level object should converte to rlp objects, this is used to encode the list
When doing rlp decoding, the output should be in the scope of rlp objects, so the The real problem, imo, is that rlp and all implementations do not distinguish the In our own rlp implementation, each high level object type is defined as a byte-string type (integer, string, float, etc) or a nest-list type (list, map, struct), and convert to null as following:
|
Copying my comment from #32:
|
The rlp encoding of 0 is 0x80.
decoding 0x80 should return 0x0. The source returns an empty buffer which is incorrect.
rlp.decode(rlp.encode(0))
returnsBuffer.from([])
instead of 0.The text was updated successfully, but these errors were encountered: