Introduction
We studied the type-checker in the Rust implementation of Move for the Sui blockchain. This report records the instruction cases we worked through in Coq and the parts of the proof that remain open.
For now, we concentrate on the type-checker of the Move bytecode. Smart contracts are stored as Move bytecode on the blockchain, and several sanity checks are performed on the bytecode before it is executed. The type-checker is one of these checks, and the one that is the most involved.
Here are some reference files:
- The type-checker move-bytecode-verifier/src/type_safety.rs
- The interpreter of the Move bytecode move-vm-runtime/src/interpreter.rs
- A README about the list of checks performed on the bytecode crates/move-bytecode-verifier/README.md
General strategy
We use the 🐓 Coq proof assistant for our formal verification effort.
We wrote coq-of-rust to translate Rust programs automatically. For this project its output included more detail about memory, libraries, and traits than we could handle in the proofs.
Instead we write a Coq translation by hand of the Rust code of:
- the type-checker and
- the interpreter
and compare the models with Rust on a set of test cases.
Our verification chapter gives the status of the 67 non-deprecated instructions. Its central property concerns one instruction of the Coq models:
Assume a well-typed starting state and a successful type check. The interpreter may report an execution error. It cannot panic, and if it succeeds, the resulting state has the types predicted by the checker.
The report records completed cases for 43 instructions. The general lemma still has admitted cases. Extending the result to whole programs would also require reasoning about instruction sequences and other bytecode checks. Our longer-term goal is:
If the type-checker is successful, then the interpreter does not run with a critical error.
To ensure this property, other checks such as the "stack safety" (analysis of the stack height) will be necessary.