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

Nested memory arrays not implemented in ABICoder V1 #15398

Open
Subway2023 opened this issue Sep 3, 2024 · 0 comments
Open

Nested memory arrays not implemented in ABICoder V1 #15398

Subway2023 opened this issue Sep 3, 2024 · 0 comments
Labels

Comments

@Subway2023
Copy link

Description

When I use abicoderV1 to encode a two-dimensional array, it executes normally. However, when decoding, a code generation error occurs.

Environment

  • Compiler version: 0.8.26
  • Target EVM version (as per compiler settings): None
  • Framework/IDE (e.g. Truffle or Remix): None
  • EVM execution environment / backend / blockchain client: None
  • Operating system: Linux

Steps to Reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma abicoder v1;
contract BuggyContract {
    int[5][] public a;
    function initialize() public {
        a.push([int(1), int(-45), int(-78), int(56), int(60)]);
        a.push([int(-1), int(42), int(334), int(-45455), int(-446)]);
        a.push([int(1), int(10), int(-5435), int(45), int(-7)]);

        bytes memory encodedA2 = abi.encode(a);
        int[5][] memory decodedA2 = abi.decode(encodedA2, (int[5][]));

    }
}

Compile

solc test.sol
Compiler run successful. No output generated.

Codegen

solc test.sol --bin
Unimplemented feature:
/solidity/libsolidity/codegen/CompilerUtils.cpp(287): Throw in function void solidity::frontend::CompilerUtils::abiDecode(const TypePointers&, bool)
Dynamic exception type: boost::wrapexcept<solidity::langutil::UnimplementedFeatureError>
std::exception::what: Nested memory arrays not yet implemented here.
[solidity::util::tag_comment*] = Nested memory arrays not yet implemented here.

Analyse

I believe this is a bug for the following two reasons:

  1. During the compilation phase, there is no error indicating that abicoderV1 does not support two-dimensional arrays. If it were a struct, solc would directly throw an error to indicate this.
  2. abicoderV1 supports encoding two-dimensional arrays, but it does not support decoding them back into two-dimensional arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant