Title: Change genesis block, regtest mining fail Post by: victorkimba17 on August 06, 2018, 02:22:22 AM after i change genesis block in chainparams.cpp, i do mining in regtest mode.
Quote $ bitcoin-cli -datadir=../datadir2/ generate 101 the return result is empty. However, i can see new blocks created in debug.log[ ] Quote CreateNewBlock(): block weight: 900 txs: 0 fees: 0 sigops 400 2018-08-02 08:15:24 nProofOfWorkLimit = 545259519 before bounds 2018-08-02 08:15:24 nProofOfWorkLimit = 545259519 before bounds 2018-08-02 08:15:24 nProofOfWorkLimit = 545259519 before bounds i found out the reason , in regtest mode, after changing the genesis block, in bitcoin core mining.cpp, generateBlocks() call CheckProofOfWork(), the parameter passed to the function, includes hash value of block, so in CheckProofOfWork() , the line `if (UintToArith256(hash) > bnTarget)` is fulfilled and returns false, so mining fails. Why changing of genesis block causing mining to fail in regtest ? Title: Re: Change genesis block, regtest mining fail Post by: achow101 on August 06, 2018, 04:33:44 AM Because the genesis block actually has to be mined. It must have a valid proof of work, you cannot just make a genesis block that fails the consensus rules (except for the prevblock rule).
Title: Re: Change genesis block, regtest mining fail Post by: victorkimba17 on August 06, 2018, 05:39:41 AM Because the genesis block actually has to be mined. It must have a valid proof of work, you cannot just make a genesis block that fails the consensus rules (except for the prevblock rule). I used the program genesisgen to mine the genesis block , and put the information , such as, nBits, nonce , unix time , into CreateGenesisBlock() function. May i know what is still missing ? Title: Re: Change genesis block, regtest mining fail Post by: TheArchaeologist on August 06, 2018, 07:14:38 AM You could always compare your generated block with the actual genesis block:
Code: 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000 Or when looking for specific values in a human readable fornat: Code: { Title: Re: Change genesis block, regtest mining fail Post by: victorkimba17 on August 06, 2018, 08:58:58 AM You could always compare your generated block with the actual genesis block: May i know how to compare the generated block to actual genesis block? Comparing the hash of the block?Code: 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000 Quote Or when looking for specific values in a human readable fornat: what is the command to generate the info above?Code: { Title: Re: Change genesis block, regtest mining fail Post by: victorkimba17 on August 06, 2018, 01:14:38 PM i generate the unix time, nonce from scratch, for regtest , now mining is working.
previously, i re-use the unix time, nonce that are generated for mainnet , in regtest. For that, mining wasn't working |