Artifacts are from different compiler runs MacOS Node 14

I still got same problem. Deleted build folder and run compile --all again.
Problem persists.

Here are my packages:
“ensdomains/ens”: “^0.4.5”,
“ensdomains/resolver”: “^0.2.4”,
“gnosis.pm/safe-contracts”: “^1.2.0”,
“openzeppelin/contracts”: “^3.2.0”,
“openzeppelin/contracts-ethereum-package”: “^3.0.0”,
“openzeppelin/truffle-upgrades”: “^1.2.3”

NODE v14.7.0
NPM 6.14.7
MACOS Catalina
Truffle v5.1.53 (core: 5.1.53)
SOLC: 0.6.0+commit.26b70077.Emscripten.clang

// Compiled contracts

Compiling @ensdomains/ens/contracts/ENS.sol
Compiling @ensdomains/resolver/contracts/Resolver.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol
Compiling @openzeppelin/contracts/GSN/Context.sol
Compiling @openzeppelin/contracts/access/Ownable.sol
Compiling @openzeppelin/contracts/math/SafeMath.sol
Compiling @openzeppelin/contracts/token/ERC20/IERC20.sol

ERROR:

Error: Artifacts are from different compiler runs
    Run a full recompilation using `truffle compile --all`
    https://zpl.in/upgrades/truffle-recompile-all
    at reconstructSolcInputOutput (/.../.../node_modules/@openzeppelin/truffle-upgrades/src/validate.ts:70:15)
...
1 Like

Hi @filipesoccol,

Welcome to the community :wave:

I am sorry that you are having this issue. I wasn’t able to reproduce using Truffle and Node 14 unfortunately on Windows Subsystem for Linux (WSL2).

Can you share a cut down version of your contract so that I can try to reproduce?

I also recommend that you change from OpenZeppelin Contracts Ethereum Package to OpenZeppelin Contracts Upgradeable (see: First release of OpenZeppelin Contracts Upgradeable)

Thanks @abcoathup,

I updated the package to Contracts Upgradeable and cleaned some dependencies, but problem persists. I have a github repo with the project.

Repo

Just run a npm install and them run truffle test. You’ll see even the first time it runs throws an error. Also a file named .openzeppelin/unknown-1337.json is created when I run migrate or test. But I don’t see any useful informations there. The only way I can test is supressing the validation part on oz/validate.js script.

If you could help me I’ll appreciate a lot.

1 Like

I was able to reproduce it. I’ll take a look now.

1 Like

I was able to find the cause of the issue and a workaround is possible.

In two of your migrations you run:

artifacts.require('@openzeppelin/contracts/ERC20.sol');

This is copying our ERC20 artifact into the artifacts directory of Truffle’s test environment, which triggers our detection of independent compilation artifacts.

If you remove this line from your migration it works. If you need to use ERC20, as a workaround, you can create a Solidity file in your project containing only:

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

(plus pragma, etc.)

And then run artifacts.require('ERC20').

I will see now what we can do to fix this out of the box.

2 Likes

Wow. I have no idea that validations took into account the artifacts imported on migrations.
I was neglecting those requires because I tought they don’t make any difference.

Correcting requires solved the problem. Thank you so much @frangio. :star_struck:

P.S.: Would be nice if the error report those cases.

1 Like

Yes, but it’s very hard to reliably detect. :frowning:

I’ve put together a fix that I’m going to try out for a bit and then release.

1 Like

@filipesoccol I just released the fix in version 1.2.4 of the Truffle plugin. I tried it out on your branch and it works.

Thanks for reporting the issue!

1 Like

Thank you so much @frangio!

2 Likes