Skip to content
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

Execution of contract initialization code #54

Merged
merged 37 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d6d54c9
port contract initialization code to kontrol
nwatson22 Sep 27, 2023
21dc4d5
Set Version: 0.1.10
Sep 27, 2023
48964ad
Point to branch
nwatson22 Sep 27, 2023
8b2f8e5
Merge branch 'noah/contract-initialization' of https://github.com/run…
nwatson22 Sep 27, 2023
a300e3a
Fix formatting
nwatson22 Sep 27, 2023
edced3f
Update expected files
nwatson22 Sep 28, 2023
ed7457e
Turn on verbose flag for integration tests
nwatson22 Sep 28, 2023
f44ee0e
Revert test-pr.yml
nwatson22 Sep 28, 2023
2935940
edit workflow file
nwatson22 Sep 28, 2023
d3fe8df
Set Version: 0.1.11
Sep 28, 2023
57eeab2
Merge branch 'master' into noah/contract-initialization
nwatson22 Sep 28, 2023
9dca3dd
Set Version: 0.1.11
Sep 28, 2023
c045b6e
edit workflow file
nwatson22 Sep 28, 2023
21a86f4
Merge branch 'noah/contract-initialization' of https://github.com/run…
nwatson22 Sep 28, 2023
3682db1
Fix contracts.k.expected
nwatson22 Sep 28, 2023
1d69ce5
Revert test-pr.yml
nwatson22 Sep 28, 2023
3257380
Merge branch 'master' into noah/contract-initialization
nwatson22 Sep 29, 2023
30cb863
Set Version: 0.1.12
Sep 29, 2023
5117a5a
Merge branch 'master' into noah/contract-initialization
nwatson22 Sep 30, 2023
a1c50de
Set Version: 0.1.13
Sep 30, 2023
1742fc3
Merge master into branch, use master branch of kevm
nwatson22 Oct 3, 2023
02723dc
Set Version: 0.1.14
Oct 3, 2023
0c7a56c
Merge master into branch
nwatson22 Oct 5, 2023
5f89520
Add warning if constructor doesn't exist
nwatson22 Oct 6, 2023
dad24c3
Merge master into branch
nwatson22 Oct 6, 2023
aa3d117
Use master branch of kevm
nwatson22 Oct 6, 2023
073764b
Merge branch 'master' into noah/contract-initialization
nwatson22 Oct 6, 2023
a90b25b
Set Version: 0.1.21
Oct 6, 2023
9063bcd
Fix formatting, update kevm
nwatson22 Oct 6, 2023
a4d994a
Merge branch 'noah/contract-initialization' of https://github.com/run…
nwatson22 Oct 6, 2023
49d025d
Update test_foundry_kompile expected
nwatson22 Oct 6, 2023
7df4345
Update expected output
nwatson22 Oct 6, 2023
36d014b
Remove commented lines
nwatson22 Oct 6, 2023
ef49f94
Merge branch 'master' into noah/contract-initialization
nwatson22 Oct 10, 2023
6f8da17
Set Version: 0.1.23
Oct 10, 2023
f1ffeaa
Merge branch 'master' into noah/contract-initialization
nwatson22 Oct 10, 2023
0b9fcb4
Set Version: 0.1.24
Oct 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.13
0.1.14
118 changes: 59 additions & 59 deletions poetry.lock

Large diffs are not rendered by default.

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.13"
version = "0.1.14"
description = "Foundry integration for KEVM"
authors = [
"Runtime Verification, Inc. <contact@runtimeverification.com>",
Expand Down
9 changes: 9 additions & 0 deletions src/kontrol/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def exec_prove(
counterexample_info: bool = False,
trace_rewrites: bool = False,
auto_abstract_gas: bool = False,
run_constructor: bool = False,
**kwargs: Any,
) -> None:
_ignore_arg(kwargs, 'main_module', f'--main-module: {kwargs["main_module"]}')
Expand Down Expand Up @@ -196,6 +197,7 @@ def exec_prove(
smt_retry_limit=smt_retry_limit,
trace_rewrites=trace_rewrites,
auto_abstract_gas=auto_abstract_gas,
run_constructor=run_constructor,
)
failed = 0
for pid, r in results.items():
Expand Down Expand Up @@ -524,6 +526,13 @@ def _parse_test_version_tuple(value: str) -> tuple[str, int | None]:
action='store_true',
help='Use the booster RPC server instead of kore-rpc.',
)
prove_args.add_argument(
'--run-constructor',
dest='run_constructor',
default=False,
action='store_true',
help='Include the contract constructor in the test execution.',
)

show_args = command_parser.add_parser(
'show',
Expand Down
12 changes: 9 additions & 3 deletions src/kontrol/foundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def all_non_tests(self) -> list[str]:
for contract in self.contracts.values()
for method in contract.methods
if f'{contract.name}.{method.signature}' not in self.all_tests
]
] + [f'{contract.name}.init' for contract in self.contracts.values()]

@staticmethod
def _escape_brackets(regs: list[str]) -> list[str]:
Expand Down Expand Up @@ -387,8 +387,14 @@ def get_optional_proof(self, test_id: str) -> Proof | None:
return Proof.read_proof_data(self.proofs_dir, test_id)
return None

def get_method(self, test: str) -> Contract.Method:
def get_method(self, test: str) -> Contract.Method | Contract.Constructor:
contract_name, method_name = test.split('.')

if method_name == 'init':
constructor = self.contracts[contract_name].constructor
assert constructor is not None
nwatson22 marked this conversation as resolved.
Show resolved Hide resolved
return constructor

contract = self.contracts[contract_name]
return contract.method_by_sig[method_name]

Expand Down Expand Up @@ -426,7 +432,7 @@ def resolve_proof_version(
_LOGGER.info(
f'Using the the latest version {latest_version} of test {test} because it is up to date and no version was specified.'
)
if not method.contract_up_to_date(self.digest_file):
if type(method) is Contract.Method and not method.contract_up_to_date(self.digest_file):
_LOGGER.warning(
f'Test {test} was not reinitialized because it is up to date, but the contract it is a part of has changed.'
)
Expand Down
Loading