Unable to invoke the Eldarica solver (SMTChecker)
Description
By using solvers = [ 'eld' ] in the foundry.toml file, I get 'Warning (1218): CHC: Error trying to invoke SMT solver.' message. But eldarica is installed in my mac and accessible via the command eld in any folder.
Environment
- Compiler version: solc 0.8.21
- Framework/IDE (e.g. Truffle or Remix): Foundry (forge 0.2.0)
- Operating system: macOS Monterey (12.6.8)
Steps to Reproduce
Using this content in foundry.toml:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
[profile.default.model_checker]
engine = 'chc'
solvers = [ 'eld' ]
timeout = 0
targets = [
"assert",
"constantCondition",
"divByZero",
"outOfBounds",
"overflow",
"underflow"
]
invariants = [ 'contract' ]
showProved = true
showProvedSafe = true
[profile.default.model_checker.contracts]
'src/Monotonic.sol' = [ 'Monotonic' ]
After running this command line 'forge build --force', I get:
[⠢] Compiling...
[⠒] Compiling 16 files with 0.8.21
[⠆] Solc 0.8.21 finished in 8.49s
Compiler run successful with warnings:
Warning (1218): CHC: Error trying to invoke SMT solver.
--> src/Monotonic.sol:7:16:
|
7 | return x * 42;
| ^^^^^^
Warning (1218): CHC: Error trying to invoke SMT solver.
--> src/Monotonic.sol:12:9:
|
12 | assert(f(b) > f(a));
| ^^^^^^^^^^^^^^^^^^^
Warning (5840): CHC: 2 verification condition(s) could not be proved. Enable the model checker option "show unproved" to see all of them. Consider choosing a specific contract to be verified in order to reduce the solving problems. Consider increasing the timeout per query.
For this example (found in SMTchecker documentation from https://docs.soliditylang.org/en/latest/smtchecker.html:
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.8.21;
contract Monotonic {
function f(uint x) internal pure returns (uint) {
require(x < type(uint128).max);
return x * 42;
}
function inv(uint a, uint b) public pure {
require(b > a);
assert(f(b) > f(a));
}
}
Thanks!
Hi @acmLL, I did a quick test here and everything seems to work fine, however I'm on a linux machine, I don't have a macOS to test, I'm sorry. But the fact that it worked for me could be a sign that there is some problem with your eldarica installation. What is your eldarica version?
I tried your example with solc version 0.8.21 and eldarica version 2.0.9.
https://github.com/uuverifiers/eldarica/releases/tag/v2.0.9
> forge build --force
[⠊] Compiling...
[⠢] Compiling 22 files with 0.8.21
[⠔] Solc 0.8.21 finished in 5.16s
Compiler run successful!
Info (9576): CHC: Overflow (resulting value larger than 2**256 - 1) check is safe!
--> src/Monotonic.sol:7:16:
|
7 | return x * 42;
| ^^^^^^
Info (9576): CHC: Assertion violation check is safe!
--> src/Monotonic.sol:12:9:
|
12 | assert(f(b) > f(a));
| ^^^^^^^^^^^^^^^^^^^
Hey, @r0qs . Thanks for your reply. My Eldarica version is v2.0.9 as well. Maybe the problem is related to macOS. I read somewhere that Eldarica works fine in Linux, not with mac OS (The user has to compile solc from source to link with Eldarica...). But I thought that maybe this difficulty was already fixed for macOS. This is the reason I opened up this theme here... Best!
The user has to compile solc from source to link with Eldarica...
This is only true for z3 because it's used via the C++ API. Eldarica is used via a system's binary called eld, so I don't see why it shouldn't work on OSX, as long as that binary itself works, of course. Can you double check whether eld is in the system's $PATH?
Hey, @acmLL. you can fix it by installing the z3 package or update OS version, unless of course you have an M1 chip, but the problem also lies in the Mac OS version, I don't know if it was done intentionally or not, but everyone has problems with version 12 now. For example, I have an Intel chip on my typewriter, so I can't install a new version of the operating system and installing the z3 package didn't help me either