From e58275b3b842109338a031f5d0ff69be44dfe987 Mon Sep 17 00:00:00 2001 From: argfamobile Date: Thu, 20 Aug 2026 19:27:52 -0400 Subject: [PATCH] Fix genesis blocks for testnet, testnet4, signet and regtest The genesis parameters for all four test networks were still Bitcoins, while BTGS uses its own timestamp message: "The Times 31/Mar/2026 BTGSG Chancellor on brink of second bailout for banks" A different message means a different coinbase, a different merkle root and therefore a different block hash, so Bitcoins nonces no longer satisfy the proof of work for these chains. The node writes the genesis block and then fails to read it back: [error] Errors in block header at FlatFilePos(nFile=0, nPos=8) while reading block [error] A fatal internal error occurred: Failed to read block. [error] Failed to connect best block (Failed to read block.) This is why -regtest, -testnet and -signet could not start at all. testnet4 did start, but only because it kept Bitcoins message and script verbatim, so its genesis was literally Bitcoins testnet4 genesis rather than a BTGS one. Mined new nonces for the four networks using the BTGS genesis message, so each chain now has its own genesis: testnet nTime 1296688603 nonce 640026520 testnet4 nTime 1714777861 nonce 453240970 signet nTime 1598918400 nonce 8705482 regtest nTime 1296688602 nonce 0 testnet4 now uses the standard CreateGenesisBlock overload with the BTGS message, replacing the inherited Bitcoin message and script. Re-enabled the eight hashGenesisBlock and hashMerkleRoot asserts that were commented out in these four networks. Those asserts are what would have caught this on the first run: mainnet has them active and mainnet is correct. With them commented out the node accepted a genesis block that does not meet its own proof of work, and the failure only surfaced later as a block read error, which points at the wrong place. Mainnet is not touched. Its genesis, its nonce and its asserts are unchanged. Verified by building from this commit and starting the node on all five networks: mainnet 0000000d1c5a497963a46c0348cb4346779c52d9e1d7cc8b5efb1be0a4a0f964 testnet 00000000dec2f478c7277b937818c3ad7515ce9ca7c9a5f8f6345e5c18f78381 testnet4 000000001d07bb1394fd589dbd041c1618cde63ba6d611e7b1f0c82678f58697 signet 000002e46f9760f1d878dab0735f04a592c8d4bcdb6bfcd9c7b321f54e2e8ba7 regtest 7bb66a7fba8df679c927b239aa09d5f40ce6600eb8aea11b915bb7844517969a Also mined 101 blocks on regtest and confirmed the coinbase matures, which means the functional test suite in test/functional/ can run for the first time. --- src/kernel/chainparams.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index e717835..5a1e97f 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -205,10 +205,10 @@ class CTestNetParams : public CChainParams { m_assumed_blockchain_size = 240; m_assumed_chain_state_size = 19; - genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN); + genesis = CreateGenesisBlock(1296688603, 640026520, 0x1d00ffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); - //assert(consensus.hashGenesisBlock == uint256{"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"}); - //assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"}); + assert(consensus.hashGenesisBlock == uint256{"00000000dec2f478c7277b937818c3ad7515ce9ca7c9a5f8f6345e5c18f78381"}); + assert(genesis.hashMerkleRoot == uint256{"9349824da96d7c3c2a9e8a5ab54b61e14df2c77788b0b25aaa178545362bebc8"}); vFixedSeeds.clear(); vSeeds.clear(); @@ -301,18 +301,10 @@ class CTestNet4Params : public CChainParams { m_assumed_blockchain_size = 22; m_assumed_chain_state_size = 2; - const char* testnet4_genesis_msg = "03/May/2024 000000000000000000001ebd58c244970b3aa9d783bb001011fbe8ea8e98e00e"; - const CScript testnet4_genesis_script = CScript() << "000000000000000000000000000000000000000000000000000000000000000000"_hex << OP_CHECKSIG; - genesis = CreateGenesisBlock(testnet4_genesis_msg, - testnet4_genesis_script, - 1714777860, - 393743547, - 0x1d00ffff, - 1, - 50 * COIN); + genesis = CreateGenesisBlock(1714777861, 453240970, 0x1d00ffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); - //assert(consensus.hashGenesisBlock == uint256{"00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"}); - //assert(genesis.hashMerkleRoot == uint256{"7aa0a7ae1e223414cb807e40cd57e667b718e42aaf9306db9102fe28912b7b4e"}); + assert(consensus.hashGenesisBlock == uint256{"000000001d07bb1394fd589dbd041c1618cde63ba6d611e7b1f0c82678f58697"}); + assert(genesis.hashMerkleRoot == uint256{"9349824da96d7c3c2a9e8a5ab54b61e14df2c77788b0b25aaa178545362bebc8"}); vFixedSeeds.clear(); vSeeds.clear(); @@ -437,10 +429,10 @@ class SigNetParams : public CChainParams { nDefaultPort = 38333; nPruneAfterHeight = 1000; - genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN); + genesis = CreateGenesisBlock(1598918400, 8705482, 0x1e0377ae, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); - //assert(consensus.hashGenesisBlock == uint256{"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"}); - //assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"}); + assert(consensus.hashGenesisBlock == uint256{"000002e46f9760f1d878dab0735f04a592c8d4bcdb6bfcd9c7b321f54e2e8ba7"}); + assert(genesis.hashMerkleRoot == uint256{"9349824da96d7c3c2a9e8a5ab54b61e14df2c77788b0b25aaa178545362bebc8"}); m_assumeutxo_data = { { @@ -543,10 +535,10 @@ class CRegTestParams : public CChainParams consensus.vDeployments[deployment_pos].min_activation_height = version_bits_params.min_activation_height; } - genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN); + genesis = CreateGenesisBlock(1296688602, 0, 0x207fffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); - //assert(consensus.hashGenesisBlock == uint256{"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"}); - //assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"}); + assert(consensus.hashGenesisBlock == uint256{"7bb66a7fba8df679c927b239aa09d5f40ce6600eb8aea11b915bb7844517969a"}); + assert(genesis.hashMerkleRoot == uint256{"9349824da96d7c3c2a9e8a5ab54b61e14df2c77788b0b25aaa178545362bebc8"}); vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds. vSeeds.clear();