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

CSE: constrain address and contract field and parameters #828

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
27 changes: 26 additions & 1 deletion src/kontrol/prove.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def _init_cterm(
else:
# Symbolic accounts of all relevant contracts
accounts, storage_constraints = _create_cse_accounts(
foundry, storage_fields, contract_account_name, contract_code
foundry, storage_fields, contract_account_name, contract_code, schedule
)

accounts.append(KVariable('ACCOUNTS_REST', sort=KSort('AccountCellMap')))
Expand Down Expand Up @@ -1135,6 +1135,7 @@ def _create_cse_accounts(
storage_fields: tuple[StorageField, ...],
contract_name: str,
contract_code: KInner,
schedule: KApply,
) -> tuple[list[KInner], list[KApply]]:
"""
Recursively generates a list of new accounts corresponding to `contract` fields, each having <code> and <storage> cell (partially) set up.
Expand Down Expand Up @@ -1216,6 +1217,30 @@ def extend_storage(map: KInner, slot: int, value: KInner) -> KInner:
address_range_ub = ltInt(field_variable, intToken(1461501637330902918203684832716283019655932542976))
new_account_constraints.append(mlEqualsTrue(address_range_lb))
new_account_constraints.append(mlEqualsTrue(address_range_ub))
# Address is not the cheatcode contract address
new_account_constraints.append(
mlEqualsFalse(
KApply(
'_==Int_',
[
field_variable,
Foundry.address_CHEATCODE(),
],
)
)
)
# Address is not a precompiled contract address
# _account_constraints.append(
# mlEqualsFalse(KEVM.is_precompiled_account(acct_id.args[0], cterm.cell('SCHEDULE_CELL')))
# )
new_account_constraints.append(
mlEqualsFalse(
KEVM.is_precompiled_account(
field_variable,
schedule,
)
)
)
# Processing of contracts
if field.data_type.startswith('contract '):
if field.linked_interface:
Expand Down
Loading