Closed haseebrabbani closed 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
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!
Expected Behavior
When invoking a contract function using
delegatecall
, expecting the function to be invoked without throwing an exceptionCurrent Behavior
Invoking a function using
delegatecall
always throws an exceptionSteps to Reproduce (for bugs)
ganache-cli
locallyImplementation
andProxy
contracts into Remixcontract Implementation {
}
pragma solidity 0.4.24;
/**
@dev source https://github.com/zeppelinos/labs/blob/master/upgradeability_using_unstructured_storage/contracts/Proxy.sol */ contract Proxy {
// Storage position of the address of the current implementation bytes32 private constant implementationPosition = keccak256("org.meridio.proxy.implementation");
/**
/**
/**
This function will return whatever the implementation call returns */ function () payable public { address _impl = implementation(); require(_impl != address(0));
assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size)
} } }
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