Bitcoin Forum
January 03, 2026, 03:05:48 PM *
News: Latest Bitcoin Core release: 30.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Genesis Block  (Read 141 times)
tedud (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 6


View Profile
December 31, 2025, 05:35:09 AM
Merited by BlackHatCoiner (4), ABCbits (2)
 #1

Why are all the `genesis.hashMerkleRoot` values ​​the same in the Bitcoin network, yet the `consensus.hashGenesisBlock` values ​​printed are different? How is this implemented?
tedud (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 6


View Profile
January 01, 2026, 04:44:41 AM
 #2

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.
BlackHatCoiner
Legendary
*
Offline Offline

Activity: 1890
Merit: 9229


Bitcoin is ontological repair


View Profile
January 01, 2026, 07:44:42 PM
Last edit: January 02, 2026, 02:10:22 PM by BlackHatCoiner
Merited by ABCbits (1), stwenhao (1)
 #3

Why are all the `genesis.hashMerkleRoot` values ​​the same in the Bitcoin network, yet the `consensus.hashGenesisBlock` values ​​printed are different? How is this implemented?
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.

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.
What kind of results? If you changed pszTimestamp, it should abort.

██████████████████████████████████████████████████████████████████████
████████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄████████▄▄▄▄▄▄▄███▄▄▄▄▄▄▄▄▄████████████████████
███████▄██▀▀▀▀▀▀▀▀▀▀▀██▄▄▄▄▄▄▄▄███████▄▄▄██▀▀▀▀▀██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄████
███████
█▄▄▄▄▄▄▄▄▄▄████▀▀▀▀██▀▀▄▄██▀██▀▀▀███████▀▀▀█▀▀▀▀▀▀▀▀▀▀████
███████
▀█
█████▀▀▀▀█████████████████▀█████████▀██▄██▄▄▄▄▄█████████
███████
▄█
███▄▄▄▄▄▄▄██████████████████████▀▀██▄███████▀████▀████
██████
▄█
██████████████████████████▄██████████████████▀████▀██████
█████
▄█
██████▀▀▀████████████████████████████████▀█████████████
████
▄█
██████▀█████████████████████████████████▀███▀▀▀▀▀█▄██████
████
▄████▀████▀███████████████████████████▀██████████████████████
████
▀█
███▀▀▀██████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████████▀██████
█████
▀▀▀▀█████████████████████████████████████████▀▀▀▀▀▀▀▀▀▀▀▀▀
███████
██████████████████████████████████████████████████████████████████████
.
.. SPORTSBOOK..NEW..
.
..100% WELCOME BONUS │ NO KYC │ UP TO 15% CASHBACK....PLAY NOW...
stwenhao
Hero Member
*****
Offline Offline

Activity: 576
Merit: 1373


View Profile
January 01, 2026, 09:49:40 PM
Merited by vapourminer (4), BlackHatCoiner (4), ABCbits (2)
 #4

Quote
but it can only be true in one, because these networks use a different genesis coinbase transaction
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:
Code:
+----------+----------+------------------------------------------------------------------+----------+----------+----------+
| network  | version  | merkle root                                                      | unixtime | target   | nonce    |
+----------+----------+------------------------------------------------------------------+----------+----------+----------+
| mainnet  | 01000000 | 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a | 29ab5f49 | ffff001d | 1dac2b7c |
| testnet3 | 01000000 | 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a | dae5494d | ffff001d | 1aa4ae18 |
| signet   | 01000000 | 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a | 008f4d5f | ae77031e | 8ad22203 |
| testnet4 | 01000000 | 4e7b2b9128fe0291db0693af2ae418b767e657cd407e80cb1434221eaea7a07a | 046f3566 | ffff001d | bb0c7817 |
+----------+----------+------------------------------------------------------------------+----------+----------+----------+
After decoding timestamps, we get:
Code:
+----------+------------+------------+------------------------------+
| network  | endian32   | hex2dec    | unixtime                     |
+----------+------------+------------+------------------------------+
| mainnet  | 0x495fab29 | 1231006505 | Sat Jan 03 18:15:05 2009 UTC |
| testnet3 | 0x4d49e5da | 1296688602 | Wed Feb 02 23:16:42 2011 UTC |
| signet   | 0x5f4d8f00 | 1598918400 | Tue Sep 01 00:00:00 2020 UTC |
| testnet4 | 0x66356f04 | 1714777860 | Fri May 03 23:11:00 2024 UTC |
+----------+------------+------------+------------------------------+
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.

Proof of Work puzzle in mainnet, testnet4 and signet.
Eze BTC
Newbie
*
Offline Offline

Activity: 24
Merit: 1


View Profile
January 02, 2026, 01:31:03 PM
 #5

Why are all the `genesis.hashMerkleRoot` values ​​the same in the Bitcoin network, yet the `consensus.hashGenesisBlock` values ​​printed are different? How is this implemented?

They all contain same transaction, which is the coin base. That's a reason why they are same.

The difference in consensus.hashGenesisBlock values printed is attributed to the block header fields that are differently set for each block chain.
Eze BTC
Newbie
*
Offline Offline

Activity: 24
Merit: 1


View Profile
January 02, 2026, 06:02:34 PM
 #6

Why are all the `genesis.hashMerkleRoot` values ​​the same in the Bitcoin network, yet the `consensus.hashGenesisBlock` values ​​printed are different? How is this implemented?
The Merkle root is the same because the genesis block contains the same single coinbase transaction on all Bitcoin networks. Since the Merkle root is derived only from the transactions, it does not change.

What differs is the block header. Each network (mainnet, testnet, regtest, signet) uses different values for fields like nTime, nBits, and nNonce. These header differences produce different block hashes, which is why consensus.hashGenesisBlock is not the same.

In Bitcoin Core, this is handled by creating the same transaction and Merkle root, then varying the header parameters when constructing the genesis block for each network.


You're on point. The block header fields such as the nTime, nBits, etc. are what changes accross mainnet, testnet, regtest and signet. The effect of this is the genesis block hashes. Also, the difference in hashes are what enforce separation of networks.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!