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

VM Exception when interfacing with Kyber contract #606

Open
michaelcohen716 opened this issue Apr 24, 2020 · 8 comments · May be fixed by cleancoindev/macaron-core#5
Open

VM Exception when interfacing with Kyber contract #606

michaelcohen716 opened this issue Apr 24, 2020 · 8 comments · May be fixed by cleancoindev/macaron-core#5

Comments

@michaelcohen716
Copy link

Testing a contract that otherwise works against a ganache mainnet fork but when interfacing with the KyberProxy contract I get VM Exception while processing transaction: revert.

Kyber address: 0x818E6FECD516Ecc3849DAf6845e3EC868087B755

The code is as simple as this

function testFunc() public view returns(uint minConversionRate, uint  slippageRate){
uint value = 1000000000000000;
(minConversionRate, slippageRate) = kyberNetworkProxy.getExpectedRate(ERC20(ETH_ADDRESS), ERC20(snxAddress), value);
}

and the same code works on mainnet without issue. So we can safely rule out any issues related to contract code. Additionally, JS calls to the Kyber contract directly on ganache fork are working, so this bug is specific to interfacing with this contract from another contract on ganache.

Expected Behavior

Return two values from the getExpectedRate view function

Current Behavior

EVM Revert

Possible Solution

Not sure but I've tested with very high gasLimits and it wasn't any help.

Steps to Reproduce (for bugs)

  1. run ganache-cli --fork https://mainnet.infura.io/v3/<infura-token>
  2. run testFunc()

Context

Your Environment

  • Version used: Ganache CLI v6.4.3 (ganache-core: 2.5.5)
  • Version of Truffle/Remix/Other tools used:Truffle v5.0.7 (core: 5.0.7)
  • Solidity - 0.5.0 (solc-js)
  • NodeJS Version: Node v13.3.0
@davidmurdoch
Copy link
Member

Looks like you are using a version of ganache-cli released over 1 year ago. Please update to latest (npm install -g ganache-cli) and try again.

If that doesn't fix it, I don't think there is anything on your side you can do at the moment, this is likely a bug in Ganache core itself. :-/

That said, if you don't have access to archive data at Infura, forking might not always behave as expected.

It's not immediately apparent to me what could be going wrong, and I can't jump to fix this at the moment. If you have time to dive in and try to track down whats going wrong, all the forking-related code is contained within these two files:

https://github.com/trufflesuite/ganache-core/blob/develop/lib/utils/forkedblockchain.js

https://github.com/trufflesuite/ganache-core/blob/develop/lib/utils/forkedstoragetrie.js

@michaelcohen716
Copy link
Author

Troubleshooted with latest ganache version after posting this. Still facing same bug

@alonmuroch
Copy link

I'm experiencing a similar thing with uniswap when forking

Uniswap/v2-periphery#44

@davidmurdoch davidmurdoch transferred this issue from trufflesuite/ganache-cli-archive Aug 14, 2020
@bertmiller
Copy link

bertmiller commented Oct 25, 2020

Hi, commenting to add that I am also facing the same problem with Kyber, and have had similar issues with 1inch and Curve.

@mikeseese
Copy link
Contributor

@michaelcohen716 @alonmuroch @bertmiller, any chance any of you can try reproducing the issue with the latest version?

ganache-cli: https://github.com/trufflesuite/ganache-cli/releases/tag/v6.12.0
ganache-core: https://github.com/trufflesuite/ganache-core/releases/tag/v2.13.0

We fixed a handful of issues with storage that hopefully fixed this issue. Thanks!

@michaelcohen716
Copy link
Author

it's been awhile so probably won't be able to reproduce. good luck!

@bertmiller
Copy link

@seesemichaelj so, I checked and I'm up to date on ganache-cli and ganache-core.

On my 1st try I was able to compile and execute a smart contract that interfaced with 1inch. Success!
Then I moved to compile and execute a smart contract that interfaced with Kyber. This failed with a VM exception.
Then I returned to my 1inch smart contract. Same code as before. But bewilderingly after restarting ganache, re-compiling, and re-executing it now returns a VM exception.

@mikeseese
Copy link
Contributor

Thanks for the info @bertmiller! I'm going to defer to @davidmurdoch on this one going forward due to a shift of priorities on my end

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

Successfully merging a pull request may close this issue.

6 participants