Skip to content

Commit b62ec58

Browse files
AIQnetLabclaude
andcommitted
Log hygiene: sample/demote the 4 cosmetic high-volume WARNs (~75k/node/19h)
None touch consensus or production timing — verified: the PoH count is an embedded VDF proof (never a timing/election gate), and block_ts is slot-anchored/deterministic (cannot fork). The noise is steady-state + heterogeneous-hardware, not a fault. - PoH "Clock drift X%" (poh.rs): sampled 1 per 300 slots (~5 min). Drift = this node's CPU hash-rate vs wall mapping; it never gates production/round/election. - PACING "chain off real-time schedule" (node.rs): sampled 1 per 300 blocks; the lag is cosmetic since block_ts is deterministic. - P2P "Certificate already cached, skipping" (unified_p2p.rs): WARN->DBG — an expected dedup no-op, not a warning. - QUIC "uni_read_failed" (quic_transport.rs): WARN->DBG — a benign early close of a one-way broadcast stream; the payload still arrives via other peers/repair. Genuine P2P/QUIC/BFT warnings stay at WARN. cargo check clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 06b2076 commit b62ec58

4 files changed

Lines changed: 29 additions & 21 deletions

File tree

development/qnet-integration/src/crypto/poh.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ const HASHES_PER_SLOT: u64 = HASHES_PER_TICK * 100; // 500,000
6464

6565
/// Maximum drift allowed between PoH time and wall clock (5%)
6666
const MAX_DRIFT_PERCENT: f64 = 0.05;
67+
/// Drift is cosmetic (PoH count is an embedded proof, never a timing/consensus gate); log it at most
68+
/// once per this many slots (~5 min) instead of every slot, so non-nominal hardware doesn't spam.
69+
const POH_DRIFT_LOG_SLOTS: u64 = 300;
6770

6871
// ============================================================================
6972
// DATA STRUCTURES
@@ -328,23 +331,20 @@ impl PoH {
328331
POH_HASH_COUNT.inc_by(HASHES_PER_TICK as f64);
329332
POH_CURRENT_SLOT.set(new_slot as f64);
330333

331-
// Check drift on slot change
332-
if new_slot > old_slot {
334+
// Drift = this node's PoH-count vs wall mapping (hardware-dependent). Sampled every
335+
// POH_DRIFT_LOG_SLOTS (~5 min): non-nominal hardware drifts every slot, but the rate
336+
// is purely informational — PoH count is an embedded VDF proof, NEVER a consensus or
337+
// production-timing gate, so it cannot desync the node.
338+
if new_slot > old_slot && new_slot % POH_DRIFT_LOG_SLOTS == 0 {
333339
let elapsed = start_time.elapsed();
334340
let expected = Duration::from_secs(new_slot);
335-
336-
if elapsed > expected {
337-
let drift = (elapsed - expected).as_secs_f64() / expected.as_secs_f64();
338-
if drift > MAX_DRIFT_PERCENT {
339-
println!("[PoH] ⚠️ Clock drift: {:.2}% slow (slot {})",
340-
drift * 100.0, new_slot);
341-
}
341+
let (drift, dir) = if elapsed > expected {
342+
((elapsed - expected).as_secs_f64() / expected.as_secs_f64(), "slow")
342343
} else {
343-
let drift = (expected - elapsed).as_secs_f64() / expected.as_secs_f64();
344-
if drift > MAX_DRIFT_PERCENT {
345-
println!("[PoH] ⚠️ Clock drift: {:.2}% fast (slot {})",
346-
drift * 100.0, new_slot);
347-
}
344+
((expected - elapsed).as_secs_f64() / expected.as_secs_f64(), "fast")
345+
};
346+
if drift > MAX_DRIFT_PERCENT {
347+
println!("[PoH] ⚠️ Clock drift: {:.2}% {} (slot {})", drift * 100.0, dir, new_slot);
348348
}
349349
}
350350

development/qnet-integration/src/node.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,15 @@ pub fn observe_clock_drift(block_ts: u64, local_now: u64) {
776776
// median ring, so a drifted node already converges with the network on
777777
// the slot-offset computation without any process-exit gate.
778778
let ema_secs = next / 1000;
779-
if ema_secs > 10 && is_warn() {
779+
// Sampled (1 per PACING_LOG_EVERY blocks, ~5 min): the lag is informational — block_ts is
780+
// slot-anchored/deterministic, so it cannot fork; logging every block just spams.
781+
const PACING_LOG_EVERY: u64 = 300;
782+
static PACING_LOG_CTR: AtomicU64 = AtomicU64::new(0);
783+
if ema_secs > 10 && is_warn()
784+
&& PACING_LOG_CTR.fetch_add(1, Ordering::Relaxed) % PACING_LOG_EVERY == 0 {
780785
println!(
781-
"[WARN][PACING] ema={}s peak={}s wall={} block_ts={} — chain off real-time schedule",
782-
ema_secs, abs_drift_secs, local_now, block_ts
786+
"[WARN][PACING] ema={}s peak={}s wall={} block_ts={} — chain off real-time schedule (sampled 1/{})",
787+
ema_secs, abs_drift_secs, local_now, block_ts, PACING_LOG_EVERY
783788
);
784789
}
785790
}

development/qnet-integration/src/quic_transport.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,8 +1750,10 @@ impl QuicTransport {
17501750
).await {
17511751
Ok(Ok(d)) => d,
17521752
Ok(Err(e)) => {
1753-
if crate::node::is_warn() {
1754-
println!("[WARN][QUIC] uni_read_failed peer={} err={:?}",
1753+
// One-way broadcast uni-stream read error (mostly a benign early stream close) — the
1754+
// payload still arrives from other peers / repair, so this is DBG, not a node fault.
1755+
if crate::node::is_debug() {
1756+
println!("[DBG][QUIC] uni_read_failed peer={} err={:?}",
17551757
get_privacy_id_for_addr(&peer_addr.to_string()), e);
17561758
}
17571759
return;

development/qnet-integration/src/unified_p2p.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14286,8 +14286,9 @@ impl SimplifiedP2P {
1428614286
// Check if already in pending or verified
1428714287
if cert_manager.remote_certificates.contains_key(&cert_serial) ||
1428814288
cert_manager.pending_certificates.contains_key(&cert_serial) {
14289-
if crate::node::is_info() {
14290-
println!("[WARN][P2P] Certificate {} already cached, skipping", cert_serial);
14289+
// Expected dedup of a re-offered cert — a no-op, not a warning (DBG only).
14290+
if crate::node::is_debug() {
14291+
println!("[DBG][P2P] cert_already_cached serial={} (dedup skip)", cert_serial);
1429114292
}
1429214293
return;
1429314294
}

0 commit comments

Comments
 (0)