Skip to content

[High] Prove the pure arithmetic and parsing helpers with Kani #415

Description

@james2177

Description:
Use the Kani model checker to prove properties of the pure (non-Env) helpers: compute_slash_amount (never exceeds the bond, never negative), tier_fill_window (monotonic, no overflow), fee math (fee ≤ amount, rounding direction), Dutch-decay math, tier lookup monotonicity, and the proof registry's payload byte decoding.

Problem Statement & Context:
Proptests sample the input space, while Kani proves the property for all inputs. Arithmetic helpers are small enough to verify fully, and their bugs directly move funds.

Scope & Acceptance Criteria:

  • Pull the helpers into Env-free functions (a pure math module) if they aren't already.
  • At least 10 Kani harnesses with #[kani::proof], each with a documented property.
  • A make kani target, and harnesses that finish in under 10 minutes in total.
  • Out of scope: proving Env-dependent code.

Implementation Guidelines:

  1. Key Files/Modules: intent_settlement/src/math.rs, solver_registry/src/lib.rs (score_of, tier), proof_registry/src/lib.rs (the decode helpers), Makefile.
  2. Design/Architecture: Keep soroban-sdk types out of the proven functions and use primitive types.
  3. Edge Cases/Constraints: i128 multiplication overflow, where Kani needs unwind bounds for the loops.
  4. Testing: The Kani harnesses themselves, plus unit tests.

Definition of "Done":

  • Kani passes locally with the output in the PR, and the Makefile target is added.
  • Reviewed and approved.

Resources:

Complexity: High (200 points)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programhigh (200 pts)Drips Wave complexity: high, 200 pointssecuritySecurity hardening or audit finding

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions