Skip to content

Conversation

@AlanRuno
Copy link
Owner

Summary

Fixes genesis block propagation issue where late-joining nodes never receive the genesis block. Previously, the genesis block was only broadcast once when created, but if only 1-2 peers were connected at that time, other nodes would never receive it.

This change adds a mechanism to broadcast the genesis block whenever a new peer completes handshake, helping late joiners receive the genesis block. Includes rate limiting (30s per peer address) to reduce redundant broadcasts.

Key changes:

  • Added push_genesis_to_peer() function that broadcasts genesis block after handshake completion
  • Added rate limiting tracking arrays to prevent flooding
  • Called at end of handle_handshake_message() after successful handshake

Review & Testing Checklist for Human

  • IMPORTANT: Verify the broadcast-to-all behavior is acceptable. The function broadcasts to ALL peers (via mxd_broadcast_block), not just the newly connected peer. This means every new peer connection triggers a network-wide genesis broadcast (subject to rate limiting).
  • Verify rate limiting logic is sufficient - currently tracks by peer address, but broadcasts go to everyone. Multiple different peers connecting in quick succession will each trigger a full broadcast.
  • Test with 10-node network: reset all nodes, start them, verify all 10 reach Height: 1 (not just 2-3 nodes)

Recommended test plan:

  1. Run ./letsgo testnet -reset on all 10 test nodes
  2. Monitor logs for "Pushing genesis block to network after new peer" messages
  3. Verify all 10 nodes show Height: 1 within 2-3 minutes

Notes

Link to Devin run: https://app.devin.ai/sessions/f0a6357d898e440ea3745d77dfb91d8d
Requested by: Runo (runonetworks@gmail.com) / @AlanRuno

This is part of ongoing work to fix genesis block propagation. Previous fixes (PR #226) addressed DHT peer port issues but genesis still wasn't reaching all nodes because the initial broadcast happened too early.

When a node has the genesis block and a new peer connects via handshake,
the node will now broadcast the genesis block to help late-joining nodes
receive it. This fixes the issue where genesis block was only broadcast
once when created, causing late joiners to never receive it.

Includes rate limiting (30s per peer) to prevent flooding.
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@AlanRuno AlanRuno merged commit 5f4b92f into main Jan 17, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants