Commit Graph

14 Commits

Author SHA1 Message Date
Kilian Tyler bfdefcd1a7 fix(peers): count and relay peers even when storage is full
Previously, when seenPeers reached MAX_PEERS, new peer messages were
completely dropped - never verified, counted, or relayed. This caused
the node to stop discovering new peers and stop propagating messages.

Now we always verify, count (HyperLogLog), and relay valid messages.
We just don't store peers in seenPeers if we're at capacity.
2026-01-02 14:39:49 -05:00
Kilian Tyler 8711a4e0fa perf(heartbeat): add adaptive rate with fast startup sync
- Fast mode (2s interval) for first 2 minutes after first connection
- Slow mode (30s interval) for steady state operation
- Timer starts on first connection, not process start
- Stale peer timeout increased to 90s to match slower heartbeat
2026-01-02 14:30:21 -05:00
Kilian Tyler 3fcf71d6e8 perf(peers): use lightweight Buffer storage instead of KeyObject
Store raw DER buffer (~100 bytes) instead of parsed KeyObject (~2-5KB)
per peer. Parse on-demand during verification only. Also reduces
MAX_PEERS from 10000 to 1000 for better memory efficiency.
2026-01-02 14:29:19 -05:00
Kilian Tyler 5d1e4f059e feat(peers): add HyperLogLog for scalable peer counting
Adds approximate unique peer counting with fixed ~1KB memory usage.
Can count millions of peers with ~2% accuracy. Separates counting
(unlimited) from storage (capped at MAX_PEERS for verification).
2026-01-02 14:28:25 -05:00
Kilian Tyler 895281e54d perf(gossip): add bloom filter for message deduplication
Prevents re-relaying messages we've already forwarded. Uses a
time-bucketed dual bloom filter that rotates every 30 seconds
to prevent fill-up while maintaining deduplication.
2026-01-02 14:26:46 -05:00
Kilian Tyler 86dff90364 perf(gossip): add fanout-limited relay to reduce bandwidth
Instead of relaying messages to ALL connections, relay to max 3
random peers. This reduces O(N) per-hop to O(1) while maintaining
epidemic spread through the network.
2026-01-02 14:25:59 -05:00
lklynet 2bd144ba07 perf(peers): optimize message handling and peer management
- Add MAX_PEERS limit to prevent memory exhaustion
- Check message sequence early to drop duplicates before expensive verify
- Simplify peer update logic by removing redundant checks
2026-01-02 13:12:05 -05:00
lklynet 0d589872cd perf(peer-handling): optimize peer verification and cleanup intervals
- Cache peer public keys to avoid repeated key creation
- Increase peer cleanup interval from 2.5s to 15s to reduce overhead
- Adjust cleanup check interval from 500ms to 5s
2026-01-02 12:49:38 -05:00
lklynet 1e16d431d5 perf: throttle updates and limit particles to prevent crashes
Added rate limiting to broadcast updates to once per second and cap visual particles at 500 to prevent browser crashes from excessive rendering. Stop ruining my fun.
2026-01-02 11:40:26 -05:00
lklynet 81864969da feat(security): add PoW and Ed25519 signatures to prevent Sybil attacks 2026-01-02 11:05:44 -05:00
lklynet 149298016e some flair and pizzazz 2026-01-02 09:52:00 -05:00
lklynet c6d4a3e8f1 my god hes done it 2026-01-01 23:31:21 -05:00
lklynet 0dc2c6efb2 refactor: replace uuidv4 with crypto.randomUUID for id generation 2026-01-01 23:27:07 -05:00
lklynet d5f517658f Screaming into the void 2026-01-01 22:40:32 -05:00