vyperlang / titanoboa

a vyper interpreter
https://titanoboa.readthedocs.io
Other
242 stars 41 forks source link

unexpected priority for dev reason when reverting #199

Closed AlbertoCentonze closed 2 months ago

AlbertoCentonze commented 3 months ago

What is the problem

boa.reverts(dev="error message") does not always work as expected.

How to reproduce

Minimized example from Curve contracts: Given a pool contract deployer:

@external
@pure
def some_math(x: uint256):
    assert x < 10 # dev: math not ok

And a math contract deployer:

math: address

interface Math:
    def some_math(x: uint256): pure

@external
def __init__(math: address):
    self.math = math

@external
def ext_call():
    Math(self.math).some_math(11)

The following code raises the error ValueError: expected <dev: math not ok> but got None:

m = math.deploy()
p = pool.deploy(m.address)
with boa.reverts(dev="math not ok"):
    p.ext_call()

The above example can be tested on this link

charles-cooper commented 2 months ago

After discussing offline with @AlbertoCentonze, I think we should make dev reasons "propagate" up the call stack. @DanielSchiavini wdyt?

DanielSchiavini commented 2 months ago

I recently added this test to make sure the pretty_vm_reason is propagated. It seems to pass fine: https://github.com/vyperlang/titanoboa/pull/195/commits/2dfdf53fff6584504c8ecb6ce7712d3062aa1d3d

The dev reason should definitely work the same way. Something like this? https://github.com/vyperlang/titanoboa/pull/207