-
Notifications
You must be signed in to change notification settings - Fork 43
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
Dynamic types encoding doesn't conform to spec #22
Comments
Tried wrapping my head around the code and it was rather difficult... For example, strings as dynamic types are incorrectly encoded and decoded. And in a set of types, like:
results are not correctly padded. |
@pdobacz, 0.3.0 just issued (https://github.com/poanetwork/ex_abi/releases/tag/0.3.0). It should fix issues, that you noticed. Do you still experience incorrect decoding/encoding of dynamic-size types? |
@vbaranov Hi, cool, thank you! I've seen you've extended tests in that PR. Did you use the tests proposed in this issue? (https://github.com/omisego/ex_abi/commits/fix_dynamic_arrays_decoding) |
@vbaranov it seems like .3. wasn't pushed to hex. |
@vbaranov Thank you for the fix! Like above, I can confirm that |
By spec I mean this: https://solidity.readthedocs.io/en/v0.5.13/abi-spec.html#use-of-dynamic-types
In particular:
There was one test that touched this encoding/decoding, but it used the "decodes to binary that it encoded to" assertion, so it passed tests.
I suspect this worked before #14, but got missed there and removed. Now decoding "forgets" the "start of their data area" so it is not possible with the
decode_...
functions currently existing.To spin this up, I added the tests for
type_decoder
to cover this and I did some tidies to facilitate that. Now there's a separation between tests that only useencode |> decode
to test, tests leveraging examples from the spec and tests running on own data examples. New tests fail with exceptions, because things don't pattern match inside the guts of decoding. These tests are in a branch:https://github.com/omisego/ex_abi/tree/fix_dynamic_arrays_decoding
It would be ideal to have the fix for the problem branch off of this branch/commit, so that the tests listed can start to pass and be kept.
(this branch with tests doesn't remove any of the existing tests, at most does some cosmetic refactors and moves them around)
Steps to reproduce
Checkout the branch ☝️ and
mix test
The text was updated successfully, but these errors were encountered: