foundry: Not being able to compile because of "Discovered incompatible solidity versions in following"
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
0.2.0
What command(s) is the bug in?
forge build
Operating System
macOS (amd)
Describe the bug
I’m migrating https://www.damnvulnerabledefi.xyz/ v2 to forge as both a CTF exercise and a learning exercise (for Forge).
I’m attempting to migrate the Puppet-v2 challenge and when I attempt to build the code I get this error:
[⠃] Compiling...2022-04-01T06:28:20.723718Z ERROR ethers_solc::resolver: failed to resolve versions
[⠊] Compiling...
Error:
0: Discovered incompatible solidity versions in following
: src/test/puppet-v2/PuppetV2Test.t.sol (^0.6.0) imports:
lib/forge-std/src/stdlib.sol (>=0.6.0 <0.9.0)
src/test/utils/Utilities.sol (>=0.8.0)
src/test/BaseTest.sol (0.8.10)
src/DamnValuableToken.sol (^0.8.0)
lib/forge-std/src/Vm.sol (>=0.6.0)
lib/ds-test/src/test.sol (>=0.4.23)
lib/forge-std/src/Vm.sol (>=0.6.0)
lib/ds-test/src/test.sol (>=0.4.23)
lib/forge-std/src/Vm.sol (>=0.6.0)
lib/forge-std/src/console.sol (>=0.4.22 <0.9.0)
src/test/utils/Utilities.sol (>=0.8.0)
lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol (^0.8.0)
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol (^0.8.0)
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol (^0.8.0)
lib/openzeppelin-contracts/contracts/utils/Context.sol (^0.8.0)
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol (^0.8.0)
If you want to reproduce this clone the puppet-v2 branch from my repo and just hit forge build.
This specific challenge involves a mix of external contracts like WETH9 + Uniswap v2 core + Uniswap v2 periphery.
The testing file that will break everything is PuppetV2Test.t.sol
I’ve already moved WETH9 from being a solidity contract (in the original CTF) to be an artifact deployed using deployCode but as soon you uncomment this line
import "../../puppet-v2/PuppetV2Pool.sol";
and attempt to build, you will see the above error.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (8 by maintainers)
src/test/puppet-v2/PuppetV2Test.t.solis usingpragma solidity 0.8.10;not^0.6.0src/puppet-v2/PuppetV2Pool.solis usingpragma solidity ^0.6.0;. If the Pool is the problem, I’m afraid that I cannot change that. That is part of the CTF, so I would say that there’s a specific reason why Tincho made the contract usesolc <0.8but I need to solve the CTF before saying so.The question would be: is fixable on foundry side? Or should I fix it on my side? If we’re on the second option, do you have any suggestions?
these are semver incompatible
It would be good to specify an array of solc versions i think tho. I don’t feel comfortable removing the pinning and just relying on auto-detection. Being explicit is always better so if it was possible to do this i would:
You cannot import a contract with an incompatible Solidity version in another contract! The ‘right’ way to do this, is via
deployCode, e.g. see here.