-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
DefaultFunctionEncoder calculates offset incorrectly for nested structs #2052
Labels
bug
A bug in behaviour or functionality
Comments
Hey @bladekp , thanks for opening the issue. Thanks |
This was referenced May 13, 2024
Looks like fix was prepared by @penuel-leo in #2054 and merged, and was released in https://github.com/hyperledger/web3j/releases/tag/v4.12.0 so I think we can close this issue. Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DefaultFunctionEncoder calculates offset incorrectly for nested structs
Steps To Reproduce
Minimal example:
Note that first argument is StaticStruct having one property which is also StaticStruct, nested one have two Address properties, which is important in this example. Also having dynamic type as second argument is important.
FunctionEncoder.encode(f)
. Result will be:Expected behavior
Offset value in that case should equal to
0x60
.Actual behavior
Offset value is (as you can see above)
0x40
, this is because nested StaticStruct is calculated to have size of 1 (but 2 addresses are inside, so size should be 2).Environment
Additional context
My production case, Im attaching two executions:
0xe0
in my case), failure:0x100
), succeeded:I think the solution is to make
getLength
function recursive, and change line:web3j/abi/src/main/java/org/web3j/abi/DefaultFunctionEncoder.java
Line 102 in 5173684
to
count += getLength(((StaticArray) type).getValue())
The text was updated successfully, but these errors were encountered: