So I've been wondering why every `genesis.hashMerkleRoot` in the Bitcoin network is identical, but the `consensus.hashGenesisBlock` values that get printed out are different? What’s going on with this implementation?
Genesis Block Question
3 replies 44 views
I tested modifying the value of `const char* pszTimestamp` and it printed different results using `assert(consensus.hashGenesisBlock)`. I'm not sure if this is correct.
paul.stakeHero Member
Posts: 651 · Reputation: 3798
#3Oct 22, 2024, 01:21 PM
That's actually a good question. Reading chainparams.cpp, merkle root "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b" is used in both mainnet and test networks, but it can only be true in one, because these networks use a different genesis coinbase transaction, and genesis' merkle root is determined by the coinbase transaction.
It doesn't fail though, for if it did, Bitcoin Core with --testnet would fail at startup.
What kind of results? If you changed pszTimestamp, it should abort.
They are the same:
https://mempool.space/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
https://mempool.space/signet/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
https://mempool.space/testnet/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
Except testnet4: https://mempool.space/testnet4/tx/7aa0a7ae1e223414cb807e40cd57e667b718e42aaf9306db9102fe28912b7b4e
However, block hashes are different, just because block headers are different:
After decoding timestamps, we get:
Changing timestamp alone would lead to a different nonce, and a different block hash. This is what testnet3 did. Later, signet lowered the minimal difficulty. And then, testnet4 changed the first transaction completely.
Which also means, that all testnets had some potential for premine: testnet4 tried to pick a different transaction to avoid it, but still ended up with premine, because the first version was released around block 40k.
By the way: the first testnet reused all parameters from mainnet, but then, it was possible to easily destroy the whole network by copy-pasting the chain from mainnet to testnet.
Related topics
- Hex data from the prenet genesis transaction 3
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3
- New Optional Hourglass Implementation is Live 3
- Ways to earn some sats by contributing to bitcoin core development 5