Unable to run tests using ganache-cli and open-zepplin 2.4.0

Hi OZ team, I have upgraded one of our projects to use OZ 2.4.0 release but run into a few problems when trying to build the project.

All our tests pass first time locally using truffle (local) but when running on a CI test runner (GitHub Actions) we hit the issues below:

  • Initial state - tests passing - OZ 2.3.0 (all good)

  • Bump to OZ 2.4.0 - test failing - this error makes sense, I needed to bump to a EVM with compatible instructions, error; I get is:

@openzeppelin/contracts/utils/Address.sol:29:32: Warning: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for. It will be interpreted as an invalid instruction on this VM.
        assembly { codehash := extcodehash(account) }
  • After bumping to 0.5.5 and upwards I get the following:
    Error: while migrating Migrations: Returned error: VM Exception while processing transaction: invalid opcode

  • Tried solc 0.5.5 - 0.5.12 and ganache-cli latest and @instabul (beta version) with the same issues being raised.

  • I have also tried using OZ 2.3.0 with newer versions of solc without much luck - this also fail

I suspect its an issue with ganache-cli just wondered if you have come across it or know or any issues around using ganache-cli and OZ 2.4.0 ?

1 Like

Hi @jamesmorgan,

Sorry to hear that you are having an issue with CI and OpenZeppelin Contracts 2.4.

I had seen an issue with Remix which was resolved by bumping the required compiler version for Address.sol

I haven’t come across this anywhere else. I couldn’t find a relevant issue in the ganache-cli repository either.

Are you able to share your GitHub repository (or some minimal code/CI config), as would be great to be able to reproduce?

Thanks for the quick response, I can share some code yes.

This is the branch which has been failing with a 2.4.0 upgrade - https://github.com/blockrockettech/tokenlandia-contracts/pull/2

You can see the failed test CI run here - https://github.com/blockrockettech/tokenlandia-contracts/runs/292651294

The CI runner uses the yml file here .github/workflows/node_test_runner.yml

Let me know if you spot something.

Many thanks for taking a look.


1 Like

Hi @jamesmorgan,

The issue appears to be the version of solidity-coverage which spins up it’s own testrpc (which I assume doesn’t support the latest opcodes).
I get the same error when running locally:

$ npm run coverage


Using account [0x81945dA5e825E6694F6d73dF862f6777aC65930e] for network [coverage]
Error: Error: Error: while migrating Migrations: Returned error: VM Exception while processing transaction: invalid opcode

To resolve you could try using the solidity-coverage beta version:

I did the following locally:

npm uninstall solidity-coverage
npm install --save-dev solidity-coverage@beta

Remove the coverage network in truffle-config.js
Add solidity-coverage as a truffle plugin in truffle-config.js

  plugins: [

Run coverage

truffle run coverage

Hi @jamesmorgan,

As an aside, you could use abi.encodePacked for string concatenation see the following PR:

This is part of a potential ERC721 extension which includes a Strings library (just does uint256 to string):

Thanks for your awesome support, OZ 2.4.0 working as expected now, may thanks :pray:

1 Like