Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Incorrect return value from pyethereum contract. #745

Open
MicahZoltu opened this issue Jun 9, 2017 · 3 comments
Open

Incorrect return value from pyethereum contract. #745

MicahZoltu opened this issue Jun 9, 2017 · 3 comments

Comments

@MicahZoltu
Copy link
Contributor

Removing the return type of method bar resolves the issue, though it is completely baffling as to why the return type of bar has any influence on what foo returns.

from ethereum import tester
import os

library = """
def bar():
    return(1: uint256)
"""

code = """
event Message(a)
def foo():
    library = create('garbage.se')
    log(type=Message, library)
    return(library)
"""

with open("garbage.se", "w") as file:
    file.write(library)

try:
    state = tester.state()
    state.block.number += 2000000
    contract = state.abi_contract(code)
    print(contract.foo())
finally:
    os.remove("garbage.se")

Actual Output:

{u'a': 510244585160389217769106449722952381674178085494L, '_event_type': 'Message'}
[]

Expected Output:

{u'a': 510244585160389217769106449722952381674178085494L, '_event_type': 'Message'}
510244585160389217769106449722952381674178085494
@MicahZoltu
Copy link
Contributor Author

Same problem occurs when garbage.se contains:

def any():
    ~return(0, 32)

@MicahZoltu
Copy link
Contributor Author

The problem appears to be rooted in serpent.mk_signature(code). In both cases, it is generating an invalid signature like [foo:[]:]. Note the missing return type. Adding an explicit return type to foo via return(library: int256) does not resolve the issue.

@MicahZoltu
Copy link
Contributor Author

I believe the root cause of this is ethereum/serpent#119. Pyethereum should do a better job of failing in this case though, I have probably sunk 2-3 days of effort debugging and troubleshooting this issue, if Pyethereum would have just failed hard on the invalid signature from serpent I would have narrowed down the issue much faster.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant