Skip to content

Commit 728a30a

Browse files
AIQnetLabclaude
andcommitted
fix: bypass rate limiter during bootstrap (height=0) to prevent registration deadlock
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f6c9cfc commit 728a30a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

development/qnet-integration/src/unified_p2p.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13127,10 +13127,19 @@ impl SimplifiedP2P {
1312713127
// 5 nodes → 11/min, 100 nodes → 30/min, 1000 nodes → 200/min (cap).
1312813128
// This ensures: (a) small networks aren't over-limited, (b) large networks
1312913129
// don't allow unbounded CPU burn, (c) no magic constants to tune manually.
13130-
let active_count = self.active_full_super_nodes.len();
13131-
let adaptive_limit = (10 + active_count / 5).min(200);
13132-
if self.is_consensus_rate_limited(from_peer, "active_announce", adaptive_limit) {
13133-
return;
13130+
//
13131+
// v9.5: Bootstrap bypass — at height 0 (no blocks produced yet), nodes MUST
13132+
// register with each other to reach quorum and start producing. Rate limiting
13133+
// at this stage causes a deadlock: nodes can't register → can't produce →
13134+
// stay at height 0 forever. Dedup (seen_announcements below) still prevents
13135+
// redundant Dilithium3 verification, so CPU is protected without rate limiting.
13136+
let local_h = LOCAL_BLOCKCHAIN_HEIGHT.load(std::sync::atomic::Ordering::Relaxed);
13137+
if local_h > 0 {
13138+
let active_count = self.active_full_super_nodes.len();
13139+
let adaptive_limit = (10 + active_count / 5).min(200);
13140+
if self.is_consensus_rate_limited(from_peer, "active_announce", adaptive_limit) {
13141+
return;
13142+
}
1313413143
}
1313513144

1313613145
// v9.1: Dedup — skip if already processed this exact announcement.

0 commit comments

Comments
 (0)