test: add kani harness for blacklist idempotency - #829
Open
PHADAR6 wants to merge 1 commit into
Open
Conversation
Add a bounded Kani verification harness that non-deterministically executes sequences of blacklist add and remove operations and proves the final state is a set (idempotent, order-independent) modulo ordering. The harness models the per-offering blacklist as a set (one membership slot per address, mirroring the on-chain Map storage key) and proves: - add and remove are both idempotent - operations on distinct addresses commute - the final state after any bounded op sequence is a set - sequences converge to the reference last-op-wins membership - the add-remove-add-on-same-address edge case equals a single add Proofs run only with the Kani toolchain (gated behind #[cfg(kani)]); concrete-input test shims run under cargo test in CI.
|
@PHADAR6 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Description
Add a kani harness that non-deterministically executes sequences of blacklist add and remove operations and proves the final state is a set (idempotent, order-independent) modulo ordering.
Requirements and context
src/kani_harness/Suggested execution
git checkout -b test/kani-blacklist-idempotencySummary of changes
Added
src/kani_harness/blacklist_idempotency.rsand registered it insrc/kani_harness/mod.rs.The harness models the per-offering blacklist as a set — one membership slot per address, mirroring the on-chain
Map<Address, SanctionsAttestation>storage key — and proves:addtwice equals a singleadd.removetwice equals a singleremove; removing an absent address is a no-op.add(a); remove(b)equalsremove(b); add(a)whena != b(order-independent modulo the addresses touched).MAX_OPS = 4non-deterministic add/remove ops reaches exactly the membership computed by the reference last-op-wins set semantics.add; the dualremove; addcase is also proven.Files included
src/kani_harness/blacklist_idempotency.rs— pure-Rust state model, 7#[kani::proof]harnesses, and 6#[cfg(test)]concrete-input shims.src/kani_harness/mod.rs— module registration + doc comment.Design notes
Env, no Soroban host — so Kani can reason over the full symbolic domain without host stubs.require_auth, issuer/admin checks) is out of scope for the convergence proofs; auth-failure paths are covered by integration tests insrc/test.rs.get_blacklist(Implement Deterministic Ordering for Query Results #38) is intentionally not modelled — ordering is a determinism concern, not a membership concern.UNIVERSE_SIZE = 4,MAX_OPS = 4) so all proofs terminate under kani defaults.Test and commit
cargo test --allTest output
The
#[cfg(test)]shims run undercargo testin CI without the Kani toolchain. Kani is not installed in this environment, so the#[cfg(kani)]proofs could not be executed locally; they are gated so they do not affect default CI, and the concrete-input shims verify the same model logic:Example commit message
test: add kani harness for blacklist idempotencyCommit
Security notes
auth_ok = trueand focus on storage-convergence invariants, as documented in the harness module.Guidelines
Related issues