Skip to content

Commit bf45d49

Browse files
committed
Fix critical blockchain desynchronization issue with out-of-order block handling
CRITICAL FIXES: - Add block buffering for out-of-order blocks (pending_blocks HashMap) - Implement immediate P2P request for missing blocks via sync_blocks() - Add DDoS protection with rate limiting (max 10 concurrent requests, 10s cooldown) - Implement parallel processing of consecutive blocks (up to 10 blocks like Solana) - Add automatic retry mechanism with exponential backoff (max 3 retries) - Add periodic cleanup of stale buffers (60s timeout) GENESIS FIXES: - Implement deterministic Genesis block signature using SHA3-256 - Add Genesis creation coordination (only node_001 creates in bootstrap mode) - Ensure Genesis block is saved with retry mechanism (panic on failure) - Add validation for Genesis block before creating block #1 - Improve previous_hash validation for all blocks including Genesis ARCHITECTURE: - Pass unified_p2p to process_received_blocks for P2P operations - Use dual-channel approach (block_rx + retry_rx) with priority for retries - Maintain compatibility with existing Turbine and Reed-Solomon protocols - Scale for millions of nodes with proper resource management This resolves the split-brain issue where nodes would get stuck when blocks arrived out of order, particularly when block N+1 arrived before block N due to network delays.
1 parent 6c0935d commit bf45d49

2 files changed

Lines changed: 310 additions & 134 deletions

File tree

0 commit comments

Comments
 (0)