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

Abstract gas v3 #427

Merged
merged 11 commits into from
Jan 16, 2024
Merged

Abstract gas v3 #427

merged 11 commits into from
Jan 16, 2024

Conversation

arcz
Copy link
Collaborator

@arcz arcz commented Nov 17, 2023

Description

Another try for abstract gas (see #403, #404).

I introduced two types of VMs that we can specialize execution for: VM Symbolic and VM Concrete. The behavior can be specialized in instances of VMOps class and data structures with type families similar to Gas (t :: VMType) introduced here. Thanks to -fspecialize-aggressively -fexpose-all-unfoldings this version is only slightly (~2%) slower than main as all the VMOps-dependent functions should be picked at compile time. This opens a whole world of possibilities for optimizing the concrete version of the VM without introducing too many changes.

For instance, having branch specialized to branch (Lit cond) continue = continue (cond > 0) in concrete VM speeds up ethereum-tests over 10% which puts way ahead compared to the current main. I didn't include further optimizations to limit the scope of this PR to gas.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@d-xo d-xo mentioned this pull request Nov 24, 2023
4 tasks
@arcz arcz force-pushed the gas-family branch 3 times, most recently from 00b3541 to 7a05327 Compare November 25, 2023 19:42
cli/cli.hs Outdated
@@ -203,7 +203,7 @@ main = do
} }
case cmd of
Version {} ->putStrLn getFullVersion
Symbolic {} -> do
Symbolic' {} -> do
Copy link
Collaborator

Choose a reason for hiding this comment

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

This breaks the cli interface and turns hevm symbolic into hevm symbolic'. We should keep this as is

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

src/EVM.hs Outdated
freezeMemory memory =
ConcreteBuf . BS.pack . VUnboxed.toList <$> VUnboxed.freeze memory


class VMOps (t :: VMType) where
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to pull this out into it's own section at the top of the file (or maybe into Types.hs?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved to Types, instances have to stay in EVM otherwise it would cause cyclic dependency

Copy link
Collaborator

@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.

Looks awesome in general 👏, just a few minor comments.

@arcz
Copy link
Collaborator Author

arcz commented Jan 2, 2024

@d-xo it's ready

@d-xo d-xo merged commit 7a828a5 into main Jan 16, 2024
7 checks passed
@d-xo
Copy link
Collaborator

d-xo commented Jan 16, 2024

Merged. Thanks <3

@d-xo d-xo deleted the gas-family branch January 16, 2024 12:09
@arcz arcz mentioned this pull request Feb 1, 2024
4 tasks
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.

2 participants