-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
feat[venom]: add effects to instructions #4264
Changes from all commits
2987d36
e9b5303
8be0bef
fcb688f
2e6cbb1
bcd4580
e5923e4
e994e53
2136585
2efaf68
53fa900
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from enum import Flag, auto | ||
|
||
|
||
class Effects(Flag): | ||
STORAGE = auto() | ||
TRANSIENT = auto() | ||
MEMORY = auto() | ||
MSIZE = auto() | ||
IMMUTABLES = auto() | ||
RETURNDATA = auto() | ||
LOG = auto() | ||
BALANCE = auto() | ||
EXTCODE = auto() | ||
|
||
|
||
EMPTY = Effects(0) | ||
ALL = ~EMPTY | ||
STORAGE = Effects.STORAGE | ||
TRANSIENT = Effects.TRANSIENT | ||
MEMORY = Effects.MEMORY | ||
MSIZE = Effects.MSIZE | ||
IMMUTABLES = Effects.IMMUTABLES | ||
RETURNDATA = Effects.RETURNDATA | ||
LOG = Effects.LOG | ||
BALANCE = Effects.BALANCE | ||
EXTCODE = Effects.EXTCODE | ||
|
||
|
||
_writes = { | ||
"sstore": STORAGE, | ||
"tstore": TRANSIENT, | ||
"mstore": MEMORY, | ||
"istore": IMMUTABLES, | ||
"call": ALL ^ IMMUTABLES, | ||
"delegatecall": ALL ^ IMMUTABLES, | ||
"staticcall": MEMORY | RETURNDATA, | ||
"create": ALL ^ (MEMORY | IMMUTABLES), | ||
"create2": ALL ^ (MEMORY | IMMUTABLES), | ||
"invoke": ALL, # could be smarter, look up the effects of the invoked function | ||
"log": LOG, | ||
"dloadbytes": MEMORY, | ||
"returndatacopy": MEMORY, | ||
"calldatacopy": MEMORY, | ||
"codecopy": MEMORY, | ||
"extcodecopy": MEMORY, | ||
"mcopy": MEMORY, | ||
} | ||
|
||
_reads = { | ||
"sload": STORAGE, | ||
"tload": TRANSIENT, | ||
"iload": IMMUTABLES, | ||
"mload": MEMORY, | ||
"mcopy": MEMORY, | ||
"call": ALL, | ||
"delegatecall": ALL, | ||
"staticcall": ALL, | ||
"create": ALL, | ||
"create2": ALL, | ||
"invoke": ALL, | ||
"returndatasize": RETURNDATA, | ||
"returndatacopy": RETURNDATA, | ||
"balance": BALANCE, | ||
"selfbalance": BALANCE, | ||
"extcodecopy": EXTCODE, | ||
"selfdestruct": BALANCE, # may modify code, but after the transaction | ||
"log": MEMORY, | ||
"revert": MEMORY, | ||
"return": MEMORY, | ||
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. return has an offset to memory, right? so in theory you might be forced to zero-extend the memory 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. applies to other opcodes as well 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. do we really care about zero extension? i think gas is an effect we don't need to preserve 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. what about 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. hmm that's true. but return can't be reordered past other instructions anyways 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. you have the same for eg |
||
"sha3": MEMORY, | ||
"msize": MSIZE, | ||
} | ||
|
||
reads = _reads.copy() | ||
writes = _writes.copy() | ||
|
||
for k, v in reads.items(): | ||
if MEMORY in v: | ||
if k not in writes: | ||
writes[k] = EMPTY | ||
writes[k] |= MSIZE | ||
|
||
for k, v in writes.items(): | ||
if MEMORY in v: | ||
writes[k] |= MSIZE |
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.
modeling code (e.g., for code copy) isn't useful?
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's not that useful, since it can't change during execution
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.
(At least that I know of)