1

For clearity I am using two different ubuntu machines as follows, please note that both machines are sync to my private black chain and working on the same smart-contract:

Contract call was working on 1.9.9 where it starts not to work on 1.9.13.

=> ubuntu-a uses:

- web3==5.7.0`, Python `3.6.8`, OS: `linux` on `venv`
- geth Version: 1.9.9-stable

Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

=> ubuntu-b uses:

- On `web3==5.7.0`, Python `3.7.5` on `venv` I have also tried for Python `3.6.8`
- geth Version: 1.9.13-unstable

Ubuntu 19.10
Release:    19.10
Codename:   eoan

Following function call works using web3py on ubuntu-a which has (geth Version: 1.9.9-stable): but when I upgrade the geth version to geth Version: 1.9.13-unstable it starts not to work.

contract.functions.getReceivedStorageDeposit(b'97fc72c7b24e499b79cb9e2d42300ad1').call()

where the function has the following signature:

function getReceivedStorageDeposit(bytes32 sourceCodeHash)
    external
    view
    whenProviderRegistered returns (uint256)

On ubuntu-b, I get the following error message:

Traceback (most recent call last):
  File "/home/alper/venv/lib/python3.7/site-packages/web3/contract.py", line 1432, in call_contract_function
    output_data = web3.codec.decode_abi(output_types, return_data)
  File "/home/alper/venv/lib/python3.7/site-packages/eth_abi/codec.py", line 181, in decode_abi
    return decoder(stream)
  File "/home/alper/venv/lib/python3.7/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/home/alper/venv/lib/python3.7/site-packages/eth_utils/functional.py", line 45, in inner
    return callback(fn(*args, **kwargs))
  File "/home/alper/venv/lib/python3.7/site-packages/eth_abi/decoding.py", line 173, in decode
    yield decoder(stream)
  File "/home/alper/venv/lib/python3.7/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/home/alper/venv/lib/python3.7/site-packages/eth_abi/decoding.py", line 198, in decode
    raw_data = self.read_data_from_stream(stream)
  File "/home/alper/venv/lib/python3.7/site-packages/eth_abi/decoding.py", line 308, in read_data_from_stream
    len(data),
eth_abi.exceptions.InsufficientDataBytes: Tried to read 32 bytes.  Only got 0 bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "koo.py", line 5, in <module>
    eBlocBroker.functions.getReceivedStorageDeposit(b"").call()
  File "/home/alper/venv/lib/python3.7/site-packages/web3/contract.py", line 904, in call
    **self.kwargs
  File "/home/alper/venv/lib/python3.7/site-packages/web3/contract.py", line 1454, in call_contract_function
    raise BadFunctionCallOutput(msg) from e
web3.exceptions.BadFunctionCallOutput: Could not decode contract function call getReceivedStorageDeposit return data b'' for output_types ['uint256']

[Q] What may cause this error? How can I fix it?

20
  • I tried to comment on this question when you just posted it, but you deleted it before I managed to complete the comment and send it. Anyway, can you try to replace b'97fc72c7b24e499b79cb9e2d42300ad1' with 0x97fc72c7b24e499b79cb9e2d42300ad1 (an integer), and also with '0x97fc72c7b24e499b79cb9e2d42300ad1' (a string)? At least on web3.js, I know that the string option works, so perhaps web3.py dev-team has decided to align with "the parent". – goodvibration Mar 19 '20 at 8:43
  • Sorry I thought it was related to web3py's version or Python. I tried both cases but I wanted to be sure. I have tried using "0x..." which also had the same error message. – alper Mar 19 '20 at 10:25
  • It does sound related to web3.py version (at least it did in the original question, maybe I've missed some of your points in this one)... So I figured that they might have decided to align it with web3.js behavior, hence the error. – goodvibration Mar 19 '20 at 10:44
  • Its pretty difficult on my end to figure out what's wrong because the latest web3py works on ubuntu version 18.0 but does not work on the version 19.0. Its also diffuclt to downgrade ubuntu to debug it more. Could it also be related to geth version? – alper Mar 19 '20 at 10:48
  • BTW, 97fc72c7b24e499b79cb9e2d42300ad1 is only 16 bytes, so why are you passing this piece of data to a function which expects 32 bytes? The b prefix indeed makes it into an array of 32 bytes, but the information contained in each one of them is at most 4-bit long. Is that really what you had in mind? – goodvibration Mar 19 '20 at 10:55
0

@karalabe (https://github.com/ethereum/go-ethereum/issues/20785#issuecomment-601590678)

We've merged in a change to eth_call so that it will not default to your first account if you don't specify any sender (rather to 0x00). This was made to make the operations more predictable in different environments.


I was calling as follows, where inside call() was empty:

self.eB.functions.func(source_code_hash).call()

adding from: option identifying the called addres is fixed the problem.

self.eB.functions.func(source_code_hash).call({"from": self.w3.toChecksumAddress("0x47b60037B89954eC7149132c606BA024fBb0f991")})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.