-
Notifications
You must be signed in to change notification settings - Fork 92
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
Rlp decoding fails for byte strings that also happen to be hex. #292
Comments
How do i replicate this error ? @RogerPodacter |
If you run |
Okay! I have a fix. I will send in a PR now, maybe you can review as well and test. |
This is a temporary draft PR that you can test. @RogerPodacter Also bringing in @q9f for visibility. |
That PR looks good! However there will still be a bug if any RLP-encoded byte string happens to consist of all hex chars due to the This is a problem elsewhere as well and though it stems from a noble desire to make things “just work” for the user and most of the time it’s fine, in production contexts consistent behavior is important. Anyway, that’s a larger topic. For the moment your PR looks good and is a definite improvement! |
Duly noted! I can check other pointers, however we can get this merged. Thanks |
I think the problem is not RLP coder but the utility function that handles binary versus hexstrings. I just discovered this: Util.bin_to_hex Util.hex_to_bin "a"
=> "a0"
Ok this is just me confusing the nibble sin Ruby's pack library. I got a fix incoming for this. Sorry for the slow response, I'm not spending so much time on this library anymore. |
@RogerPodacter can you check if #298 works for you? |
For example,
Eth::Rlp.decode(Eth::Rlp.encode("a"))
throwsRLP string ends with -32 superfluous bytes (Eth::Rlp::DecodingError)
The issue is the hex conversion here: https://github.com/q9f/eth.rb/blob/main/lib/eth/rlp/decoder.rb#L34
The text was updated successfully, but these errors were encountered: