Skip to content
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

Wrong encoding and decoding tests for two-dimensional variadic arrays #1570

Closed
abdulowork opened this issue Apr 20, 2018 · 2 comments
Closed
Assignees
Labels
Bug Addressing a bug

Comments

@abdulowork
Copy link

Encoding of two-dimensional variadic arrays in these tests is wrong:

https://github.com/ethereum/web3.js/blob/f15caf13c91682cccd7b7762b80feadb9fb969dc/test/coder.encodeParam.js#L43-L64

I took these tests for my own implementation of ABI encoding and found out that contracts would not deploy when I wrote some integration tests. These tests are built on the premise that offset of dynamic elements in a dynamic collection should be counted from the beginning of the whole encoding. The correct encoding is that offset is counted from the beginning of the dynamic collection regardless of the position of the dynamic collection in the whole encoding.

Here is a deployed contract using a correct encoding in the ctor: https://kovan.etherscan.io/address/0x812b72fa1fb3b842cb193d743a44ec8439c9a060#readContract

Here is my corrected version of the tests zeriontech/Web3Swift@8ab1f12
I would be very grateful if you star my project if that information was of any help : )

abdulowork added a commit to abdulowork/web3.js that referenced this issue Apr 27, 2018
abdulowork added a commit to abdulowork/web3.js that referenced this issue Apr 27, 2018
abdulowork added a commit to abdulowork/web3.js that referenced this issue Apr 27, 2018
@abdulowork abdulowork changed the title Wrong encoding tests for two-dimensional variadic arrays Wrong encoding and decoding tests for two-dimensional variadic arrays Apr 27, 2018
@abdulowork
Copy link
Author

You can also observe the correct encoding if you call the data() for a simple getter contract like:

pragma solidity ^0.4.23;
pragma experimental ABIEncoderV2;

contract SimpleGetter {
    
    address[][] public _data = [[0x407d73d8a49eeb85d32cf465507dd71d507100c1,0x407d73d8a49eeb85d32cf465507dd71d507100c2],[0x407d73d8a49eeb85d32cf465507dd71d507100c3,0x407d73d8a49eeb85d32cf465507dd71d507100c4]];
    
    function data() external view returns (address[][]) {
        return _data;
    }

}

@nivida nivida self-assigned this Aug 9, 2018
@nivida nivida added the In Progress Currently being worked on label Aug 9, 2018
@nivida nivida added Bug Addressing a bug and removed In Progress Currently being worked on labels Nov 28, 2018
@nivida
Copy link
Contributor

nivida commented Jan 22, 2019

This should be fixed since I've implemented the new ABICoder. Could you test it and drop a comment here if not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

2 participants