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

Decode input data with bad padding #227

Open
ArielTM opened this issue Feb 14, 2024 · 2 comments
Open

Decode input data with bad padding #227

ArielTM opened this issue Feb 14, 2024 · 2 comments

Comments

@ArielTM
Copy link

ArielTM commented Feb 14, 2024

We want to decode input data sent to old contracts compiled using solc 0.5.16.
In some of the transactions, an address parameter was sent with a none empty padding:

pragma solidity >=0.5.0;

contract TestContract {
    function testInner(address addr) public pure returns(address) {
        return addr;
    }

    function test() public view returns(address) {
        (bool success, bytes memory data) = address(this).staticcall(hex"21803c550000000000000000000022221111111111111111111111111111111111111111");
        require(success, "test error");
        address ret_addr = abi.decode(data, (address));
        return ret_addr;
    }
}

Compiling this with solc 0.5.16 and calling test() will return 0x1111111111111111111111111111111111111111
Compiling this with solc 0.8.24 and calling test() will result in revert.

We want to be able to decode the input data in python without checking for empty padding (strict=False does not apply for fixed length parameters). How can we do this?

@pacrob
Copy link
Contributor

pacrob commented Jul 1, 2024

Why not just compile it with an older compiler version?

@ArielTM
Copy link
Author

ArielTM commented Jul 1, 2024

The above contract is just an example. We want to decode historic transactions to already deployed contacts

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

No branches or pull requests

2 participants