New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing a wrong contract via the cli leads to crash with exception #1996

Closed
LefterisJP opened this Issue Jul 29, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@LefterisJP
Collaborator

LefterisJP commented Jul 29, 2018

Problem Definition

Providing a wrong contract via the CLI leads to a crash with exception.

Example trace:

You are connected to the 'smoketest' network and the DB path is: /tmp/lefteris/tmp_ak84ss2/keystore/netid_627/0x67a5e2/log.db
Traceback (most recent call last):
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/web3/contract.py", line 1363, in call_contract_function
    output_data = decode_abi(output_types, return_data)
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_abi/abi.py", line 96, in decode_abi  
    return decoder(stream)                       
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_abi/decoding.py", line 118, in __call__             
    return self.decode(stream)
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_utils/functional.py", line 22, in inner
    return callback(fn(*args, **kwargs))
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_abi/decoding.py", line 164, in decode
    yield decoder(stream)
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_abi/decoding.py", line 118, in __call__
    return self.decode(stream)                                          
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_abi/decoding.py", line 186, in decode
    raw_data = self.read_data_from_stream(stream)            
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/eth_abi/decoding.py", line 279, 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 "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main                                
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code                                              
    exec(code, run_globals)                                
  File "/home/lefteris/ew/raiden/raiden/__main__.py", line 15, in <module>                                
    main()                                        
  File "/home/lefteris/ew/raiden/raiden/__main__.py", line 11, in main                                    
    run(auto_envvar_prefix='RAIDEN')
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/click/core.py", line 722, in __call__     
    return self.main(*args, **kwargs)               
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)     
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)                                       
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func      
    return f(get_current_context(), *args, **kwargs)                    
  File "/home/lefteris/ew/raiden/raiden/ui/cli.py", line 1138, in smoketest                                 
    success = _run_smoketest()
  File "/home/lefteris/ew/raiden/raiden/ui/cli.py", line 1076, in _run_smoketest                                              
    app = run_app(**args)                  
  File "/home/lefteris/ew/raiden/raiden/ui/cli.py", line 670, in run_app                                                                                                                                                                                                        
    discovery=discovery,                                                                                                                                                                                                                                                        
  File "/home/lefteris/ew/raiden/raiden/app.py", line 94, in __init__
    config['settle_timeout'] < default_registry.settlement_timeout_min() or
  File "/home/lefteris/ew/raiden/raiden/network/proxies/token_network_registry.py", line 164, in settlement_timeout_min
    return self.proxy.contract.functions.settlement_timeout_min().call()
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/web3/contract.py", line 1106, in call
    **self.kwargs
  File "/home/lefteris/.virtualenvs/raiden/lib/python3.6/site-packages/web3/contract.py", line 1385, in call_contract_function
    raise BadFunctionCallOutput(msg) from e
web3.exceptions.BadFunctionCallOutput: Could not decode contract function call settlement_timeout_min return data b'' for output_types ['uint256']

Task

  • Catch these exceptions in the beginning and make sure that the contract addresses provided by the user correspond to properly deployed raiden contracts or else quit with an appropriate error.
  • Add a CLI test for it. Depends on #1711 having been merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment