py-solc-x icon indicating copy to clipboard operation
py-solc-x copied to clipboard

py-solc-x handles sequences of version constraints incorrectly

Open gsalzer opened this issue 3 years ago • 0 comments

Environment information

  • py-solc-x Version: 1.1.1
  • solc Version: irrelevant
  • Python Version: 3.8.0
  • OS: linux

What was wrong?

Some contracts out there contain sequences of contraints, like https://etherscan.io/address/0x0a76C7913C94F2AF16958FbDF9b4CF0bBdb159d8#code:

pragma solidity =0.6.11 >=0.6.0 <0.8.0 >=0.6.2 <0.8.0;

solc determines the specified version correctly as 0.6.11. py-solc-x, however, takes the last constraint only and determines 0.7.6 as matching version.

How can it be fixed?

In solcx/install.py, in the function _select_pragma_version, two changes are required:

  • The last quantifier + in the regex (([<>]?=?|\^)\d+\.\d+\.\d+)+ has to be removed, such that findall will return all constraints.
  • In the call to SimpleSpec, the constraints have to be joined to a single string, separated by commas.

Fixed in PR #148

gsalzer avatar Mar 27 '22 18:03 gsalzer