// SPDX-License-Identifier: Apache-2.0 // Origin Chain — Pilar 4 · Charon // // ATENCION AL LEER ESTOS NUMEROS: un weight es una LATENCIA, y una latencia sin // el hardware y el perfil de potencia que la produjeron no se puede reproducir. // La cabecera dice HOSTNAME y CPU: creele a eso y a nada mas. Un weight medido // en un portatil y cobrado en un Pi 5 es mispricing estructural, solo que // invisible. Los numeros CANONICOS de mainnet salen del banco de referencia // (Pi 5, governor y aislamiento declarados), no de la maquina de quien compila. // MEDIDO POR LAURHA 🌊 EN EL BANCO DE REFERENCIA, 2026-10-24 17:41-17:46. El perfil es el mismo // al empezar y al acabar: // CyberDeckRP1 · Raspberry Pi 5 · Cortex-A76 · kernel 6.18.34+rpt-rpi-2712. // Núcleo 3 aislado (partición cgroup «isolated» de origin-banco), governor performance a // 2,4 GHz, CI parada, throttled 0x0, 45-49 °C. // frame-omni-bencher 0.15.0 · wasm sha256 40cb5a1d…a1cf744 (spec 16, main 3cd1068). // steps 50 · repeat 20 · taskset -c 3 · 5 PROCESOS por pallet, y se cobra el MÁXIMO de los 5 // (scripts/bench/max-de-n.py): procesos idénticos se separan hasta un 35 % en el base weight. // Evidencia en la rp1: ~/laurha-work/banco/spec16-20261024-1631 (SHA256SUMS d930c5e1…). // La Pi es el hardware MÁS LENTO que puede validar la red: sus pesos son el techo honesto. El // TIEMPO DE EJECUCIÓN sale de 2,5 a 3,9 veces el del Mac M3 Max (~6 veces en los que verifican // Ed25519). Lo COBRADO sube menos, entre +4 % y +56 %, porque lecturas y escrituras de storage // (RocksDbWeight) no cambian y pesan más que la ejecución (revisión adversarial, 25-oct). //! Weights AUTOGENERADOS para `origin_chain_agent_identity` — NO editar a mano. //! //! Regenerar: `scripts/bench/regen-weights.sh` (ver ese script para el //! procedimiento completo y el hardware al que hay que creerle). //! //! GENERADO POR SUBSTRATE BENCHMARK CLI VERSION 51.0.0 //! FECHA: 2026-10-24, STEPS: `50`, REPEAT: `20` //! HOSTNAME: `CyberDeckRP1`, CPU: `` //! WASM-EXECUTION: `Compiled`, DB CACHE: 1024 // Comando ejecutado: // /home/davidherran/.cargo/bin/frame-omni-bencher // v1 // benchmark // pallet // --runtime // /home/davidherran/charon/bench/origin_chain_runtime_spec16_3cd1068_bench.compact.compressed.wasm // --genesis-builder-preset // development // --pallet // origin_chain_agent_identity // --extrinsic // // --steps // 50 // --repeat // 20 // --template // /home/davidherran/charon/bench/origin-weights-template.hbs // --header // /home/davidherran/charon/bench/HEADER.txt // --output // /home/davidherran/laurha-work/banco/spec16-20261024-1631/r1/origin_chain_agent_identity.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] #![allow(missing_docs)] use core::marker::PhantomData; use frame_support::{traits::Get, weights::constants::RocksDbWeight, weights::Weight}; /// Trait de weights para los extrinsics de `origin_chain_agent_identity`. // MAXIMO DE N = 5 PROCESOS (scripts/bench/max-de-n.py): cada coeficiente // de tiempo y de proof es el maximo de los N; reads/writes iguales en los N. // Entradas (sha256[:12]): a5fa48706c19 65ad82789014 9632521ec280 416b5bbced02 817bf8aed8db pub trait WeightInfo { /// Peso de `register_agent_did` — MEDIDO sobre el WASM, no estimado a mano. fn register_agent_did() -> Weight; /// Peso de `rotate_agent_key` — MEDIDO sobre el WASM, no estimado a mano. fn rotate_agent_key() -> Weight; } /// Weights parametrizados por el `DbWeight` real del runtime. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// Storage: `AgentIdentity::Identities` (r:1 w:1) /// Proof: `AgentIdentity::Identities` (`max_values`: None, `max_size`: Some(475), added: 2950, mode: `MaxEncodedLen`) /// Storage: `AgentIdentity::DidToAccount` (r:1 w:1) /// Proof: `AgentIdentity::DidToAccount` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// Storage: `AgentIdentity::KeyToDid` (r:1 w:1) /// Proof: `AgentIdentity::KeyToDid` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// Storage: `System::Number` (r:1 w:0) /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::ExecutionPhase` (r:1 w:0) /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) /// Storage: `System::EventCount` (r:1 w:1) /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::Events` (r:1 w:1) /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn register_agent_did() -> Weight { // Proof size en bytes: // Medido: `26` // Estimado: `3940` // Tiempo minimo de ejecucion: 301_353_000 picosegundos. Weight::from_parts(320_835_000, 0) .saturating_add(Weight::from_parts(0, 3940)) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `AgentIdentity::Identities` (r:1 w:0) /// Proof: `AgentIdentity::Identities` (`max_values`: None, `max_size`: Some(475), added: 2950, mode: `MaxEncodedLen`) /// Storage: `AgentIdentity::CurrentKey` (r:1 w:1) /// Proof: `AgentIdentity::CurrentKey` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// Storage: `AgentIdentity::KeyToDid` (r:2 w:1) /// Proof: `AgentIdentity::KeyToDid` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// Storage: `AgentIdentity::DidToAccount` (r:1 w:0) /// Proof: `AgentIdentity::DidToAccount` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// Storage: `AgentIdentity::RotationNonce` (r:1 w:1) /// Proof: `AgentIdentity::RotationNonce` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `System::BlockHash` (r:1 w:0) /// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) /// Storage: `System::Number` (r:1 w:0) /// Proof: `System::Number` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::ExecutionPhase` (r:1 w:0) /// Proof: `System::ExecutionPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`) /// Storage: `System::EventCount` (r:1 w:1) /// Proof: `System::EventCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `System::Events` (r:1 w:1) /// Proof: `System::Events` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn rotate_agent_key() -> Weight { // Proof size en bytes: // Medido: `435` // Estimado: `6100` // Tiempo minimo de ejecucion: 534_966_000 picosegundos. Weight::from_parts(584_021_000, 0) .saturating_add(Weight::from_parts(0, 6100)) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } } /// Impl para mocks y tests — `RocksDbWeight` directo, sin necesitar `T`. impl WeightInfo for () { fn register_agent_did() -> Weight { Weight::from_parts(320_835_000, 0) .saturating_add(Weight::from_parts(0, 3940)) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } fn rotate_agent_key() -> Weight { Weight::from_parts(584_021_000, 0) .saturating_add(Weight::from_parts(0, 6100)) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } } #[cfg(test)] mod guard { use super::*; /// NINGUN EXTRINSIC PUEDE DECLARAR `proof_size = 0`. /// /// El `proof_size` es lo que el block-builder usa para no pasarse del limite /// de PoV. Un cero no dice «este extrinsic no toca storage»: dice «miento /// sobre lo que va a ocupar la prueba», y con eso entra en un bloque mucho /// mas de lo que cabe. /// /// El test nace de un error propio y de la peor clase: la cabecera de los /// weights 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 `Weight::from_parts(read * r, 0)`. Los interinos /// arreglaron reads/writes y dejaron el proof_size donde estaba: en 0. La /// afirmacion de haberlo cerrado sobrevivio mas de un mes sin que ninguna /// lectura la desmintiera; la desmintio una medicion. /// /// Esta lista la GENERA la plantilla a partir de los benchmarks reales, asi /// que no puede quedarse corta cuando se anada un extrinsic nuevo. #[test] fn ningun_weight_declara_proof_size_cero() { let casos: &[(&str, Weight)] = &[ ("register_agent_did", <() as WeightInfo>::register_agent_did()), ("rotate_agent_key", <() as WeightInfo>::rotate_agent_key()), ]; for (nombre, w) in casos { assert!( w.proof_size() > 0, "`{nombre}` declara proof_size = 0: miente al block-builder sobre el peso PoV" ); assert!( w.ref_time() > 0, "`{nombre}` declara ref_time = 0: el extrinsic saldria gratis" ); } } }