-
Notifications
You must be signed in to change notification settings - Fork 491
Fix smtchecker callback tests and add Eldarica #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5f84390
to
72221c3
Compare
smtchecker.js
Outdated
return function (query) { | ||
try { | ||
var result = solver(query); | ||
var result = solverFunction(query, solver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it possible to choose the solver from the callers side.
name: 'Eldarica', | ||
command: 'eld', | ||
params: '-horn -t:' + (timeout / 1000) | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just adding Eldarica for easy future use, it's currently not used for the tests.
st.skip('No SMT solver available.'); | ||
// For these tests we actually need z3/Spacer. | ||
const z3HornSolvers = smtsolver.availableSolvers.filter(solver => solver.command === 'z3'); | ||
if (z3HornSolvers.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to change things too much, we require z3 to run these tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make it opt-out instead of opt-in. With some equivalent of the --no-smt
flag. Otherwise it's too easy for such tests to never run in CI.
@@ -167,9 +169,8 @@ tape('SMTCheckerCallback', function (t) { | |||
if (source.includes(option)) { | |||
let idx = source.indexOf(option); | |||
if (source.indexOf(option, idx + 1) !== -1) { | |||
st.skip('SMTEngine option given multiple times.'); | |||
st.end(); | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually making none of the actual smtcheckertests to run lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main fix, I reckon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solverFunction
and solver
fixes in smtsolver.js
too, solvers were actually not run
test/smtcallback.js
Outdated
settings = { modelChecker: { engine: engine } }; | ||
settings = { modelChecker: { | ||
engine: engine, | ||
solvers: [ 'smtlib2' ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also wrong before, we need to force the callback to be used.
5e1ea98
to
5e037da
Compare
45ae5fe
to
29d2b8b
Compare
1363a9d
to
f6fa111
Compare
0017ffa
to
8ed2597
Compare
8ed2597
to
96f47c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise this looks good to me, but we may need to revisit keeping "backwards compatibility" before the next release (0.8.12).
solc.compile(JSON.stringify(input), { smtSolver: smt.smtSolver }) | ||
solc.compile( | ||
JSON.stringify(input), | ||
{ smtSolver: smtchecker.smtCallback(smtsolver.smtSolver, smtsolver.availableSolvers[0]) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should show an example of how to pass in a custom function as a callback?
Otherwise, if user is expected to use smtCallback()
, why don't we just expect its parameters instead of a full callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just way more convenient, there's 3 layers of different stuff here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe we should show both. I mean, this is the only reference doc we have for the library. Having an easy to run example is good but we should also say something about what the callback looks like. Looking quickly at README, I don't think it even mentions what args the actual callback takes. Only the args of this helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense. Next PR tho? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. Let's get this one merged :)
st.skip('No SMT solver available.'); | ||
// For these tests we actually need z3/Spacer. | ||
const z3HornSolvers = smtsolver.availableSolvers.filter(solver => solver.command === 'z3'); | ||
if (z3HornSolvers.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make it opt-out instead of opt-in. With some equivalent of the --no-smt
flag. Otherwise it's too easy for such tests to never run in CI.
The annoying part about this is that the solc-js CI tests run a bunch of old versions that have no idea about this, I think it'd look quite ugly to just disable it in all of them |
Maybe we could just have it wrapped in some helper that gets a version and tells us if it supports a modern version of the SMT stuff? In any case, that's not a huge blocker for me, could be done separately. Would be nice to have but this PR has been waiting long enough :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found mostly typos and added a some suggestions about overall I see nothing wrong here.
As I said in one of my comments, I'd recommend testing it against solc-js tests in the main repo before we merge to avoid breakage.
96f47c3
to
9a893e7
Compare
Updated the small things. |
9a893e7
to
08d4aa8
Compare
Please rebase now after #587 was merged (also likely need to run |
LGTM |
Besides fixing things, the nicest thing this PR enables is to use alternative solvers much more easily in a different script, like this:
https://gist.github.com/leonardoalt/70d659eb0ec2f0e82b1fa5681d5ce3e8