The Formal VerSo project aims to create formal verification tools for Soroban, ensuring smart contract correctness and safety. We envision a future where users can easily define Soroban application behavior and verify it in an automated manner. Formal VerSo utilizes Galois’s Software Analysis Workbench, a tool for formally verifying code in languages like Rust, C, Java, or Cryptol. SAW employs SAT and SMT solvers to streamline verification, offering SAWScript for scaling up verification to complex systems.
A recording of the PoC demo can be found here (YT link).
Note: this project is still in its early stages, and only supports a small fraction of the Soroban API. In addition, due to tooling limitations, we currently only support v0.8.4 of the Soroban SDK. We are actively working to support more APIs and versions.
This repository contains:
lib
: A SAWScript+Cryptol library for verifying Soroban smart contractssoroban-examples
(submodule): A fork of the officialsoroban-examples
repo at v0.8.4, with slight configuration changes to enable symbolic execution of contractsextra-examples
: More examples of contracts that are suitable for formal verificationexample-proofs
: SAWScript proofs of correctness for selected examples fromsoroban-examples
andextra-examples
increment.saw
: Verifiessoroban-examples/increment
. Demonstrates verification involving the Storage and Short Symbol APIs.alloc.saw
: Verifiessoroban-examples/alloc
. Demonstrates verification involving dynamic allocation.sqrt.saw
: Verifiesextra-examples/sqrt
. Demonstrates verification involving complex computations, the Storage API, and compositional verification.
- Install a nightly version of SAW, either
prebuilt
or from
source
- Make sure you also install the
z3
solver
- Make sure you also install the
- Install
mir-json
- Install
crux-mir
Rust libraries- Clone
crucible
cd crux-mir
TARGET=wasm32-unknown-unknown ./translate_libs.sh
- Add
export SAW_RUST_LIBRARY_PATH="/path/to/crucible/crux-mir/rlibs"
to your.bashrc
or similar
- Clone
- Clone this repo
git submodule update --init
- For each contract that you want to verify:
cd
to the contract packagemake saw-build
cd example-proofs
saw <example-proof>.saw
- Note:
sqrt
takes a long time (hours) to run from scratch. To use cached SMT solver results, runSAW_SOLVER_CACHE_PATH=solver-cache saw sqrt.saw
.
- Note: