Ganache-cli: Invalid opcode when deploying ConvertLib from metacoin with ganache v6.1.2

Created on 12 Jun 2018  路  9Comments  路  Source: trufflesuite/ganache-cli

While trying to migrate metacoin example with ganache-cli v6.1.2 it fails with

Error: VM Exception while processing transaction: invalid opcode

Expected Behavior

With ganache-cli v6.1.0 it deploy without issue

Current Behavior

With ganache-cli v6.1.2 it fails to deploy with

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0xaed2971eaa09c508c53f7fad14850cda331ebb38148666160fdc366b8f262075
  Migrations: 0xc867923bc1c5d4e215c1b729fdb47f1a97573de5
Saving successful migration to network...
  ... 0xbac48c3993fcf2c88eb6211765cc1287905414b08b04be8991d6c9a6fabb11c4
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying ConvertLib...
  ... 0x594b7fb3c7aa77020965f1ebc18a9801252c80414a2205dfe7a1a4018a12dc8b
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: VM Exception while processing transaction: invalid opcode
    at Object.InvalidResponse (C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\errors.js:38:1)
    at C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
    at C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-migrate\index.js:225:1
    at C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:509:1)
    at IncomingMessage.<anonymous> (C:\Users\daffy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:469:1)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Possible Solution

Downgrade to ganache-cli v6.1.0 as temporary measure seems to work.

Steps to Reproduce (for bugs)

  1. mkdir metacoin
  2. cd metacoin
  3. truffle unbox metacoin
  4. edit truffle.js to add
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      gas: 47000000000,
      gasPrice: 1
    }
  }
  1. launch ganache-cli with ganache-cli.cmd -l 47000000000 -p 8545
  2. truffle compile
  3. truffle migrate

Context

Your Environment

  • Version used:
    ganache-cli v6.1.2

  • Version of Truffle/Remix/Other tools used:
    $ truffe.cmd version
    Truffle v4.1.11 (core: 4.1.11)
    Solidity v0.4.24 (solc-js)

  • NodeJS Version: [ ] 6.x, [ ] 7.x (unsupported), [x] 8.x, [ ] 9.x
    $ node --version
    v8.11.2

  • Operating System and version (include distro if Linux):
    Windows 7 x64
    Also happens with a travis-ci build on Ubuntu 16.04

  • Link to your project or repro gist:

  • Commit hash to use with above link for reproduction:

  • I intend to submit a pull request to fix this issue: [ ]

bug

Most helpful comment

Thanks everyone for the quick reporting & sleuthing on this - [email protected] has just been released, and it should fix this problem.

This was really a process failure on my part. Prior to releasing I usually run the zeppelin-solidity test suite against the ganache-cli release candidate as a smoke test to make sure everything is good. I skipped that step last time. We'll take this as a hard prod to get that process baked into our CI builds!

All 9 comments

Same issue here, deploying a library with the new ganache-cli v6.1.2 fails with invalid opcode consuming all gas. If it helps, transaction and receipt for the lib deployment are below

truffle(development)> web3.eth.getTransactionReceipt("0x159d8c2a4ef243e89a32c4d38c555ba57914d455e85335f36525140bfd1c9d53")
{ transactionHash: '0x159d8c2a4ef243e89a32c4d38c555ba57914d455e85335f36525140bfd1c9d53',
  transactionIndex: 0,
  blockHash: '0x79b8cb328be16f412b92b0099b7d25f3b03f542077c697b1c558b0923b4151f3',
  blockNumber: 15,
  gasUsed: 6700000,
  cumulativeGasUsed: 6700000,
  contractAddress: '0x3cdd6370b1239c1a09fd930b6e97277a96ac8700',
  logs: [],
  status: '0x0',
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' }
truffle(development)> web3.eth.getTransaction("0x159d8c2a4ef243e89a32c4d38c555ba57914d455e85335f36525140bfd1c9d53")
{ hash: '0x159d8c2a4ef243e89a32c4d38c555ba57914d455e85335f36525140bfd1c9d53',
  nonce: 14,
  blockHash: '0x79b8cb328be16f412b92b0099b7d25f3b03f542077c697b1c558b0923b4151f3',
  blockNumber: 15,
  transactionIndex: 0,
  from: '0xb77d57f4959eafa0339424b83fcfaf9c15407461',
  to: '0x0',
  value: BigNumber { s: 1, e: 0, c: [ 0 ] },
  gas: 6700000,
  gasPrice: BigNumber { s: 1, e: 11, c: [ 100000000000 ] },
  input: '0x61020d610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f300730000000000000000000000000000000000000000301460806040526004361061008e5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630dd11c7481146100935780631f0cd67b146100b35780631f49da09146100d55780634dad5d1e146100e357806395e0488c146100f1578063c7f62b91146100ff575b600080fd5b6100a160043560243561010d565b60408051918252519081900360200190f35b6100c1600435602435610129565b604080519115158252519081900360200190f35b6100c160043560243561015b565b6100a160043560243561017c565b6100c1600435602435610198565b6100a16004356024356101c4565b6000610119838361015b565b151561012457600080fd5b500290565b600080821215801561013d57508282840313155b806101545750600082128015610154575082828403135b9392505050565b60008115806101545750828283850281151561017357fe5b05149392505050565b60006101888383610198565b151561019357600080fd5b500190565b60008082121580156101ac57508282840112155b80610154575060008212801561015457505081011290565b60006101d08383610129565b15156101db57600080fd5b509003905600a165627a7a723058207596a20bb53527bcac49062dc881e567b8a2aad70db66250ebcec536954ebde30029' }

Thanks for detailed write ups! Will look at this tomorrow!

The same problem here with LIBS contracts

It seems to me a bug related to ethereumjs-vm, and in particular about how BYTE opcode is implemented. [email protected] now references [email protected], and it uses [email protected]. There's already a pull request for ganache-core upgrading the reference to the fixed version [email protected]

To reproduce the bug I tried to deploy the same lib over the two versions.

These are the opcodes executed over 6.1.0 (the good one):

PUSH1
PUSH2
PUSH1
DUP3
DUP3
DUP3
CODECOPY 0xdc 0x2f 0xb
DUP1
MLOAD 0xb
PUSH1
BYTE 0x7300000000000000000000000000000000000000003014608060405260043610 0x0 <--- BYTE here
PUSH1
EQ 0x73 0x73 <--- 1st EQ
PUSH1
DUP2
EQ 0x0 0x1 <--- 2nd EQ, notice 0x1
PUSH2
JUMPI 0x0 0x1f
PUSH2
JUMP 0x21
JUMPDEST
POP 0x1
ADDRESS
PUSH1
MSTORE 0x7034d9b815d6d1e96016ed33e205d78db6394412 0x0
PUSH1
DUP2
MSTORE8 0x73 0xb
DUP3
DUP2
RETURN 0xdc 0xb

These are the opcodes executed over 6.1.2. I sent exactly the same transaction but it fails:

PUSH1
PUSH2
PUSH1
DUP3
DUP3
DUP3
CODECOPY 0xdc 0x2f 0xb
DUP1
MLOAD 0xb
PUSH1
BYTE 0x7300000000000000000000000000000000000000003014608060405260043610 0x0 <---- BYTE here
PUSH1
EQ 0x73 0x73 <---- 1st EQ
PUSH1
DUP2
EQ 0x0 0x0 <---- 2nd EQ, notice 0x0
PUSH2
JUMPI 0x1 0x1f
JUMPDEST
INVALID

As you can see in 6.1.0 EQ output is 0x1 (true), so the next EQ is false and the JUMP is not executed. In 6.1.2 the first EQ returns 0x0 (false), so the second EQ returns true and the JUMP is executed, returning error.

Thus the culprit seems to be the BYTE operation, fixed in [email protected].

Fantastic; thanks @Neurone! I will look at the reproduction and see if upgrading ethereumjs-vm to 2.3.5 fixes this and doesn't cause any blatant issues with our other tests

I updated ganche-core to use [email protected] and then ganache-cli started working as usual, but I needed to fix these two files first, because [email protected] renamed the function StateManager._putAccount to StateManager.putAccount

Was able to reproduce the problem. We're working the release now

Thanks everyone for the quick reporting & sleuthing on this - [email protected] has just been released, and it should fix this problem.

This was really a process failure on my part. Prior to releasing I usually run the zeppelin-solidity test suite against the ganache-cli release candidate as a smoke test to make sure everything is good. I skipped that step last time. We'll take this as a hard prod to get that process baked into our CI builds!

I can verify that the metabox Truffle box now works with 6.1.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zweicoder picture zweicoder  路  3Comments

zatsepinvl picture zatsepinvl  路  5Comments

mariam-crissi picture mariam-crissi  路  6Comments

SCBuergel picture SCBuergel  路  5Comments

remote-gildor picture remote-gildor  路  4Comments