trufflesuite / ganache-cli-archive

Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.
https://www.trufflesuite.com/ganache
MIT License
3.36k stars 695 forks source link

delegatecall always throws exception #614

Closed haseebrabbani closed 5 years ago

haseebrabbani commented 5 years ago

Expected Behavior

When invoking a contract function using delegatecall, expecting the function to be invoked without throwing an exception

Current Behavior

Invoking a function using delegatecall always throws an exception

Steps to Reproduce (for bugs)

  1. Run ganache-cli locally
  2. Open up Remix in Chrome browser (https://remix.ethereum.org/#optimize=false&version=soljson-v0.4.24+commit.e67f0147.js)
  3. Connect to local Ganache on port 8545 using Metamask (and import at least one Ganache account)
  4. Load the following Implementation and Proxy contracts into Remix
    
    pragma solidity 0.4.24;

contract Implementation {

bool public boolean = false;

function initBoolean() public {
    boolean = true;
}

}

pragma solidity 0.4.24;

/**

Context

This bug is preventing our app from working correctly while pointed to a local instance of ganache-cli. The issue also reproduces with Ganache UI 1.2.3.397. We verified that the above contracts work as expected on Rinkeby, as well as the Remix Javascript VM. What is also strange is that our Mocha tests written for this specific scenario pass successfully.

Your Environment

davidmurdoch commented 5 years ago

Thanks for filing the issue, @haseebrabbani. This is due to a gas estimation bug when contract functions use certain op codes defined in EIP-150. We are currently working on a fix for this underestimation bug and are tracking this issue here: https://github.com/trufflesuite/ganache-core/issues/147

davidmurdoch commented 5 years ago

This should now be fixed in the latest beta tagged releases of ganache-cli and ganache-core.

This fix involved pretty significant code changes; check out the release notes for details.

We'd love it if you'd test this beta out to make sure things are good to go before we release to stable.

If you using ganache-cli, run:

npm install -g ganache-cli@beta

If you are using ganache-core, run:

npm install ganache-core@beta

Let us know if you discover any bugs with this new beta release! Thanks!