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
Labels
Milestone
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 contractsCurrent 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
Web3.js v1.3.5
Solidity - 0.6.12 (solc-js)
The text was updated successfully, but these errors were encountered: