From b97aae370489b62cf210658210de5a68eaa449d7 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:06:50 -0400 Subject: [PATCH 01/22] enable python3.12 tests --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7030cf45bc..1a05aad46d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,9 +93,10 @@ jobs: opt-mode: gas debug: false evm-version: shanghai - - # TODO 3.12 doesn't work yet, investigate - may be hypothesis issue - #- python-version: ["3.12", "312"] + - python-version: ["3.12", "312"] + opt-mode: gas + debug: false + evm-version: shanghai name: py${{ matrix.python-version[1] }}-opt-${{ matrix.opt-mode }}${{ matrix.debug && '-debug' || '' }}-${{ matrix.evm-version }} From f7db6f35bb896148586d7445c3a6b70071b72924 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:12:44 -0400 Subject: [PATCH 02/22] add pip freeze rule --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a05aad46d..cb7a054a41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,9 @@ jobs: - name: Install Dependencies run: pip install .[lint] + - name: Debug dependencies + run: pip freeze + - name: Run Black run: black --check -C --force-exclude=vyper/version.py ./vyper ./tests ./setup.py @@ -115,6 +118,9 @@ jobs: - name: Install dependencies run: pip install .[test] + - name: Debug dependencies + run: pip freeze + - name: Run tests run: | pytest \ From e6705576fc9f442ebddd05e8bfc6f997af6882a8 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:17:18 -0400 Subject: [PATCH 03/22] add setuptools, it is not provided by default in python3.12 see https://github.com/python/cpython/issues/95299 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 0f9a1e1dfc..595b3ee7bf 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ "lark==1.1.9", "hypothesis[lark]>=5.37.1,<6.0", "eth-stdlib==0.2.6", + "setuptools", ], "lint": [ "black==23.12.0", From 0bec1dc0d03e9a78169dc4b1274b0e5bca60aa1d Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:22:59 -0400 Subject: [PATCH 04/22] update hypothesis --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 595b3ee7bf..0c7190c5fc 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "web3==6.0.0", "tox>=3.15,<4.0", "lark==1.1.9", - "hypothesis[lark]>=5.37.1,<6.0", + "hypothesis[lark]>=6.0,<7.0", "eth-stdlib==0.2.6", "setuptools", ], From aaa419c8e2a94fb46427fbc9448dbd775c35b2d6 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:26:05 -0400 Subject: [PATCH 05/22] update pytest while we are at it --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0c7190c5fc..5564220956 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ extras_require = { "test": [ - "pytest>=6.2.5,<7.0", + "pytest>=8.0,<9.0", "pytest-cov>=2.10,<3.0", "pytest-instafail>=0.4,<1.0", "pytest-xdist>=2.5,<3.0", From 1dcbb0c0bec691715d399ad5bd534e832c37c3de Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:26:40 -0400 Subject: [PATCH 06/22] add 3.12 to supported python list --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 5564220956..34e72fcfb1 100644 --- a/setup.py +++ b/setup.py @@ -116,6 +116,7 @@ def _global_version(version): "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], package_data={"vyper.ast": ["grammar.lark"]}, data_files=[("", [hash_file_rel_path])], From a689164927f960096662ba2e2769d8f5dcec66ff Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 15 Mar 2024 08:45:21 -0400 Subject: [PATCH 07/22] hypothesis fix --- tests/functional/grammar/test_grammar.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index 351793b28e..234a5d0639 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -51,11 +51,14 @@ def utf8_encodable(terminal: str) -> bool: return False +ALLOWED_CHARS = st.characters(codec="utf-8", min_codepoint=1) + + # With help from hyposmith # https://github.com/Zac-HD/hypothesmith/blob/master/src/hypothesmith/syntactic.py class GrammarStrategy(LarkStrategy): def __init__(self, grammar, start, explicit_strategies): - super().__init__(grammar, start, explicit_strategies) + super().__init__(grammar, start, explicit_strategies, alphabet=ALLOWED_CHARS) self.terminal_strategies = { k: v.map(lambda s: s.replace("\0", "")).filter(utf8_encodable) for k, v in self.terminal_strategies.items() # type: ignore From b7e2d2df08d8daab046ffbe0dc964ac102f8f123 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 08:11:19 -0400 Subject: [PATCH 08/22] remove deprecated uses of python_ast.Constant.n --- tests/functional/syntax/test_structs.py | 10 +++++----- vyper/ast/parse.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/functional/syntax/test_structs.py b/tests/functional/syntax/test_structs.py index d34a4a6c58..9a9a397c48 100644 --- a/tests/functional/syntax/test_structs.py +++ b/tests/functional/syntax/test_structs.py @@ -589,9 +589,9 @@ def foo(): with warnings.catch_warnings(record=True) as w: assert compiler.compile_code(code) is not None - expected = "Instantiating a struct using a dictionary is deprecated " - expected += "as of v0.4.0 and will be disallowed in a future release. " - expected += "Use kwargs instead e.g. Foo(a=1, b=2)" + expected = "Instantiating a struct using a dictionary is deprecated " + expected += "as of v0.4.0 and will be disallowed in a future release. " + expected += "Use kwargs instead e.g. Foo(a=1, b=2)" - assert len(w) == 1 - assert str(w[0].message).startswith(expected) + assert len(w) == 1, [s.message for s in w] + assert str(w[0].message).startswith(expected) diff --git a/vyper/ast/parse.py b/vyper/ast/parse.py index 787b1404e6..e06b3c260f 100644 --- a/vyper/ast/parse.py +++ b/vyper/ast/parse.py @@ -435,7 +435,7 @@ def visit_Num(self, node): node.col_offset, ) node.ast_type = "Hex" - node.n = value + node.value = value elif value.lower()[:2] == "0b": node.ast_type = "Bytes" @@ -449,15 +449,15 @@ def visit_Num(self, node): ) node.value = int(value, 2).to_bytes(len(value) // 8, "big") - elif isinstance(node.n, float): + elif isinstance(node.value, float): node.ast_type = "Decimal" - node.n = Decimal(value) + node.value = Decimal(value) - elif isinstance(node.n, int): + elif isinstance(node.value, int): node.ast_type = "Int" else: - raise CompilerPanic(f"Unexpected type for Constant value: {type(node.n).__name__}") + raise CompilerPanic(f"Unexpected type for Constant value: {type(node.value).__name__}") return node From 694def9797cbfdb0a5f8e922b4c82beb25db348c Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 08:58:45 -0400 Subject: [PATCH 09/22] fix a bad use of assert_compile_failed latest hypothesis complains with a health check about the fixture scoping, it's better to fix the usage anyways. --- tests/functional/builtins/codegen/test_slice.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/functional/builtins/codegen/test_slice.py b/tests/functional/builtins/codegen/test_slice.py index 0c5a8fc485..9fc464ed35 100644 --- a/tests/functional/builtins/codegen/test_slice.py +++ b/tests/functional/builtins/codegen/test_slice.py @@ -2,7 +2,8 @@ import pytest from hypothesis import given, settings -from vyper.compiler.settings import OptimizationLevel +from vyper.compiler import compile_code +from vyper.compiler.settings import OptimizationLevel, Settings from vyper.exceptions import ArgumentException, TypeMismatch _fun_bytes32_bounds = [(0, 32), (3, 29), (27, 5), (0, 5), (5, 3), (30, 2)] @@ -32,6 +33,12 @@ def slice_tower_test(inp1: Bytes[50]) -> Bytes[50]: _bytes_1024 = st.binary(min_size=0, max_size=1024) +def _fail_contract(code, opt_level, exceptions): + settings = Settings(optimize=opt_level) + with pytest.raises(exceptions): + compile_code(code, settings) + + @pytest.mark.parametrize("use_literal_start", (True, False)) @pytest.mark.parametrize("use_literal_length", (True, False)) @pytest.mark.parametrize("opt_level", list(OptimizationLevel)) @@ -40,7 +47,6 @@ def slice_tower_test(inp1: Bytes[50]) -> Bytes[50]: @pytest.mark.fuzzing def test_slice_immutable( get_contract, - assert_compile_failed, tx_failed, opt_level, bytesdata, @@ -76,7 +82,8 @@ def _get_contract(): or (use_literal_start and start > length_bound) or (use_literal_length and length == 0) ): - assert_compile_failed(lambda: _get_contract(), ArgumentException) + _fail_contract(code, opt_level, ArgumentException) + elif start + length > len(bytesdata) or (len(bytesdata) > length_bound): # deploy fail with tx_failed(): @@ -95,7 +102,6 @@ def _get_contract(): @pytest.mark.fuzzing def test_slice_bytes_fuzz( get_contract, - assert_compile_failed, tx_failed, opt_level, location, @@ -173,7 +179,8 @@ def _get_contract(): ) if compile_time_oob or slice_output_too_large: - assert_compile_failed(lambda: _get_contract(), (ArgumentException, TypeMismatch)) + _fail_contract(code, opt_level, (ArgumentException, TypeMismatch)) + elif location == "code" and len(bytesdata) > length_bound: # deploy fail with tx_failed(): From dd847f361fc721bd95eea11b9f8ec1516e0867fb Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 10:43:23 -0400 Subject: [PATCH 10/22] update eth-stdlib --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 34e72fcfb1..b0f7ef15f2 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ "tox>=3.15,<4.0", "lark==1.1.9", "hypothesis[lark]>=6.0,<7.0", - "eth-stdlib==0.2.6", + "eth-stdlib==0.2.7", "setuptools", ], "lint": [ From 5a5612c6c48d572edc640e3b81936ce30dc01b0b Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 10:44:30 -0400 Subject: [PATCH 11/22] update st_uint256 2**256 was always out of range, but apparently hypothesis was not generating the example before --- tests/functional/builtins/folding/test_powmod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/builtins/folding/test_powmod.py b/tests/functional/builtins/folding/test_powmod.py index ad1197e8e3..3235699818 100644 --- a/tests/functional/builtins/folding/test_powmod.py +++ b/tests/functional/builtins/folding/test_powmod.py @@ -4,7 +4,7 @@ from tests.utils import parse_and_fold -st_uint256 = st.integers(min_value=0, max_value=2**256) +st_uint256 = st.integers(min_value=0, max_value=(2**256 - 1)) @pytest.mark.fuzzing From 33dadd505afa66242de5677450b271127aee85bd Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 11:23:07 -0400 Subject: [PATCH 12/22] update draw_state references --- tests/functional/grammar/test_grammar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index 234a5d0639..dae6ee570b 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -65,11 +65,11 @@ def __init__(self, grammar, start, explicit_strategies): } def draw_symbol(self, data, symbol, draw_state): # type: ignore - count = len(draw_state.result) + count = len(draw_state) super().draw_symbol(data, symbol, draw_state) try: compile( - source="".join(draw_state.result[count:]) + source="".join(draw_state[count:]) .replace("contract", "class") .replace("struct", "class"), # HACK: Python ast.parse filename="", From 6593dd3b105a326483ddc58f3280ec7dbedce2e5 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 11:48:49 -0400 Subject: [PATCH 13/22] fix a bound --- tests/functional/codegen/types/test_bytes_zero_padding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/codegen/types/test_bytes_zero_padding.py b/tests/functional/codegen/types/test_bytes_zero_padding.py index 6597facd1b..40bd1de6fc 100644 --- a/tests/functional/codegen/types/test_bytes_zero_padding.py +++ b/tests/functional/codegen/types/test_bytes_zero_padding.py @@ -25,7 +25,7 @@ def get_count(counter: uint256) -> Bytes[24]: @pytest.mark.fuzzing -@hypothesis.given(value=hypothesis.strategies.integers(min_value=0, max_value=2**64)) +@hypothesis.given(value=hypothesis.strategies.integers(min_value=0, max_value=(2**64 - 1))) def test_zero_pad_range(little_endian_contract, value): actual_bytes = value.to_bytes(8, byteorder="little") contract_bytes = little_endian_contract.get_count(value) From 0c0eac1d3602ab156ec238f7eeaf354505ae8bef Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 11:58:11 -0400 Subject: [PATCH 14/22] add coverage pragma --- vyper/ast/parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vyper/ast/parse.py b/vyper/ast/parse.py index e06b3c260f..a4a8617730 100644 --- a/vyper/ast/parse.py +++ b/vyper/ast/parse.py @@ -456,7 +456,7 @@ def visit_Num(self, node): elif isinstance(node.value, int): node.ast_type = "Int" - else: + else: # pragma: nocover raise CompilerPanic(f"Unexpected type for Constant value: {type(node.value).__name__}") return node From 3b92c85f8df8cbdc4168d33863eda07ce799f36a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 12:31:29 -0400 Subject: [PATCH 15/22] get rid of utf8_encodable checks the filter is triggering a hypothesis health check, and the new alphabet should address the issue anyway --- tests/functional/grammar/test_grammar.py | 25 +++++------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index dae6ee570b..66a5958330 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -37,20 +37,6 @@ def test_basic_grammar_empty(): assert len(tree.children) == 0 -def utf8_encodable(terminal: str) -> bool: - try: - if "\x00" not in terminal and "\\ " not in terminal and "\x0c" not in terminal: - terminal.encode("utf-8-sig") - return True - else: - return False - except UnicodeEncodeError: # pragma: no cover - # Very rarely, a "." in some terminal regex will generate a surrogate - # character that cannot be encoded as UTF-8. We apply this filter to - # ensure it doesn't happen at runtime, but don't worry about coverage. - return False - - ALLOWED_CHARS = st.characters(codec="utf-8", min_codepoint=1) @@ -60,7 +46,7 @@ class GrammarStrategy(LarkStrategy): def __init__(self, grammar, start, explicit_strategies): super().__init__(grammar, start, explicit_strategies, alphabet=ALLOWED_CHARS) self.terminal_strategies = { - k: v.map(lambda s: s.replace("\0", "")).filter(utf8_encodable) + k: v.map(lambda s: s.replace("\0", "")) for k, v in self.terminal_strategies.items() # type: ignore } @@ -105,10 +91,9 @@ def has_no_docstrings(c): @pytest.mark.fuzzing -@given(code=from_grammar().filter(lambda c: utf8_encodable(c))) +@given(code=from_grammar()) @hypothesis.settings(max_examples=500, suppress_health_check=[HealthCheck.too_slow]) def test_grammar_bruteforce(code): - if utf8_encodable(code): - _, _, _, reformatted_code = pre_parse(code + "\n") - tree = parse_to_ast(reformatted_code) - assert isinstance(tree, Module) + _, _, _, reformatted_code = pre_parse(code + "\n") + tree = parse_to_ast(reformatted_code) + assert isinstance(tree, Module) From 1127fc41c4ca8f8862a6280096bf7bb81c617eca Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 13:18:09 -0400 Subject: [PATCH 16/22] ignore a health check --- tests/functional/grammar/test_grammar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index 66a5958330..fba1137f76 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -92,7 +92,9 @@ def has_no_docstrings(c): @pytest.mark.fuzzing @given(code=from_grammar()) -@hypothesis.settings(max_examples=500, suppress_health_check=[HealthCheck.too_slow]) +@hypothesis.settings( + max_examples=500, suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much] +) def test_grammar_bruteforce(code): _, _, _, reformatted_code = pre_parse(code + "\n") tree = parse_to_ast(reformatted_code) From e6143e5a40e017469a39361c0dd0d0abe3e95744 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 13:50:20 -0400 Subject: [PATCH 17/22] Revert "get rid of utf8_encodable checks" This reverts commit 3b92c85f8df8cbdc4168d33863eda07ce799f36a. --- tests/functional/grammar/test_grammar.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index fba1137f76..699865b24f 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -37,6 +37,20 @@ def test_basic_grammar_empty(): assert len(tree.children) == 0 +def utf8_encodable(terminal: str) -> bool: + try: + if "\x00" not in terminal and "\\ " not in terminal and "\x0c" not in terminal: + terminal.encode("utf-8-sig") + return True + else: + return False + except UnicodeEncodeError: # pragma: no cover + # Very rarely, a "." in some terminal regex will generate a surrogate + # character that cannot be encoded as UTF-8. We apply this filter to + # ensure it doesn't happen at runtime, but don't worry about coverage. + return False + + ALLOWED_CHARS = st.characters(codec="utf-8", min_codepoint=1) @@ -46,7 +60,7 @@ class GrammarStrategy(LarkStrategy): def __init__(self, grammar, start, explicit_strategies): super().__init__(grammar, start, explicit_strategies, alphabet=ALLOWED_CHARS) self.terminal_strategies = { - k: v.map(lambda s: s.replace("\0", "")) + k: v.map(lambda s: s.replace("\0", "")).filter(utf8_encodable) for k, v in self.terminal_strategies.items() # type: ignore } @@ -91,7 +105,7 @@ def has_no_docstrings(c): @pytest.mark.fuzzing -@given(code=from_grammar()) +@given(code=from_grammar().filter(lambda c: utf8_encodable(c))) @hypothesis.settings( max_examples=500, suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much] ) From 6248493ef4a41b746fe3079b7382e3fe344b901f Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 14:23:44 -0400 Subject: [PATCH 18/22] only need the filter on one function --- tests/functional/grammar/test_grammar.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index 699865b24f..e8e3e5cdd9 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -37,18 +37,8 @@ def test_basic_grammar_empty(): assert len(tree.children) == 0 -def utf8_encodable(terminal: str) -> bool: - try: - if "\x00" not in terminal and "\\ " not in terminal and "\x0c" not in terminal: - terminal.encode("utf-8-sig") - return True - else: - return False - except UnicodeEncodeError: # pragma: no cover - # Very rarely, a "." in some terminal regex will generate a surrogate - # character that cannot be encoded as UTF-8. We apply this filter to - # ensure it doesn't happen at runtime, but don't worry about coverage. - return False +def good_terminal(terminal: str) -> bool: + return all(bad not in terminal for bad in ("\x00", "\\ ", "\x0c")) ALLOWED_CHARS = st.characters(codec="utf-8", min_codepoint=1) @@ -60,7 +50,7 @@ class GrammarStrategy(LarkStrategy): def __init__(self, grammar, start, explicit_strategies): super().__init__(grammar, start, explicit_strategies, alphabet=ALLOWED_CHARS) self.terminal_strategies = { - k: v.map(lambda s: s.replace("\0", "")).filter(utf8_encodable) + k: v.map(lambda s: s.replace("\0", "")).filter(good_terminal) for k, v in self.terminal_strategies.items() # type: ignore } @@ -105,7 +95,7 @@ def has_no_docstrings(c): @pytest.mark.fuzzing -@given(code=from_grammar().filter(lambda c: utf8_encodable(c))) +@given(code=from_grammar()) @hypothesis.settings( max_examples=500, suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much] ) From d7fecb4f89e8ebc9820b136ed5bb5686f95fe686 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 14:34:47 -0400 Subject: [PATCH 19/22] remove implicit evm-version --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb7a054a41..4cf44daaf3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,7 +99,6 @@ jobs: - python-version: ["3.12", "312"] opt-mode: gas debug: false - evm-version: shanghai name: py${{ matrix.python-version[1] }}-opt-${{ matrix.opt-mode }}${{ matrix.debug && '-debug' || '' }}-${{ matrix.evm-version }} From 931bf75fb0dc70f78a973895fed95627cade88f2 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 14:42:34 -0400 Subject: [PATCH 20/22] Revert "remove implicit evm-version" This reverts commit d7fecb4f89e8ebc9820b136ed5bb5686f95fe686. turns out, it is not implicit --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4cf44daaf3..cb7a054a41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,6 +99,7 @@ jobs: - python-version: ["3.12", "312"] opt-mode: gas debug: false + evm-version: shanghai name: py${{ matrix.python-version[1] }}-opt-${{ matrix.opt-mode }}${{ matrix.debug && '-debug' || '' }}-${{ matrix.evm-version }} From c0a48aa1acab50918d03860835881ea60087a3a0 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 14:59:08 -0400 Subject: [PATCH 21/22] refactor to fix_terminal --- tests/functional/grammar/test_grammar.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/functional/grammar/test_grammar.py b/tests/functional/grammar/test_grammar.py index e8e3e5cdd9..716986ffe4 100644 --- a/tests/functional/grammar/test_grammar.py +++ b/tests/functional/grammar/test_grammar.py @@ -37,8 +37,11 @@ def test_basic_grammar_empty(): assert len(tree.children) == 0 -def good_terminal(terminal: str) -> bool: - return all(bad not in terminal for bad in ("\x00", "\\ ", "\x0c")) +def fix_terminal(terminal: str) -> bool: + # these throw exceptions in the grammar + for bad in ("\x00", "\\ ", "\x0c"): + terminal = terminal.replace(bad, " ") + return terminal ALLOWED_CHARS = st.characters(codec="utf-8", min_codepoint=1) @@ -50,8 +53,7 @@ class GrammarStrategy(LarkStrategy): def __init__(self, grammar, start, explicit_strategies): super().__init__(grammar, start, explicit_strategies, alphabet=ALLOWED_CHARS) self.terminal_strategies = { - k: v.map(lambda s: s.replace("\0", "")).filter(good_terminal) - for k, v in self.terminal_strategies.items() # type: ignore + k: v.map(fix_terminal) for k, v in self.terminal_strategies.items() # type: ignore } def draw_symbol(self, data, symbol, draw_state): # type: ignore From 6f953c25d0da46e82bcf0251c1dbf9e8a5844a27 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 16 Mar 2024 16:01:06 -0400 Subject: [PATCH 22/22] remove translations of Constant.n --- vyper/ast/nodes.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/vyper/ast/nodes.py b/vyper/ast/nodes.py index 02c7e15686..5079303cd3 100644 --- a/vyper/ast/nodes.py +++ b/vyper/ast/nodes.py @@ -774,7 +774,6 @@ def is_literal_value(self): class Num(Constant): # inherited class for all numeric constant node types __slots__ = () - _translated_fields = {"n": "value"} @property def n(self): @@ -843,7 +842,6 @@ class Hex(Constant): """ __slots__ = () - _translated_fields = {"n": "value"} def validate(self): if "_" in self.value: