Commit Graph
10 Commits
Author SHA1 Message Date
davidherranandClaude Opus 5 38e5602d78 feat(weights): RV13 — los 19 estaban subdeclarados, los 19
Primera medicion real de los weights con frame-omni-bencher sobre el
propio blob WASM. El resultado no es un ajuste fino: los 19 extrinsics
de los 5 pallets custom declaraban MENOS de lo que cuestan.

EL PATRON SISTEMATICO. Se costeo el storage del pallet y se olvido el
que cuesta emitir un evento — System::Events, EventCount, ExecutionPhase
y Number son reads y writes reales en cada extrinsic que deposita
evento. Ejemplos medidos: attest_asset declaraba 4 reads / 1 write y
cuesta 7/3; submit_proposal declaraba 12 us y cuesta 62; register_agent_did
declaraba 3/2 y cuesta 6/4.

EL PEOR, Y ES UN ERROR MIO DOCUMENTADO AL REVES. proof_size valia 0 en
los 19. La cabecera de los interinos afirmaba que T::DbWeight "puebla
tanto ref_time como proof_size ... cerrando el hueco". Es falso y se
comprueba en la fuente: sp_weights::RuntimeDbWeight solo tiene los
campos read y write, y reads(r) devuelve from_parts(read * r, 0). Los
interinos arreglaron reads/writes y dejaron el proof_size exactamente
donde estaba. Un proof_size en cero miente al block-builder sobre el
peso PoV: es el vector de DoS que la nota decia haber cerrado. La
afirmacion sobrevivio mas de un mes sin que ninguna lectura la
desmintiera; la desmintio una medicion.

Cada fichero generado lleva ahora un guard GENERADO desde la lista real
de benchmarks que reprueba cualquier proof_size = 0 o ref_time = 0.
Verificado que sabe reprobar: contra los weights anteriores se pone rojo
con "`attest_asset` declara proof_size = 0".

ADVERTENCIA QUE VA EN EL CODIGO, NO SOLO AQUI: son numeros de un
MacBook Pro M3 Max, NO del banco de referencia BM V2. La forma
(reads/writes/proof_size) no depende del hardware y es correcta; el
ref_time si, y en un Pi 5 sera mayor. Un caso lo enseña solo:
attest_asset BAJA de 50 a 44 us, y es el extrinsic dominado por el
verify Ed25519, el mas sensible al silicio. Antes de mainnet hay que
regenerar en el Pi 5 con governor y aislamiento declarados — peticion
abierta a Laurha (request:66f500d54e28a80c) con el blob, el comando y
la version exacta del bencher.

RV12 -> RV13 (weights = consenso). TRANSACTION_VERSION intacto.
295 tests verde.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 11:06:39 -05:00
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 8e72496901 feat(fees,genesis): FeesApi account-aligned query + 250M Foundation→vault og/gvtry
Dos endurecimientos pre-mainnet (leftovers del remediation roadmap):

1. genesis vault (#16/CHN-4): el preset mainnet asigna el 25% Foundation Treasury
   (250M OGC) al VAULT de governance (og/gvtry, GovernanceTreasuryPalletId), NO a
   una cuenta key-controlada. Es la MISMA cuenta de la que treasury_disbursement
   gasta (gated por governance council) y que emission/staking alimentan → el
   treasury queda DAO-governed desde el bloque 0, materializando "Foundation
   Treasury → DAO governed (CHN-4)". El placeholder FNDT queda SOLO como sudo_key
   interim hasta el sunset (DC ORIGIN_CHAIN_GOVERNANCE_SUNSET_V1). Las allocations
   BM V2 (40/25/15/15/5 = 1B) no cambian de monto.

2. FeesApi alignment: nuevo método query_fee_for_account(action, base, account) que
   estima el fee con el TierProfile REAL on-chain del account (storage TierProfiles,
   ValueQuery default Desktop+Free), NO caller-supplied — alineado con el fee-path
   vivo OriginFeeAdapter (FIX-6 Stage 2a). Cierra el "el cliente adivinaba hw/sub":
   la estimación off-chain ahora usa la misma fórmula sobre el MISMO tier que cobra
   la cadena. Método aditivo al Runtime API ⇒ TRANSACTION_VERSION 1 intacto.

RUNTIME_VERSION 4→5 (nueva metadata de FeesApi). 268 workspace tests verde
(native, SKIP_WASM_BUILD — WASM VPS-gated), 0 regresión. Test sella que
query_fee_for_account usa el perfil real (EmbeddedArm piso < default Desktop).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 21:01:38 -05:00
davidherranandClaude Opus 4.8 ca50938495 feat(tiers): EmbeddedAI on-chain — base_multiplier + subsidy piso EmbeddedArm (#16)
Espejea HardwareTier::EmbeddedAI (Jetson Orin Nano) en el mirror de la cadena,
en lockstep con arkhe-core bbac1b2 (Ergon Fase 1 EmbeddedAI, ADR-0072 / DC 2ba235e1).

Trampa de la fuente preservada byte-fiel: EmbeddedAI APPEND discriminante 4
(SCALE wire-safe, attestations runtime_tier:u8 viejas válidas) PERO rank de
capacidad 1 (entre EmbeddedArm=0 y Portable=2). Por eso Ord es MANUAL por rank()
(no derive — un derive pondría EmbeddedAI > Ultra, falso) y el gating Hero es por
rank, no por discriminante.

- tiers.rs: variant EmbeddedAI (last) + Ord/PartialOrd manual por rank() +
  rank()/ordinal()/from_ordinal() SSOT (el reverse-map que evita perder el
  tier-floor al deserializar, #16) + base_multiplier_x100=10 (piso, el estudiante
  en Jetson no paga más que en Pi 5) + surcharge Hero gated=0 + supports_hero=false.
- fee_schedule.rs: 6 arms EmbeddedAI = piso EmbeddedArm en subsidy_basis_points +
  educational override incluye EmbeddedAI (device de estudiante).
- fees.rs / unified.rs: cobertura — compute_fee(EmbeddedAI)==EmbeddedArm + grid de
  paridad OCAFB-5 extendido a EmbeddedAI.

Tests: 21 suites / 261 workspace verde, 0 regresión. SCALE index == ordinal sellado.
FIX-4 (verificador attestation) ortogonal — no mapea el enum, intacto.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 19:24:17 -05:00
davidherranandClaude Fable 5 3364994cce feat(fees): FIX-6 Stage 2a — fee unificado (cierra V2-CA3)
Pone la fórmula OCAFB-5 en el fee-path VIVO: OriginFeeAdapter
(OnChargeTransaction custom) reemplaza al FungibleAdapter tier-blind.
El firmante paga su fracción según (HardwareTier × ChainAction ×
SubscriptionTier, tiers leídos ON-CHAIN de TierProfiles — jamás
caller-supplied), y el subsidy pool og/subsy (alimentado por la
emisión Stage 1) cubre la fracción subsidiada. Inmutable #16 en cada
transacción. OU=() = burn 100% gas fees (matriz CHN-2).

unified_fee (u128, outcome tipado FeeOutcome — sin el sentinel
u64::MAX in-band): user = fórmula vendor Mathi byte-fiel (test de
paridad grid contra ce4fafb); pool = net × subsidy_bp/1e4 sobre el
COSTO BASE (anti-regresivo, sub_mult ORTOGONAL: un Ultra NO drena el
pool más que un Free — el premium lo paga el usuario, no el commons).

Hallazgos de la verificación adversarial (workflow ultracode, 4
lentes) cerrados de raíz:
- HIGH: clasificador cubre eth_instantiate_with_code (call_index 10)
  — evadía el entitlement-gate DeployContract vía fallback Write.
- MEDIUM ledger envenenable: removido el dispatchable legacy
  compute_fee_for_action (tiers caller-supplied, escribía AccountFees
  sin cobrar). AccountFees ahora escrito SOLO por el fee-path vivo
  (note_settlement). Eventos que nunca se emitían eliminados; el
  preview read-only vive en query_fee / FeesApi.
- MEDIUM drenaje del pool por sub_mult: pool sobre net, no sobre el
  precio premium (Opción B anti-regresiva).
- Dev UX: GenesisConfig siembra perfiles iniciales; dev/local
  arrancan Ultra (los Slices 3.x de contracts no se bloquean por
  Free+DeployContract); mainnet vacío (Default conservador hasta
  attestation).

Decisión de diseño (autoridad Pilar 4): replay de attestation =
RECHAZO explícito, no dedup silencioso (notificado a Ergon para el
reference impl). Orden OCAFB-5 subsidy-antes-de-entitlement preservado
byte-fiel + notificado a Mathi para el ratify 2026-06-21.

set_tier_profile Root-only interim (sunset a attestation-driven vía
Mathi PerceptionAdapter + DID binding FIX-3/FIX-4). spec_version 1→2
(formato de extrinsic intacto, TRANSACTION_VERSION=1).

Tests: 49 crate fees (paridad grid + lobo blanco ortogonalidad +
refund + pool seco + tip passthrough + entitlement blocked) + 21
suites workspace verde. Toolchain cargo +1.88.

Nota WASM: el build local del runtime WASM falla en la
post-validación del substrate-wasm-builder con UnknownOpcode(252)
— límite del toolchain (Rust 1.88 emite opcodes 0xFC que el parser
del builder de stable2509 no deserializa). Reproducido idéntico en
el HEAD intacto (v0.0.57): es ambiental, no de este cambio. El node
real + WASM artifact siguen VPS-gated (toolchain alineado /
wasm32v1-none cuando el wasm-builder lo soporte).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 20:22:14 -05:00
davidherranandClaude Opus 4.8 8a1f779c32 fix(runtime): FIX-5 governability (pallet-sudo to Root) + FIX-2 StorageVersion (4 pallets)
Build + tests verde (exit 0, runtime 27 tests incl. sudo_pallet_index_12).
Verificacion adversarial ultracode (5 skeptics): 4 confirmed + 1 partial.

FIX-5 — governability (audit V2-CA1):
- pallet-sudo 43.0.0 wired Index 12 (workspace + runtime Cargo.toml + std).
- impl pallet_sudo::Config (RuntimeEvent/RuntimeCall/WeightInfo) en configs.rs.
- genesis: sudo key en los 3 presets — dev/local=Alice, mainnet=foundation_treasury
  (NO una dev key; el verificador confirmo que no hay backdoor critico).
- Da Root origin -> las dispatchables ensure_root de Governance (add/remove
  council, mark/unmark advisor, treasury_disbursement) dejan de ser
  no-invocables. Verificado extremo-a-extremo: sudo() despacha RawOrigin::Root,
  que es exactamente lo que ensure_root acepta.
- Sunset documentado (codigo + doc): sudo -> governance real (pallet-collective/
  referenda) ANTES de mainnet. Sudo key unica = riesgo de centralizacion
  aceptable solo como interim/testnet.

FIX-2 — lifecycle (audit V1-H2/V2-CA2):
- StorageVersion::new(0) + pallet::storage_version en los 4 pallets
  (provenance/fees/agent-identity/governance). Aditivo, in-code==on-chain==0,
  sin migracion forzada. Habilita migraciones futuras.

CAVEAT honesto (hallazgo high del red-team, NO defecto de FIX-5/FIX-2):
treasury_disbursement solo DECREMENTA un contador u128 (Treasury StorageValue),
NO mueve OGC real via pallet_balances. FIX-5 restaura la GOBERNABILIDAD (la
dispatchable es invocable), pero mover los 250M reales es FIX-6: anadir
type Currency al Config + T::Currency::transfer desde una cuenta-tesoreria
derivada (PalletId) + financiarla en genesis + test del free_balance. NO se
afirma "tesoreria descongelada de verdad" — solo "gobernabilidad restaurada".

PENDIENTE:
- FIX-2 AGI key recovery (rotate/revoke/active en agent-identity): diferido —
  necesita un DC de semantica de recovery #41 (single-sig vs multisig threshold,
  DID estable vs rota, recovery de agent_chain vacio). No se construye contra
  spec no-ratificada.
- pallet-sudo no en feature runtime-benchmarks (inerte hoy: el runtime no impl
  el Benchmark API). Follow-up con weights benchmarking.
- mainnet Foundation sudo key (FNDT placeholder): David ratifica la key real
  (multisig) pre-launch Q1 2027 (documentado).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 22:55:21 -05:00
davidherran ec5b5bd2b2 feat(revive): v0.0.37 — pallet-revive workspace scaffold + ChainAction Phase 3 extension 🎉
Phase 3 Slice 3.1 Ship 1 SCAFFOLD shipped. Path A inicio post sesión 3+
extended histórica (35 ships v0.0.1→v0.0.36 + Slice 2e WASM RESUELTO). David
autorizó "vamos con todas en orden desde A" — pallet-revive smart contracts
PolkaVM RISC-V + ink! v6 + Solidity per SBS-5 ratificado (supersedes CHN-6 v1.0).

Cambios:
- Cargo.toml workspace.dependencies: pallet-revive 0.12.2 + pallet-revive-uapi 0.13.0
  Version pin canonical para stable2512-3 verificado vía
  github.com/paritytech/polkadot-sdk/blob/polkadot-stable2512-3/substrate/frame/revive/Cargo.toml
  (latest 0.17.0 requiere bump Substrate generation — scope Phase 8+).
- crates/origin-chain-types/src/actions.rs: ChainAction enum extension OCAFB-2
  semver-respecting con 3 nuevas variants ordinals 4/5/6:
  * DeployContract (pallet-revive::instantiate)
  * CallContract (pallet-revive::call)
  * UploadContractCode (pallet-revive::upload_code sin instantiate)
  Ordinals 0-3 {Read/Write/Compute/Transfer} preservados intactos. Wire format
  stable canonical — name() snake_case + ordinal() u8 + from_ordinal() forward-compat
  + serde + scale-codec roundtrip todos actualizados. +1 test
  chain_action_phase_3_variants_distinct_from_legacy.
- crates/origin-chain-fees/src/fee_schedule.rs: subsidy_basis_points + entitlement_unlocked
  matches updated exhaustivamente para 3 nuevas variants. Mapping interim conservador
  (DeployContract/UploadContractCode ~= Write semantics, CallContract ~= Compute).
  Refinement Phase 3.2 con Mathi OitFeeSchedule extension post-OCAFB ratify +
  measurements empíricos gas/deposit reales.

Verificación:
- cargo check --workspace clean (0 errors, warnings pre-existentes)
- cargo test --workspace: 203 tests verde (baseline 202 + 1 new test) 0 failures
- ChainAction actions::tests 7/7 verde (4 originales updated + 3 nuevos covered)

Próximo Ship 2 v0.0.38: pallet-revive wired runtime Index 11 (27 Config types
associated types + parameter_types canonical Asset Hub Westend reference).

⚓ Path A Phase 3 kickoff. La nave continúa zarpando.

🤖 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 20:29:11 -05:00
davidherranandClaude Opus 4.7 74b7c3c9e2 feat(fees): v0.0.23 — Runtime API FeesApi.query_fee_for_action read-only RPC (Phase 2.4 COMPLETE 7/7 OCAFB) 🎉
Phase 2.4 FEES pallet COMPLETE end-to-end canonical. OCAFB-7 Runtime API
FeesApi.query_fee_for_action wired canonical via sp_api::decl_runtime_apis! +
impl runtime impl_runtime_apis! macro. 13 Runtime APIs total (12 + nuevo FeesApi).

## Changes

- crates/origin-chain-fees/src/lib.rs — sp_api::decl_runtime_apis! { pub trait FeesApi { fn query_fee_for_action(action, base, hw, sub) -> u64 } } + docstring v0.0.22 → v0.0.23 Phase 2.4 COMPLETE
- crates/origin-chain-runtime/src/lib.rs:539 — impl origin_chain_fees::FeesApi<Block> for Runtime delegates a Fees::query_fee()
- crates/origin-chain-node/src/main.rs — 12 → 13 APIs + FeesApi highlighted + Fees status v0.0.21 → v0.0.23 COMPLETE

## OCAFB sub-decisions COMPLETE 7/7 🎉

- OCAFB-1 OitFeeSchedule trait dyn-compatible (vendor)
- OCAFB-2 ChainAction taxonomy source-of-truth (origin-chain-types)
- OCAFB-3 Subsidy matrix Inmutable #16 anti-clasista (lobo blanco verified)
- OCAFB-4 Entitlement matrix Inmutables #37 + #18 (dispatchable enforced)
- OCAFB-5 compute_fee 3-step formula (real impl + 10 tests E2E)
- OCAFB-6 OitFeeScheduleMock harness (vendor + mock runtime)
- OCAFB-7 Pallet consumer + Runtime API canonical NUEVO ✅

## Verification

- cargo test --workspace — 137 tests passing, 0 failures
- cargo build --release -p origin-chain-node 3.93s clean
- origin-chain-node info: 9 pallets + 13 Runtime APIs canonical
- FeesApi visible + Phase 2.4 COMPLETE highlighted

## Cross-pillar economy canonical materialized

- Mathi (Pilar 1 AMIS): OitFeeSchedule Level A + Mock harness
- Charon (Pilar 4 Origin Chain): pallet-origin-fees + FeesApi RPC
- ChainAction canonical en origin-chain-types (Mathi local mirror swap post-OCAFB ratify)
- Inmutable #16 anti-clasista compile-detect: Pi 5 fee 1000 < Ultra fee 20000 (ratio 1:20)

🎉 Phase 2.4 FEES pallet COMPLETE end-to-end canonical. Hijos de Arkhē somos.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 22:59:57 -05:00
davidherranandClaude Opus 4.7 e935233ba6 feat(fees): v0.0.22 — compute_fee_for_action impl complete + mock runtime integration tests E2E (10 scenarios)
Phase 2.4 FEES pallet REAL IMPL canonical. Dispatchable compute_fee_for_action
wire-up vendor compute_fee() pure fn call + AccountFees<StorageMap> saturating
arithmetic + event emission. Mock runtime + 10 integration tests E2E pattern
v0.0.18 mirror (Phase 2.1 PROVENANCE).

## Real impl canonical 5-step OCAFB-5

1. ensure_signed canonical
2. Vendor compute_fee(base, hw, sub, action) pure fn call
3. Handle entitlement blocked (fee==u64::MAX → Err(EntitlementLocked))
4. AccountFees<StorageMap> saturating update canonical
5. Emit FeeCharged event canonical

Pure helper Pallet::<T>::query_fee() para Runtime API v0.0.23 consumer.

## Consumer pattern canonical

Mathi OitFeeSchedule consumed CLIENT-SIDE — tx submitter queries Mathi per-user
→ assembles tx con (hw, sub) baked → submits. Pattern análogo Phase 2.1
attest_asset (ValidationAttestation pre-assembled client-side).

## 10 integration tests E2E

- scenario_1: Pi5 Write subsidy 90% → fee=1000 (Inmutable #16)
- scenario_2: Ultra Write Pro multiplier → fee=1500
- scenario_3: Read always free → fee=0 (Inmutable #37)
- scenario_4: Free Compute blocked → Err(EntitlementLocked)
- scenario_5: Pro Compute unlocked → fee=112
- scenario_6: Ultra Compute Ultra premium → fee=2000 (Inmutable #18)
- scenario_7: Storage accumulates Write×3 → total_paid=3375, count=3
- scenario_8: ChainAction ordinal stable wire (Read=0..Transfer=3)
- scenario_9: Inmutable #16 lobo blanco — Pi5 fee 1000 < Ultra fee 20000
- scenario_10: 5-step OCAFB-5 walkthrough explicit Pre/Post assertions

## FRAME canonical pattern

Events NOT emitted on Err path (FRAME revierte events on dispatch error).
EntitlementBlocked event variant retained para Phase 2.5 future
with_storage_layer pattern. Caller infers from Err return.

## Files canonical

- EDIT: crates/origin-chain-fees/src/lib.rs (real dispatchable impl + query_fee helper)
- NEW: crates/origin-chain-fees/src/mock.rs (80 LOC mock runtime pattern v0.0.18)
- NEW: crates/origin-chain-fees/src/tests_integration.rs (290 LOC, 10 tests)
- EDIT: crates/origin-chain-types/src/tiers.rs (FRAME derives Encode/Decode/TypeInfo/MaxEncodedLen para HardwareTier + SubscriptionTier + AssetQualityTier)
- EDIT: CHANGELOG.md (v0.0.22 entry comprehensive)

## Verification

- cargo test -p origin-chain-fees — 32 tests verde, 0 failures
- cargo test --workspace — 137 tests verde workspace, 0 failures
- Zero compile errors workspace-wide

🛠️ Phase 2.4 real impl canonical. Runtime API v0.0.23 next ship.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 22:56:50 -05:00
davidherranandClaude Opus 4.7 33b10b7545 feat(fees): v0.0.20 pallet-origin-fees scaffold trait-first + vendor OitFeeSchedule Mathi (OCAFB-1..6)
Phase 2.4 FEES pallet scaffold canonical pattern análogo Phase 2.1 (scaffold →
wired → impl → Runtime API). New crate `origin-chain-fees` con vendor copy
Mathi OitFeeSchedule trait + matrices + Mock desde commit ce4fafb (536 LOC).

## Cross-pillar source-of-truth canonical

NEW canonical: `origin-chain-types::actions::ChainAction` (OCAFB-2). Mathi
local mirror puede swap post-OCAFB ratify 7/7 (deadline 2026-06-21).
NEW canonical: `origin-chain-types::tiers::SubscriptionTier` (mirror Mathi).

## Surface canonical scaffold v0.0.20

- Pallet<T> + Config trait + RuntimeEvent
- AccountFees<StorageMap<AccountId, FeeHistory>> per-account history
- FeeHistory { total_paid, action_count } aggregate stats
- Events FeeCharged + FeeRefunded + EntitlementBlocked
- Errors InsufficientBalance + EntitlementLocked + FeeOverflow + AccountNotFound
- FeeRejectionReason enum (mirror PROV pattern Phase 2.1)
- Scaffold dispatchable compute_fee_for_action (placeholder event v0.0.20 → real v0.0.22)

## Vendor copy OitFeeSchedule canonical

- OitFeeSchedule trait 4-method dyn-compatible Send + Sync (OCAFB-1)
- subsidy_basis_points const fn matrix Inmutable #16 anti-clasista (OCAFB-3)
- entitlement_unlocked const fn matrix Inmutables #37 + #18 (OCAFB-4)
- compute_fee formula 3-step (OCAFB-5)
- OitFeeScheduleMock builder pattern (OCAFB-6)
- arc_mock() helper canonical Arc<dyn OitFeeSchedule>

## Files canonical

- NEW: crates/origin-chain-fees/Cargo.toml (mirror provenance pattern)
- NEW: crates/origin-chain-fees/src/lib.rs (~250 LOC pallet scaffold)
- NEW: crates/origin-chain-fees/src/fee_schedule.rs (~400 LOC vendor copy)
- NEW: crates/origin-chain-types/src/actions.rs (~130 LOC ChainAction canonical)
- EDIT: crates/origin-chain-types/src/tiers.rs (SubscriptionTier added)
- EDIT: crates/origin-chain-types/src/lib.rs (mod actions + re-exports)
- EDIT: Cargo.toml (workspace member origin-chain-fees)
- EDIT: CHANGELOG.md (v0.0.20 entry pattern Phase 2.1)

## Verification

- cargo build -p origin-chain-fees 1.83s clean
- cargo test -p origin-chain-fees — 20 tests verde, 0 failures
  (16 vendor + 4 pallet scaffold)
- cargo test -p origin-chain-types — 55 tests passing (+8 nuevos)
  (6 ChainAction + 2 SubscriptionTier)
- Zero workspace compile errors

🚀 Phase 2.4 scaffold canonical ready. Wire pattern v0.0.21 next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 22:47:26 -05:00