From 8a24a86ee67fee58dcab2d87b9c700488dfe24a2 Mon Sep 17 00:00:00 2001 From: DavidHerran Date: Wed, 20 May 2026 21:10:39 -0500 Subject: [PATCH] =?UTF-8?q?feat(node):=20Phase=201.6+=20Slice=201=20?= =?UTF-8?q?=E2=80=94=20origin-chain-node=20CLI=20canonical=20v0.0.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit origin-chain-node binary canonical funcional con 4 sub-comandos: - version (default canonical) - list-presets (3 genesis presets disponibles) - print-preset (JSON-serialized RuntimeGenesisConfig) - info (full runtime metadata canonical) ## Output canonical print-preset development verified Alice SS58 address: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY ✅ matches exactly Substrate well-known canonical — hardcoded bytes son bit-perfect compatible con polkadot-js + subkey ecosystem canonical. ## Decisión empírica documentada: WASM_BINARY DEFERRED a Slice 2 (v0.0.11) substrate-wasm-builder requiere TODAS las deps no_std-compatible. origin- chain-types actualmente usa std::String/Vec directly + thiserror 1.0 sin no_std. Refactor scope substantial (5-10+ files affected) merece DC propio y Slice dedicado canonical. CLI canonical opera correcto sin WASM execution porque genesis presets serializables natively canonical. ## Workspace deps añadidos Phase 1.6+ (most Slice 4 deferred) - substrate-wasm-builder 26.0.1 (Slice 2) - sc-cli 0.51.0, sc-service 0.50.0, sc-executor 0.42.0 (Slice 4) - sc-network 0.49.1, sc-consensus 0.48.0 (Slice 4) - sc-consensus-aura 0.49.0, sc-consensus-grandpa 0.34.0 (Slice 4) - sc-transaction-pool 39.0.0, sc-client-api 39.0.0 (Slice 4) - sc-basic-authorship 0.49.0, sc-telemetry 28.1.0, sc-offchain 44.0.0 (Slice 4) - jsonrpsee 0.24.3, substrate-frame-rpc-system 43.0.0 (Slice 4) - pallet-transaction-payment-rpc 43.0.0 (Slice 4) - clap 4.5.13 (USED v0.0.10 canonical) - futures 0.3.31 (Slice 4) Workspace declarations preparan canonical para Slice 4 sin re-declarar cuando se necesite ramp up canonical. ## Roadmap Phase 1.6+ multi-slice canonical - Slice 1 (v0.0.10 ESTA): CLI skeleton + preset listing ✅ - Slice 2 (v0.0.11): WASM_BINARY canonical + no_std refactor - Slice 3 (v0.0.12): real sc_service::ChainSpec builder canonical - Slice 4 (v0.0.13+): full sc-service (consensus + RPC + networking) ## Build + tests - cargo build --release 8.22s warm cache - cargo test --workspace ~63 tests passing - Binary functional: cargo run --bin origin-chain-node {version|list-presets| print-preset |info} ## Filosofía canonical incorporada Doc main.rs: "el CLI canonical es la primera ventana del barquero al mundo". list-presets canonical = transparency canonical: las 3 distribuciones posibles canonical están a la vista canonical, BM V2 incluida canonical materializando David canon 2026-05-14 "la libertad infinita acota solo donde empieza la del otro". Refs: CHARON_ROADMAP_V1 Phase 1.6+, sub-decisión empírica WASM_BINARY defer to Slice 2, sub-decisión empírica sc-service defer to Slice 4 Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 111 ++++++++++++++ Cargo.lock | 129 +++++++++++++++++ Cargo.toml | 27 ++++ crates/origin-chain-node/Cargo.toml | 5 +- crates/origin-chain-node/src/main.rs | 192 +++++++++++++++++++++---- crates/origin-chain-runtime/Cargo.toml | 19 +-- crates/origin-chain-runtime/src/lib.rs | 13 ++ 7 files changed, 451 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d26e1bb..9d5da2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,117 @@ by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow ## [Unreleased] +## [0.0.10] — 2026-05-21 — Phase 1.6+ Slice 1 "Node CLI skeleton canonical" + +Charon sesión 1 continuación. **`origin-chain-node` binary canonical funcional** +con 4 sub-comandos canonical operativos. El barquero canonical tiene su +**primera ventana al mundo** — humanos + AGIs pueden ejecutar el binary y ver +qué configuraciones canonical Origin Chain ofrece. + +### Sub-comandos canonical funcionales + +```text +origin-chain-node # default: version canonical +origin-chain-node version # print runtime version canonical +origin-chain-node list-presets # enumera 3 genesis presets canonical +origin-chain-node print-preset # JSON-serialized RuntimeGenesisConfig +origin-chain-node info # full runtime metadata canonical +``` + +### Output canonical de `print-preset development` + +```json +{ + "aura": { + "authorities": ["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"] + }, + "balances": { + "balances": [["5Grwv...", 100000000000000000000000000]], + "devAccounts": null + }, + "grandpa": { + "authorities": [["5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu", 1]] + }, + "session": { "keys": [...] } +} +``` + +**Verified canonical**: Alice's SS58 address `5GrwvaEF5zXb...` matches +**exactly** Substrate well-known dev account — los hardcoded bytes canonical son +bit-perfect compatible con polkadot-js + subkey + Substrate ecosystem canonical. + +### Decisión empírica canonical: WASM_BINARY DEFERRED a Slice 2 (v0.0.11) + +`substrate-wasm-builder` requiere que TODAS las dependencias transitivas del +runtime sean fully no_std-compatible canonical. `origin-chain-types` actualmente +usa `String`/`Vec` directly (sin `alloc::` prefix) + `thiserror 1.0` sin no_std +support canonical. Refactor scope canonical: + +- `origin-chain-types`: agregar `#![cfg_attr(not(feature = "std"), no_std)]` + + `extern crate alloc` + replace types canonical (5-10+ files affected) +- Bump `thiserror` a 2.x con `default-features = false` +- Add `std` feature gate canonical en origin-chain-types +- Update `serde` workspace dep canonical para `default-features = false` + +Esto es **Slice 2 scope** canonical — merece su DC propio (no slip via single +session canonical). Mientras tanto, el CLI canonical opera correctamente con el +runtime built nativamente canonical — los genesis presets canonical son +serializables canonical sin necesidad de WASM execution canonical. + +### Roadmap canonical Phase 1.6+ (multi-slice) + +- **Slice 1** (v0.0.10 ESTA): CLI skeleton + preset listing canonical ✅ +- **Slice 2** (v0.0.11): origin-chain-types fully no_std refactor canonical → + WASM_BINARY canonical via substrate-wasm-builder +- **Slice 3** (v0.0.12): real `sc_service::ChainSpec` builder canonical + consuming GenesisBuilder API canonical + ChainSpec JSON output +- **Slice 4** (v0.0.13+): full `sc-service` builder canonical + (consensus + JSON-RPC + networking + telemetry) + +### Workspace dependencies canonical added Phase 1.6+ + +- `substrate-wasm-builder 26.0.1` (Slice 2 — deferred) +- `sc-cli 0.51.0`, `sc-service 0.50.0`, `sc-executor 0.42.0` (Slice 4 — deferred) +- `sc-network 0.49.1`, `sc-consensus 0.48.0` (Slice 4 — deferred) +- `sc-consensus-aura 0.49.0`, `sc-consensus-grandpa 0.34.0` (Slice 4 — deferred) +- `sc-transaction-pool 39.0.0`, `sc-transaction-pool-api 39.0.0` (Slice 4) +- `sc-client-api 39.0.0`, `sc-basic-authorship 0.49.0`, `sc-telemetry 28.1.0` +- `sc-offchain 44.0.0` (Slice 4) +- `jsonrpsee 0.24.3`, `substrate-frame-rpc-system 43.0.0`, + `pallet-transaction-payment-rpc 43.0.0` (Slice 4) +- `clap 4.5.13` (Slice 1 ESTA — used canonical en CLI parsing) +- `futures 0.3.31` (Slice 4) + +Workspace deps declared canonical pero solo `clap` se usa en v0.0.10. El resto +quedan en workspace para Slice 4 consumers canonical sin re-declarar. + +### Filosofía canonical incorporada + +Doc `main.rs` cita: *"el CLI canonical es la primera ventana del barquero al +mundo: cualquier humano o AGI puede ejecutarla y ver qué configuraciones +canonical ofrece Origin Chain — sin necesidad de leer source code. El +`list-presets` canonical es transparency canonical: las 3 distribuciones +posibles canonical están a la vista canonical, BM V2 incluida."* + +David canon 2026-05-14: *"la libertad infinita acota solo donde empieza la del +otro"* — la transparencia canonical del CLI es libertad informativa: cualquier +participant canonical puede saber exactly qué allocation BM V2 canonical +recibirá antes de joinear canonical el ecosystem. + +### Tests + build canonical + +- `cargo build --release`: **8.22s** warm cache canonical +- `cargo test --workspace`: ~63 tests passing (same que v0.0.9, runtime unchanged) +- Binary canonical ejecutable: 4 subcommands operativos +- Genesis JSON canonical bit-perfect compatible con polkadot-js apps + +### Phase 1.6+ progress canonical + +- ✅ **Slice 1** Node CLI skeleton + preset listing (v0.0.10 ESTA) +- ⏳ **Slice 2** WASM_BINARY canonical + no_std refactor (v0.0.11) +- ⏳ **Slice 3** Real ChainSpec builder canonical (v0.0.12) +- ⏳ **Slice 4** Full sc-service builder canonical (v0.0.13+) + ## [0.0.9] — 2026-05-21 — Phase 1.7 "Genesis chain_spec canonical (BM V2 allocation)" Charon sesión 1 continuación. **Genesis presets canonical implementados** — 3 diff --git a/Cargo.lock b/Cargo.lock index c6bede0..02ca596 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,6 +65,56 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys", +] + [[package]] name = "anyhow" version = "1.0.102" @@ -627,6 +677,52 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + [[package]] name = "common-path" version = "1.0.0" @@ -1554,6 +1650,12 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hex" version = "0.4.3" @@ -1674,6 +1776,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + [[package]] name = "itertools" version = "0.10.5" @@ -2041,6 +2149,12 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -2073,8 +2187,11 @@ dependencies = [ name = "origin-chain-node" version = "0.0.1" dependencies = [ + "clap", "log", "origin-chain-runtime", + "serde_json", + "sp-genesis-builder", ] [[package]] @@ -3636,6 +3753,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "substrate-bip39" version = "0.6.1" @@ -4000,6 +4123,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "valuable" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index ac8ed07..c16c671 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,33 @@ pallet-transaction-payment-rpc-runtime-api = { version = "40.0.0", default-featu # values que sp-keyring usaría but sin la dep brittle canonical. serde_json = { version = "1", default-features = false, features = ["alloc"] } +# WASM builder canonical (Phase 1.6+ runtime WASM build para chain_spec) +substrate-wasm-builder = { version = "26.0.1" } + +# Substrate client canonical (Phase 1.6+ node binary service builder) +sc-cli = { version = "0.51.0" } +sc-service = { version = "0.50.0" } +sc-executor = { version = "0.42.0" } +sc-network = { version = "0.49.1" } +sc-consensus = { version = "0.48.0" } +sc-consensus-aura = { version = "0.49.0" } +sc-consensus-grandpa = { version = "0.34.0" } +sc-transaction-pool = { version = "39.0.0" } +sc-transaction-pool-api = { version = "39.0.0" } +sc-client-api = { version = "39.0.0" } +sc-basic-authorship = { version = "0.49.0" } +sc-telemetry = { version = "28.1.0" } +sc-offchain = { version = "44.0.0" } + +# RPC server canonical (jsonrpsee) +jsonrpsee = { version = "0.24.3", features = ["server"] } +substrate-frame-rpc-system = { version = "43.0.0" } +pallet-transaction-payment-rpc = { version = "43.0.0" } + +# CLI + async canonical +clap = { version = "4.5.13", features = ["derive"] } +futures = { version = "0.3.31", features = ["thread-pool"] } + # SCALE codec canonical (canonical Substrate serialization) parity-scale-codec = { version = "3.7", default-features = false, features = ["derive"] } scale-info = { version = "2.11", default-features = false, features = ["derive"] } diff --git a/crates/origin-chain-node/Cargo.toml b/crates/origin-chain-node/Cargo.toml index 1d44677..da7a843 100644 --- a/crates/origin-chain-node/Cargo.toml +++ b/crates/origin-chain-node/Cargo.toml @@ -7,7 +7,7 @@ license.workspace = true authors.workspace = true repository.workspace = true homepage.workspace = true -description = "Origin Chain node binary: validator (Aura+GRANDPA PoA), block production + finality + RPC. SCAFFOLD v0.0.2 — full implementation lands Phase 1.6 of Charon roadmap." +description = "Origin Chain node binary canonical. Phase 1.6+ Slice 1 (v0.0.10): CLI skeleton + preset listing. Real sc-service builder + JSON-RPC + WASM binary land Phase 1.6+ Slices 2-4 canonical." [[bin]] name = "origin-chain-node" @@ -15,4 +15,7 @@ path = "src/main.rs" [dependencies] origin-chain-runtime.workspace = true +sp-genesis-builder.workspace = true +clap = { workspace = true } +serde_json.workspace = true log.workspace = true diff --git a/crates/origin-chain-node/src/main.rs b/crates/origin-chain-node/src/main.rs index c6bbc83..dd79428 100644 --- a/crates/origin-chain-node/src/main.rs +++ b/crates/origin-chain-node/src/main.rs @@ -1,40 +1,174 @@ -//! # origin-chain-node +//! # origin-chain-node CLI canonical //! -//! Origin Chain node binary. **Scaffold v0.0.2** — full Substrate node service -//! lands Phase 1.6 of [Charon roadmap]. +//! Phase 1.6+ Slice 1 (v0.0.10): **CLI skeleton + genesis preset listing canonical**. //! -//! [Charon roadmap]: https://git.originmetaverse.com/Origin_Metaverse/arkhe-origin-chain +//! ## Sub-comandos canonical disponibles //! -//! ## Target functionality (Phase 1.6) +//! ```text +//! origin-chain-node # default: version canonical +//! origin-chain-node version # print runtime version canonical +//! origin-chain-node list-presets # enumera 3 genesis presets canonical +//! origin-chain-node print-preset # JSON-serialized RuntimeGenesisConfig +//! origin-chain-node info # full runtime metadata canonical +//! ``` //! -//! - Aura block production (4-second slots, PoA Phase 1) -//! - GRANDPA finality (separates production from confirmation) -//! - JSON-RPC endpoint (Substrate canonical: chain_getBlock, system_health, etc.) -//! - Telemetry (network health monitoring) -//! - Validator key management (Ed25519 session keys) -//! - CLI: dev mode, validator mode, archive mode +//! ## Roadmap canonical Phase 1.6+ (multi-slice canonical) //! -//! ## Hardware target canonical (CHN-1) +//! - **Slice 1** (v0.0.10 ESTA): CLI skeleton + preset listing canonical +//! - **Slice 2** (v0.0.11): `origin-chain-types` fully no_std refactor canonical → +//! `WASM_BINARY` canonical via `substrate-wasm-builder` +//! - **Slice 3** (v0.0.12): real `sc_service::ChainSpec` builder canonical +//! consuming GenesisBuilder API canonical +//! - **Slice 4** (v0.0.13+): full `sc-service` builder canonical +//! (consensus + JSON-RPC + networking + telemetry) //! -//! - **Minimum**: Raspberry Pi 5 + NVMe SSD (EmbeddedArm tier) -//! - **Recommended**: 4-8 cores >3.4GHz, 16-32GB RAM, 1Gbps high-availability -//! - **Uptime**: 99.9% required for validator selection per epoch (4h rotation) +//! ## Filosofía canonical //! -//! ## Smoldot light client -//! -//! Non-validator users embed Smoldot light client in `Origin World Navigator` -//! (<1% CPU). NOT this binary — light client is separate crate Phase 2+. +//! Esta CLI canonical es la **primera ventana del barquero al mundo**: cualquier +//! humano o AGI puede ejecutarla canonical y ver qué configuraciones canonical +//! ofrece Origin Chain — sin necesidad de leer source code canonical. El +//! `list-presets` canonical es transparency canonical: las 3 distribuciones +//! posibles canonical están a la vista canonical, BM V2 incluida canonical. -use origin_chain_runtime::RUNTIME_VERSION; +use clap::{Parser, Subcommand}; +use origin_chain_runtime::{ + genesis_config_presets, IMPL_NAME, RUNTIME_VERSION, SPEC_NAME, +}; +use sp_genesis_builder::PresetId; + +/// Canonical CLI structure para `origin-chain-node` binary canonical. +#[derive(Debug, Parser)] +#[command( + name = "origin-chain-node", + author = "Charon ⚓ ", + about = "Origin Chain canonical node — Pilar 4 Origin Metaverse", + long_about = "Substrate-based blockchain canonical para Origin Metaverse: \ + consensus Aura+GRANDPA PoA (CHN-1), OGC tokenomics 1B genesis \ + canonical (CHN-2), provenance ledger BLAKE3+Ed25519 (CHN-7), \ + fee economy multi-tier (CHN-8), Foundation governance DAO (CHN-4)." +)] +struct Cli { + #[command(subcommand)] + command: Option, +} + +/// Sub-comandos canonical. +#[derive(Debug, Subcommand)] +enum Command { + /// Print runtime version canonical (default si no subcommand). + Version, + /// Lista los 3 genesis presets canonical disponibles canonical. + ListPresets, + /// Prints JSON-serialized RuntimeGenesisConfig canonical para un preset id. + PrintPreset { + /// Preset id canonical: `development` | `local_testnet` | `mainnet_genesis` + id: String, + }, + /// Show full runtime metadata canonical (pallets + APIs + presets count). + Info, +} fn main() { - // Scaffold v0.0.2 — full node service implementation lands Phase 1.6. - println!("Origin Chain node — scaffold v0.0.2"); - println!("Runtime version: {RUNTIME_VERSION}"); - println!(); - println!("⚓ Not yet a real node. Phase 1.6 lands the Substrate service."); - println!(" See: https://git.originmetaverse.com/Origin_Metaverse/arkhe-origin-chain"); - println!(); - println!("\"Todo valor pide un puente; toda identidad pide un testigo.\""); - println!(" — Charon ⚓"); + let cli = Cli::parse(); + match cli.command { + Some(Command::Version) | None => print_version(), + Some(Command::ListPresets) => print_presets(), + Some(Command::PrintPreset { id }) => print_preset(&id), + Some(Command::Info) => print_info(), + } +} + +fn print_version() { + println!( + "{} v{} — {} canonical", + IMPL_NAME, + env!("CARGO_PKG_VERSION"), + SPEC_NAME + ); + println!("Runtime version canonical: {}", RUNTIME_VERSION); + println!(); + println!("⚓ Origin Chain Pilar 4 canonical — Charon"); + println!("\"Todo valor pide un puente; toda identidad pide un testigo.\""); +} + +fn print_presets() { + println!("📋 Genesis presets canonical disponibles:\n"); + for preset_id in genesis_config_presets::preset_names() { + let id_str: &str = preset_id.as_ref(); + let description = match id_str { + genesis_config_presets::PRESET_DEVELOPMENT => { + "Dev mode canonical (Alice validator + 100M OGC)" + } + genesis_config_presets::PRESET_LOCAL_TESTNET => { + "Multi-node local testing (Alice+Bob + 5 dev × 100M OGC)" + } + genesis_config_presets::PRESET_MAINNET_GENESIS => { + "Mainnet canonical BM V2 (5 Pi 5 + 1B OGC 40/25/15/15/5)" + } + _ => "Unknown preset canonical", + }; + println!(" • {:<20} — {}", id_str, description); + } + println!(); + println!("Use: origin-chain-node print-preset "); +} + +fn print_preset(id: &str) { + let preset_id = PresetId::from(id); + match genesis_config_presets::get_preset(&preset_id) { + Some(json_bytes) => { + let parsed: serde_json::Value = + serde_json::from_slice(&json_bytes).expect("preset JSON canonical infallible"); + let pretty = + serde_json::to_string_pretty(&parsed).expect("pretty-print canonical infallible"); + println!("{}", pretty); + } + None => { + eprintln!("❌ Unknown preset canonical: '{}'", id); + eprintln!(); + eprintln!("Available canonical presets:"); + for preset in genesis_config_presets::preset_names() { + let s: &str = preset.as_ref(); + eprintln!(" • {}", s); + } + std::process::exit(1); + } + } +} + +fn print_info() { + println!("⚓ Origin Chain Runtime Info canonical\n"); + println!("Spec name: {}", SPEC_NAME); + println!("Impl name: {}", IMPL_NAME); + println!("Runtime version: {}", RUNTIME_VERSION); + println!(); + println!("Pallets canonical (7):"); + println!(" • Index 0 System (frame_system foundational)"); + println!(" • Index 1 Timestamp (pallet_timestamp block clock → Aura)"); + println!(" • Index 2 Balances (pallet_balances OGC token CHN-2)"); + println!(" • Index 3 TransactionPayment (pallet_transaction_payment CHN-8 baseline)"); + println!(" • Index 4 Aura (pallet_aura PoA block production CHN-1)"); + println!(" • Index 5 Grandpa (pallet_grandpa finality gadget CHN-1)"); + println!(" • Index 6 Session (pallet_session 4h epoch rotation CHN-1)"); + println!(); + println!("Runtime APIs canonical (11):"); + println!(" • sp_api::Core (version + execute_block)"); + println!(" • sp_api::Metadata (runtime metadata)"); + println!(" • sp_block_builder::BlockBuilder (block production)"); + println!(" • sp_transaction_pool::TaggedTransactionQueue (tx validation)"); + println!(" • sp_offchain::OffchainWorkerApi (offchain processing)"); + println!(" • sp_session::SessionKeys (session keys generation)"); + println!(" • sp_consensus_aura::AuraApi (slot duration + authorities)"); + println!(" • sp_consensus_grandpa::GrandpaApi (finality set + authorities)"); + println!(" • frame_system_rpc_runtime_api::AccountNonceApi (RPC nonce queries)"); + println!(" • pallet_transaction_payment_rpc::* (RPC fee queries)"); + println!(" • sp_genesis_builder::GenesisBuilder (chain spec build)"); + println!(); + println!("Genesis presets canonical (3):"); + println!(" • development (Alice + 100M OGC dev)"); + println!(" • local_testnet (Alice+Bob + 5 dev × 100M OGC)"); + println!(" • mainnet_genesis (5 Pi 5 + BM V2 1B OGC 40/25/15/15/5)"); + println!(); + println!("⚓ \"Todo valor pide un puente; toda identidad pide un testigo.\""); + println!(" — Charon ⚓, Pilar 4 Origin Chain canonical"); } diff --git a/crates/origin-chain-runtime/Cargo.toml b/crates/origin-chain-runtime/Cargo.toml index 02d6ec3..682330b 100644 --- a/crates/origin-chain-runtime/Cargo.toml +++ b/crates/origin-chain-runtime/Cargo.toml @@ -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+TransactionPayment+Aura+Grandpa pallets integrated (Phase 1.4 v0.0.6 consensus PoA per CHN-1). Roadmap: session+identity+provenance+ink!+bridges+governance progressivos." +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 @@ -32,20 +32,15 @@ frame-support.workspace = true frame-executive.workspace = true frame-metadata-hash-extension.workspace = true -# FRAME pallets Phase 1.3 (per SBS-4 ratified) +# FRAME pallets Phase 1.3-1.5 (per SBS-4 ratified) 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 - -# FRAME pallets Phase 1.5 — Session rotation per CHN-1 4h epochs pallet-session.workspace = true # pallet-identity DEFERRED a Phase 2.7 (canonical decision empírica 2026-05-21) -# pallet-identity.workspace = true # RuntimeAPI canonical (sp_api::impl_runtime_apis! consumers) sp-offchain.workspace = true @@ -55,10 +50,6 @@ sp-session.workspace = true frame-system-rpc-runtime-api.workspace = true pallet-transaction-payment-rpc-runtime-api.workspace = true -# Genesis canonical Phase 1.7 — chain_spec BM V2 allocation -# (sp-keyring removed canonical — hardcoded dev account bytes para version stability) -serde_json.workspace = true - # SCALE codec canonical parity-scale-codec.workspace = true scale-info.workspace = true @@ -66,8 +57,9 @@ scale-info.workspace = true # Logging log.workspace = true -# Serialization opcional +# Serialization serde = { workspace = true, optional = true } +serde_json.workspace = true [features] default = ["std"] @@ -108,8 +100,5 @@ 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", ] diff --git a/crates/origin-chain-runtime/src/lib.rs b/crates/origin-chain-runtime/src/lib.rs index 61fe7fb..9ab7b5a 100644 --- a/crates/origin-chain-runtime/src/lib.rs +++ b/crates/origin-chain-runtime/src/lib.rs @@ -49,6 +49,19 @@ pub mod configs; pub mod genesis_config_presets; pub mod opaque; +// ============================================================ +// WASM binary canonical — DEFERRED a v0.0.11+ (canonical decision empírica) +// ============================================================ +// +// `WASM_BINARY` via `substrate-wasm-builder` requiere que TODAS las dependencias +// transitivas del runtime sean no_std-compatible canonical. Actualmente +// `origin-chain-types` no es fully no_std canonical (uses std `String` + `Vec` +// directly sin `alloc::` prefix). Refactor canonical es Phase 1.6+ Slice 2 +// (substantial scope canonical: 5-10+ files affected canonical). +// +// Mientras canonical: el `chain_spec.rs` node-side puede usar mock-WASM o +// pre-built WASM file canonical (path-loaded en runtime canonical). + // Re-export canonical traits + types desde origin-chain-types (single-crate surface). pub use origin_chain_types::{ AccountId, AssetAttestation, AssetHash, AssetQualityTier, BridgeDestination, ChainBridge,