Skip to content

[Feature] Implement On-Chain Dispute Resolution System for Billing, Metering, and Payment Disputes #29

Description

@KarenZita01

Description

The contract has no on-chain dispute resolution mechanism for billing disputes, incorrect meter readings, or stream payment disagreements. Disputes currently require off-chain legal processes or social consensus. For a DePIN (Decentralized Physical Infrastructure Network) protocol, automated dispute resolution with arbitration is essential for trustless operation. The enterprise.rs mentions dispute resolution for P2P exchanges but doesn't implement it.

Dispute resolution gaps:

  • No BillingDispute struct or dispute lifecycle
  • No arbitration panel (multi-sig of trusted third parties)
  • No escrow mechanism for disputed funds
  • No timeout-based auto-resolution for stale disputes
  • No dispute fee (to prevent frivolous disputes)
  • No oracle-based verification for metering disputes (e.g., cross-reference with neighbor meters)
  • No appeal process for arbitration decisions

Technical Context & Impact

  • Affected Components/Files: contracts/utility_contracts/src/lib.rs, contracts/utility_contracts/src/enterprise.rs, contracts/utility_contracts/src/asset.rs
  • Impact: User Trust, Decentralization, Operational Efficiency

Step-by-Step Implementation Guide

  1. Create dispute resolution module: src/dispute.rs with Dispute struct:
    struct Dispute {
        id: u64,
        disputant: Address,
        respondent: Address,
        dispute_type: DisputeType,
        amount_escrowed: i128,
        evidence_hashes: Vec<BytesN<32>>,
        status: DisputeStatus,
        arbitrator: Address,
        created_ledger: u32,
        resolution_deadline: u32,
    }
  2. Implement dispute lifecycle: file_dispute -> submit_evidence -> escalate_to_arbitration -> resolve -> appeal with timeouts at each stage
  3. Add escrow for disputed funds: lock_disputed_amount(stream_id, dispute_id) freezes stream funds until resolution
  4. Implement arbitrator selection: set_arbitrators(Vec<Address>) (admin or multi-sig); select_arbitrator(dispute_id) picks random arbitrator from pool
  5. Add evidence submission: submit_evidence(dispute_id, evidence_hash, description) with Evidence struct and maximum evidence count per party
  6. Implement auto-resolution: If current_ledger > dispute.resolution_deadline, auto-resolve in favor of disputant (if no response) or split funds 50/50
  7. Add appeal process:
    • Losing party can appeal within 72 hours by paying appeal fee
    • Appeal goes to full arbitrator panel (3 arbitrators instead of 1)
    • Appeal decision is final

Verification & Testing Steps

  1. Test full dispute lifecycle: file -> evidence -> arbitrator assigned -> resolve -> verify fund distribution
  2. Test appeal: initial ruling -> losing party appeals -> panel votes -> final ruling
  3. Test auto-resolution: file dispute -> respondent never responds -> timeout -> auto-resolve
  4. Test dispute fee: frivolous dispute -> fee deducted from disputant
  5. Test multiple disputes on same stream: dispute 1 ongoing -> dispute 2 filed (should be queued or rejected)
  6. Run full test suite: cargo test --package utility_contracts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions