feat(consensus): Phase 1.4 — Consensus PoA canonical Aura+GRANDPA v0.0.6
Origin Chain runtime canonical ahora produces blocks + finalizes via Aura+GRANDPA per CHN-1 ratified. PoA Phase 1 substrate fundación bien anclada. ## Pallets añadidos canonical (per SBS-4) - Index 4 Aura (pallet_aura 39.0.0) — block production canonical PoA per CHN-1 Round-Robin 6-segundo slots alineados Pi 5 + NVMe SSD. AuraId sr25519. - Index 5 Grandpa (pallet_grandpa 40.0.0) — finality gadget per CHN-1 2/3 honest majority irreversible confirmation. GrandpaId Ed25519. ## Primitives consumidas - sp-consensus-aura 0.42.0 (feature serde canonical) - sp-consensus-grandpa 23.0.0 → 23.1.0 (feature serde canonical) ## Configs canonical - pallet_aura::Config: MaxAuthorities 32 + AllowMultipleBlocksPerSlot false + SlotDuration = MinimumPeriodTimesTwo (clock↔consensus coupling canonical) - pallet_grandpa::Config: MaxAuthorities 32 + MaxNominators 0 + KeyOwnerProof Void + EquivocationReportSystem () (Phase 1 simple, real Phase 2 NPoS) ## Wiring canonical clock↔consensus pallet_timestamp::OnTimestampSet = crate::Aura (was ()) — cada nuevo timestamp triggera Aura slot advance canonical. Materializa 6-segundo block production deterministic Pi 5. ## Opaque SessionKeys canonical (nuevo opaque.rs module) impl_opaque_keys! con aura (sr25519) + grandpa (Ed25519) — substrate canonical pattern para forkless runtime upgrades. Cada validator posee 2 keys canonical. Pre-Phase 1.5: static keys en genesis chain_spec. Phase 1.5: pallet_session introduces rotation 4h epochs per CHN-1. ## Filosofía canonical opaque.rs cita David canon 2026-05-14 "la libertad infinita acota solo donde empieza la del otro" — opaque types son la frontera canonical entre node sovereignty + runtime sovereignty. Each layer respeta la libertad del otro. ## Build + tests - cargo check 6.17s warm cache (Aura+Grandpa deps incremental) - cargo build --release 8.64s warm cache clean - ~57 tests passing (count preserved — Aura/Grandpa tests llegan Phase 1.5+) ## Edge case empírico pallet-aura 39.0.0 + pallet-grandpa 40.0.0 NO exponen feature runtime-benchmarks en stable2512 canonical. Wire-up benchmark scaffolding land Phase 1.5+ cuando pallet_session se integre. ## Phase 1 progress 1.1 ✅ + 1.2 ✅ + 1.3 ✅ + 1.4 ✅ (esta). Next: 1.5 pallet_session validator rotation 4h epochs per CHN-1. Origin Chain runtime composition canonical actual (6 pallets): - 0 System + 1 Timestamp + 2 Balances + 3 TransactionPayment - 4 Aura + 5 Grandpa - Opaque SessionKeys: aura sr25519 + grandpa Ed25519 Refs: CHARON_ROADMAP_V1 Phase 1.4, CHN-1 ratified Aura+GRANDPA canonical, SBS-4 ratified extended pallet set Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
adab264d54
commit
4988693d4b
7 files changed
+430
-9
No files matched your search
@@ -7,7 +7,7 @@ license.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Origin Chain Substrate runtime canonical. Pilar 4: System + Balances + Timestamp pallets integrated (Phase 1.3 v0.0.5). Roadmap: consensus Aura+GRANDPA + provenance + ink! + bridges + governance progressivos."
|
||||
description = "Origin Chain Substrate runtime canonical. Pilar 4: System+Balances+Timestamp+TransactionPayment+Aura+Grandpa pallets integrated (Phase 1.4 v0.0.6 consensus PoA per CHN-1). Roadmap: session+identity+provenance+ink!+bridges+governance progressivos."
|
||||
|
||||
[dependencies]
|
||||
# Origin Chain canonical traits + types
|
||||
@@ -22,6 +22,10 @@ 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
|
||||
@@ -33,6 +37,10 @@ pallet-balances.workspace = true
|
||||
pallet-timestamp.workspace = true
|
||||
pallet-transaction-payment.workspace = true
|
||||
|
||||
# FRAME pallets Phase 1.4 — Consensus PoA per CHN-1 ratified
|
||||
pallet-aura.workspace = true
|
||||
pallet-grandpa.workspace = true
|
||||
|
||||
# SCALE codec canonical
|
||||
parity-scale-codec.workspace = true
|
||||
scale-info.workspace = true
|
||||
@@ -53,6 +61,8 @@ 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",
|
||||
@@ -60,6 +70,8 @@ std = [
|
||||
"pallet-balances/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"pallet-aura/std",
|
||||
"pallet-grandpa/std",
|
||||
"parity-scale-codec/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
@@ -70,4 +82,8 @@ runtime-benchmarks = [
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-transaction-payment/runtime-benchmarks",
|
||||
# pallet-aura 39.0.0 + pallet-grandpa 40.0.0 NO exponen feature
|
||||
# runtime-benchmarks en stable2512 canonical. Wire-up canonical Phase 1.5+
|
||||
# cuando pallet_session se integre + benchmark scaffolding land.
|
||||
"pallet-grandpa/try-runtime",
|
||||
]
|
||||
@@ -40,8 +40,7 @@ use crate::{
|
||||
};
|
||||
use frame_support::derive_impl;
|
||||
use frame_support::parameter_types;
|
||||
use frame_support::traits::VariantCountOf;
|
||||
use sp_runtime::traits::ConstU32;
|
||||
use frame_support::traits::{ConstBool, ConstU32, ConstU64, VariantCountOf};
|
||||
|
||||
// ============================================================
|
||||
// Canonical constants (per CHN-1/2/8 + SBS-3)
|
||||
@@ -141,7 +140,10 @@ parameter_types! {
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = (); // Phase 1.2: Aura wired aquí cuando se integre
|
||||
/// `Aura` wired canonical post Phase 1.4: cada nuevo timestamp triggera el
|
||||
/// Aura slot advance canonical. Materializa el coupling consensus↔clock que
|
||||
/// hace posible 6-segundo block production deterministic canonical.
|
||||
type OnTimestampSet = crate::Aura;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
@@ -168,3 +170,62 @@ impl pallet_transaction_payment::Config for Runtime {
|
||||
type FeeMultiplierUpdate = ();
|
||||
type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// pallet_aura::Config canonical (CHN-1 — block production PoA)
|
||||
// ============================================================
|
||||
|
||||
/// Canonical Aura authority id type. `sr25519` canonical per Substrate
|
||||
/// standard — más eficiente que Ed25519 para slot signing canonical (Schnorr
|
||||
/// signature aggregation futuro). Wallet identity sigue Ed25519 (CHN-7), pero
|
||||
/// validator authority keys sr25519 per Substrate convention canonical.
|
||||
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
|
||||
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
/// `DisabledValidators = ()`: Phase 1 PoA simple — no disable mechanism
|
||||
/// canonical. Phase 2 NPoS introduces pallet_session disabling vía slashing.
|
||||
type DisabledValidators = ();
|
||||
/// `MaxAuthorities = 32`: canonical para Phase 1 PoA (5-7 validators
|
||||
/// inaugurales + room para growth pre-NPoS). Aligned con polkadot-stable2512
|
||||
/// solochain-template default canonical.
|
||||
type MaxAuthorities = ConstU32<32>;
|
||||
/// `AllowMultipleBlocksPerSlot = false`: canonical Substrate — un block por
|
||||
/// slot. Disallow multiplicity para deterministic block time canonical Pi 5.
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||
/// Slot duration canonical = `pallet_aura::MinimumPeriodTimesTwo<Runtime>` —
|
||||
/// derivado automáticamente del `pallet_timestamp::MinimumPeriod` config
|
||||
/// canonical. Garantiza coupling canonical entre clock + consensus slot.
|
||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// pallet_grandpa::Config canonical (CHN-1 — finality gadget)
|
||||
// ============================================================
|
||||
|
||||
/// Canonical GRANDPA authority id type. `Ed25519` canonical per GRANDPA spec —
|
||||
/// signature aggregation matemáticamente diferente a Aura sr25519 pero
|
||||
/// canonical convention.
|
||||
pub type GrandpaId = sp_consensus_grandpa::AuthorityId;
|
||||
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
/// `WeightInfo = ()`: Phase 1 PoA simple. Phase 2 NPoS introduces real
|
||||
/// weights para equivocation reporting + on_finalize hooks canonical.
|
||||
type WeightInfo = ();
|
||||
/// `MaxAuthorities = 32`: aligned con Aura canonical para 1:1 mapping
|
||||
/// validator ↔ finalizer Phase 1 PoA (mismo set canonical).
|
||||
type MaxAuthorities = ConstU32<32>;
|
||||
/// `MaxNominators = 0`: Phase 1 PoA simple — no nominators canonical (no
|
||||
/// stake delegation aún). Phase 2 NPoS bump canonical a 256 nominators.
|
||||
type MaxNominators = ConstU32<0>;
|
||||
/// `MaxSetIdSessionEntries = 0`: Phase 1 simple — no historical session
|
||||
/// proofs canonical. Phase 2 NPoS introduces session tracking.
|
||||
type MaxSetIdSessionEntries = ConstU64<0>;
|
||||
/// `KeyOwnerProof = sp_core::Void`: Phase 1 simple — no equivocation proof
|
||||
/// type. Phase 2 NPoS introduces real `MembershipProof` canonical.
|
||||
type KeyOwnerProof = sp_core::Void;
|
||||
/// `EquivocationReportSystem = ()`: Phase 1 PoA simple — equivocation
|
||||
/// reports not handled. Phase 2 NPoS introduces real handler canonical.
|
||||
type EquivocationReportSystem = ();
|
||||
}
|
||||
@@ -44,6 +44,7 @@
|
||||
extern crate alloc;
|
||||
|
||||
pub mod configs;
|
||||
pub mod opaque;
|
||||
|
||||
// Re-export canonical traits + types desde origin-chain-types (single-crate surface).
|
||||
pub use origin_chain_types::{
|
||||
@@ -56,12 +57,12 @@ pub use origin_chain_types::{
|
||||
// Substrate canonical types re-export para runtime consumers + node binary.
|
||||
pub use sp_core::H256;
|
||||
pub use sp_runtime::traits::{BlakeTwo256, IdentifyAccount, Verify};
|
||||
pub use sp_runtime::{generic, MultiAddress, MultiSignature};
|
||||
pub use sp_runtime::{generic, impl_opaque_keys, MultiAddress, MultiSignature};
|
||||
|
||||
// Re-export configs canonical para downstream consumers + node binary.
|
||||
pub use configs::{
|
||||
BLOCK_HASH_COUNT, EXISTENTIAL_DEPOSIT, MILLI_OGC, MILLISECS_PER_BLOCK, OGC, SLOT_DURATION,
|
||||
SS58_PREFIX,
|
||||
AuraId, GrandpaId, BLOCK_HASH_COUNT, EXISTENTIAL_DEPOSIT, MILLI_OGC, MILLISECS_PER_BLOCK,
|
||||
OGC, SLOT_DURATION, SS58_PREFIX,
|
||||
};
|
||||
|
||||
/// Canonical block number type. `u32` canonical: 6-second blocks × 4B = 817+ años
|
||||
@@ -204,6 +205,18 @@ mod runtime {
|
||||
/// — Phase 2.4 refactor canonical para integrar `OriginFees` multi-tier).
|
||||
#[runtime::pallet_index(3)]
|
||||
pub type TransactionPayment = pallet_transaction_payment::Pallet<Runtime>;
|
||||
|
||||
/// Aura pallet canonical (block production PoA per CHN-1). 6-segundo slots
|
||||
/// canonical Round-Robin selección validators. Pi 5 + NVMe SSD hardware
|
||||
/// target canonical (Inmutable #16 anti-clasista from block 0).
|
||||
#[runtime::pallet_index(4)]
|
||||
pub type Aura = pallet_aura::Pallet<Runtime>;
|
||||
|
||||
/// GRANDPA pallet canonical (finality gadget per CHN-1). 2/3 honest majority
|
||||
/// canonical para irreversible block confirmation. Separa production cadence
|
||||
/// (Aura ~6s) de finality cadence (canonical ~6-12s combined).
|
||||
#[runtime::pallet_index(5)]
|
||||
pub type Grandpa = pallet_grandpa::Pallet<Runtime>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//! # Opaque types canonical — pre-genesis identification para node binary
|
||||
//!
|
||||
//! `opaque` types canonical son aquellos que el **node** consume sin necesidad
|
||||
//! de saber detalles del runtime composition. Pattern canonical Substrate: el
|
||||
//! node binary identifica session keys + block headers sin importar qué pallets
|
||||
//! exact se composen runtime-side.
|
||||
//!
|
||||
//! Esto permite **forkless runtime upgrades canonical**: el node ejecuta WASM
|
||||
//! runtime mientras los opaque types canonical permanecen wire-compatible.
|
||||
//!
|
||||
//! ## Filosofía canonical
|
||||
//!
|
||||
//! David canon 2026-05-14 *"la libertad infinita acota solo donde empieza la
|
||||
//! del otro"* — el opaque types son la frontera canonical entre node sovereignty
|
||||
//! (puede correr cualquier runtime WASM compatible) + runtime sovereignty (puede
|
||||
//! evolucionar pallets sin breakar node binaries).
|
||||
|
||||
use crate::{AuraId, GrandpaId};
|
||||
use sp_runtime::impl_opaque_keys;
|
||||
|
||||
impl_opaque_keys! {
|
||||
/// Canonical session keys para Origin Chain validators canonical.
|
||||
///
|
||||
/// Cada validator canonical posee:
|
||||
/// - **`aura`**: `AuraId` (sr25519) para slot signing canonical block production
|
||||
/// - **`grandpa`**: `GrandpaId` (Ed25519) para finality voting canonical
|
||||
///
|
||||
/// Estos keys canonical se rotan periódicamente per Phase 1.5 `pallet_session`
|
||||
/// canonical (4-hour epochs per CHN-1). Pre-Phase 1.5 = static keys canonical
|
||||
/// definidos en genesis chain_spec.
|
||||
pub struct SessionKeys {
|
||||
pub aura: crate::Aura,
|
||||
pub grandpa: crate::Grandpa,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user