-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Get StringIndexOutOfBoundsException when receive result as a dynamic array with single struct #1858
Comments
@sweexordious, I know you left the project, but could you please take a look on this? The behaviour is quite odd and I am not sure I got right the idea of bit shift for evaluating next offset. Why does when it parse the 1st item it use the same |
I have got a similar issue when run this function over
It is able to execute the request and even return data, but fails on decoding the returned data. Did you and etherjs author worked independently and didn't use the parse algorithm described somewhere else? |
Most likely an issue with the library. I guess that this is one of the limitations of the decoder that Web3J has. Anyway, that portion of code needs to be refactored and corrected with more tests and all. Since I last worked on it, there have been multiple issues with different edge cases where the library fails. A good approach is to gather them all somewhere and test against them and fix. I suspect it would be a 1 month work at least to have the decoder working perfectly. |
Thank you. It is good to localise the issue. |
You can even be more sure of the issue via adding a test in the abi, but that's a bit of work. You could create your function similar to this: and define your struct like this: Probably, you could get it from the java wrappers. Then add a test similar to this: And see if the issue persists. You have all the ingredients needed to write such thing. |
@sweexordious , thank you, here is PR to spot this issue. |
Title
I get
StringIndexOutOfBoundsException
on the call offunction getMatches(address userFirst, address userSecond) external view override returns (Match[] memory)
. Research shows client receives data, but can not parse it properly.Description
The function
getMatches()
returns dynamic array withstruct
items. A test case return a single item array.The client successfully receives encoded bytecode, but can failed to parse it with error:
As you might see the index is irrelevant.
The encoded result is:
which match to array code, array size and match struct with params:
By debugging I figured out it fails on 128 offset where it tries to represent first item of the
struct
as aDynamicArray
and this is a reason why it returns wrong offset.Context
Relevant
TypeDecoder
code:Relevant code from Android client:
Related PR: #1321
Related issues:
#935
#449
The question is why does it happen? Has been anything changed in dynamic array with struct encoded format over passed 2 years?
The text was updated successfully, but these errors were encountered: