Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incremental compilation #1411

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Improve support for Ganache 7 reverted transactions
- 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