Skip to content

Feature/sc 002 claim lifecycle - #338

Merged
dDevAhmed merged 3 commits into
DigiNodes:mainfrom
Tobi-8:feature/sc-002-claim-lifecycle
Jul 30, 2026
Merged

Feature/sc 002 claim lifecycle#338
dDevAhmed merged 3 commits into
DigiNodes:mainfrom
Tobi-8:feature/sc-002-claim-lifecycle

Conversation

@Tobi-8

@Tobi-8 Tobi-8 commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Implement the canonical Claim Lifecycle State Machine (SC-002) defining all legal
claim state transitions and preventing invalid protocol behaviour.

  • ClaimLifecycle.sol: standalone, inheritable contract with:
    • ClaimStatus enum: Pending, UnderVerification, VerificationEnded, UnderDispute,
      VerifiedTrue, VerifiedFalse, Inconclusive, Cancelled
    • _canTransition(current, next) — pure validator for all state machine rules
    • 7 internal transition functions: _startVerification, _endVerification,
      _markVerifiedTrue, _markVerifiedFalse, _markInconclusive, _openDispute,
      _cancelClaim — each validates transition, updates storage, emits event
    • ClaimStatusChanged event with indexed claimId and actor for full
      on-chain history reconstruction
    • Time-based validation: verification deadline, verification window end,
      dispute deadline — all checked against block.timestamp
    • 6 view helpers: isPending, isUnderVerification, isResolved,
      isDisputed, canReceiveVotes, canBeCancelled
    • __gap[50] for upgrade-safe storage
  • ClaimLifecycleTestWrapper.sol: test harness exposing internal functions
  • No global iteration, minimal storage writes, pure validation

Gas Benchmarks

Transition Avg Gas
startVerification 68,587
endVerification 31,096
markVerifiedTrue 29,187
cancelClaim 46,271

Testing

  • 48 unit tests covering:
    • All 10 valid transitions (_canTransition)
    • All invalid transitions across every source state
    • validateTransition revert on illegal, pass on legal
    • 5 full lifecycle paths (incl. dispute flow)
    • 5 event emission tests (exact args: claimId, prev, new, actor)
    • 3 time-based validation reverts
    • 9 view helper correctness tests
    • 4 gas benchmark measurements

Closes #282

Tobi Olusanya added 3 commits July 28, 2026 21:16
- Add VerificationAggregation contract with ClaimOutcome enum, AggregationResult struct
- Implement deterministic weighted consensus: TRUE/FALSE weight calculation, confidence scoring
- Add configurable thresholds: min verification count, min total stake, min confidence
- Handle ties deterministically (INCONCLUSIVE)
- Emit ClaimAggregated event for indexers
- Add IVerificationSource interface for future extensibility (reputation weighting, quadratic voting, etc.)
- Add view functions to TruthBountyWeighted for voter iteration: getClaimVoterCount, getClaimVoterAt, getVerificationWeight, getVerificationSupport, getClaimVerificationWindowEnd, getClaimSubmitter
- Write comprehensive Foundry tests: successful cases, tie handling, determinism, stress tests, gas benchmarks
- Pure integer arithmetic, no floating-point
- Order-independent aggregation guarantees identical output across all nodes
…SC-009)

- Rewrite ReputationDecay.sol: inherit GovernanceOwnable, minimum reputation
  floor, inactivity tracking, linear decay, recordActivity, applyDecay,
  view functions, full IReputationOracle compliance.
- Rewrite tests (ReputationDecay.ts, RBAC.test.ts): 57 tests across
  deployment, decay, governance, access control, edge cases.
- Add Foundry fuzz tests (test/fuzz/ReputationDecayFuzz.t.sol).
- Fix pre-existing compilation errors in BootstrapController.sol and
  MigrationManager.sol (missing PAUSER_ROLE). Enable viaIR in hardhat
  config for stack-too-deep in RewardEngine.sol.
@dDevAhmed

Copy link
Copy Markdown
Contributor

resolve conflicts @Tobi-8

@dDevAhmed
dDevAhmed merged commit d928113 into DigiNodes:main Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SC-002 — Implement Claim Lifecycle State Machine

2 participants