Skip to content

Commit

Permalink
Fix incremental compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
danhper committed Jan 26, 2022
1 parent c3dd4a7 commit 6a6be85
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 21 additions & 3 deletions brownie/project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 6a6be85

Please sign in to comment.