-
Notifications
You must be signed in to change notification settings - Fork 149
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
WordStack optimizations #2632
WordStack optimizations #2632
Changes from 10 commits
f846164
7c9a7eb
3c3fa50
ceacb63
a3a1a56
5e89634
1269317
7205c9b
5e1f946
e2fb909
b4dc91f
b554704
05cab84
bccdb04
aaec015
ff6adbe
c0c088b
5acb050
7899ab3
3d7c9c2
3801e92
f0bfa6e
550111f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,9 @@ requires "lemmas/int-simplification.k" | |
module EVM-OPTIMIZATIONS-LEMMAS [symbolic] | ||
imports EVM | ||
|
||
rule #sizeWordStack(WS , N) => #sizeWordStack(WS, 0) +Int N requires N =/=Int 0 [simplification] | ||
rule #sizeWordStack(WS [ I := _ ], N) => #sizeWordStack(WS, N) requires I <Int #sizeWordStack(WS) [simplification] | ||
rule 0 <=Int #sizeWordStack(_ , 0) => true [simplification] | ||
rule #sizeWordStack(_ , 0) <Int N => false requires N <=Int 0 [simplification] | ||
rule #sizeWordStack(WS [ I := _ ]) => #sizeWordStack(WS, N) requires I <Int #sizeWordStack(WS) [simplification] | ||
gtrepta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rule 0 <=Int #sizeWordStack(_) => true [simplification, smt-lemma] | ||
rule #sizeWordStack(_) <Int N => false requires N <=Int 0 [simplification, smt-lemma] | ||
|
||
endmodule | ||
|
||
|
@@ -23,8 +22,40 @@ module EVM-OPTIMIZATIONS | |
imports INT-SIMPLIFICATION | ||
|
||
|
||
// {OPTIMIZATIONS} | ||
|
||
claim | ||
[optimized.add]: | ||
<kevm> | ||
<k> | ||
( #next[ ADD ] => .K ) ... | ||
</k> | ||
<schedule> | ||
SCHED | ||
</schedule> | ||
<useGas> | ||
USEGAS | ||
</useGas> | ||
<ethereum> | ||
<evm> | ||
<callState> | ||
<wordStack> | ||
( W0 : W1 : WS => chop( ( W0 +Int W1 ) ) : WS ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this added here? We already have a test-harness that takes the rules in this file and discharges them as claims directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, actually, this entire directory isn't used at all anymore. We really should delete it, but I left it for illustrative purposes. Any reason to add this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that's a leftover of me trying to test a failing optimisation, will remove. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. |
||
</wordStack> | ||
<pc> | ||
( PCOUNT => ( PCOUNT +Int 1 ) ) | ||
</pc> | ||
<gas> | ||
( GAVAIL => #if USEGAS #then ( GAVAIL -Gas Gverylow < SCHED > ) #else GAVAIL #fi ) | ||
</gas> | ||
... | ||
</callState> | ||
... | ||
</evm> | ||
... | ||
</ethereum> | ||
... | ||
</kevm> | ||
requires ( #if USEGAS #then Gverylow < SCHED > <=Gas GAVAIL #else true #fi ) | ||
andBool ( #sizeWordStack( WS ) <=Int 1023 ) | ||
|
||
endmodule | ||
``` |
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.
Why does this rule fail the
preserves-definedness
check in the first place?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.
Ah, it shouldn't anymore, there was an interim moment when it did. I'll remove that.
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.
Removed.