Skip to content

Conversation

@AlanRuno
Copy link
Owner

Summary

This PR fixes the issue where genesis validators had 0 MXD stake despite the initial_stake config being set to 100.0 MXD. The root cause was that the genesis block creation code was setting total_supply = 0 without actually minting any tokens.

Changes:

  • Added serialize_coinbase_for_block() helper function to serialize coinbase transactions for block storage
  • Modified mxd_try_coordinate_genesis_block() to create coinbase transactions for each of the 3 genesis validators using the initial_stake config value
  • Set genesis_block.total_supply to reflect the total minted tokens (3 × initial_stake)

The coinbase transactions are added to the genesis block before the transaction set is frozen, ensuring they are included in the block's merkle root calculation.

Review & Testing Checklist for Human

  • Verify serialization format: Compare serialize_coinbase_for_block() with the existing serialize_transaction_for_block() in mxd_block_proposer.c to ensure the format matches what the deserialization code expects
  • Verify UTXO recognition: Confirm that the UTXO system will properly index these coinbase outputs so validators can actually spend their initial stake
  • Test on live network: Deploy to test nodes and verify:
    • Genesis block shows total_supply = 30000000000 (300 MXD in base units for 3 validators × 100 MXD each)
    • Each genesis validator shows 100.0 MXD stake in metrics
    • Validators can use their stake for consensus participation
  • Verify addresses[] array: Confirm that at line 2264, the addresses[] array contains the correct sorted genesis validator addresses

Recommended test plan:

  1. Destroy existing test VMs
  2. Pull latest main on MXDTestSuite
  3. Run a fresh 10-node test: ./build/mxd_test_suite test --project mxd-network --nodes 10 --startup-mode letsgo-testnet --network-type testnet
  4. After genesis block creation, SSH into nodes and verify stake amounts in metrics output

Notes

  • The first genesis block creation (for membership digest calculation) is intentionally not modified - it's only used for signing, not for the actual blockchain
  • Build passes locally with all tests compiling successfully

Link to Devin run: https://app.devin.ai/sessions/4f2bfeca9bee46ca90ac744cb8b94bf8
Requested by: @AlanRuno

- Add serialize_coinbase_for_block helper function to serialize coinbase
  transactions for block storage
- Modify mxd_try_coordinate_genesis_block to create coinbase transactions
  for each genesis validator using the initial_stake config value
- Set genesis block total_supply to reflect the minted tokens
- Add mxd_serialize.h include for serialization functions

This fixes the issue where genesis validators had 0 MXD stake despite
the initial_stake config being set to 100.0 MXD. Now each of the 3
genesis validators will receive initial_stake amount of MXD minted
via coinbase transactions in the genesis block.
@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 76177b5 into main Jan 18, 2026
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