# nu-node — CLAUDE.md L1 node implementasyonu. Consensus, mempool, state, block üretimi, RPC. ## Crate Yapısı | Crate | Sorumluluk | |-------|-----------| | `nu-consensus` | PoN validator seçim, slot sistemi, PoN skoru, oylama scheduler | | `nu-mempool` | Bekleyen tx havuzu; öncelik: Critical > High > Normal | | `nu-state` | AccountState, StoryNodeState, NftState; RocksDB backend | | `nu-block` | BlockBuilder (Merkle root), BlockVerifier | | `nu-rpc` | JSON-RPC HTTP server + WebSocket subscription | | `nu-vm` | Tx executor, ödül dağıtımı, slashing | ## Kritik Kurallar - `unwrap()` / `expect()` sadece test kodunda. Production'da `?` veya açık hata. - State'e dokunan her fonksiyon: önce **tam doğrulama**, sonra mutation. - Slashing ve ödül dağıtımı **atomik** — başarısız olursa state değişmez. - `BURN_WALLET` ve `DEV_WALLET` adresleri env variable; hardcode yasak. ## Sabitler (nu-consensus/src/types.rs) ``` SLOT_DURATION_MS = 6_000 ROUND_SIZE = 21 MIN_VALIDATOR_STAKE = 1_000 NUT PoN: start=1.0, max=1.8, min=0.5 win=+0.02, lose=-0.05, honest_block=+0.01 WHALE_CAP = 5% of total weight ``` ## Geliştirme ```bash # Devnet (tek validator, consensus devre dışı) cargo run --bin nu-node -- --dev --validator # Testleri çalıştır cargo test # Lint cargo fmt && cargo clippy ``` ## Faz Durumu - **Faz 0:** ✅ Scaffold, tipler, modül sınırları. - **Faz 1:** ✅ Tüm tx tipleri, block loop, JSON-RPC, P2P forwarding (`--p2p-api`). - **Faz 2 (sıradaki):** Tam PoN consensus (rotation, slashing), 3+ validator testnet. ## P2P Entegrasyonu nu-node, nu-p2p'ye `reqwest` ile HTTP POST atar. nu-p2p ayrı process olarak çalışır. ```bash # P2P ile başlat cargo run -- --dev --validator --p2p-api http://127.0.0.1:30334 ```