ethereum / remix-project

Remix is a browser-based compiler and IDE that enables users to build Ethereum contracts with Solidity language and to debug transactions.
https://remix-ide.readthedocs.io
MIT License
2.42k stars 925 forks source link

Error during deployment "invalid type (arg="type", value="function", version=4.0.47)" #404

Open hrkrshnn opened 4 years ago

hrkrshnn commented 4 years ago

The contract:

pragma solidity >= 0.7.0;
contract C {
    event Test(function() external);
}

when deployed produces the error

creation of C errored: Error: invalid type (arg="type", value="function", version=4.0.47)

hrkrshnn commented 4 years ago

This is likely an issue with ethers context: https://github.com/ethereum/solidity/issues/7569#issuecomment-688433458

yann300 commented 4 years ago

This is likely an issue with ethers context: ethereum/solidity#7569 (comment)

@hrkrshnn can you confirm this? is there a filed issue in the ethers repo? thanks for your help

hrkrshnn commented 4 years ago

I cannot confirm if it's an issue with ethers. Perhaps @haltman-at can confirm it.

haltman-at commented 4 years ago

I mean, that is exactly the type of error produced by ethers when it can't encode or decode something. The ethers encoder/decoder doesn't handle external functions. I've seen those errors often enough to recognize them. The ethers code is split up enough that I can't point to a single line that puts this message together, but just try it -- try using ethers to do some invalid encodes or decodes, or to encode or decode external functions. You'll see errors that look like this.

yann300 commented 3 years ago

hello @ricmoo We tried to fix this by moving to the latest version of ethers (5.0.13), but the issue persist... Is there something we can do to get around that and will this be handled by ethers? Thanks for the help ;)

The following contract pragma solidity >= 0.7.0; contract C { event Test(function() external); } compiles, but I was unable to deploy it through remix. "creation of C errored: Error: invalid type (arg="type", value="function", > > version=4.0.47)" was the error.

ricmoo commented 3 years ago

The function() syntax is not currently available in the human-readable ABI parser. Can you provide the topic for that event? My guess is you could probably replace the function() with bytes4, but I’m not sure whether they do that conversion when computing the topic hash.

Please feel free to open an issue on ethers GitHub to track this. If changing it to a bytes4 fixes this, I would probably recommend this as the solution for now, since adding parenthesis to the parser would complicate a lot of the LL(1) states, as the parser was hand-written.

I may switch to a Jison-based parser in the future which would make these changes much easier, but does add quite a bit of overhead to the library.

ricmoo commented 3 years ago

Actually. Poking around with Solidity and the generated assembly, it looks like it uses the hash of Test(function) for the topic hash.

I’ve added this issue to track it: https://github.com/ethers-io/ethers.js/issues/1089