3

I developed some smart contracts to be deployed to a private PoA (Proof of Authority) blockchain. I spun up a private blockchain via truffle develop and got the following receipt:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.


Starting migrations...
======================
> Network name:    'development'
> Network id:      5777
> Block gas limit: 0x6691b7


1_initial_migration.js
======================

   Replacing 'Migrations'
   ----------------------
   > transaction hash:    0x3d13fe576e83c051ab7814c9c4b221310e55fe49ab4b75e6b0af8905856c9fbf
   > Blocks: 0            Seconds: 0
   > contract address:    0xf00B83D756789D8Ad24a0DceE356B26973279390
   > block number:        1
   > block timestamp:     1559731765
   > account:             0xCe6cd87Dea71E58A020A076dD0a820cC6d3879fB
   > balance:             99.999477214
   > gas used:            261393
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.000522786 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:         0.000522786 ETH


Summary
=======
> Total deployments:   1
> Final cost:          0.000522786 ETH

The Azure solution I am currently using for the private blockchain is the Ethereum on Azure template. This template is set up that nobody has any Ether in their accounts. I configured Truffle as follows:

cloudDev: {
  network_id: "*",
  provider: () =>
    new HDWalletProvider(
      mnemonic,
      "<azure_url>:<azure_port>"
    ),
  gasPrice: 0
}

However, when I execute the deployment to this blockchain, I get the following receipt:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.


Starting migrations...
======================
> Network name:    'cloudDev'
> Network id:      5230
> Block gas limit: 0x2faf080


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x85b99478d90fa12b52b26307ee0fb1d688537a55e4346fdc2fe8a76696f6e2b1
   > Blocks: 0            Seconds: 0
   > contract address:    0x3BE3DeB6910E5493aEbA67141F7FFb560eC80955
   > block number:        24773
   > block timestamp:     1559732366
   > account:             0x4e33D8a245Ad3C28634726607a5F9bb8d7BB295f
   > balance:             0
   > gas used:            261393
   > gas price:           0 gwei
   > value sent:          0 ETH
   > total cost:          0 ETH


   ⠧ Saving migration to chain.Error: Error: StatusError: Transaction: 0xcff0b628f0ae784a33c3fdf4b743c8414cd8031ddd34c6a7efda8bfd9d6e2fdf exited with an error (status 0) after consuming all gas.
     Please check that the transaction:
     - satisfies all conditions set by Solidity `assert` statements.
     - has enough gas to execute the full transaction.
     - does not trigger an invalid opcode by other means (ex: accessing an array out of bounds).
    at Object.run (/home/DevNebulae/.nvm/versions/node/v10.15.3/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:92:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.20 (core: 5.0.20)
Node v10.15.3

What may be the cause of this issue and how can I fix this?

1
  • 1
    Since I had the issue, I switched over to a custom VM with a Geth node running on it and providing the sealer account with a very large amount of gas. If anybody has a solution for this problem, please let the Ethereum community know!
    – DevNebulae
    Jun 15, 2019 at 14:59

3 Answers 3

5

In my case, downgrading Truffle from v5.0.27 to v5.0.5 fixed the issue.

npm i -g [email protected]

0
1

For those who might be encountering this in 2022 and later:

The fix is to add gas and gasPrice parameters directly to your transaction:

contract.FunctionThatRunsOutOfGas(someArgument, { from: senderAddress, gas: 5000000, gasPrice: 500000000 });

This will fix the "transaction exited ... after consuming all gas" error for most cases. Probably will not work when deploying the contract. But it should work when running contract functions.

Trivia:

I'd spent over two hours trying to work around this error with global per-network and per-contract .gas and .gasPrice values. Had no success. Until I'd found this GitHub pull request.

Prior to this pull request, Truffle's getGasEstimate() function never actually estimated gas. There was a hardcoded default gas value in the configuration defaults that was added to the params before we hit the gas estimation function. The gas estimation function would check for gas in the params before estimating, and that value was never empty.

A workaround was to add gas: 0 to the config, which would force the estimation function to do the estimation ...

Apparently, as of version v5.4.11 of September 17 2021, Truffle now performs proper gas estimation. Prior to that - it would be using hardcoded values.

My problem was that Truffle just could not estimate gas correctly for my function. The function is fairly simple. But because Truffle couldn't estimate gas - it would set it too low for the transaction itself. As a result, no matter how much I changed global .gas and .gasPrice values - the function just kept running out of gas.

Which is why I have finally managed to fix it by increasing gas values on the transaction itself.

0

Just wanted to add StatusError exited with an error (status 0) could also be a permission issue. In my case I assigned a wrong wallet and then a modifier caused a revert during migration. If you are on testnet/mainnet you can check the transaction on etherscan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.