-
Notifications
You must be signed in to change notification settings - Fork 9
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
Contract storage fields in CSE #571
Closed
Closed
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fe72c6d
solc_to_k.py: add length field to StorageField
anvacaru ae14033
prove.py: encode storage layout in kast
anvacaru cff7dff
update expected output
anvacaru d36f419
Set Version: 0.1.281
6b55465
prove.py: apply storage field constraints only for symbolic exploration
anvacaru c9304eb
Merge branch 'master' into storage-field2
PetarMax 641ce6c
Set Version: 0.1.282
ebe458d
prove.py: use KAst helper functions
anvacaru 1e86af9
prove.py: store fields as words
anvacaru 39bd29e
Merge remote-tracking branch 'origin/master' into storage-field2
anvacaru f759350
update expected output
anvacaru a792b72
Set Version: 0.1.283
7353ad5
Merge branch 'master' into storage-field2
anvacaru 5ed0d5d
Set Version: 0.1.284
2dca1d5
Merge branch 'master' into storage-field2
anvacaru e3b2ba9
Set Version: 0.1.285
c762d87
Merge branch 'master' into storage-field2
PetarMax c75471a
Set Version: 0.1.286
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
from pyk.kdist import kdist | ||
from pyk.prelude.kbool import TRUE, andBool | ||
from pyk.prelude.kint import eqInt, intToken | ||
from pyk.prelude.ml import mlEqualsTrue | ||
from pyk.prelude.string import stringToken | ||
from pyk.utils import hash_str, run_process, single | ||
|
||
|
@@ -334,6 +335,7 @@ class StorageField(NamedTuple): | |
data_type: str | ||
slot: int | ||
offset: int | ||
length: int | ||
|
||
|
||
@dataclass | ||
|
@@ -1289,9 +1291,25 @@ def process_storage_layout(storage_layout: dict) -> tuple[StorageField, ...]: | |
data_type=type_info.get('label', field['type']), | ||
slot=int(field['slot']), | ||
offset=int(field['offset']), | ||
length=int(type_info.get('numberOfBytes', 32)), | ||
) | ||
fields_list.append(storage_field) | ||
except (KeyError, ValueError) as e: | ||
_LOGGER.error(f'Error processing field {field}: {e}') | ||
|
||
return tuple(fields_list) | ||
|
||
|
||
def type_constraint(data_type: str, symbolic_var: KVariable) -> KApply: | ||
# TODO: fill with rest of the cases | ||
data_type = data_type.lower() | ||
if data_type.startswith('uint'): | ||
return mlEqualsTrue(KEVM.range_uint(int(data_type[4:]), symbolic_var)) | ||
|
||
match data_type: | ||
case 'address': | ||
return mlEqualsTrue(KEVM.range_address(symbolic_var)) | ||
case 'bool': | ||
return mlEqualsTrue(KEVM.range_bool(symbolic_var)) | ||
case _: | ||
raise ValueError(f'Unimplemented: {data_type}') | ||
Comment on lines
+1303
to
+1315
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. Note: this will be useful in future. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note: This will be useful for future.