From 6cd8f3d795342d3597f2327497503e7f0c554824 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sun, 23 Apr 2023 08:29:01 -0700 Subject: [PATCH 1/2] update vyper default evm version to paris --- brownie/project/compiler/__init__.py | 2 +- tests/project/compiler/test_vyper.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie/project/compiler/__init__.py b/brownie/project/compiler/__init__.py index b19f6b349..cb0afb0cc 100644 --- a/brownie/project/compiler/__init__.py +++ b/brownie/project/compiler/__init__.py @@ -180,7 +180,7 @@ def generate_input_json( if language == "Solidity": evm_version = next(i[0] for i in EVM_SOLC_VERSIONS if solidity.get_version() >= i[1]) else: - evm_version = "istanbul" + evm_version = "paris" input_json: Dict = deepcopy(STANDARD_JSON) input_json["language"] = language diff --git a/tests/project/compiler/test_vyper.py b/tests/project/compiler/test_vyper.py index 67dfd4493..e9e80d105 100644 --- a/tests/project/compiler/test_vyper.py +++ b/tests/project/compiler/test_vyper.py @@ -23,7 +23,7 @@ def test_generate_input_json(vysource): def test_generate_input_json_evm(vysource): fn = functools.partial(compiler.generate_input_json, {"path.vy": vysource}, language="Vyper") - assert fn()["settings"]["evmVersion"] == "istanbul" + assert fn()["settings"]["evmVersion"] == "paris" assert fn(evm_version="byzantium")["settings"]["evmVersion"] == "byzantium" assert fn(evm_version="petersburg")["settings"]["evmVersion"] == "petersburg" From 846026b52f59a7993cbf626ec6a42af11b1ca490 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Thu, 1 Jun 2023 10:17:45 -0400 Subject: [PATCH 2/2] add evm version mapping for vyper, tiny refactor of evm version mapping logic --- brownie/project/compiler/__init__.py | 12 +++--------- brownie/project/compiler/solidity.py | 6 ++++++ brownie/project/compiler/vyper.py | 8 ++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/brownie/project/compiler/__init__.py b/brownie/project/compiler/__init__.py index cb0afb0cc..a35b061dd 100644 --- a/brownie/project/compiler/__init__.py +++ b/brownie/project/compiler/__init__.py @@ -39,11 +39,7 @@ "remappings": [], }, } -EVM_SOLC_VERSIONS = [ - ("istanbul", Version("0.5.13")), - ("petersburg", Version("0.5.5")), - ("byzantium", Version("0.4.0")), -] + def compile_and_format( @@ -177,10 +173,8 @@ def generate_input_json( optimizer = {"enabled": optimize, "runs": runs if optimize else 0} if evm_version is None: - if language == "Solidity": - evm_version = next(i[0] for i in EVM_SOLC_VERSIONS if solidity.get_version() >= i[1]) - else: - evm_version = "paris" + _module = solidity if language == "Solidity" else vyper + evm_version = next(i[0] for i in _module.EVM_VERSION_MAPPING if _module.get_version() >= i[1]) input_json: Dict = deepcopy(STANDARD_JSON) input_json["language"] = language diff --git a/brownie/project/compiler/solidity.py b/brownie/project/compiler/solidity.py index e244735bd..7523412ea 100644 --- a/brownie/project/compiler/solidity.py +++ b/brownie/project/compiler/solidity.py @@ -26,6 +26,12 @@ AVAILABLE_SOLC_VERSIONS = None +EVM_VERSION_MAPPING = [ + ("istanbul", Version("0.5.13")), + ("petersburg", Version("0.5.5")), + ("byzantium", Version("0.4.0")), +] + # error codes used in Solidity >=0.8.0 # docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require SOLIDITY_ERROR_CODES = { diff --git a/brownie/project/compiler/vyper.py b/brownie/project/compiler/vyper.py index 1b0c60ff3..76d6e7a7f 100644 --- a/brownie/project/compiler/vyper.py +++ b/brownie/project/compiler/vyper.py @@ -28,6 +28,14 @@ _active_version = Version(vyper.__version__) +EVM_VERSION_MAPPING = [ + ("shanghai", Version("0.3.9")), + ("paris", Version("0.3.7")), + ("berlin", Version("0.2.12")), + ("istanbul", Version("0.1.0")), +] + + def get_version() -> Version: return _active_version