Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Launching ganache with fork is throwing revert errors when communicating with 3rd party contracts #956

Open
haydenyoung opened this issue May 13, 2021 · 1 comment

Comments

@haydenyoung
Copy link

Expected Behavior

I run a development chain I fork kovan because I am testing some interactions with 3rd party contracts (mainly defi and oracles).

Some of my smart contracts make calls to chain link and uniswap contracts. These are available on the forked chain.

When I run truffle test the tests should complete successfully, even those that communicate with 3rd party contracts via my locally deployed contracts

Current Behavior

When I run truffle test, my unit tests run correctly. However, when using either solidity coverage or when using web3 from a web page, my contracts throw a "Revert" whenever I call a function from my smart contract which then goes on to call a 3rd party contract, either a chainlink or uniswap contract. If I call the 3rd party contract directly from web3 and javascript and truffle's TruffleContract interface I do not run into this issue so this seems to be isolated to my smart contracts.

I have verbose on ganache-cli but I'm not seeing any errors.

I am seeing this problem on Rinkeby as well so I don't think it is a chain-related issue.

Steps to Reproduce (for bugs)

I have created a small example of this issue which I hope will help with replication.

https://github.com/haydenyoung/metacoin

To install:

check out from git,
npm ci.

Make sure truffle and ganche-cli are installed.

Start up ganache-cli with a fork of kovan:

npx ganache-cli -d -m "seed phrase" -f https://eth-kovan.alchemyapi.io/v2/DjLaJSg4gNXdWfDmSufgzuFeRBs-2eRw -v

replacing seed phrase with what is configured in truffle-config.js.

Run tests to see a successful output:

truffle test

If everything is install correctly you should see successful output. I have just console.log(ged) the output but it should be bignumber.

Next, run:

truffle run coverage

This will result in a revert error which I am almost certain is a failure of the MetaCoin2 contract to contact the 3rd party chainlink contract. My expectation is that the MetaCoin2 contract should successfully communicate with the chainlink contract as it does above when running truffle test.

One other interesting thing is that I'm experiencing the same problem when integrating into a UI frontend using Vue.js. Same revert error.

One other thing is that this does not happen if I deploy two contracts from my project and have one communicate with the other.

If truffle test was breaking as well I would imagine there is some kind of abi issue. However, this seems quite inconsistent and I do not have this problem with truffle test but do with coverage and interacting with the contracts from a front end app.

I originally posted this to the solidity coverage devs but a) I haven't heard back and b) I'm wondering if this is a deeper issue with ganache. Please see sc-forks/solidity-coverage#628.

Context

I have managed to create test harnesses and mocks to handle this shortcoming but it does make it difficult to test against real-world contracts and maintaining mocks has increased development time (and has added complexity to the code base).

Your Environment

  • Version used: Ganache CLI v6.12.2 (ganache-core: 2.13.2)
  • Version of Truffle: Truffle v5.3.4
  • NodeJS Version: Node v12.19.0, NPM 7.11.2
  • Operating System and version (include distro if Linux): Linux
  • Link to your project or repro gist: https://github.com/haydenyoung/metacoin
    Web3.js v1.3.5
    Solidity - 0.6.12 (solc-js)
@davidmurdoch davidmurdoch transferred this issue from trufflesuite/ganache-cli-archive Aug 19, 2021
@davidmurdoch davidmurdoch added this to the 7.1.0 milestone Aug 25, 2021
@davidmurdoch
Copy link
Member

I have a hunch as to what is happening here and it boils down to managing forking state changes over time being complicated :-). I've added his to our backlog and set a high-priority so it can be worked sooner rather than later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Backlog
Development

No branches or pull requests

2 participants