Commit Graph
13 Commits
Author SHA1 Message Date
dcrubro af888258f4 cmake analyzer and strict modes 2026-08-16 22:08:47 +02:00
dcrubro 914fa6e5a7 Change cmakelists for compile strictness 2026-08-16 20:48:24 +02:00
dcrubro 0e90f7d5db Fix multi-homed / IPv6 peer identity: nodes adding themselves and reconnect churn
Root cause: peers were keyed only by (IP, listen port). An IPv6 host holds several addresses at once, so one node appeared as several peers and could not recognise its own addresses.

Protocol:
 - Added a random per-run node identity (localNodeId), advertised as a length-guarded trailing field in HELLO and ACK_HELLO — backwards compatible with peers that omit it
 - Added peerNodeId to tcp_connection_t; peers are now identified by this rather than by an endpoint
 - ACK_HELLO is now sent before any decision to drop the connection, so a rejected dialer learns whose address it reached instead of retrying forever

Self-connection:
 - Identity match → close the connection and record that endpoint permanently as our own
 - Self-endpoint set preemptively seeded from getifaddrs() at startup, so a node knows its own addresses before ever dialing one
 - Node_ConnectPeer refuses self endpoints, which also kills the echo-back chain that could exhaust connection slots

Duplicate connections and churn:
 - Dedup by identity per direction — one inbound and one outbound per physical peer, regardless of how many addresses it has
 - Moved dial history out of the peer table, so striking a peer no longer resets its connect-retry cooldown (this was the loop engine: strike → re-learn via gossip → redial next tick)
 - Node_HasOtherInboundFrom / Node_HasLiveConnectionTo now ignore connections that are already tearing down, and match on identity as well as endpoint

Gossip hygiene:
 - Never hand a peer its own other addresses in a PEERS reply (matched on identity, not just the socket address)
 - Reject unusable endpoints: link-local without scope id, unspecified, multicast, site-local (loopback stays allowed for local testing)
 - Normalise IPv4-mapped IPv6 so one host cannot occupy two entries

Two bugs found along the way:
 - All nodes drew the same identity — random_eight_byte() comes from srand(time(NULL)), so processes started in the same second produced identical values. Added random_secure_eight_byte() (/dev/urandom) for the identity, and mixed the pid into the seed so connection IDs stop colliding too
 - Identity dedup initially left inbound-only nodes mute — broadcasts traverse outbound connections only, so suppressing a dial-back because an inbound existed would have silenced such a node. Corrected to per-direction

Other:
 - peers output now shows each entry's node identity and the node's own endpoints
 - Added _DEFAULT_SOURCE to the build so getifaddrs() stays visible on glibc
2026-07-27 14:08:57 +02:00
dcrubro 644695c018 linux errors 2026-05-15 16:07:16 +02:00
dcrubro 361ac73e45 global externs refactor, some tcp methods 2026-05-14 17:36:40 +02:00
dcrubro 1e9fc9b024 fetch depends 2026-05-08 18:12:42 +02:00
dcrubro 8b40fe7c56 fetch depends 2026-05-08 18:10:21 +02:00
dcrubro 189aa357af fetch depends 2026-05-08 18:07:28 +02:00
dcrubro 24f20c81f8 rename 2026-04-03 17:02:46 +02:00
dcrubro 075793c24c huge chain test, added 1.5% yearly inflation at 3.5 million blocks 2026-03-30 23:46:22 +02:00
dcrubro b47ff30bc7 difficulty calculation, move from randomx to autolykos2 2026-03-30 15:42:28 +02:00
dcrubro 0d7adc39e0 BigInts, save/load, will make a calculation for block rewards soon 2026-03-29 22:18:57 +02:00
dcrubro 57bfe61c13 Copied TCP impl from other project, basic Block implementation, randomx pow, signing via secp256k1 2026-03-29 17:18:23 +02:00