-
Notifications
You must be signed in to change notification settings - Fork 50
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
Abstract gas v3 #427
Conversation
00b3541
to
7a05327
Compare
cli/cli.hs
Outdated
@@ -203,7 +203,7 @@ main = do | |||
} } | |||
case cmd of | |||
Version {} ->putStrLn getFullVersion | |||
Symbolic {} -> do | |||
Symbolic' {} -> do |
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 breaks the cli interface and turns hevm symbolic
into hevm symbolic'
. We should keep this as is
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.
fixed
src/EVM.hs
Outdated
freezeMemory memory = | ||
ConcreteBuf . BS.pack . VUnboxed.toList <$> VUnboxed.freeze memory | ||
|
||
|
||
class VMOps (t :: VMType) where |
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 would be nice to pull this out into it's own section at the top of the file (or maybe into Types.hs
?)
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.
moved to Types, instances have to stay in EVM otherwise it would cause cyclic dependency
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.
Looks awesome in general 👏, just a few minor comments.
@d-xo it's ready |
Merged. Thanks <3 |
Description
Another try for abstract gas (see #403, #404).
I introduced two types of VMs that we can specialize execution for:
VM Symbolic
andVM Concrete
. The behavior can be specialized in instances ofVMOps
class and data structures with type families similar toGas (t :: VMType)
introduced here. Thanks to-fspecialize-aggressively -fexpose-all-unfoldings
this version is only slightly (~2%) slower thanmain
as all theVMOps
-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 tobranch (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