Skip to content
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

Brownie console running in Vagrant couldnt connect to ganache running on Host. #371

Closed
GraphicalDot opened this issue Mar 12, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@GraphicalDot
Copy link

GraphicalDot commented Mar 12, 2020

Environment information

  • brownie Version: 1.6.7
  • ganache-cli Version: 2.1.2
  • solc Version: 0.6.2
  • Python Version: 3.7.6
  • OS: linux

What was wrong?

I am running ganache on my ubuntu host and running brownie project on a vagrant machine with ubuntu version18.04.
Brownie couldn't connect to the ganache but web3.py can.
My config file for brownie is

# Brownie configuration file
# https://eth-brownie.readthedocs.io/en/stable/config.html
network:
    default: development # the default network that brownie connects to
    settings:
        gas_limit: "auto"
        gas_price: "auto"
        persist: true
        reverting_tx_gas_limit: false  # if false, reverting tx's will raise without broadcasting
    networks:
        # any settings given here will replace the defaults
        development:
            host: http://172.28.128.1
            gas_price: 0
            persist: false
            reverting_tx_gas_limit: 6721975
            test_rpc:
                cmd: ganache-cli
                port: 3399
                gas_limit: 6721975
                accounts: 10
                evm_version: istanbul
                mnemonic: brownie
        # set your Infura API token to the environment variable WEB3_INFURA_PROJECT_ID
        mainnet:
            host: https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        goerli:
            host: https://goerli.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        kovan:
            host: https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        rinkeby:
            host: https://rinkeby.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        ropsten:
            host: https://ropsten.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        classic:
            host: https://www.ethercluster.com/etc
        kotti:
            host: https://www.ethercluster.com/kotti
pytest:
    # these settings replace the defaults when running pytest
    gas_limit: 6721975
    default_contract_owner: true
    reverting_tx_gas_limit: 6721975
    revert_traceback: true
compiler:
    evm_version: null
    minify_source: false
    solc:
        version: null
        optimize: true
        runs: 200

The port is open on host to accept new connections which can be checked with netstat.

tcp        0      0 127.0.0.1:2222          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:5949          0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      -                   
tcp        0      0 172.28.128.1:3399       0.0.0.0:*               LISTEN      9425/Ganache        


  • what command you ran
(ERC721Implementation) vagrant@ethereum:~/EthereumProjects/ERC721Implementation$ ipython
Python 3.7.6 (default, Dec 19 2019, 23:50:13) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import os 
   ...: from web3 import Web3, HTTPProvider                                                                                                                                                                                                                                                                             

In [2]: w3 = Web3(HTTPProvider('http://172.28.128.1:3399'))                                                                                                                                                                                                                                                             

In [3]: w3.eth.accounts                                                                                                                                                                                                                                                                                                 
Out[3]: 
['0xd5373B59FDF14e9F1f5cc858eCAE0e6662FfedC1',
 '0x533D7aa17435Ee227FdC30BA94fF8a509532D776',
 '0x40E29Ca2269785f2F53d7E41006FC83eb3df4D0a',
 '0x537f82751024Ed22F9f943e32A30e47B5A1Da6Df',
 '0x28556574cfE7331738FadEE2fb6eC2630A9C142b',
 '0xfe96534827B237951d4Ab4018Ff8c014B8918521',
 '0xF32D5DfeCf6e1F6Fb2b29DF29Aba8fBd6bCB9D9E',
 '0x88fdA9f0938A1fB5C5C902aeA8Bf28dE76d5467f',
 '0xf6FAdCF3e805E61B1051A610a38365c74310ecCc',
 '0x42904B9429E8d0599b90d6E24dF578684c0E03d3']

In [4]: !brownie console                                                                                                                                                                                                                                                                                                
Brownie v1.6.7 - Python development framework for Ethereum

ErcImplementationProject is the active project.
  File "brownie/_cli/__main__.py", line 57, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/console.py", line 44, in main
    network.connect(ARGV["network"])
  File "brownie/network/main.py", line 42, in connect
    rpc.attach(host)
  File "brownie/network/rpc.py", line 122, in attach
    raise ProcessLookupError("Could not find RPC process.")
ProcessLookupError: Could not find RPC process.

How can it be fixed?

Fill this in if you know how the bug could be fixed.

@iamdefinitelyahuman
Copy link
Member

Thanks for letting me know! I have an idea what the issue is, will take a look.

A workaround is to let brownie launch ganache itself rather than attaching to an already running process.

@iamdefinitelyahuman iamdefinitelyahuman added bug Something isn't working priority Should be included in next release labels Mar 13, 2020
@GraphicalDot
Copy link
Author

If the ganache is running locally then brownie doesn't have any problems connecting to it.

@iamdefinitelyahuman
Copy link
Member

I think handled in #972

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants