OpenZeppelin / openzeppelin-sdk

OpenZeppelin SDK repository for CLI and upgrades.js. No longer actively developed.
MIT License
432 stars 201 forks source link

Cryptic error message on verify for incomplete Solidity pragmas #1365

Open nventuro opened 4 years ago

nventuro commented 4 years ago

When verifying a contract with an incomplete Solidity version pragma, such as pragma solidity ^0.5, the CLI outputs the following error message:

✖ Verifying and publishing contract source code of Counter on etherscan (this usually takes under 30 seconds) Could not parse .sol for extracting its imports: ParserError: mismatched input '0.5' expecting VersionLiteral (1:17)

Changing the pragma to pragma solidity ^0.5.0 fixes the issue.

The underlying cause is this issue in the parser, which truffle-flattener relies on: https://github.com/federicobond/solidity-parser-antlr/issues/15.

I'm not sure how we can handle this other than fixing the bug in the parser, but in the meantime, hopefully this report will help others facing the same issue.

nventuro commented 4 years ago

(note that this only happens when verifying and not when compiling due to our new custom parser)

spalladino commented 4 years ago

Maybe we can build a custom flattener based on our own parser...?

nventuro commented 4 years ago

Alternatively we can change truffle-flattener to use our own parser, since it only uses the antlr one to extract the imports. It'd also be faster as a side effect :stuck_out_tongue:

@alcuadrado would you be open to this?

alcuadrado commented 4 years ago

I can update it, but I'm not sure which parser you are talking about.

nventuro commented 4 years ago

This is the one: https://github.com/frangio/fuzzy-import-parser

alcuadrado commented 4 years ago

How is that parser generated? Have you tested it enough?

Maybe I can release an rc of truffle-flattener with it first