target_configs.py

verification/tools/target_configs.py

target_configs.py461 lines← SDK documentation
1#!/usr/bin/env python32"""Check actual pool configurations and keep target execution separate from proofs."""3from pathlib import Path4import argparse5import datetime6import fcntl7import hashlib8import json9import os10import re11import shutil12import shlex13import subprocess14import sys15import tempfile16import uuid1718import equality_bridge19import kani20import native_witness21import run_receipt22from platform_providers import item2324ROOT = kani.ROOT25PLATFORM = kani.PLATFORM26PROOFS = ROOT / 'verification/proofs/platform'27VALIDATION = ROOT / 'verification/proofs/page-pool/creusot/validation.rs'28DEPENDENCY = ROOT / 'cdk-rsx/crates/cdk-rsx-page-profile'29EXPECTED = {30    'target-width': {'page_pool::proofs::' + name for name in (31        'actual_native_committed_word', 'scalar_u64_width_projection', 'actual_builtin_configs_admitted')},32    'target-width-negative': {'page_pool::proofs::negative_header_width_always_lossless'},33}34MALFORMED = {35    'zero-reserved': 'Config { reserved_pages: 0, ..NATIVE_CONFIG }',36    'reserved-over-limit': 'Config { reserved_pages: NATIVE_CONFIG.max_pages + 1, ..NATIVE_CONFIG }',37    'over-table-capacity': 'Config { max_pages: page_pool::MAX_PAGES + 1, ..NATIVE_CONFIG }',38    'protected-overlap': 'Config { protected: Some(Run { start: 0, count: 1 }), ..NATIVE_CONFIG }',39    'protected-empty': 'Config { protected: Some(Run { start: 1, count: 0 }), ..NATIVE_CONFIG }',40    'protected-end': 'Config { protected: Some(Run { start: NATIVE_CONFIG.max_pages, count: 1 }), ..NATIVE_CONFIG }',41    'protected-overflow': 'Config { protected: Some(Run { start: usize::MAX, count: 2 }), ..NATIVE_CONFIG }',42}434445def predicate_source(source):46    selected = item(source, 'pub(super) fn config_well_formed(')47    match = re.fullmatch(r'pub\(super\) fn config_well_formed\(config: Config\) -> bool \{\s*pearlite! \{(.*)\}\s*\}',48                         selected, re.S)49    kani.require(match is not None, 'Unreviewed config precondition syntax')50    # Every term in this particular logical precondition is executable Rust.51    # Preserve its expression bytes; do not learn a new predicate from results.52    return 'const fn config_well_formed(config: Config) -> bool {' + match[1] + '}\n'535455def context_source():56    wasm = (PLATFORM / 'wasm.rs').read_text()57    memory = (PLATFORM / 'memory.rs').read_text()58    native = item(memory, 'fn native_pool_config() -> page_pool::Config')59    native_body = native[native.index('{'):]60    return ('use page_pool::{Config, Run};\nuse page_pool::MAX_PAGES;\n'61            'use profile::{CONTROL_BASE, WASM_PAGE};\n'62            + item(wasm, 'const POOL_CONFIG: Config') + ';\n'63            + native + '\nconst NATIVE_CONFIG: Config = ' + native_body + ';\n'64            + predicate_source(VALIDATION.read_text())65            + 'const _: () = {\n'66              'assert!(config_well_formed(NATIVE_CONFIG));\n'67              'assert!(config_well_formed(POOL_CONFIG));\n'68            + ''.join('assert!(!config_well_formed(' + bad + '));\n' for bad in MALFORMED.values())69            + '};\n')707172def inputs():73    return [PLATFORM / name for name in ('wasm.rs', 'memory.rs', 'profile.rs', 'memory/page_pool.rs')]747576def snapshot(paths):77    return {str(path.relative_to(ROOT)): kani.sha(path) for path in paths}787980def stage(output, negative=False):81    output.mkdir(parents=True, exist_ok=False)82    original = (PLATFORM / 'memory/page_pool.rs').read_bytes()83    proof = PROOFS / 'kani' / ('target_width_negative.rs' if negative else 'target_width.rs')84    suffix = ('\n#[cfg(kani)] mod proofs { include!(' + json.dumps(str(proof)) + '); }\n').encode()85    (output / 'page_pool.rs').write_bytes(original + suffix)86    common = ('#[path=' + json.dumps(str(PLATFORM / 'profile.rs')) + '] mod profile;\n'87              'mod page_pool;\n' + context_source())88    (output / 'lib.rs').write_text('#![cfg_attr(not(kani),no_std)]\n'89        '#![allow(dead_code,unexpected_cfgs)]\n' + common)90    (output / 'Cargo.toml').write_text(91        '[package]\nname="target-config-proof"\nversion="0.0.0"\nedition="2024"\n'92        '[workspace]\n[features]\npage-profile=[]\n[lib]\npath="lib.rs"\n[dependencies]\n'93        'cdk-rsx-page-profile={path=' + json.dumps(str(DEPENDENCY)) + '}\n')94    memory = (PLATFORM / 'memory.rs').read_text()95    declaration = "struct VecBacking<'a>(&'a mut Vec<u8>);"96    kani.require(memory.count(declaration) == 1, 'Native backing declaration changed')97    actual_vec = declaration + '\n' + item(memory, "unsafe impl page_pool::Backing for VecBacking<'_>")98    runtime = ('#![allow(dead_code,unexpected_cfgs)]\n' + common + actual_vec99        + '\n#[path=' + json.dumps(str(PROOFS / 'targets/header.rs')) + '] mod header;\n'100          '#[cfg(not(target_arch="wasm32"))] fn main() { println!("{:?}", header::report()); }\n'101          '#[cfg(target_arch="wasm32")] #[link(wasm_import_module="ic0")] unsafe extern "C" {\n'102          'fn msg_reply_data_append(src: usize, size: usize); fn msg_reply(); }\n'103          '#[cfg(target_arch="wasm32")] #[unsafe(export_name="canister_query check")]\n'104          'pub extern "C" fn check() { let bytes=header::report(); unsafe {\n'105          'msg_reply_data_append(bytes.as_ptr() as usize, bytes.len()); msg_reply(); } }\n')106    (output / 'runtime.rs').write_text(runtime)107    return original, suffix108109110def all_inputs():111    return [*inputs(), VALIDATION, DEPENDENCY / 'Cargo.toml', DEPENDENCY / 'src/lib.rs',112            ROOT / 'cdk-rsx/Cargo.toml', Path(__file__),113            Path(__file__).with_name('target_header.mjs'),114            Path(__file__).with_name('platform_providers.py'),115            Path(kani.__file__), Path(kani.__file__).with_suffix('.toml'),116            PROOFS / 'kani/target_width.rs', PROOFS / 'kani/target_width_negative.rs',117            PROOFS / 'targets/header.rs', *run_receipt.INPUTS, Path(native_witness.creusot.__file__),118            *native_witness.INPUTS, *kani.kani_obligations.INPUTS, *kani.kani_install.INPUTS,119            *[ROOT / 'tests/pocketic' / name for name in ('session.mjs', 'strict-tick.mjs', 'package-lock.json')]]120121122def output_dir(label):123    stamp = datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%dT%H%M%SZ')124    return kani.TEMP / 'runs' / (stamp + '-targets-' + label + '-' + uuid.uuid4().hex[:8])125126127def validate_kani_run(output, suite, code):128    summary = kani.validate_run(output, suite, code)129    if suite == 'target-width-negative':130        report = json.loads((output / 'result.json').read_text())131        required = kani.kani_obligations.required(suite, EXPECTED[suite])132        marker = kani.kani_obligations.normalized(json.dumps(kani.NEGATIVE_CONTROLS[suite]))133        designated = [item for items in required.values() for item in items134            if item.category == 'assertion' and item.description == marker]135        failed = [check for result in report['verification_results']['results']136            for check in result['checks'] if check['status'] == 'Failure']137        kani.require(len(designated) == 1 and kani.kani_obligations.check_identity(failed[0]) == designated[0],138            'Target-width negative failed away from its designated source assertion')139    return summary140141142def run_kani(negative=False, timeout=90):143    checkout = run_receipt.checkout(ROOT)144    suite = 'target-width-negative' if negative else 'target-width'145    kani.EXPECTED_HARNESSES.update(EXPECTED)146    kani.NEGATIVE_CONTROLS['target-width-negative'] = 'NEGATIVE_CONTROL_HEADER_WIDTH_LOSSLESS'147    kani.kani_obligations.required(suite, EXPECTED[suite])148    before = snapshot(all_inputs())149    tool_identity = kani.kani_install.capture(kani.TEMP)150    kani.require(checkout == run_receipt.checkout(ROOT), 'Checkout changed during tool authentication')151    kani.require(snapshot(all_inputs()) == before, 'Target-width sources changed during authentication')152    output = output_dir(suite)153    original, suffix = stage(output, negative)154    staged = {path.name: kani.sha(path) for path in output.iterdir() if path.is_file()}155    receipt = run_receipt.write(ROOT, output, {156        **checkout, 'sources': before, 'staged': staged, 'toolIdentity': tool_identity,157        'scope': 'native64 actual query/configs and explicit u32 scalar cast model; not a Wasm proof',158    })159160    def verify():161        receipt.verify()162        kani.require(snapshot(all_inputs()) == before, 'Target-width sources changed')163        kani.require((output / 'page_pool.rs').read_bytes() == original + suffix, 'Production source prefix changed')164        kani.kani_install.verify(tool_identity, kani.TEMP)165        receipt.verify()166167    env = kani.environment()168    env.update(CARGO_HOME=str(kani.TEMP / 'platform-cargo-home'), CARGO_TARGET_DIR=str(output / 'target'))169    args = [kani.LAUNCHER / 'cargo-kani', '--manifest-path', output / 'Cargo.toml',170            '-Z', 'unstable-options', '--harness-timeout', str(timeout) + 's',171            '--export-json', output / 'result.json', '--jobs', '3', '--output-format', 'terse']172    print('Target-width Kani: ' + str(output), flush=True)173    verify()174    with (output / 'run.log').open('w') as log:175        process = subprocess.run([str(arg) for arg in args], cwd=ROOT, env=env,176                                 stdout=log, stderr=subprocess.STDOUT)177    verify()178    kani.require(all(run_receipt.regular(output / name) for name in ('result.json', 'run.log')),179                 'Missing or symlinked target-width report/log')180    summary = validate_kani_run(output, suite, process.returncode)181    print(json.dumps({'status': kani.result_status(suite), 'suite': suite, 'summary': summary,182                      'output': str(output)}))183    return output184185186def compiler_environment():187    env = dict(os.environ)188    for name in ('RUSTFLAGS', 'CARGO_ENCODED_RUSTFLAGS', 'RUSTC_WRAPPER',189                 'RUSTC_WORKSPACE_WRAPPER', 'RRT_PIC_SERVER_URL', 'RRT_PIC_STATE_DIR',190                 'LD_PRELOAD', 'LD_AUDIT', 'NODE_OPTIONS', 'NODE_PATH',191                 'NODE_COMPILE_CACHE', 'NODE_V8_COVERAGE'):192        env.pop(name, None)193    env['RUSTUP_AUTO_INSTALL'] = '0'194    return env195196197def compile_command(args, log, env, cwd):198    return subprocess.run([str(arg) for arg in args], cwd=cwd, env=env,199                          stdout=log, stderr=subprocess.STDOUT)200201202def validate_config_rejection(log, returncode):203    log = re.sub(r'\x1b\[[0-?]*[ -/]*[@-~]', '', log)204    headers = re.findall(r'^error(?:\[[^\]]+\])?: .+$', log, re.M)205    primary = [line for line in headers if not re.fullmatch(206        r'error: aborting due to 1 previous error(?:; [1-9][0-9]* warnings? emitted)?', line)]207    substantive = [re.sub(r'^error(?:\[[^\]]+\])?: ', '', line) for line in primary]208    kani.require(type(returncode) is int and returncode == 1209                 and substantive == ['evaluation panicked: NEGATIVE_CONFIG_ADMISSION'],210                 'Malformed config failed for an unrelated reason: ' + repr(headers))211    # Only the exact admitted primary/summary population may bypass the generic screen.212    kani.validate_diagnostics('\n'.join(line for line in log.splitlines() if line not in headers))213214215def standard_library_hash(root):216    digest = hashlib.sha256()217    for path in sorted(root.rglob('*')):218        if path.is_file():219            digest.update(path.relative_to(root).as_posix().encode() + b'\0')220            digest.update(bytes.fromhex(kani.sha(path)))221    return digest.hexdigest()222223224def compiler_identity(rustc, env):225    path = rustc.resolve(strict=True)226    digest = native_witness.executable_hash(path)227    version = subprocess.check_output([str(path), '--version'], env=env, text=True).strip()228    kani.require(version == equality_bridge.VERSIONS['production'], 'Wrong production compiler')229    native_witness.executable_hash(path, digest)230    kani.require(rustc.resolve(strict=True) == path, 'Target compiler selection changed')231    return {'path': str(path), 'version': version, 'sha256': digest}232233234def dependency_hash(root):235    root = root.resolve(strict=True)236    digest = hashlib.sha256()237    for path in sorted(root.rglob('*')):238        if path.is_symlink():239            kani.require(path.resolve(strict=True).is_relative_to(root), 'Dependency link leaves its tree')240            digest.update(path.relative_to(root).as_posix().encode() + b'\0link\0')241            digest.update(os.readlink(path).encode() + b'\0')242        if path.is_file():243            digest.update(path.relative_to(root).as_posix().encode() + b'\0')244            digest.update(bytes.fromhex(kani.sha(path)))245    return digest.hexdigest()246247248def wasm64_inputs(rustc):249    cargo = rustc.parent / 'cargo'250    library = rustc.parent.parent / 'lib/rustlib/src/rust/library'251    kani.require(cargo.is_file() and (kani.TEMP / 'target-cargo-home').is_dir()252                 and (library / 'Cargo.lock').is_file(),253                 'Wasm64 check requires existing pinned Cargo/rust-src and a private populated Cargo home')254    return {'cargoPath': str(cargo.resolve(strict=True)),255            'cargoSha256': native_witness.executable_hash(cargo.resolve(strict=True)),256            'rustLibrarySha256': standard_library_hash(library)}257258259def wasm64_environment(rustc, env):260    return dict(env, RUSTC=str(rustc), CARGO_HOME=str(kani.TEMP / 'target-cargo-home'),261        CARGO_TARGET_DIR=str(kani.TEMP / 'target-config-wasm64-cache'),262        CARGO_UNSTABLE_CHECKSUM_FRESHNESS='true', CARGO_BUILD_FINGERPRINT='content')263264265def compile_wasm64(output, rustc, env, identity, verify):266    # The private core is built offline from already provisioned sources/cache.267    # Cargo.lock is prepared and sealed before this compilation phase.268    with (output / 'wasm64.log').open('w') as log:269        for profile in (False, True):270            verify()271            flags = ['--features', 'page-profile'] if profile else []272            result = compile_command([identity['cargoPath'], 'build', '--manifest-path', output / 'Cargo.toml',273                '--target', 'wasm64-unknown-unknown', '-Zbuild-std=core', '--locked', '--offline', *flags],274                log, wasm64_environment(rustc, env), output)275            verify()276            kani.require(result.returncode == 0, 'Wasm64 const compilation failed; inspect wasm64.log')277278279def run_targets(rustc, pocket_ic=None, wasm64=False):280    checkout = run_receipt.checkout(ROOT)281    before = snapshot(all_inputs())282    host_env = compiler_environment()283    env = dict(host_env)284    env.pop('LD_LIBRARY_PATH', None)285286    def verify_sources():287        kani.require(checkout == run_receipt.checkout(ROOT), 'Target checkout changed')288        kani.require(snapshot(all_inputs()) == before, 'Target source changed')289290    compiler = compiler_identity(rustc, env)291    verify_sources()292    rustc_argument = rustc293    rustc = Path(compiler['path'])294    core = wasm64_inputs(rustc) if wasm64 else None295    host_inputs = None296    if pocket_ic is not None:297        node_path = shutil.which('node', path=env.get('PATH'))298        kani.require(node_path is not None, 'Node is needed for the target witness')299        node = Path(node_path).resolve(strict=True)300        pic = pocket_ic.resolve(strict=True)301        dependencies = (ROOT / 'tests/pocketic/node_modules').resolve(strict=True)302        host_inputs = {'node': {'path': str(node), 'sha256': native_witness.executable_hash(node),303            'version': subprocess.check_output([str(node), '--version'], env=env, text=True).strip()},304            'pocketIc': {'path': str(pic), 'sha256': native_witness.executable_hash(pic)},305            'nodeModules': {'path': str(dependencies), 'sha256': dependency_hash(dependencies)},306            'loaderLibraryPath': host_env.get('LD_LIBRARY_PATH')}307        verify_sources()308    output = output_dir('compiled')309    stage(output)310    for name, bad in MALFORMED.items():311        (output / (name + '.rs')).write_text((output / 'lib.rs').read_text()312            + '\nconst _: () = assert!(config_well_formed(' + bad + '), "NEGATIVE_CONFIG_ADMISSION");\n')313    if host_inputs:314        launcher = output / 'pocketic-launcher'315        launcher.write_text('#!/bin/sh\nexec ' + shlex.quote(str(pic))316            + ' "$@" 2>' + shlex.quote(str(output / 'pocketic-server.log')) + '\n')317        launcher.chmod(0o755)318    staged = {str(path.relative_to(output)): kani.sha(path) for path in output.rglob('*') if path.is_file()}319    if core:320        # Lockfile generation is preparation, not a compiled-target result. Bind321        # the existing stage and source/tool identity around that action too.322        run_receipt.verify_staged(output, staged)323        with (output / 'wasm64-prepare.log').open('w') as log:324            result = compile_command([core['cargoPath'], 'generate-lockfile', '--manifest-path',325                output / 'Cargo.toml', '--offline'], log, wasm64_environment(rustc, env), output)326        verify_sources()327        run_receipt.verify_staged(output, staged)328        kani.require(compiler_identity(rustc_argument, env) == compiler329            and wasm64_inputs(rustc) == core, 'Wasm64 preparation tools changed')330        kani.require(result.returncode == 0 and run_receipt.regular(output / 'Cargo.lock'),331                     'Offline Wasm64 lockfile preparation failed')332        staged['Cargo.lock'] = kani.sha(output / 'Cargo.lock')333    receipt = run_receipt.write(ROOT, output, {**checkout, 'sources': before, 'staged': staged,334        'compiler': compiler, 'wasm64Inputs': core, 'hostInputs': host_inputs,335        'scope': 'actual const compilation and header witnesses; no general target/VM proof'})336    artifacts = {}337338    def seal(path, executable=False):339        kani.require(run_receipt.regular(path), 'Missing or substituted target artifact')340        digest = native_witness.executable_hash(path) if executable else kani.sha(path)341        artifacts[str(path.relative_to(output))] = {'sha256': digest, 'executable': executable}342343    def verify():344        receipt.verify()345        verify_sources()346        kani.require(compiler_identity(rustc_argument, env) == compiler, 'Target compiler changed')347        if core:348            kani.require(wasm64_inputs(rustc) == core, 'Wasm64 tool/standard-library sources changed')349        if host_inputs:350            kani.require(pocket_ic.resolve(strict=True) == pic351                and native_witness.executable_hash(pic) == host_inputs['pocketIc']['sha256']352                and native_witness.executable_hash(node) == host_inputs['node']['sha256'], 'Target host tool changed')353            kani.require((ROOT / 'tests/pocketic/node_modules').resolve(strict=True) == dependencies354                and dependency_hash(dependencies) == host_inputs['nodeModules']['sha256'], 'Target dependencies changed')355        for name, identity in artifacts.items():356            path = output / name357            kani.require(run_receipt.regular(path) and kani.sha(path) == identity['sha256'], 'Target artifact changed')358            if identity['executable']:359                native_witness.executable_hash(path, identity['sha256'])360        receipt.verify()361362    def compile_checked(args, log):363        verify()364        result = compile_command(args, log, env, output)365        verify()366        return result367368    observations = {}369    common = [rustc, '--edition=2024', '-Cpanic=abort', '-Copt-level=2']370    print('Target/config output: ' + str(output), flush=True)371    with (output / 'run.log').open('w') as log:372        for target in ('x86_64-unknown-linux-gnu', 'wasm32-unknown-unknown'):373            folder = output / target374            folder.mkdir()375            dependency = folder / 'libcdk_rsx_page_profile.rlib'376            result = compile_checked([*common, '--crate-name', 'cdk_rsx_page_profile', '--crate-type=rlib',377                '--target', target, DEPENDENCY / 'src/lib.rs', '-o', dependency], log)378            kani.require(result.returncode == 0, 'Page-profile target compile failed; inspect run.log')379            seal(dependency)380            link = ['--extern', 'cdk_rsx_page_profile=' + str(dependency)]381            for profile in (False, True):382                flags = ['--cfg', 'feature="page-profile"'] if profile else []383                result = compile_checked([*common, '--crate-name', 'config_admission', '--crate-type=lib',384                    '--emit=metadata', '--target', target, *flags, output / 'lib.rs', *link,385                    '-o', folder / ('profile.rmeta' if profile else 'default.rmeta')], log)386                kani.require(result.returncode == 0, 'Source-known config compile failed; inspect run.log')387            if target.startswith('x86_64'):388                for name in MALFORMED:389                    with (output / (name + '.log')).open('w') as negative_log:390                        result = compile_checked([*common, '--crate-name', 'bad_config', '--crate-type=lib',391                            '--emit=metadata', '--target', target, output / (name + '.rs'), *link,392                            '-o', folder / 'bad.rmeta'], negative_log)393                    validate_config_rejection((output / (name + '.log')).read_text(), result.returncode)394                artifact = folder / 'header'395                result = compile_checked([*common, '--target', target, output / 'runtime.rs', *link,396                    '-o', artifact], log)397                kani.require(result.returncode == 0, 'Native witness compile failed; inspect run.log')398                seal(artifact, True)399                verify()400                response = subprocess.check_output([str(artifact)], text=True, env=env).strip()401                verify()402                kani.require(response == '[64, 1, 1, 1, 0, 1]', 'Unexpected native header witness: ' + response)403                observations['nativeResponse'] = response404                print('EXECUTED_NATIVE64_HEADER_WITNESS: ' + response, flush=True)405            elif host_inputs:406                artifact = folder / 'header.wasm'407                result = compile_checked([*common, '--crate-type=cdylib', '--target', target,408                    output / 'runtime.rs', *link, '-o', artifact], log)409                kani.require(result.returncode == 0, 'Wasm32 witness compile failed; inspect run.log')410                seal(artifact)411                verify()412                with tempfile.TemporaryDirectory(prefix='rsx-targets-', dir='/tmp') as state:413                    host = subprocess.run([str(node), str(Path(__file__).with_name('target_header.mjs')),414                        str(launcher), str(artifact), state], cwd=ROOT, env=host_env,415                        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)416                (output / 'pocketic.log').write_text(host.stdout)417                verify()418                kani.require(host.returncode == 0, 'Wasm32 execution failed; inspect pocketic.log and pocketic-server.log')419                records = [json.loads(line) for line in host.stdout.splitlines() if line.startswith('{')]420                kani.require(records == [{'status': 'EXECUTED_WASM32_HEADER_WITNESS',421                    'response': [32, 1, 1, 0, 1, 1]}], 'Changed or missing Wasm32 header outcome')422                kani.validate_diagnostics(host.stdout)423                observations['wasm32Response'] = records[0]424                print(host.stdout.strip(), flush=True)425    if core:426        compile_wasm64(output, rustc, env, core, verify)427        observations['wasm64CoreBuild'] = {**core, 'dependencyLockSha256': kani.sha(output / 'Cargo.lock')}428    verify()429    (output / 'observations.json').write_text(json.dumps({'artifacts': artifacts, **observations}, indent=2) + '\n')430    print(json.dumps({'status': 'TARGET_CHECKS_PASSED', 'output': str(output),431        'executedWasm32': pocket_ic is not None, 'compiledWasm64': wasm64,432        'configFeatures': ['default', 'page-profile'],433        'scope': 'actual const compilation and header witnesses; no general target/VM proof'}), flush=True)434    return output435436437def main():438    parser = argparse.ArgumentParser(description=__doc__)439    parser.add_argument('action', choices=('all', 'proofs', 'targets'), nargs='?', default='all')440    parser.add_argument('--rustc', type=Path, default=equality_bridge.production_compiler())441    parser.add_argument('--pocket-ic', type=Path)442    parser.add_argument('--wasm64', action='store_true', help='compile the const checks with a private source-built core')443    args = parser.parse_args()444    kani.TEMP.mkdir(exist_ok=True)445    with (kani.TEMP / '.kani-runner.lock').open('w') as lock:446        fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)447        if args.action in ('all', 'proofs'):448            run_kani()449            run_kani(True)450        if args.action in ('all', 'targets'):451            kani.require(args.rustc.is_file(), 'Existing pinned compiler required; no setup is performed')452            kani.require(args.pocket_ic is None or args.pocket_ic.is_file(), 'PocketIC binary does not exist')453            run_targets(args.rustc, args.pocket_ic, args.wasm64)454455456if __name__ == '__main__':457    try:458        main()459    except (RuntimeError, subprocess.CalledProcessError, BlockingIOError) as error:460        print('Target/config verification refused: ' + str(error), file=sys.stderr)461        sys.exit(1)