Skip to content

Commit

Permalink
Always update digest
Browse files Browse the repository at this point in the history
  • Loading branch information
nwatson22 committed Sep 7, 2023
1 parent 1ee5923 commit 912ded5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions kevm-pyk/src/kontrol/foundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,20 +402,19 @@ 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) -> Method:
contract_name, method_name = test.split('.')
contract = self.contracts[contract_name]
return contract.method_by_sig[method_name]


def resolve_proof_version(
self,
test: str,
reinit: bool,
user_specified_version: int | None,
) -> int:
def _proof_up_to_date() -> bool:
contract_name, method_name = test.split('.')
contract = self.contracts[contract_name]
method = contract.method_by_sig[method_name]
if not method.up_to_date(self.digest_file):
method.update_digest(self.digest_file)
return False
return True
method = self.get_method(test)

if reinit and user_specified_version is not None:
raise ValueError('--reinit is not compatible with specifying proof versions.')
Expand All @@ -428,13 +427,13 @@ def _proof_up_to_date() -> bool:
_LOGGER.info(f'Using user-specified versions {user_specified_version} for test {test}')
if not Proof.proof_data_exists(f'{test}:{user_specified_version}', self.proofs_dir):
raise ValueError(f'The specified version {user_specified_version} of proof {test} does not exist.')
if not _proof_up_to_date():
if not method.up_to_date(self.digest_file):
_LOGGER.warn(
f'Using specified version {user_specified_version} of proof {test}, but it is out of date.'
)
return user_specified_version

if not _proof_up_to_date():
if not method.up_to_date(self.digest_file):
_LOGGER.info(f'Creating a new version of test {test} because it is out of date.')
return self.free_proof_version(test)

Expand Down Expand Up @@ -736,6 +735,13 @@ def _split_test(test: tuple[str, int]) -> tuple[str, str, int]:
for setup_method_name in setup_methods
]

_LOGGER.info(f'Updating digests: {[test_name for test_name, _ in tests]}')
for (test_name, _) in tests:
foundry.get_method(test_name).update_digest(foundry.digest_file)
_LOGGER.info(f'Updating digests: {setup_methods}')
for test_name in setup_methods:
foundry.get_method(test_name).update_digest(foundry.digest_file)

_LOGGER.info(f'Running setup functions in parallel: {list(setup_methods)}')
results = run_cfg_group(setup_methods_with_versions)
failed = [setup_cfg for setup_cfg, passed in results.items() if not passed]
Expand Down

0 comments on commit 912ded5

Please sign in to comment.