Files
arkhe-origin-chain/crates/origin-chain-runtime/Cargo.toml
T
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

203 lines
8.2 KiB
TOML

[package]
name = "origin-chain-runtime"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
description = "Origin Chain Substrate runtime canonical. Pilar 4: 7 pallets integrated (System+Timestamp+Balances+TransactionPayment+Aura+Grandpa+Session) + 11 Runtime APIs + 3 Genesis presets (dev+local+mainnet BM V2). Phase 1 COMPLETE canonical."
[dependencies]
# Origin Chain canonical traits + types
origin-chain-types.workspace = true
# Substrate Primitives canonical (SBS-1 polkadot-stable2512-3)
sp-core.workspace = true
sp-runtime.workspace = true
sp-std.workspace = true
sp-version.workspace = true
sp-api.workspace = true
sp-block-builder.workspace = true
sp-inherents.workspace = true
# Consensus primitives canonical (Phase 1.4 per CHN-1 Aura+GRANDPA)
sp-consensus-aura.workspace = true
sp-consensus-grandpa.workspace = true
# FRAME canonical
frame-system.workspace = true
frame-support.workspace = true
frame-executive.workspace = true
frame-metadata-hash-extension.workspace = true
# Benchmarking canonical (FRAME v2) — optional, solo activo bajo runtime-benchmarks.
# Provee el runtime API `Benchmark` + los macros define/list/add_benchmarks.
frame-benchmarking = { workspace = true, optional = true }
# FRAME pallets Phase 1.3-1.5 (per SBS-4 ratified)
pallet-balances.workspace = true
pallet-timestamp.workspace = true
pallet-transaction-payment.workspace = true
pallet-aura.workspace = true
pallet-grandpa.workspace = true
pallet-session.workspace = true
# FIX-5 governability v0.0.5x: pallet-sudo wired runtime composition Index 12
# (Root origin para dispatchables admin — sunset → governance real pre-mainnet)
pallet-sudo.workspace = true
# FIX-6 Stage 2b NPoS (DC ORIGIN_CHAIN_NPOS_V1) — infra dormida.
pallet-staking.workspace = true
frame-election-provider-support.workspace = true
sp-staking.workspace = true
# Charon custom pallets Phase 2.x (per DCs)
# Phase 2.1 v0.0.15: pallet-origin-provenance scaffold canonical wired
origin-chain-provenance.workspace = true
# Phase 2.4 v0.0.21: pallet-origin-fees wired runtime composition Index 8 canonical
# (OCAFB-1..6 consumer Mathi OitFeeSchedule via vendor copy interim Option B)
origin-chain-fees.workspace = true
# Phase 2.7 v0.0.25: pallet-agent-identity wired runtime composition Index 9 canonical
# (Inmutable #41 AGI DIDs Cross-Species Co-authorship)
origin-chain-agent-identity.workspace = true
# Slice 2e v0.0.36 — Direct getrandom deps (both 0.2 + 0.3 transitive):
# 0.2 via const-random-macro → frame-support-procedural
# 0.3 via ahash → schnellru → sp-trie → frame-support
getrandom_02 = { workspace = true }
getrandom_03 = { workspace = true }
# Phase 5.1 v0.0.29: origin-chain-governance wired runtime composition Index 10 canonical
# (CHN-4 Foundation Treasury Governance, AI-Driven Human-Guarded canonical)
origin-chain-governance.workspace = true
# FIX-6 Stage 1: origin-chain-emission wired Index 13 — paga a los validadores
# Aura (mintea block reward + split treasury/subsidy). Cierra V2-CA2.
origin-chain-emission.workspace = true
# Phase 3 Slice 3.1 v0.0.39: pallet-revive wired runtime composition Index 11
# (SBS-5 ratificado supersedes CHN-6 v1.0 → PolkaVM RISC-V + ink! v6 + Solidity).
# Smart contracts deployable canonical post Slice 3.1 SCAFFOLD COMPLETE (v0.0.41).
# Workspace bump stable2509-3 v0.0.38 desbloqueó esta integración.
pallet-revive.workspace = true
# RuntimeAPI canonical (sp_api::impl_runtime_apis! consumers)
sp-offchain.workspace = true
sp-genesis-builder.workspace = true
sp-transaction-pool.workspace = true
sp-session.workspace = true
frame-system-rpc-runtime-api.workspace = true
pallet-transaction-payment-rpc-runtime-api.workspace = true
# SCALE codec canonical
parity-scale-codec.workspace = true
scale-info.workspace = true
# Logging
log.workspace = true
# Serialization canonical — Slice 2b finding: solochain-template upstream NO
# declara serde directly canonical. Solo serde_json. Serde viene transitive
# from FRAME pallets canonical (frame-support + frame-system). Direct serde
# dep rompía isolated WASM build canonical.
serde_json.workspace = true
[build-dependencies]
# Slice 2e v0.0.35 — Re-enabled substrate-wasm-builder for active investigation.
# Slice 2c+2d findings: WASM_BUILD_STD=0 resuelve alloc/exchange_malloc pero
# descubre serde/std leak via types/std transitive activation. Slice 2e attempt:
# patch.crates-io serde override + types/std isolation.
substrate-wasm-builder = { version = "26.0.1", optional = true }
[features]
default = ["std"]
# Slice 2e v0.0.35 — WASM build feature gate canonical.
# Enable with `--features wasm-build` para build real WASM_BINARY canonical.
wasm-build = ["substrate-wasm-builder"]
std = [
"origin-chain-types/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-version/std",
"sp-api/std",
"sp-block-builder/std",
"sp-inherents/std",
"sp-consensus-aura/std",
"sp-consensus-grandpa/std",
"frame-system/std",
"frame-support/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"pallet-balances/std",
"pallet-timestamp/std",
"pallet-transaction-payment/std",
"pallet-aura/std",
"pallet-grandpa/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-staking/std",
"frame-election-provider-support/std",
"sp-staking/std",
"origin-chain-provenance/std",
"origin-chain-fees/std",
"origin-chain-agent-identity/std",
"origin-chain-governance/std",
"origin-chain-emission/std",
"pallet-revive/std",
"sp-offchain/std",
"sp-genesis-builder/std",
"sp-transaction-pool/std",
"sp-session/std",
"serde_json/std",
"frame-system-rpc-runtime-api/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"parity-scale-codec/std",
"scale-info/std",
"frame-benchmarking?/std",
# Slice 2c canonical deferred — substrate-wasm-builder bloqueado WASM build
]
runtime-benchmarks = [
"dep:frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
# Pallets upstream wired restantes. Necesarios para ALINEAR sus impls de traits
# benchmark-gated (p.ej. StakingUnchecked::migrate_to_direct_staker de
# pallet-staking, gated en sp-staking/runtime-benchmarks) con los traits upstream.
# La feature del runtime nunca fue comprehensiva — producción Substrate lista TODO.
"pallet-staking/runtime-benchmarks",
"frame-election-provider-support/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"pallet-session/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
# NOTA: `pallet-revive/runtime-benchmarks` OMITIDO a propósito — arrastra
# `pallet-revive-fixtures`, cuyo build script requiere el toolchain PolkaVM
# RISC-V (rv32/rv64) que no está disponible aquí y NO es benchmarkeado (ReviveApi
# deferred, ver impl_runtime_apis §SCAFFOLD). Su gating queda OFF de forma
# consistente → sin misalignment de traits. Re-activar cuando el toolchain PolkaVM
# esté en el reference HW y se quieran weights de contratos.
# Pallets custom Charon. TODOS deben propagar runtime-benchmarks para que sus
# impls de traits benchmark-gated (p.ej. OnChargeTransaction del OriginFeeAdapter
# en fees) alineen con los traits upstream. Provenance ya tiene maquinaria FRAME
# v2 (ver `mod benches`); los demás la reciben en el fan-out.
"origin-chain-provenance/runtime-benchmarks",
"origin-chain-fees/runtime-benchmarks",
"origin-chain-emission/runtime-benchmarks",
"origin-chain-agent-identity/runtime-benchmarks",
"origin-chain-governance/runtime-benchmarks",
# BUGFIX: antes decía `pallet-grandpa/try-runtime` — activar try-runtime desde
# la feature de benchmarks era un copy-paste erróneo (features ortogonales;
# metía código try-runtime en builds de benchmark y NUNCA activaba los
# benchmarks de grandpa). Grandpa no está en `define_benchmarks!`, así que la
# corrección es removerlo, no re-apuntarlo.
]