vyperlang / titanoboa

a vyper interpreter
https://titanoboa.readthedocs.io
Other
255 stars 51 forks source link

Fix for VVM with non-fixed version pragma #315

Open ritzdorf opened 2 months ago

ritzdorf commented 2 months ago

What I did

There was the following problem with non-fixed pragmas (vyper_version = 0.4.0):

import boa
boa.load("examples/simple.vy")

Leads to error:

vyper.exceptions.VersionException: Version specification "~=0.3.9" is not compatible with compiler version "0.4.0"

simple.vy:

# pragma version ^0.3.9
@external
def foo() -> uint256:
    x: uint256 = 1
    return x + 7

That happens because _detect_version returns None in this case, so VVM is not used, but compilation also fails.

So I changed _detect_version so that it:

  1. Parses the full pragma (including >= or ^)
  2. Decides on the right version depending on the pragma and the optionally provided vyper_version
  3. Returns the right version

How I did it

How to verify it

See the new tests I added

Description for the changelog

Parse version pragma more precisely to use vvm if necessary

Cute Animal Picture

DanielSchiavini commented 2 months ago

@charles-cooper I guess we will need a release. But first I found this issue: https://github.com/vyperlang/vvm/pull/24