diff --git a/crates/origin-chain-runtime/src/lib.rs b/crates/origin-chain-runtime/src/lib.rs index c0f45e4..75ae9d4 100644 --- a/crates/origin-chain-runtime/src/lib.rs +++ b/crates/origin-chain-runtime/src/lib.rs @@ -49,6 +49,41 @@ pub mod configs; pub mod genesis_config_presets; pub mod opaque; +// ============================================================ +// WASM binary (Slice 4 Paso 4a — WASM_BINARY export v0.0.48) +// ============================================================ +// +// `build.rs` genera `OUT_DIR/wasm_binary.rs` con `pub const WASM_BINARY: +// Option<&[u8]>` cuando el feature `wasm-build` está activo (vía +// substrate-wasm-builder). El node lo consume para construir el ChainSpec real +// (`sc_service::GenericChainSpec`) en Slice 4 Paso 4b. +// +// Gate: el `include!` solo corre con `wasm-build` on (si está off, el archivo +// generado no existe → error de compilación). El fallback `None` cubre los +// builds host-only (`cargo test`/`cargo check`). El inner build wasm32 que +// dispara substrate-wasm-builder NO hereda `wasm-build` (no es default feature), +// lo que evita recursión en build.rs. +#[cfg(feature = "wasm-build")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +/// Fallback de `WASM_BINARY` para builds host-only (feature `wasm-build` off). +/// Para obtener el binary real: `cargo build --features wasm-build` + env vars +/// `CC=/opt/homebrew/opt/llvm/bin/clang` (ver SLICE_2E). El node activa +/// `origin-chain-runtime/wasm-build` para embeberlo en el ChainSpec. +#[cfg(not(feature = "wasm-build"))] +pub const WASM_BINARY: Option<&[u8]> = None; + +/// Devuelve el `WASM_BINARY` o falla con un mensaje claro si no está disponible. +/// Consumido por el node al construir ChainSpecs (Slice 4 Paso 4b). +#[cfg(feature = "std")] +pub fn wasm_binary_unwrap() -> &'static [u8] { + WASM_BINARY.expect( + "WASM binary no disponible: build con `--features wasm-build` + \ + CC=LLVM env vars (ver SLICE_2E). El node debe activar \ + origin-chain-runtime/wasm-build.", + ) +} + // ============================================================ // WASM binary canonical (Slice 2b investigation registered, Slice 2c deferred) // ============================================================