Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vyperlang/vyper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.1b2
Choose a base ref
...
head repository: vyperlang/vyper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.1b3
Choose a head ref
  • 8 commits
  • 33 files changed
  • 7 contributors

Commits on Nov 26, 2024

  1. fix[venom]: fix duplicate allocas (#4321)

    this commit fixes a bug in the ir_node_to_venom translator. previously,
    `ir_node_to_venom` tried to detect unique allocas based on
    heuristics. this commit removes the heuristics and fixes the issue
    in the frontend by passing through a unique ID for each variable in
    the metadata. this ID is also passed into the `alloca` and `palloca`
    instructions to aid with debugging. note that this results in improved
    code, presumably due to more allocas being able to be reified.
    
    this commit makes a minor change to the `sqrt()`, builtin, which is to
    use `z_var.as_ir_node()` instead of `z_var.pos`, since `.as_ir_node()`
    correctly tags with the alloca metadata. to be maximally conservative,
    we could branch, only using `z_var.as_ir_node()` if we are using
    the venom pipeline, but the change should be correct for the legacy
    pipeline as well anyways.
    
    ---------
    
    Co-authored-by: Harry Kalogirou <harkal@nlogn.eu>
    charles-cooper and harkal authored Nov 26, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    jvnipers Juniper
    Copy the full SHA
    cda634d View commit details
  2. fix[venom]: add missing extcodesize+hash effects (#4373)

    per title -- effects.py was missing extcodesize and extcodehash effects.
    charles-cooper authored Nov 26, 2024
    Copy the full SHA
    e98e004 View commit details

Commits on Dec 3, 2024

  1. chore[ci]: enable Python 3.13 tests (#4386)

    python 3.13 was released on oct 7 2024
    
    https://docs.python.org/3/whatsnew/3.13.html
    pcaversaccio authored Dec 3, 2024
    Copy the full SHA
    794022e View commit details

Commits on Dec 6, 2024

  1. fix[ux]: fix validation for abi_encode() method_id kwarg (#4369)

    code like in the test case (`abi_encode(..., method_id=b"123")`) will
    panic due to the assertion in `_parse_method_id()`, since the original
    typecheck only checked that the method_id is <=4 bytes. this adds a rule
    to validate that bytestring method ids are exactly 4 bytes directly in
    `abi_encode()`'s typecheck routine.
    
    ---------
    
    Co-authored-by: cyberthirst <cyberthirst.eth@gmail.com>
    charles-cooper and cyberthirst authored Dec 6, 2024
    Copy the full SHA
    c8691ac View commit details

Commits on Dec 9, 2024

  1. fix[ux]: fix false positive for overflow in type checker (#4385)

    this commit fixes a false positive for integer overflow in
    the typechecker involving nested pow operations by filtering
    `OverflowException` in `_validate_op`. the previous code assumed that
    `validate_numeric_op` could throw anything besides `InvalidOperation`,
    but for the `Pow` binop, it can throw `OverflowException`.
    
    ---------
    
    Co-authored-by: Charles Cooper <cooper.charles.m@gmail.com>
    tserg and charles-cooper authored Dec 9, 2024
    Copy the full SHA
    12ab491 View commit details

Commits on Dec 13, 2024

  1. fix[tool]: add missing user errors to error map (#4286)

    This commit fixes a bug where not all errors are present in the
    error_map (in the `-f source_map` output). This could happen when the
    `IRnode` with an error message was optimized out, since the error
    message was not propagated to its descendants.
    
    To resolve this, two changes were made. In `set_error_msg`, the code
    now ensures that existing error messages are not overwritten if they
    have already been set. In `IRnode.from_list`, when an `error_msg`
    argument is provided, it is assigned to all nodes in the list unless a
    node already has an existing `error_msg`. Both changes were made, since
    both methods are used in the codebase to set `IRnode.error_msg`.
    sandbubbles authored Dec 13, 2024
    Copy the full SHA
    c4669d1 View commit details
  2. fix[ux]: add missing filename to syntax exceptions (#4343)

    this commit adds a filename to `SyntaxException`s. previously, they did
    not include filename information because that is typically added from
    the `Module` AST node fields. but, at the time a `SyntaxException`
    is thrown, the AST is not yet available, so the normal handler does
    not have the filename info. this commit adds the filename info in two
    places where the path is known, one in natspec.py and one in parse.py.
    sandbubbles authored Dec 13, 2024
    Copy the full SHA
    c951dea View commit details

Commits on Dec 14, 2024

  1. feat[venom]: add venom parser (#4381)

    this commit adds a frontend (parser) for venom. it uses the lark
    library to define a grammar for venom, and constructs an `IRContext`
    which can be used to emit bytecode.
    
    the entry point to the venom compiler is `vyper/cli/venom_main.py`.
    
    possible improvements in the future include:
    - make data section optional in the grammar
    - make the entry block optional in the grammar (a la llvm)
    - add asm and opcodes output formats
    
    ---------
    
    Co-authored-by: Harry Kalogirou <harkal@nlogn.eu>
    Co-authored-by: Charles Cooper <cooper.charles.m@gmail.com>
    3 people authored Dec 14, 2024
    Copy the full SHA
    537313b View commit details
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ jobs:
# modes across all python versions - one is enough
- python-version: ["3.10", "310"]
- python-version: ["3.12", "312"]
- python-version: ["3.13", "313"]

# os-specific rules
- os: windows
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ def _global_version(version):
"asttokens>=2.0.5,<3",
"pycryptodome>=3.5.1,<4",
"packaging>=23.1,<24",
"lark>=1.0.0,<2",
"importlib-metadata",
"wheel",
],
@@ -105,6 +106,7 @@ def _global_version(version):
"vyper=vyper.cli.vyper_compile:_parse_cli_args",
"fang=vyper.cli.vyper_ir:_parse_cli_args",
"vyper-json=vyper.cli.vyper_json:_parse_cli_args",
"venom=vyper.cli.venom_main:_parse_cli_args",
]
},
classifiers=[
@@ -113,6 +115,7 @@ def _global_version(version):
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
package_data={"vyper.ast": ["grammar.lark"]},
data_files=[("", [hash_file_rel_path])],
14 changes: 14 additions & 0 deletions tests/functional/codegen/types/numbers/test_exponents.py
Original file line number Diff line number Diff line change
@@ -173,3 +173,17 @@ def foo(b: int128) -> int128:
c.foo(max_power)
with tx_failed():
c.foo(max_power + 1)


valid_list = [
"""
@external
def foo() -> uint256:
return (10**18)**2
"""
]


@pytest.mark.parametrize("good_code", valid_list)
def test_exponent_success(good_code):
assert compile_code(good_code) is not None
32 changes: 31 additions & 1 deletion tests/functional/syntax/exceptions/test_vyper_exception_pos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pytest import raises

from vyper.exceptions import VyperException
from vyper import compile_code
from vyper.exceptions import SyntaxException, VyperException


def test_type_exception_pos():
@@ -29,3 +30,32 @@ def __init__():
"""
assert_compile_failed(lambda: get_contract(code), VyperException)


def test_exception_contains_file(make_input_bundle):
code = """
def bar()>:
"""
input_bundle = make_input_bundle({"code.vy": code})
with raises(SyntaxException, match="contract"):
compile_code(code, input_bundle=input_bundle)


def test_exception_reports_correct_file(make_input_bundle, chdir_tmp_path):
code_a = "def bar()>:"
code_b = "import A"
input_bundle = make_input_bundle({"A.vy": code_a, "B.vy": code_b})

with raises(SyntaxException, match=r'contract "A\.vy:\d+"'):
compile_code(code_b, input_bundle=input_bundle)


def test_syntax_exception_reports_correct_offset(make_input_bundle):
code = """
def foo():
uint256 a = pass
"""
input_bundle = make_input_bundle({"code.vy": code})

with raises(SyntaxException, match=r"line \d+:12"):
compile_code(code, input_bundle=input_bundle)
33 changes: 32 additions & 1 deletion tests/functional/syntax/test_abi_encode.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper import compiler
from vyper.exceptions import TypeMismatch
from vyper.exceptions import InvalidLiteral, TypeMismatch

fail_list = [
(
@@ -41,11 +41,37 @@ def foo(x: uint256) -> Bytes[36]:
(
"""
@external
def foo(x: uint256) -> Bytes[36]:
return _abi_encode(x, method_id=b"abc")
""",
InvalidLiteral, # len(method_id) must be greater than 3
),
(
"""
@external
def foo(x: uint256) -> Bytes[36]:
return _abi_encode(x, method_id=0x1234567890)
""",
TypeMismatch, # len(method_id) must be less than 4
),
(
"""
@external
def foo(x: uint256) -> Bytes[36]:
return _abi_encode(x, method_id=0x123456)
""",
TypeMismatch, # len(method_id) must be greater than 3
),
(
"""
@external
def foo() -> Bytes[132]:
x: uint256 = 1
y: Bytes[32] = b"234"
return abi_encode(x, y, method_id=b"")
""",
InvalidLiteral, # len(method_id) must be 4
),
]


@@ -82,6 +108,11 @@ def foo(x: Bytes[1]) -> Bytes[68]:
return _abi_encode(x, ensure_tuple=False, method_id=0x12345678)
""",
"""
@external
def foo(x: Bytes[1]) -> Bytes[68]:
return _abi_encode(x, ensure_tuple=False, method_id=b"1234")
""",
"""
BAR: constant(DynArray[uint256, 5]) = [1, 2, 3, 4, 5]
@external
Empty file.
Empty file.
Loading