From bc790b760ee2c732452340bed0ba4e518b8cb2f4 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 13:46:51 -0400 Subject: [PATCH 1/8] enable cancun testing --- .github/workflows/test.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7030cf45bc..c4d3b32cb4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,11 +81,10 @@ jobs: debug: false opt-mode: gas evm-version: shanghai - # enable when py-evm makes it work: - #- python-version: ["3.11", "311"] - # debug: false - # opt-mode: gas - # evm-version: cancun + - python-version: ["3.11", "311"] + debug: false + opt-mode: gas + evm-version: cancun # run across other python versions. we don't really need to run all # modes across all python versions - one is enough From 96731f4e7cf683945bce23bf3171523bcba02189 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 16:23:50 -0400 Subject: [PATCH 2/8] update py-evm --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0f9a1e1dfc..88fc6b7338 100644 --- a/setup.py +++ b/setup.py @@ -13,9 +13,9 @@ "pytest-instafail>=0.4,<1.0", "pytest-xdist>=2.5,<3.0", "pytest-split>=0.7.0,<1.0", - "eth-tester[py-evm]>=0.9.0b1,<0.10", + "eth-tester[py-evm]>=0.10.0b3,<0.11", "eth_abi>=4.0.0,<5.0.0", - "py-evm>=0.7.0a1,<0.8", + "py-evm>=0.10.0b2,<0.11", "web3==6.0.0", "tox>=3.15,<4.0", "lark==1.1.9", From 2a380965a6c5b872d3a78cedcd307a551db12559 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 18 Mar 2024 17:43:25 -0400 Subject: [PATCH 3/8] bump eth-tester --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index be971bea21..d016170a9d 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ "pytest-instafail>=0.4,<1.0", "pytest-xdist>=3.5,<4.0", "pytest-split>=0.7.0,<1.0", - "eth-tester[py-evm]>=0.10.0b3,<0.11", + "eth-tester[py-evm]>=0.10.0b4,<0.11", "eth_abi>=4.0.0,<5.0.0", "py-evm>=0.10.0b2,<0.11", "web3==6.0.0", From e86f2767305eee90bc1af4aac019c77a48ccdf77 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 18 Mar 2024 17:59:56 -0400 Subject: [PATCH 4/8] manually add typing_extensions --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index d016170a9d..279a552e6c 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ "hypothesis[lark]>=6.0,<7.0", "eth-stdlib==0.2.7", "setuptools", + "typing_extensions", # eth-rlp>2 asks for this properly but it has a conflict ], "lint": [ "black==23.12.0", From 8c8d4e8e7e8067be1cf01a171c630a92eba33562 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 19 Mar 2024 08:47:16 -0400 Subject: [PATCH 5/8] adjust storage layout tests for cancun --- .../cli/storage_layout/test_storage_layout.py | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/tests/unit/cli/storage_layout/test_storage_layout.py b/tests/unit/cli/storage_layout/test_storage_layout.py index 9724dd723c..ece2743b81 100644 --- a/tests/unit/cli/storage_layout/test_storage_layout.py +++ b/tests/unit/cli/storage_layout/test_storage_layout.py @@ -1,4 +1,21 @@ from vyper.compiler import compile_code +from vyper.evm.opcodes import version_check + + +def _adjust_storage_layout_for_cancun(layout): + def _go(layout): + for _varname, item in layout.items(): + if "slot" in item and isinstance(item["slot"], int): + item["slot"] -= 1 + else: + # recurse to submodule + _go(item) + + if version_check(begin="cancun"): + layout["transient_storage_layout"] = { + "$.nonreentrant_key": layout["storage_layout"].pop("$.nonreentrant_key") + } + _go(layout["storage_layout"]) def test_storage_layout(): @@ -40,13 +57,18 @@ def public_foo3(): out = compile_code(code, output_formats=["layout"]) - assert out["layout"]["storage_layout"] == { - "$.nonreentrant_key": {"slot": 0, "type": "nonreentrant lock"}, - "foo": {"slot": 1, "type": "HashMap[address, uint256]"}, - "arr": {"slot": 2, "type": "DynArray[uint256, 3]"}, - "baz": {"slot": 6, "type": "Bytes[65]"}, - "bar": {"slot": 10, "type": "uint256"}, + expected = { + "storage_layout": { + "$.nonreentrant_key": {"slot": 0, "type": "nonreentrant lock"}, + "foo": {"slot": 1, "type": "HashMap[address, uint256]"}, + "arr": {"slot": 2, "type": "DynArray[uint256, 3]"}, + "baz": {"slot": 6, "type": "Bytes[65]"}, + "bar": {"slot": 10, "type": "uint256"}, + } } + _adjust_storage_layout_for_cancun(expected) + + assert out["layout"] == expected def test_storage_and_immutables_layout(): @@ -71,6 +93,7 @@ def __init__(): "name": {"slot": 1, "type": "String[32]"}, }, } + _adjust_storage_layout_for_cancun(expected_layout) out = compile_code(code, output_formats=["layout"]) assert out["layout"] == expected_layout @@ -120,6 +143,7 @@ def __init__(): "a_library": {"supply": {"slot": 3, "type": "uint256"}}, }, } + _adjust_storage_layout_for_cancun(expected_layout) out = compile_code(code, input_bundle=input_bundle, output_formats=["layout"]) assert out["layout"] == expected_layout @@ -169,6 +193,7 @@ def __init__(): "counter2": {"slot": 3, "type": "uint256"}, }, } + _adjust_storage_layout_for_cancun(expected_layout) out = compile_code(code, input_bundle=input_bundle, output_formats=["layout"]) assert out["layout"] == expected_layout @@ -253,6 +278,7 @@ def bar(): "a_library": {"supply": {"slot": 4, "type": "uint256"}}, }, } + _adjust_storage_layout_for_cancun(expected_layout) out = compile_code(code, input_bundle=input_bundle, output_formats=["layout"]) assert out["layout"] == expected_layout @@ -334,6 +360,7 @@ def foo() -> uint256: "counter2": {"slot": 4, "type": "uint256"}, }, } + _adjust_storage_layout_for_cancun(expected_layout) out = compile_code(code, input_bundle=input_bundle, output_formats=["layout"]) assert out["layout"] == expected_layout From e819161507b99d3f3cee7e1956b86e5fbdabc001 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 19 Mar 2024 09:00:32 -0400 Subject: [PATCH 6/8] update another storage slot test for cancun --- tests/unit/semantics/test_storage_slots.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/unit/semantics/test_storage_slots.py b/tests/unit/semantics/test_storage_slots.py index 7cbe71cf29..be0b0c3159 100644 --- a/tests/unit/semantics/test_storage_slots.py +++ b/tests/unit/semantics/test_storage_slots.py @@ -1,5 +1,6 @@ import pytest +from vyper.evm.opcodes import version_check from vyper.exceptions import StorageLayoutException code = """ @@ -97,10 +98,17 @@ def test_reentrancy_lock(get_contract): def test_allocator_overflow(get_contract): - code = """ -# --> global nonreentrancy slot allocated here <-- + # cancun allocates reeentrancy slot in transient storage, + # so allocate an actual storage variable + if version_check(begin="cancun"): + slot1 = "x: uint256" + else: + slot1 = "# --> global nonreentrancy slot allocated here <--" + code = f""" +{slot1} y: uint256[max_value(uint256)] """ + with pytest.raises( StorageLayoutException, match=f"Invalid storage slot, tried to allocate slots 1 through {2**256}", From f184f1850624e1ebb7386936dfbde8e28deaeda1 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 19 Mar 2024 09:23:42 -0400 Subject: [PATCH 7/8] fix a comment --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 279a552e6c..663168cec2 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ "hypothesis[lark]>=6.0,<7.0", "eth-stdlib==0.2.7", "setuptools", - "typing_extensions", # eth-rlp>2 asks for this properly but it has a conflict + "typing_extensions", # we can remove this once dependencies upgrade to eth-rlp>=2.0 ], "lint": [ "black==23.12.0", From 392280ab29700d71435437fba46b78f1f1bf0275 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 19 Mar 2024 15:55:11 -0400 Subject: [PATCH 8/8] bump py-evm version bound --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 663168cec2..b48e1b7030 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ "pytest-split>=0.7.0,<1.0", "eth-tester[py-evm]>=0.10.0b4,<0.11", "eth_abi>=4.0.0,<5.0.0", - "py-evm>=0.10.0b2,<0.11", + "py-evm>=0.10.0b4,<0.11", "web3==6.0.0", "lark==1.1.9", "hypothesis[lark]>=6.0,<7.0",