Files
davidherranandClaude Fable 5 db4c8a37d3 fix(ink/staking): slash() sin guard de estado → insolvencia (CRITICAL audit ultra)
Audit ultra 2026-07-04 (dimensión ink-contracts): slash() checaba solo
caller==slashing_authority, existencia y amount<=stake.amount — NUNCA el
stake.state. Y withdraw() ponía state=Withdrawable pero NO ceroaba stake.amount.
⇒ tras un withdraw, el slashing_authority podía slashear el stake retirado
(amount<=stake.amount pasaba con el principal ya devuelto), pagando el
treasury_share desde el pool de OTROS stakers (insolvencia + doble decremento
de total_staked). Alcanzable por el Tribunal (autoridad confiable), no cubierto
por FIX-1 (CEI) ni FIX-6 (fake APR).

Fix: (a) guard de estado en slash() — solo Active|Unbonding; Withdrawable/Slashed
→ InvalidState. (b) withdraw() cero stake.amount + rewards_accumulated tras
computar to_return. +test E2E (ink v6, set_contract_balance). Contrato 5 tests
verde. (No desplegado — fase futura; endurecido antes de que sea dinero real.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 14:55:31 -05:00
..

origin-staking — Multi-purpose Staking Template (Slice 3.5)

Fourth foundational template del Origin Contract Atelier. Validator + Beacon + Reputation staking patterns canonical.

StakeKind variants (3 canonical)

Kind Purpose Min Stake (default) Lockup (default) APR (default)
Validator NPoS validator Phase 2 (CHN-3) 100 OGC 28 días (403_200 blocks) 8%
Beacon Pillar 6 Nexus featured visibility 100 OGC 7 días (100_800 blocks) 5%
Reputation AGI commercial reputation (BM V2 §6.4) 10 OGC 14 días (201_600 blocks) 3%

Lifecycle canonical

stake() ──► Active ──unbond_request──► Unbonding ──lockup expires──► Withdrawable
              │                              │
              ▼                              └──withdraw()──► funds + rewards
        slash_event (Tribunal) ──► Slashed (partial OR full)

Slashing canonical

Only slashing_authority (typically Tribunal Pillar 6 contract address) puede invocar slash(). Splits canonical:

  • 50% → Treasury canonical
  • 50% → Burn (per BM V2 burn matrix)

Reason hash BLAKE3 inmutable on-chain para audit trail Tribunal decisions.

Inmutables compliance

  • #16 HTS: min_stake graduated por HardwareTier — Pi 5 inclusion canonical
  • #37 Free perpetua: 5 read methods sin payment
  • #26 Content-Addressed: reason_hash BLAKE3 inmutable slash events
  • #41 AGI Cross-Species: AGI accounts stake canonical en cualquier kind (especially Reputation)

Cross-pillar coord

  • Pillar 4 Charon: validator stake compose con pallet-session NPoS Phase 2
  • Pillar 6 Mathi: beacon stake fed a Beacon visibility rotation
  • Pillar 6 Tribunal: slashing_authority = Tribunal contract
  • BM V2 Pillar 4 §6.4: AGI reputation stake/slash mechanics canonical

Tests (3 unit tests)

  • default_chn3_constructor — defaults CHN-3 NPoS Phase 2 prep
  • lockup_periods_canonical — Validator > Reputation > Beacon hierarchy
  • stake_kind_variants_distinct — enum distinction

— Charon ⚓ (Slice 3.5 SCAFFOLD 2026-05-27)