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

New ABI decoder fails on arrays of dynamic types as calldata #3293

Closed
axic opened this issue Dec 8, 2017 · 4 comments
Closed

New ABI decoder fails on arrays of dynamic types as calldata #3293

axic opened this issue Dec 8, 2017 · 4 comments
Labels
Projects

Comments

@axic
Copy link
Member

axic commented Dec 8, 2017

pragma experimental ABIEncoderV2;

contract C {
  function f(string[]) external {}    
}

throws assertion

Internal compiler error during compilation:
/Users/alex/Projects/solidity/libsolidity/codegen/ABIFunctions.cpp(1188): Throw in function string dev::solidity::ABIFunctions::abiDecodingFunctionCalldataArray(const dev::solidity::ArrayType &)
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
std::exception::what: 
[dev::tag_comment*] = 

Which means arrays of dynamic types cannot be decoded as calldata. Though changing it to public will make it working, because the decoder is invoked elsewhere.

@axic axic added the bug 🐛 label Dec 9, 2017
@carver
Copy link

carver commented Feb 13, 2018

Is this maybe related to external functions handling strings a little differently in ABI encoding? See my open question: https://ethereum.stackexchange.com/questions/39418/why-do-public-and-external-functions-emit-strings-differently-in-event-logs

I posted #3493 to track that issue.

@chriseth
Copy link
Contributor

This is unimplemented mainly due to the fact that we did not yet decide how such types are stored on the stack. It was not a problem for the old decoder because it only supported one-dimensional arrays. Those are stored with two stack items: offset and size.

I guess if we know the type, it should still be possible to do that by just storing the type. Still, a lot of infrastructure is still missing - you cannot copy multi-dimensional calldata arrays to memory or storage.

@axic
Copy link
Member Author

axic commented Jan 18, 2019

After 0.5.0:

pragma experimental ABIEncoderV2;
contract C {
  function f(string[] calldata) external {}    
}
Unimplemented feature:
/Users/alex/Projectssolidity/libsolidity/codegen/ABIFunctions.cpp(1294): Throw in function std::__1::string dev::solidity::ABIFunctions::abiDecodingFunctionCalldataArray(const dev::solidity::ArrayType &)
Dynamic exception type: boost::exception_detail::clone_impl<langutil::UnimplementedFeatureError>
std::exception::what: Calldata arrays with non-value base types are not yet supported by Solidity.
[dev::tag_comment*] = Calldata arrays with non-value base types are not yet supported by Solidity.

@axic
Copy link
Member Author

axic commented Jan 18, 2019

What is funny, without the ABIEncoderV2 pragma the message is:

3293.sol:4:14: Error: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
  function f(string[] calldata) external {}    
             ^---------------^

@axic axic added this to Inbox in 0.5.4 via automation Jan 18, 2019
@chriseth chriseth moved this from Inbox to In progress in 0.5.4 Feb 6, 2019
@chriseth chriseth moved this from In progress to Inbox in 0.5.4 Feb 6, 2019
@chriseth chriseth added this to To do in 0.5.5 via automation Feb 12, 2019
@chriseth chriseth removed this from Inbox in 0.5.4 Feb 12, 2019
@leonardoalt leonardoalt moved this from To do to In progress in 0.5.5 Feb 25, 2019
0.5.5 automation moved this from In progress to Done Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
0.5.5
  
Done
Development

No branches or pull requests

3 participants