Add karni proof harness#604
Open
gloskull wants to merge 2 commits into
Open
Conversation
…deduct Add Kani proof harness for vault.deduct conservation
Author
|
Done with this issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Provide a formal Kani harness proving that a successful deduct moves amount from the tracked vault balance to settlement without changing the combined total (i.e., preserves total supply).
Increase confidence in the vault accounting invariants by modeling the relevant arithmetic domain and edge conditions for deduct.
Surface an auditable, focused proof artifact that complements existing Rust unit tests and the repository invariants documentation.
Description
Added a new proof module contracts/vault/proofs/deduct.rs containing a small model (DeductState) and a Kani harness kani_deduct_conserves_total_supply that proves vault_balance + settlement_credit is conserved on a successful deduct, plus focused unit tests for the model.
Wired the proof module into the vault crate via a conditional include in contracts/vault/src/lib.rs using #[cfg(any(kani, test))] and #[path = "../proofs/deduct.rs"] mod deduct_proofs;.
Documented the formal conservation proof in INVARIANTS.md by adding a note referencing the new harness.
Testing
Ran rustfmt contracts/vault/proofs/deduct.rs, which completed successfully.
Invoked cargo kani --version to check Kani availability, which failed because cargo-kani is not installed in this environment (no local Kani run possible here).
Ran cargo check --package callora-vault, which failed due to pre-existing compile issues elsewhere in the workspace (duplicate contract exports / missing imports in unrelated modules), so the Kani harness was not type-checked in this environment.
Ran cargo test --package callora-vault modeled_deduct --lib, which did not complete because repository-wide compilation errors in callora-settlement prevented the test from being executed here.
Closes #558