Skip to content
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

Reduce the number of calls to the SMT solver in EVM #2411

Merged
merged 20 commits into from
May 25, 2021

Conversation

ggrieco-tob
Copy link
Contributor

@ggrieco-tob ggrieco-tob commented Mar 26, 2021

This PR reduces the number of solver queries allowing to use a list of expressions to concretize, instead of a single one.

@ehennenfent ehennenfent added this to In progress in Manticore Mar 30, 2021
@ggrieco-tob ggrieco-tob marked this pull request as ready for review March 31, 2021 20:22
@ehennenfent ehennenfent moved this from In progress to Review in progress in Manticore Apr 6, 2021
manticore/core/state.py Outdated Show resolved Hide resolved
Concretize a symbolic :class:`~manticore.core.smtlib.expression.Expression` into
one solution.
:param exprs: An iterable of manticore.core.smtlib.Expression
:param bool constrain: If True, constrain expr to solved solution value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth documenting that when constrain=True, the order of the expressions passed in could matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I haven't look on that parameter and I haven't change how other code call this. If you say this is expected behavior, I will modify the comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is the expected behavior, but the comment makes no mention of it. This could be confusing to users because if you call solve_one_n_batched with contradictory constraints in exprs, which expressions are unsat will depend on which ones are solved first. It's been that way for as long as I can remember, so this is just a "as long as you're editing this function anyway..." suggestion

manticore/core/smtlib/solver.py Outdated Show resolved Hide resolved
manticore/core/smtlib/solver.py Outdated Show resolved Hide resolved
manticore/core/smtlib/solver.py Outdated Show resolved Hide resolved
@@ -658,7 +658,7 @@ def save_constraints(testcase, state: StateBase):
@staticmethod
def save_input_symbols(testcase, state: StateBase):
with testcase.open_stream("input") as f:
for symbol in state.input_symbols:
bufs = state.solve_one_n_batched(state.input_symbols)
for symbol, buf in zip(state.input_symbols, bufs):
# TODO - constrain=False here, so the extra migration shouldn't cause problems, right?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment might need to be moved to right before the state.solve_one_n_batched

Or maybe just removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about that comment. Do you know what it means?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know exactly, but I think it's referencing the default argument constrain=False in state.solve_one

Eric Hennenfent added 2 commits May 21, 2021 10:26
Manticore automation moved this from Review in progress to Reviewer approved May 24, 2021
@ehennenfent ehennenfent merged commit c128872 into master May 25, 2021
Manticore automation moved this from Reviewer approved to Done May 25, 2021
@ehennenfent ehennenfent deleted the dev-get-batch-values branch May 25, 2021 16:42
ekilmer added a commit that referenced this pull request Jul 15, 2021
* master:
  Install pinned version of truffle to fix CI (#2467)
  Use fixed owner and attacker accounts in multi_tx_analysis (#2464)
  Manticore 0.3.6 (#2456)
  Fix IntrospectionAPIPlugin Name (#2459)
  Portfolio of parallel solvers (#2420)
  Replace Quick mode with Thorough mode (#2457)
  Fix incorrect comparison for symbolic file wildcards (#2454)
  Reduce the number of calls to the SMT solver in EVM (#2411)
  Fixes to Unicorn emulation - start/stop/resume (#1796)
  Add support for multiple compilation units (#2444)
  Basic solver stats (#2415)
ekilmer added a commit that referenced this pull request Jul 27, 2021
* master: (35 commits)
  Track last_pc in StateDescriptors (#2471)
  Expose Result Register for Native CPU (#2470)
  Install pinned version of truffle to fix CI (#2467)
  Use fixed owner and attacker accounts in multi_tx_analysis (#2464)
  Manticore 0.3.6 (#2456)
  Fix IntrospectionAPIPlugin Name (#2459)
  Portfolio of parallel solvers (#2420)
  Replace Quick mode with Thorough mode (#2457)
  Fix incorrect comparison for symbolic file wildcards (#2454)
  Reduce the number of calls to the SMT solver in EVM (#2411)
  Fixes to Unicorn emulation - start/stop/resume (#1796)
  Add support for multiple compilation units (#2444)
  Basic solver stats (#2415)
  Fix the generation of EVM tests (#2426)
  Disabled EVM events in testcases by default (#2417)
  added proper timeouts for cvc4 and boolector (#2418)
  Removed use of global solver from Native Memory (#2414)
  Support to use boolector as the SMT solver (#2410)
  Update CI and suggest to use pip3 instead of pip (#2409)
  Expressions use keyword-only arguments for init (#2395)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Manticore
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants