4 Commits
Author SHA1 Message Date
davidherranandClaude Opus 4.8 c7fc6a88fc feat(bench): maquinaria FRAME v2 de benchmarking para los 5 pallets custom (RV 8→9)
Los 19 extrinsics de provenance/fees/agent-identity/emission/governance pasan de
weights placeholder `from_parts(10_000, 0)` (proof_size=0, sin contar reads/writes
de DB — vector de DoS real) a weights INTERIM hand-derived DB-aware vía el trait
`WeightInfo`. Cierra el mispricing de DoS en TODOS los extrinsics del chain.

Cada pallet gana:
- weights.rs: trait WeightInfo + SubstrateWeight<T> (DB-aware vía T::DbWeight) + impl ()
- benchmarking.rs: benchmarks FRAME v2, VERIFICADOS por impl_benchmark_test_suite!
  (19 benchmarks ejecutan+pasan en los mocks — cargo test --features runtime-benchmarks)
- Config: `type WeightInfo` + swap de los `#[pallet::weight]`

Runtime:
- define_benchmarks! con los 5 pallets + runtime API Benchmark (inerte sin la feature)
- WeightInfo cableado a SubstrateWeight<Runtime> en cada Config
- RUNTIME_VERSION 8→9 (weights = consenso-relevante: fee + llenado de bloque;
  las firmas de los extrinsics NO cambian ⇒ TRANSACTION_VERSION intacto)

3 bugs latentes cerrados (territorio virgen — el runtime NUNCA se compiló con
runtime-benchmarks; las dimensiones nuevas cazan lo que no se había visto):
- pallet-grandpa/try-runtime mal ubicado en la feature runtime-benchmarks (copy-paste
  erróneo: features ortogonales; NUNCA activaba los benchmarks de grandpa)
- feature runtime-benchmarks incompleta → E0046 en OriginFeeAdapter (métodos
  benchmark-gated de OnChargeTransaction) + pallet-staking
  (StakingUnchecked::migrate_to_direct_staker); ahora lista TODOS los pallets como
  un runtime de producción Substrate
- pallet-revive/runtime-benchmarks omitido a propósito (fixtures RISC-V/PolkaVM
  indisponibles; ReviveApi deferred, no benchmarkeado)

emission: mock extraído del `mod tests` inline a `pub mod mock` (reuso del test-suite,
sin duplicar el scaffold; los 15 tests existentes + el benchmark verdes).

GATED (documentado en el §Estado de cada weights.rs): la generación de números
CANÓNICOS por CLI requiere el node sc-service o omni-bencher+WASM (ambos bloqueados
hace sesiones). Los weights interinos son DB-aware/DoS-safe y regenerables de forma
mecánica cuando aterrice el HW de referencia (Pi5/VPS) — benchmarking.rs es la fuente
de verdad de la FORMA.

Verificado: 5 test-suites de pallet verdes (con y sin runtime-benchmarks) + runtime
compila en ambos modos + workspace sin regresión + 40 tests de runtime (incl. v9).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 22:48:26 -05:00
davidherranandClaude Opus 4.8 1a9e37021d fix(governance): FIX-6 Stage 1 — tesoreria real Currency (cierra hallazgo de FIX-5)
Build + tests verde: governance 42 + runtime 27. Verificacion adversarial
ultracode (2 skeptics): 2 confirmed/low, sin blockers.

Cierra el hallazgo HIGH de FIX-5: treasury_disbursement era simbolico (solo
decrementaba un contador u128 desconectado de pallet_balances). Ahora:
- governance Config: type Currency (fungible Inspect+Mutate) + type
  TreasuryPalletId (pallet::constant).
- Eliminado el contador Treasury<StorageValue<u128>> (0 referencias colgantes).
- treasury_account() = PalletId.into_account_truncating() — vault keyless
  deterministico (nadie lo controla por wallet; honor Inmutable #16).
- treasury_balance() lee el balance REAL (Inspect::balance), no un contador.
- treasury_disbursement: T::Currency::transfer real desde el vault al recipient
  (ensure_root + proposal Approved). treasury_deposit: signed, dona del propio
  balance del caller (cualquiera fondea, no requiere Root, imposible robar).
- runtime configs.rs: Currency=Balances + GovernanceTreasuryPalletId(og/gvtry).
- mock con pallet_balances + scenario_4 prueba que el RECIPIENT recibe OGC REAL
  en pallet_balances (bob 100M -> 100M+300k), no solo que el contador baja.

Decision constitucional (FIX-6 V2-CA3): David ratifico sub_mult = ORTOGONALES
(la suscripcion premium NO reduce el subsidio anti-clasista de hardware, #16).
Input para el OnChargeTransaction de Stage 2. Registrado en KG.

FOLLOW-UPS (low, documentados, no bloquean):
- genesis mainnet: rutear los 250M Foundation a la cuenta og/gvtry (hoy van a
  FNDT) — detalle de pre-launch que David ratifica. El vault arranca en 0 hasta
  fondear.
- treasury_disbursement no vincula amount/recipient al proposal Approved, y el
  mismo proposal es reusable (no se marca disbursed). Check ceremonial, no
  autorizacion per-desembolso. Sin escalada nueva (Root ya puede todo via sudo).
  Endurecer antes del sunset sudo->governance.

FIX-6 Stage 1 restante (next): emision que paga Aura authors (cierra V2-CA2) +
remover APR falso del staking contract. Stage 2: NPoS + fee unificado
(OnChargeTransaction con el sub_mult ortogonal).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 05:36:31 -05:00
davidherranandClaude Opus 4.7 1bde93921e feat(governance): v0.0.28 origin-chain-governance pallet scaffold (Phase 5.1 Foundation Treasury CHN-4)
Phase 5.1 GOVERNANCE pallet scaffold canonical. Reemplaza placeholder
GovernanceConfig stub en existing origin-chain-governance crate con real FRAME
pallet. AI-Driven Human-Guarded canonical CHN-4 — 5 AI advisor agents ADVISE
only, humans-only vote canonical non-negotiable.

## Pallet surface canonical

- Pallet<T> + Config trait + RuntimeEvent
- Proposal struct (11 fields content-addressed via BLAKE2-256)
- ProposalStatus enum (Voting + Approved + Rejected + Withdrawn)
- Proposals<StorageMap<ProposalId, Proposal>> per-proposal O(1)
- Votes<StorageDoubleMap<ProposalId, AccountId, VoteStance>> double-vote prevention
- Events ProposalSubmitted + VoteCast + ProposalFinalized
- Errors 8 variants (ProposalNotFound + AlreadyVoted + VotingPeriodClosed/Open + StakeInsufficient + ProposalAlreadyFinalized + AdvisorMayNotVote + ProposalIdCollision)
- Scaffold dispatchables submit_proposal + cast_vote + finalize_proposal
- Helper derive_proposal_id via BLAKE2-256 hash (Inmutable #16 byte-determinism)
- sp_api::decl_runtime_apis! GovernanceApi declaration (query_proposal + query_vote)

## Types canonical updated

- origin-chain-types/src/governance.rs: added scale derives a ProposalId + VoteStance + Vote (Encode + Decode + DecodeWithMemTracking + MaxEncodedLen + TypeInfo) para FRAME-compatibility canonical

## Files

- EDIT: crates/origin-chain-governance/Cargo.toml (stub → FRAME pallet deps canonical)
- REPLACE: crates/origin-chain-governance/src/lib.rs (placeholder → ~360 LOC scaffold)
- EDIT: crates/origin-chain-types/src/governance.rs (scale derives canonical)
- EDIT: CHANGELOG.md (v0.0.28 entry)

## Verification

- cargo test -p origin-chain-governance — 5 tests verde, 0 failures
  (pallet_compiles + derive_proposal_id deterministic + different + status variants + re-export)

🏛️ Phase 5.1 scaffold canonical. Wire pattern v0.0.29 next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 12:41:27 -05:00
b06560863c feat(workspace): Phase 0.4 — trait-first foundation v0.0.1
Charon sesión 1 (2026-05-19) — primer commit canonical.

Ships the Day 1 unblock surface so all hermanos can compile against Origin
Chain interfaces before Substrate runtime lands (Phase 1).

## origin-chain-types (CORE)
- ProvenanceLedger trait (CHN-7)
- OgcLedger trait (CHN-2)
- ChainBridge trait + BridgeDestination enum (CHN-5)
- GovernanceProposal trait + Vote + VoteStance (CHN-4)
- FeeCalculator trait + pure compute_fee() helper (CHN-8)
- Ogc newtype (18 decimals, 1B genesis hard cap)
- AccountId (Ed25519 32-byte) + Signature (Ed25519 64-byte via serde-big-array)
- AssetHash (BLAKE3 32-byte)
- HardwareTier mirror (Mathi canonical, per ADR-0057)
- AssetQualityTier (Standard | Hero) with gating + Hero surcharge
- ChainError canonical enum (cites Inmutables + CHN-* in messages)

## Stub crates (Phase 1+ scaffolding)
- origin-chain-consensus (Aura+GRANDPA PoA→NPoS, Phase 1)
- origin-coin-tokenomics (OGC + fee matrix + burns, Phase 1-2)
- origin-chain-provenance (asset attestation impl, Phase 2)
- origin-chain-bridges (Polkadot+Eth L2 export-first, Phase 7)
- origin-chain-governance (Foundation DAO, Phase 5)

## Tests: 41 passing (33 unit + 6 stub + 2 doctest)
- Fee math: 7 tests cover EmbeddedArm/Portable/Desktop/Ultra × Standard/Hero
  matrix from CHN-8, including anti-clasista Inmutable #16 enforcement
- Genesis supply: 1B OGC × 10^18 base units fits in u128 with 100x safety margin
- Type sizes: AccountId=32, Signature=64, AssetHash=32, ProposalId=32 canonical
- Serde roundtrips: AssetAttestation, BridgeDestination, VoteStance
- Cross-crate wiring: origin-coin-tokenomics consumes origin-chain-types::fees

## Coordination notes
- DC ORIGIN_CHAIN_FOUNDATION_V1 open in Palace KG (8 sub-decisions CHN-1..CHN-8)
  Proposer: Ergon (proxy — Charon hotfix shipped in Palace v0.9.0-α.5 same day)
  Co-authors: Larihana, Lyra, Mathi, Marihan, Phanes, Codex, Sussi, Palace
  Deadline: 2026-05-26
  1/9 signatures filed so far (Palace ✅ APPROVE 8/8)

Refs: CHN-1..CHN-8, Inmutables #16/#26/#37/#41, ADR-0057, CHARON_ROADMAP_V1

Co-Authored-By: Ergon (interim Pilar 4 author) <ergon@originmetaverse.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-19 22:08:49 -05:00