1

Following smart contract works fine in Remix and Ganache. However doesn't work on private ethereum blockchains like Kaleido or Azure. What am I missing. When I call setA it consumes all gas and then fails.

pragma solidity ^0.4.24;

contract TestA {
    uint public someValue;

    function setValue(uint a) public returns (bool){
        someValue = a;
        return true;
    }
}

contract TestB {
    address public recentA;

    function createA() public returns (address) {
        recentA = new TestA();
        return recentA;
    }

    function setA() public returns (bool) {
        TestA(recentA).setValue(6);
        return true;
    }
}
Mert Ozdag
  • 13
  • 3

3 Answers3

1

I tried your contract in Kaleido, and found even calling eth_estimateGas with very large numbers was resulting in "out of gas".

I changed the setValue cross-contract call to set a gas value, and I was then able to call setA, and estimating the gas for setA showed just 31663.

recentA.setValue.gas(10000)(6);

I suspect this EVM behavior is related to permissioned chains with a gasprice of zero. However, that is speculation as I haven't investigated the internals.

I've also added eth_estimateGas, and support for multiple contracts in a Solidity file, to kaleido-go here in case it's helpful: https://github.com/kaleido-io/kaleido-go

Another possibility for others encountering "out of gas" calling across contracts - In Geth if a require call fails in a called contract, the error is reported as "out of gas" (rather than "execution reverted", or a detailed reason for the require failing).

  • I have modified the contract to include gas price as you suggested but still it is not working. I still get: status 0x0 Transaction mined but execution failed – Mert Ozdag Jun 20 '18 at 17:32
  • This issue is now fixed in Kaleido. @MertOzdag - you should not run into the issue after you create a new environment. – Vinod Aug 02 '18 at 19:01
0

You are hitting the limit of gas allowed to be spent per block. Information about gas limit is included into every block, so you can check what's this value is right now in your blockchain. Currently on Ethereum MainNet, GasLimit (per block) is about 8 millions (see here https://etherscan.io/blocks)

To fix this, you can start your blockchain with modified genesis file. Try to increase value of gasLimit parameter in your genesis file, which specifies the maximum amount of gas processed per block. Try "gasLimit": "8000000".

Patrik Stas
  • 1,883
  • 17
  • 24
0

Try to discard the return statement of setValue method in contract TestA.

pragma solidity ^0.4.24;

contract TestA {
    uint public someValue;

    function setValue(uint a) public {
        someValue = a;
    }
}