Skip to content

Conversation

@AlanRuno
Copy link
Owner

Implement post-genesis block production loop

Summary

This PR fixes the issue where blocks were not being produced after genesis. The root cause was that the block proposer functions existed but were never called from anywhere in the codebase.

Changes:

  1. New mxd_consensus_tick() function - Drives block production after genesis (height > 0). Determines if this node is the proposer, starts block proposals, closes blocks after timeout, signs them, stores them, and broadcasts to the network.

  2. New mxd_is_proposer_for_height() function - Deterministic proposer selection using round-robin: proposer_index = height % validator_count. Uses the membership entries from the latest block as the canonical validator list.

  3. Fixed mxd_should_close_block() bug - The original condition rapid_membership_count == 0 && !transaction_set_frozen was preventing blocks with transactions from closing. Fixed to properly check if block is empty before deciding not to close.

  4. Main loop integration - Calls mxd_consensus_tick() from the main loop when blockchain_height > 0.

Review & Testing Checklist for Human

  • Verify mxd_should_close_block() logic - The original condition was inverted. Confirm the new logic correctly allows blocks with transactions to close after timeout.
  • Test proposer selection - Verify that mxd_is_proposer_for_height() correctly identifies proposers using the genesis block's membership entries. If membership entries are empty, no blocks will be produced.
  • Mempool integration is incomplete - Lines 2371-2384 in mxd_rsc.c only log mempool size but don't actually add transactions to blocks. This may need follow-up work.
  • Deploy to test network and verify blocks are produced - Check logs for "Started block proposal", "Block closed", "Block broadcast" messages. Verify blockchain height increases beyond 0.
  • Thread safety - Consensus tick is called with metrics_mutex held. Verify no deadlocks with block proposer internal locking.

Recommended test plan:

  1. Deploy updated code to the 10-node test network
  2. Wait for genesis coordination to complete (height becomes 1)
  3. Monitor logs for block production messages
  4. Verify blockchain height continues to increase
  5. Check that blocks are being broadcast and received by other nodes

Notes

  • This implements single-proposer block production. Other validators do not sign blocks before broadcast (only the proposer signs).
  • The proposer selection is deterministic based on block height, ensuring all nodes agree on who should propose each block.

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

- Fix mxd_should_close_block() to check for transactions (not just membership entries)
- Add mxd_consensus_tick() function to drive block production after genesis
- Add mxd_is_proposer_for_height() for deterministic proposer selection
- Call mxd_consensus_tick() from main loop when height > 0

This fixes the issue where blocks were not being produced after genesis
because the block proposer functions were never called.
@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 389139b into main Jan 3, 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