Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
This PR adds back the Sui Move prover with significant changes and enhancements.
The most important change is that the prover no longer uses special syntax. The specifications are now given via special functions, macros, naming conventions and annotations. This has several advantages, including:
making changes to the Move language does not require making sure the changes are compatible with the prover; for example, the old prover did not support tuples as it would have required special wiring
the syntax is much more flexible; for example, a variable used by multiple requires can be extracted out
developers do not need to learn new language features, it is more akin to learning a new sdk or library
strict checking of ghost variable declarations in specifications.
opaque specifications for functions
For verification, the implementation of the function is replaced with its specification
Format: f_spec for function f
the wiring of requires / ensures /asserts is particularly interesting
done via structured pre/post-conditions
The specifications needs to, by convention, follow the following strict format:
Identical type signatures
contact a single function call to the original function with the same arguments
no parameter modification
failure-free specification execution ???
Enforcing the format at compile time or via linting is left for the future
Loop invariants
placed before loops via invariant! macro
automatically move to loop headers
implementation handles mutable and ghost variable havoc
Struct Invariants
defined via S_inv for struct S
automatically checked as part of pre-post conditions
the current implementation is not recursive
Improved Boogie generation
including skipping unused functions
Eliminating spec code at compile time
#spec_only annotation
_spec variables
automatically eliminating call to verification/spec functions
Test plan
Unit tests covering the new features -- this could be improved
Verification of kai-leverage and DoubleUp codebases
Release notes
The changes should not affect any of the existing functionality. We still recommend extensive testing as we made some changes to the compiler to support spec_only and related.
Description
This PR adds back the Sui Move prover with significant changes and enhancements.
The most important change is that the prover no longer uses special syntax. The specifications are now given via special functions, macros, naming conventions and annotations. This has several advantages, including:
requires
can be extracted outThe prover now supports:
AMM example: https://github.com/kunalabs-io/sui-smart-contracts/pull/9
Features/Changes
std::integer
andstd::real
std::integer
module for arbitrary-precision integer arithmeticstd::real
module for real number operationsprover
modulerequires
- specifies preconditions (renamed fromassume
for clarity)ensures
- specifies postconditionsasserts
- Replacesabort-if
with its complement, which is more in line with existingassert
statements (can simply copy-paste in many cases)invariant!
macro for loop invariantsold!
macro for referencing pre-state valuesdeclare_global
/declare_global_mut
prover native commandsglobal
prover native for state manipulationf_spec
for functionf
requires
/ensures
/asserts
is particularly interestinginvariant!
macroS_inv
for structS
#spec_only
annotation_spec
variablesTest plan
Release notes
The changes should not affect any of the existing functionality. We still recommend extensive testing as we made some changes to the compiler to support
spec_only
and related.