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

Allow non-general init state for non-test functions #398

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.172
0.1.173
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.172"
version = "0.1.173"
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.172'
VERSION: Final = '0.1.173'
9 changes: 9 additions & 0 deletions src/kontrol/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def exec_prove(
maude_port: int | None = None,
use_gas: bool = False,
deployment_state_path: Path | None = None,
with_non_general_state: bool = False,
**kwargs: Any,
) -> None:
_ignore_arg(kwargs, 'main_module', f'--main-module: {kwargs["main_module"]}')
Expand Down Expand Up @@ -279,6 +280,7 @@ def exec_prove(
fail_fast=fail_fast,
use_gas=use_gas,
deployment_state_entries=deployment_state_entries,
active_symbolik=with_non_general_state,
)

rpc_options = RPCOptions(
Expand Down Expand Up @@ -797,6 +799,13 @@ def _parse_test_version_tuple(value: str) -> tuple[str, int | None]:
action='append',
help='Specify a summary to include as a lemma.',
)
prove_args.add_argument(
'--with-non-general-state',
dest='with_non_general_state',
default=False,
action='store_true',
help='Flag used by Simbolik to initialise the state of a non test function as if it was a test function.',
)

show_args = command_parser.add_parser(
'show',
Expand Down
3 changes: 3 additions & 0 deletions src/kontrol/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ProveOptions:
reinit: bool
use_gas: bool
deployment_state_entries: Iterable[DeploymentStateEntry] | None
active_symbolik: bool

def __init__(
self,
Expand All @@ -53,6 +54,7 @@ def __init__(
reinit: bool = False,
use_gas: bool = False,
deployment_state_entries: list[DeploymentStateEntry] | None = None,
active_symbolik: bool = False,
) -> None:
object.__setattr__(self, 'auto_abstract_gas', auto_abstract_gas)
object.__setattr__(self, 'bug_report', bug_report)
Expand All @@ -72,6 +74,7 @@ def __init__(
object.__setattr__(self, 'reinit', reinit)
object.__setattr__(self, 'use_gas', use_gas)
object.__setattr__(self, 'deployment_state_entries', deployment_state_entries)
object.__setattr__(self, 'active_symbolik', active_symbolik)


@dataclass(frozen=True)
Expand Down
16 changes: 9 additions & 7 deletions src/kontrol/prove.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def init_and_run_proof(test: FoundryTest) -> APRFailureInfo | None:
use_gas=prove_options.use_gas,
deployment_state_entries=prove_options.deployment_state_entries,
summary_ids=summary_ids,
active_symbolik=prove_options.active_symbolik,
)

cut_point_rules = KEVMSemantics.cut_point_rules(
Expand Down Expand Up @@ -282,6 +283,7 @@ def method_to_apr_proof(
use_gas: bool = False,
deployment_state_entries: Iterable[DeploymentStateEntry] | None = None,
summary_ids: Iterable[str] = (),
active_symbolik: bool = False,
) -> APRProof:
if Proof.proof_data_exists(test.id, foundry.proofs_dir):
apr_proof = foundry.get_apr_proof(test.id)
Expand All @@ -305,6 +307,7 @@ def method_to_apr_proof(
setup_proof=setup_proof,
use_gas=use_gas,
deployment_state_entries=deployment_state_entries,
active_symbolik=active_symbolik,
)

apr_proof = APRProof(
Expand Down Expand Up @@ -345,17 +348,13 @@ def _method_to_initialized_cfg(
setup_proof: APRProof | None = None,
use_gas: bool = False,
deployment_state_entries: Iterable[DeploymentStateEntry] | None = None,
active_symbolik: bool = False,
) -> tuple[KCFG, int, int]:
_LOGGER.info(f'Initializing KCFG for test: {test.id}')

empty_config = foundry.kevm.definition.empty_config(GENERATED_TOP_CELL)
kcfg, new_node_ids, init_node_id, target_node_id = _method_to_cfg(
empty_config,
test.contract,
test.method,
setup_proof,
use_gas,
deployment_state_entries,
empty_config, test.contract, test.method, setup_proof, use_gas, deployment_state_entries, active_symbolik
)

for node_id in new_node_ids:
Expand Down Expand Up @@ -386,6 +385,7 @@ def _method_to_cfg(
setup_proof: APRProof | None,
use_gas: bool,
deployment_state_entries: Iterable[DeploymentStateEntry] | None,
active_symbolik: bool,
) -> tuple[KCFG, list[int], int, int]:
calldata = None
callvalue = None
Expand All @@ -408,6 +408,7 @@ def _method_to_cfg(
calldata=calldata,
callvalue=callvalue,
is_constructor=isinstance(method, Contract.Constructor),
active_symbolik=active_symbolik,
)
new_node_ids = []

Expand Down Expand Up @@ -555,6 +556,7 @@ def _init_cterm(
use_gas: bool,
is_test: bool,
is_setup: bool,
active_symbolik: bool,
is_constructor: bool,
*,
calldata: KInner | None = None,
Expand Down Expand Up @@ -591,7 +593,7 @@ def _init_cterm(
'MOCKCALLS_CELL': KApply('.MockCallCellMap'),
}

if is_test or is_setup or is_constructor:
if is_test or is_setup or is_constructor or active_symbolik:
init_account_list = _create_initial_account_list(program, deployment_state_entries)
init_subst_test = {
'OUTPUT_CELL': bytesToken(b''),
Expand Down
Loading