Skip to content

[Contract] Fund-conservation invariant + property tests #28

Open

Description

@Gbangbolaoluwagbemiga

Why this matters

This is a fund-custody contract. The single most important safety property is fund conservation:
the contract can never pay out more than was deposited. There is currently no invariant or test
guarding this.

What needs to be done

  • Add a test-only helper that computes Σ(unreleased milestone amounts across all escrows) per token
  • Assert the contract's token balance ≥ that sum after every state transition in tests
  • Add property/fuzz tests (e.g. proptest) generating random sequences of
    create → fund → submit → approve → reject → dispute → refund and asserting the invariant holds
  • Cover the fee path: calculate_fee (escrow_core.rs) must never let payouts + fees exceed deposits

Acceptance criteria

Relevant files

refund_system.rs (do_transfer, arbiter_award_freelancer), work_lifecycle.rs, escrow_core.rs

Pairs with the internal audit (#18) and the arbiter bounds-check (#29).

Activity

  1. changed the title [-]Fund-conservation invariant + property tests[/-] [+][Contract] Fund-conservation invariant + property tests[/+] on Jun 17, 2026
  2. guptakumarranjeet150 commented on Oct 7, 2026

    @guptakumarranjeet150

    Hello team,

    I looked into [Contract] Fund-conservation invariant + property tests and have an implementation approach ready.

    Technical outline:

    1. Audit storage layout and state invariants ensuring strict auth guards.
    2. Implement deterministic state transitions with safe checked arithmetic.
    3. Add hermetic unit and regression tests covering authorized, unauthorized, and boundary edge cases.
    4. Profile instruction and CPU/gas limits under Soroban host environment.

    Ready to implement immediately upon assignment. Please feel free to assign!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditRequired before / part of a security auditsecuritySecurity-sensitive work

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions