This pull request introduces formal verification to the weighted consensus mechanism of the Vero Core Contracts using Kani. It also resolves pre-existing duplicate definitions and type mismatches that were breaking the unit test suite compilation.
- Extracted and isolated the weighted voting state machine to src/consensus.rs.
- Added
ConsensusStateand the pure functionapply_vote()which handles:- Vote weight accumulation.
- Votes counter saturating addition (prevents counter overflows).
- Validation of threshold logic and completion tracking (
is_done).
- Integrated
apply_vote()into the main contract lifecycle in src/lib.rs.
- Created a separate workspace crate
vero-verificationin the verification/ directory. - Implemented 9 Kani symbolic proofs verifying core properties:
- Threshold Invariant: Task completion requires cumulative weight meeting the threshold.
- No Below-Threshold Resolution: Proof that no execution path allows resolution below threshold.
- Monotone Resolution: Task completion state (
is_done) is irreversible. - Overflow Protection: Absolute prevention of weight and votes counter wrapping.
- Degenerate Case Safety: Safe handling of a zero-weight threshold.
- Integrated a new job
formal-verificationin .github/workflows/ci.yml to automatically install the Kani verifier and run proofs on every push and pull request.
- Cleaned duplicate methods and struct fields in src/lib.rs, src/events.rs, and src/types.rs.
- Rewrote the unit test suite in tests/test.rs to properly initialize token locks and setup guardians, ensuring
cargo check --testscompiles with 0 errors.
- Local Compilations: Verified that the contracts and entire test suite compile successfully (
cargo check --testsfinishes with 0 errors). - Verification Proofs: Configured to run automatically in CI.
- Environment Note: Local test running (
cargo test) requires MinGW'sdlltool.exeon Windows-GNU host environments to compilebacktrace(asoroban-sdktestutils dependency). These checks are fully supported and will run in the CI build containers.