Vyper: Vyper doesn't read bool returned by Solidity's modifying contracts after state is modified

Created on 1 Apr 2019  路  3Comments  路  Source: vyperlang/vyper

Version Information

  • vyper Version (output of vyper --version): 0.1.0b9
  • OS: linux
  • Python Version (output of python --version): 3.6.7
  • Environment (output of pip freeze):
asn1crypto==0.24.0
atomicwrites==1.3.0
attrdict==2.0.1
attrs==19.1.0
backcall==0.1.0
certifi==2019.3.9
cffi==1.12.2
chardet==3.0.4
cryptography==2.6.1
cytoolz==0.9.0.1
decorator==4.4.0
eth-abi==2.0.0b8
eth-account==0.3.0
eth-bloom==1.0.3
eth-hash==0.2.0
eth-keyfile==0.5.1
eth-keys==0.2.1
eth-rlp==0.1.2
eth-tester==0.1.0b37
eth-typing==2.0.0
eth-utils==1.4.1
ethpm==0.1.4a13
hexbytes==0.1.0
idna==2.8
ipfsapi==0.4.3
ipython==7.4.0
ipython-genutils==0.2.0
jedi==0.13.3
jsonschema==2.6.0
lru-dict==1.1.6
more-itertools==7.0.0
mypy-extensions==0.4.1
parsimonious==0.8.1
parso==0.3.4
pexpect==4.6.0
pickleshare==0.7.5
pluggy==0.9.0
prompt-toolkit==2.0.9
protobuf==3.7.1
ptyprocess==0.6.0
py==1.8.0
py-ecc==1.4.7
py-evm==0.2.0a39
py-geth==2.1.0
pycparser==2.19
pycryptodome==3.8.0
pyethash==0.1.27
Pygments==2.3.1
pytest==4.4.0
pytest-ethereum==0.1.3a6
requests==2.21.0
rlp==1.1.0
semantic-version==2.6.0
six==1.12.0
toolz==0.9.0
traitlets==4.3.2
trie==1.3.8
urllib3==1.24.1
vyper==0.1.0b9
wcwidth==0.1.7
web3==5.0.0a5
websockets==7.0

What's your issue about?

When a Vyper contract casts an address to an interface, and a modifying method is called, such as InterfaceName(address).method(), if the method returns bool, Vyper doesn't see that bool properly when the external contract deployed at address is written in Solidity.

The self-contained minimal test case (which should pass when fixed) is here: https://github.com/michwill/vyper-solidity-bug

bug

Most helpful comment

@michwill appears you were right and I totally forgot about this issue until I spent an hour debugging it...

It's not solidity specific (or even bool specific). It's the same for external calls to vyper contracts an other variable types. It has to do with directly asserting the result of an external call:

https://github.com/ethereum/vyper/issues/1468

The workaround is to set the result equal to a local variable before asserting:

success: bool = self.token.transferFrom(msg.sender, self, token_amount)
assert success

All 3 comments

Pretty sure this is not the case. If it was, this line in Uniswap would fail:

https://github.com/Uniswap/contracts-vyper/blob/master/contracts/uniswap_exchange.vy#L132

since many tokens on Uniswap (pretty sure all) are written in Solidity.

That is exactly how I discovered it: followed Uniswap as an example. However, Uniswap was compiled with vyper-0.1.0b4.
@haydenadams I strongly suspect that this line you have mentioned will fail with the newest vyper when working with contracts written in solidity. But I have to admit that I didn't try to arrange this test with Uniswap

@michwill appears you were right and I totally forgot about this issue until I spent an hour debugging it...

It's not solidity specific (or even bool specific). It's the same for external calls to vyper contracts an other variable types. It has to do with directly asserting the result of an external call:

https://github.com/ethereum/vyper/issues/1468

The workaround is to set the result equal to a local variable before asserting:

success: bool = self.token.transferFrom(msg.sender, self, token_amount)
assert success
Was this page helpful?
0 / 5 - 0 ratings