Truffle

消耗所有氣體後交易退出並出現錯誤(狀態 0)

  • February 22, 2022

我開發了一些智能合約以部署到私有 PoA(權威證明)區塊鏈。我通過創建私有區塊鏈truffle develop並獲得以下收據:

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

我目前用於私有區塊鏈的 Azure 解決方案是Azure模板上的 Ethereum 。此模板設置為沒有人在其帳戶中擁有任何乙太幣。我將鬆露配置如下:

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

但是,當我執行到此區塊鏈的部署時,我會收到以下收據:

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

這個問題的原因可能是什麼,我該如何解決這個問題?

就我而言,將 Truffle 從 v5.0.27 降級到 v5.0.5 解決了這個問題。

npm 和 -g truffle@v5.0.5

只是想添加 StatusError exited with a error (status 0) 也可能是權限問題。就我而言,我分配了一個錯誤的錢包,然後一個修改器在遷移過程中導致了還原。如果你在 testnet/mainnet 上,你可以在 etherscan 上檢查交易。

引用自:https://ethereum.stackexchange.com/questions/71481