Skip to content

Commit

Permalink
Add check for storageLayout (#660)
Browse files Browse the repository at this point in the history
* Add check for storageLayout

* Set Version: 0.1.330

* Update src/kontrol/prove.py

Co-authored-by: Palina Tolmach <[email protected]>

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: Palina Tolmach <[email protected]>
  • Loading branch information
3 people authored Jul 2, 2024
1 parent 40f90eb commit 3f7a133
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.329
0.1.330
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kontrol"
version = "0.1.329"
version = "0.1.330"
description = "Foundry integration for KEVM"
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/kontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
if TYPE_CHECKING:
from typing import Final

VERSION: Final = '0.1.329'
VERSION: Final = '0.1.330'
4 changes: 4 additions & 0 deletions src/kontrol/prove.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def foundry_prove(
for test in test_suite:
if not isinstance(test.method, Contract.Method) or test.method.function_calls is None:
continue
if not test.contract.has_storage_layout:
raise RuntimeError(
"Couldn't locate 'storageLayout' in the compiled solc output. Please add `extra_output = ['storageLayout']` to your foundry.toml file."
)

test_version_tuples = [
parse_test_version_tuple(t) for t in test.method.function_calls if t not in summary_ids
Expand Down
4 changes: 4 additions & 0 deletions src/kontrol/solc_to_k.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ def srcmap(self) -> dict[int, tuple[int, int, int, str, int]]:
def fields(self) -> tuple[StorageField, ...]:
return process_storage_layout(self.contract_json.get('storageLayout', {}), self.interface_annotations)

@cached_property
def has_storage_layout(self) -> bool:
return 'storageLayout' in self.contract_json

@cached_property
def is_test_contract(self) -> bool:
return any(field.label == 'IS_TEST' for field in self.fields)
Expand Down

0 comments on commit 3f7a133

Please sign in to comment.