Skip to content

Commit

Permalink
update chain params to use new Genesis / Merkle hash
Browse files Browse the repository at this point in the history
  • Loading branch information
toolboc committed Dec 22, 2017
1 parent a86732b commit 1150d94
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
*/
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";
const char* pszTimestamp = "BBC NEWS 20/Dec/2017 Bitcoin Cash deals frozen as insider trading is probed";
const CScript genesisOutputScript = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
Expand Down Expand Up @@ -118,10 +118,10 @@ class CMainParams : public CChainParams {
nDefaultPort = 9333;
nPruneAfterHeight = 100000;

genesis = CreateGenesisBlock(1317972665, 2084524493, 0x1e0ffff0, 1, 50 * COIN);
genesis = CreateGenesisBlock(1513784917, 2084820399, 0x1e0ffff0, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"));
assert(genesis.hashMerkleRoot == uint256S("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9"));
assert(consensus.hashGenesisBlock == uint256S("0xee686214586277080977cf43d2a0b38bcd48d696129b19c026d8208f9e745cea"));
assert(genesis.hashMerkleRoot == uint256S("0x805d8d176abe872f5cd40b558869a0d25ed02ae471fa33f80185443e5ca9cb40"));

// Note that of those with the service bits flag, most only support a subset of possible options
vSeeds.emplace_back("seed-a.faithcoin.loshan.co.uk", true);
Expand All @@ -145,6 +145,8 @@ class CMainParams : public CChainParams {

checkpointData = (CCheckpointData) {
{
{ 0, uint256S("0xee686214586277080977cf43d2a0b38bcd48d696129b19c026d8208f9e745cea")},
/*
{ 1500, uint256S("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967")},
{ 4032, uint256S("0x9ce90e427198fc0ef05e5905ce3503725b80e26afd35a987965fd7e3d9cf0846")},
{ 8064, uint256S("0xeb984353fc5190f210651f150c40b8a4bab9eeeff0b729fcb3987da694430d70")},
Expand All @@ -161,15 +163,16 @@ class CMainParams : public CChainParams {
{456000, uint256S("0xbf34f71cc6366cd487930d06be22f897e34ca6a40501ac7d401be32456372004")},
{638902, uint256S("0x15238656e8ec63d28de29a8c75fcf3a5819afc953dcd9cc45cecc53baec74f38")},
{721000, uint256S("0x198a7b4de1df9478e2463bd99d75b714eab235a2e63e741641dc8a759a9840e5")},
*/
}
};

chainTxData = ChainTxData{
// Data as of block db42d00d824950a125f9b08b6b6c282c484781562fa8b3bd29d6ce4a2627c348 (height 1259851).
1502955334, // * UNIX timestamp of last known number of transactions
11428845, // * total number of transactions between genesis and that timestamp
1513784917, // * UNIX timestamp of last known number of transactions
0, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0.06 // * estimated number of transactions per second after that timestamp
0.0 // * estimated number of transactions per second after that timestamp
};
}
};
Expand Down

15 comments on commit 1150d94

@jamiekeefer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the chainparams.cpp there are other instances of the checkpoint data (litecoin version 17)

checkpointData = { { { 1500, uint256S("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967")}, { 4032, uint256S("0x9ce90e427198fc0ef05e5905ce3503725b80e26afd35a987965fd7e3d9cf0846")}, { 8064, uint256S("0xeb984353fc5190f210651f150c40b8a4bab9eeeff0b729fcb3987da694430d70")}, { 16128, uint256S("0x602edf1859b7f9a6af809f1d9b0e6cb66fdc1d4d9dcd7a4bec03e12a1ccd153d")}, { 23420, uint256S("0xd80fdf9ca81afd0bd2b2a90ac3a9fe547da58f2530ec874e978fce0b5101b507")}, { 50000, uint256S("0x69dc37eb029b68f075a5012dcc0419c127672adb4f3a32882b2b3e71d07a20a6")}, { 80000, uint256S("0x4fcb7c02f676a300503f49c764a89955a8f920b46a8cbecb4867182ecdb2e90a")}, {120000, uint256S("0xbd9d26924f05f6daa7f0155f32828ec89e8e29cee9e7121b026a7a3552ac6131")}, {161500, uint256S("0xdbe89880474f4bb4f75c227c77ba1cdc024991123b28b8418dbbf7798471ff43")}, {179620, uint256S("0x2ad9c65c990ac00426d18e446e0fd7be2ffa69e9a7dcb28358a50b2b78b9f709")}, {240000, uint256S("0x7140d1c4b4c2157ca217ee7636f24c9c73db39c4590c4e6eab2e3ea1555088aa")}, {383640, uint256S("0x2b6809f094a9215bafc65eb3f110a35127a34be94b7d0590a096c3f126c6f364")}, {409004, uint256S("0x487518d663d9f1fa08611d9395ad74d982b667fbdc0e77e9cf39b4f1355908a3")}, {456000, uint256S("0xbf34f71cc6366cd487930d06be22f897e34ca6a40501ac7d401be32456372004")}, {638902, uint256S("0x15238656e8ec63d28de29a8c75fcf3a5819afc953dcd9cc45cecc53baec74f38")}, {721000, uint256S("0x198a7b4de1df9478e2463bd99d75b714eab235a2e63e741641dc8a759a9840e5")}, } };

and

   checkpointData = {
        {
            {0, uint256S("530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9")},
        }
    };

are these okay to leave as is?

Thanks for the guide, btw!

@toolboc
Copy link
Owner Author

@toolboc toolboc commented on 1150d94 Jun 12, 2019 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamiekeefer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you toolboc.

I have build the Cryptocurrency using your guide. Thank you very much.

I will be sure to comment out all the checkpoint data.

All the best to you for taking the time to share your experience.

@bashirk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm trying to produce the Genesis Block and Merkle Root for faithcoin, but the GenesisH0 script is outdated, shows me alot of errors. Please, is there any other way I can fix this? Probably by a similar script, please

@toolboc
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bashirk , it sounds like the issue is with the GenesisH0 script, you may want to file an issue on lhartikk's repo.

@bashirk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for the feedback, @toolboc. But the script seems to be unmaintained, as there are related issues that are still open. Is there any other script you could recommend?

I came across genesis-block, But it seems to be unmaintained too :(

@jbencina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bashirk - It looks like the GenesisH0 script is written for Python 2. The code change is relatively straight forward, but as of this comment someone has opened a PR to fix it lhartikk/GenesisH0#48. Given the simple nature of the script you can probably just fork the repo or copy/paste this PR locally.

@sovrinbloc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Python && pip (apt-get install -qq python python-pip) and it worked like that. Do not use python3 or pip3.

@mudra-project
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created new genesis but getting some issues like

Assertion failed!

Program: \usr\src\aa\mudracoin\src\mudracoin-tx.exe
File: chainparams.cpp, Line 124

Expression: consensus.hashGenesisBlock == uint256S("0x45154a058474c37337bacff3868b61a4bfa9be5c11c0baaeb6264ecf06b79532")

I don't know what I am doing wrong or my genesis code are wrong. PLEASE check my repository. let me know that error

@sovrinbloc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me a lot of the time it was my checkpoint data that threw that error.

The RegTest doesn't need to be altered really.

Basically what it's saying to you is: "With the numbers you've provided me in chainparams.cpp, I can't come up with the same numbers as you." Which means you've filled out some of the numbers incorrectly. The assertions take your input numbers in chainparams, and perform a calculation to see if they get the same outputs as you. So either you missed some data, forgot to replace the BIP data, the checkpoints, or something else on that page generally.

Also, in src/qt/test/rpcnestedtests.cpp is a merkle you need to replace as well.

@mudra-project
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be right. I think that because of I didn't put Time and Nonce at same while creating genesis. Let me try this work again.

@mudra-project
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but still same. no luck I tried doing it ....
root@DESKTOP-0HJLS87:/usr/src/newupdate/GenesisH0# python genesis.py -a scrypt -z "I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times." -p "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f" -t 1624379279 -n 351450
04ffff001d01044c73492066656172206e6f7420746865206d616e2077686f20686173207072616374696365642031302c303030206b69636b73206f6e63652c206275742049206665617220746865206d616e2077686f2068617320707261637469636564206f6e65206b69636b2031302c3030302074696d65732e
algorithm: scrypt
merkle hash: 28c32c327942d1d95e8c59eda8914c1d57089593ac5a06750f362ee8d0c0eeed
pszTimestamp: I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
pubkey: 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
time: 1624379279
bits: 0x1e0ffff0
Searching for genesis hash..
genesis hash found!
nonce: 351450
genesis hash: 45154a058474c37337bacff3868b61a4bfa9be5c11c0baaeb6264ecf06b79532

I put it same in Chainparams

    genesis = CreateGenesisBlock(1624379279, 351450, 0x1e0ffff0, 1, 50 * COIN);
    consensus.hashGenesisBlock = genesis.GetHash();
    assert(consensus.hashGenesisBlock == uint256S("0x45154a058474c37337bacff3868b61a4bfa9be5c11c0baaeb6264ecf06b79532"));
    assert(genesis.hashMerkleRoot == uint256S("0x28c32c327942d1d95e8c59eda8914c1d57089593ac5a06750f362ee8d0c0eeed"));

why it look like i get less count of nonce number.

@sovrinbloc
Copy link

@sovrinbloc sovrinbloc commented on 1150d94 Jun 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but still same. no luck I tried doing it ....
root@DESKTOP-0HJLS87:/usr/src/newupdate/GenesisH0# python genesis.py -a scrypt -z "I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times." -p "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f" -t 1624379279 -n 351450
04ffff001d01044c73492066656172206e6f7420746865206d616e2077686f20686173207072616374696365642031302c303030206b69636b73206f6e63652c206275742049206665617220746865206d616e2077686f2068617320707261637469636564206f6e65206b69636b2031302c3030302074696d65732e
algorithm: scrypt
merkle hash: 28c32c327942d1d95e8c59eda8914c1d57089593ac5a06750f362ee8d0c0eeed
pszTimestamp: I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
pubkey: 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
time: 1624379279
bits: 0x1e0ffff0
Searching for genesis hash..
genesis hash found!
nonce: 351450
genesis hash: 45154a058474c37337bacff3868b61a4bfa9be5c11c0baaeb6264ecf06b79532

I put it same in Chainparams

    genesis = CreateGenesisBlock(1624379279, 351450, 0x1e0ffff0, 1, 50 * COIN);
    consensus.hashGenesisBlock = genesis.GetHash();
    assert(consensus.hashGenesisBlock == uint256S("0x45154a058474c37337bacff3868b61a4bfa9be5c11c0baaeb6264ecf06b79532"));
    assert(genesis.hashMerkleRoot == uint256S("0x28c32c327942d1d95e8c59eda8914c1d57089593ac5a06750f362ee8d0c0eeed"));

why it look like i get less count of nonce number.

There are many more that you have to replace in that file. You need to replace the checkpoint data. Almost all of those hashes throughout the entire source code need to be modified. Also, the address hexes need to be modified too. I don't have the file in front of me but there are many more than you have replaced in that file. And it's also not at simple as search and replace. Some of the items you have to replace are not SEARCH & Replaceable, because they have alternate values. The checkpoint data means that after so many blocks, it creates a new checkpoint. Which means it's not the same repetitive search&replace data.

consensus.BIP34Hash needs to be replaced with your values.

consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE; // January 1, 2008
        consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; // December 31, 2008 // works ja

        // Deployment of BIP68, BIP112, and BIP113.
        consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
        consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE; // January 28, 2017
        consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; // January 31st, 2018

        // Deployment of SegWit (BIP141, BIP143, and BIP147)
        consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
        consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE; // January 28, 2017
        consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; // January 31st, 2018

consensus.defaultAssumeValid = uint256S("0xREPLACE WITH YOUR HASH VALUE");

checkpointData = {
            {
                { 0, uint256S("0xREPLACE WITH YOUR HASH")},
            }
        };
chainTxData = ChainTxData{
            // Data from rpc: getchaintxstats 4096 2cdba8c47858d34cf0e02dfb8733263a3ed8705b1663ec7c158783d77b93e7ee
            /* nTime    */ REPLACR WITH YOUR TIMESTAMP,
            /* nTxCount */ 0,
            /* dTxRate  */ 0
        };

Finally, make sure your base58Prefixes are not rubbish, as that will also account for messing up the compile. Trust me on this all, I spent a week doing this :)

I think that's all, but you have to repeat for the TestNet too. Not RegTest, if I remember properly. That may not be all. I'm not 100% sure that's all. Also, did you create the testnet genesis hash and the regtest hash values as well? Anyway, I think that's about all I can guide you on. Good luck!

@mudra-project
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks that's lot of info.. I found what I was doing wrong. I was making Genesis algorithm: scrypt instead of algorithm: sha256. I won't give up this easy. πŸ‘

@PeterAlfonsLoch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks that's lot of info.. I found what I was doing wrong. I was making Genesis algorithm: scrypt instead of algorithm: sha256. I won't give up this easy. πŸ‘

You used python genesis.py -a SHA256 -z.... and that worked? would be great to get more info to your solution so others, like me have a fix.

Please sign in to comment.