KMIR: the K semantics of MIR
- Team Name: Runtime Verification, Inc.
- Payment Address: 0xA3250Ab6292F2aAe7DE2DE5dC46Ba0D24dcf699E (USDC or DAI)
- Level: 3
Project Overview 📄
Overview
Overview:
There are many approaches towards (property) testing of Rust programs, such as proptest or quickcheck or arbitrary. They are quite effective, and most likely sound, but certainly not complete due to the very notion of a test as opposed to a formal proof. We would like to build out formal verification capabilities for Rust developers.
The K Framework is a language-agnostic semantic framework, quite suitable for the definition of programming language semantics, from which many compiler and verification related tools can be automatically generated.
We seek to develop KMIR: the K semantics of the MIR language, which is an internal representation for the Rust compiler. This will enable more scalable verification for the Rust programming language. A robust commitment to security and assurance does not end with a completed security audit (which we have experience doing for various Rust-based projects). Rather, it requires that all available tools and techniques are used, including rigorous proof-based formal verification (among others). Supporting the development of the KMIR semantics will enable verification at scale for smart contract developers targeting the Polkadot (and related) ecosystem.
Background:
Runtime Verification has attempted verification of Rust programs in the past. Our past approach relied on compiling to WebAssembly and then using our KWasm semantics for verification. This suffered from two problems:
- The generated WebAssembly was large, making verification less tractable, and
- We could not handle Rust code compiled to a non-WebAssembly target.
In the WebAssembly setting, even simple Rust programs (just a few hundred lines) were compiled to WebAssembly programs that were ~100 kLOC. Much of the generated code is boilerplate inserted by the compiler, which is uninteresting when verifying program correctness, but slows the verification process down significantly.
KMIR solves both problems. The Rust compiler goes through MIR before compiling to any target language, and MIR is much closer to Rust than (the generated) WebAssembly. Because of this, verification of MIR should be more tractable as we’ll be dealing with code-sizes that are closer to the original Rust source code size. This allows the difficulty of verification to be bounded by the complexity of the application rather than the complexity of the compiler toolchain.
Project Details
Goals:
- Develop the KMIR semantics.
- Understand and document how to use KMIR to do verification.
- Initial integration of KMIR into Rust development workflow.
Deliverables:
- A first draft of the MIR semantics in K.
- Corpus of tests which exercise the feature set of MIR.
- Timeboxed initial KMIR semantics, which makes progress towards passing the tests.
- The kmir command-line tool, which allows users to try out the initial semantics on the test-suite and other examples.
- Integration with the kup tool, for one-command installation of K semantics and tooling.
- Blog post describing the progress made, and instructing people how they can try out the semantics themselves.
Ecosystem Fit
Our project fits into the ecosystem as developer tooling. This tool will help Rust smart contract developers to improve their quality assurance pipeline and to move towards formal verification on their own.
The initial version delivered in this workplan will be focused on providing expert developer tooling. In particular, only developers who spend extra time learning K will be able to be effective with the tool. The next version delivered (seeking funding elsewhere) will be focused on providing developer tooling; typical Rust smart contract developers should be able to use it.
Team 👥
Team members
- Team Lead: Yan Liu
- Team Members: Christiano Braga, Everett Hildenbrandt
Contact
- Contact Name: Patrick MacKay
- Contact Email: patrick.mackay@runtimeverification.com
- Website: https://runtimeverification.com
Legal Structure
- Registered Address: 1807 South Neil Street, Champaign, IL 61820
- Registered Legal Entity: Runtime Verification, Inc.
Team's experience
Runtime Verification has significant past experience doing program verification for a variety of programming languages. In particular, KEVM has been used for verifying Ethereum smart contracts, and KPlutus has been used for verifying Plutus smart contracts.
Team Code Repos
- https://github.com/runtimeverification
- https://github.com/runtimeverification/evm-semantics
- https://github.com/runtimeverification/beacon-chain-verification
- https://github.com/runtimeverification/deposit-contract-verification
- https://github.com/runtimeverification/deposit-contract-verification
- https://github.com/runtimeverification/plutus-core-semantics
- https://github.com/runtimeverification/avm-semantics
Please also provide the GitHub accounts of all team members. If they contain no activity, references to projects hosted elsewhere or live are also fine.
Team LinkedIn Profiles (if available)
N/A