diff --git a/CHANGELOG.md b/CHANGELOG.md index a32d078a8..5b01f8f76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Force files to be opened as UTF-8 - Added a new solidity compiler setting `use_latest_patch` in brownie-config.yaml to use the latest patch version of a compiler based on the pragma version of the contract. - Add cli flag `-r` for raising exceptions to the caller instead of doing a system exit. +### Fixed +- Fix incremental compilation failing because of mismatching compiler versions ## [1.17.2](https://github.com/eth-brownie/brownie/tree/v1.17.2) - 2021-12-04 ### Changed diff --git a/brownie/project/main.py b/brownie/project/main.py index f96c78200..606b4cee6 100644 --- a/brownie/project/main.py +++ b/brownie/project/main.py @@ -291,17 +291,19 @@ def _compare_build_json(self, contract_name: str) -> bool: if build_json["sha1"] != sha1(source.encode()).hexdigest(): return True # compare compiler settings - if _compare_settings(config, build_json["compiler"]): - return True if build_json["language"] == "Solidity": # compare solc-specific compiler settings solc_config = config["solc"].copy() solc_config["remappings"] = None - if _compare_settings(solc_config, build_json["compiler"]): + if not _solidity_compiler_equal(solc_config, build_json["compiler"]): return True # compare solc pragma against compiled version if Version(build_json["compiler"]["version"]) not in get_pragma_spec(source): return True + else: + vyper_config = config["vyper"].copy() + if not _vyper_compiler_equal(vyper_config, build_json["compiler"]): + return True return False def _compile_interfaces(self, compiled_hashes: Dict) -> None: @@ -950,6 +952,22 @@ def _compare_settings(left: Dict, right: Dict) -> bool: ) +def _normalize_solidity_version(version: str) -> str: + return version.split("+")[0] + + +def _solidity_compiler_equal(config: dict, build: dict) -> bool: + return ( + config["version"] is None + or _normalize_solidity_version(config["version"]) + == _normalize_solidity_version(build["version"]) + ) and config["optimizer"] == build["optimizer"] + + +def _vyper_compiler_equal(config: dict, build: dict) -> bool: + return config["version"] is None or config["version"] == build["version"] + + def _load_sources(project_path: Path, subfolder: str, allow_json: bool) -> Dict: contract_sources: Dict = {} suffixes: Tuple = (".sol", ".vy")