Implement post-genesis block production loop #219
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.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.Fixed
mxd_should_close_block()bug - The original conditionrapid_membership_count == 0 && !transaction_set_frozenwas preventing blocks with transactions from closing. Fixed to properly check if block is empty before deciding not to close.Main loop integration - Calls
mxd_consensus_tick()from the main loop whenblockchain_height > 0.Review & Testing Checklist for Human
mxd_should_close_block()logic - The original condition was inverted. Confirm the new logic correctly allows blocks with transactions to close after timeout.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.metrics_mutexheld. Verify no deadlocks with block proposer internal locking.Recommended test plan:
Notes
Link to Devin run: https://app.devin.ai/sessions/d773ec4cb78b42dd95d494b09e3580f3
Requested by: Runo (runonetworks@gmail.com) / @AlanRuno