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

Decompilation #173

Merged
merged 49 commits into from
Aug 13, 2024
Merged

Decompilation #173

merged 49 commits into from
Aug 13, 2024

Conversation

d-xo
Copy link
Collaborator

@d-xo d-xo commented Nov 14, 2023

Adds a certified decompiler that can automatically derive act specifications from evm bytecode. The process operates in the following stages:

  1. Symbolically execute the bytecode to produce an EVM.Expr
  2. Transform that Expr into one that can be safely represented using Integers
  3. Convert that Expr into an Act spec (trusts solc compiler output)
  4. Compile the generated Act spec back to Expr and check equivalence (solc compiler output no longer trusted)

This currently supports only very simple contracts, basically value types, simple arithmethic, and storage writes. Mappings in storage are currently not supported, but doing so should be in principle possible.

Some simple tests are added, but still todo is to hook this up to the main CLI interface.

Starting from the existing solidity code produces the following spec (I'm currently unsure where the case True comes from):

contract C {
  uint x = 0;
  function f(uint v) public {
    x = v;
  }
}
constructor of C
interface C()

iff

  (CALLVALUE == 0)

creates

  uint256 x := 0


behaviour f of C
interface f(uint256 v)

iff

  (CALLVALUE == 0)

case

  true:

storage

  x => v

@d-xo d-xo requested review from zoep and msooseth November 14, 2023 09:20
@msooseth
Copy link
Collaborator

Hi!

Is this still being worked on? Should I review? Sounds cool :)

Mate

Copy link
Collaborator Author

@d-xo d-xo left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this up and getting it ready to merge.
Mostly curious if some of the soundness concerns still in the TODO comments are valid.

@msooseth
Copy link
Collaborator

Should I review? Is this active, do you want this merged? Looks like a lot of cool work!

zoep and others added 2 commits July 30, 2024 19:39
@d-xo
Copy link
Collaborator Author

d-xo commented Aug 6, 2024

I'm not allowed to approve because I opened the PR originally, but all your changes look good to me @zoep and I'm fine to merge this whenever.

Copy link
Collaborator

@zoep zoep left a comment

Choose a reason for hiding this comment

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

LGTM

@d-xo d-xo merged commit 0a63176 into main Aug 13, 2024
5 checks passed
@d-xo d-xo deleted the decompilation branch August 13, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants