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

support ganache v7 #1406

Closed
gosuto-inzasheru opened this issue Jan 21, 2022 · 5 comments
Closed

support ganache v7 #1406

gosuto-inzasheru opened this issue Jan 21, 2022 · 5 comments

Comments

@gosuto-inzasheru
Copy link
Contributor

gosuto-inzasheru commented Jan 21, 2022

Environment information

  • brownie Version: 1.17.0
  • ganache-cliganache Version: 7.0.0

What was wrong?

$ npm uninstall --global ganache-cli ganache-core

removed 101 packages, and audited 1 package in 680ms

found 0 vulnerabilities
$ npm install --global ganache

added 29 packages, and audited 30 packages in 1m

found 0 vulnerabilities
$ ganache --version
ganache v7.0.0 (@ganache/cli: 0.1.1, @ganache/core: 0.1.1)
$ brownie console
Brownie v1.17.0 - Python development framework for Ethereum

Generating interface ABIs...
*** is the active project.

Launching 'ganache-cli --fork https://mainnet.infura.io/v3/*** --port 8545 --chainId 1 --hardfork istanbul'...
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/run.py", line 44, in main
    network.connect(CONFIG.argv["network"])
  File "brownie/network/main.py", line 50, in connect
    rpc.launch(active["cmd"], **active["cmd_settings"])
  File "brownie/network/rpc/__init__.py", line 93, in launch
    raise RPCProcessError(cmd, uri)
RPCProcessError: Unable to launch local RPC client.
Command: ganache-cli
URI: http://127.0.0.1:8545
npm uninstall --global ganache                 

removed 29 packages, and audited 1 package in 636ms

found 0 vulnerabilities
$ npm install --global ganache-cli
npm WARN deprecated ganache-cli@6.12.2: ganache-cli is now ganache; visit https://trfl.io/g7 for details

added 1 package, and audited 102 packages in 4s
$ ganache-cli --version
Ganache CLI v6.12.2 (ganache-core: 2.13.2)
$ brownie console                        
Brownie v1.17.0 - Python development framework for Ethereum

*** is the active project.

Launching 'ganache-cli --fork https://mainnet.infura.io/v3/*** --port 8545 --chainId 1 --hardfork istanbul'...
Brownie environment is ready.
>>>

How can it be fixed?

obviously starting v7 ganache-cli got renamed to ganache, but i do not know if there are any other breaking changes. there is an official upgrade guide here: https://github.com/trufflesuite/ganache/blob/develop/UPGRADE-GUIDE.md

@felixsc1
Copy link

felixsc1 commented Jan 22, 2022

It works fine for me. After the update the ganache-cli command still exists but shows version 0.7.

I notice a problem with it though:
It seems that the new ganache is not returning virtual machine errors in the same way as brownie expects. Whatever this "exc" variable below usually contains, it is now None.

To get the error below I tested a solidity onlyOwner function with a non-owner account and with pytest.raises(exceptions.VirtualMachineError). The workaround is to use AttributeError instead

self = <Transaction '0x1af548f26bc63c4ba1144ff2c03583cdd92a907d37442178272bfcb8dc5eacd8'>, exc = None

    def _raise_if_reverted(self, exc: Any) -> None:
        if self.status or CONFIG.mode == "console":
            return
        if not web3.supports_traces:
            # if traces are not available, do not attempt to determine the revert reason
            raise exc or ValueError("Execution reverted")

        if self._dev_revert_msg is None:
            # no revert message and unable to check dev string - have to get trace
            self._expand_trace()
        if self.contract_address:
            source = ""
        elif CONFIG.argv["revert"]:
            source = self._traceback_string()
        else:
            source = self._error_string(1)
            contract = state._find_contract(self.receiver)
            if contract:
                marker = "//" if contract._build["language"] == "Solidity" else "#"
                line = self._traceback_string().split("\n")[-1]
                if marker + " dev: " in line:
                    self._dev_revert_msg = line[line.index(marker) + len(marker) : -5].strip()

>       raise exc._with_attr(
            source=source, revert_msg=self._revert_msg, dev_revert_msg=self._dev_revert_msg
        )
E       AttributeError: 'NoneType' object has no attribute '_with_attr'

@iSOcH
Copy link

iSOcH commented Jan 22, 2022

Forking a network with ganache v7 also currently does not work. Looks like they changed --chainId to --chain.chainId

@gosuto-inzasheru
Copy link
Contributor Author

@felixsc1 could it be that this is due to vmErrorsOnRPCResponse now defaulting to false? do you experience the same issue when starting ganache using the --vmErrorsOnRpcResponse flag?

@mliudev
Copy link

mliudev commented Feb 3, 2022

I found this PR which should address this issue: #1410

@iamdefinitelyahuman
Copy link
Member

Support for ganache v7 is added in the v1.18.0 release

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

No branches or pull requests

5 participants