Bitcoin Forum
May 09, 2024, 10:20:52 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to create unique genesis block?  (Read 196 times)
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 15, 2018, 03:30:28 PM
 #1

I am researching bitcoin/litecoin source.

I am trying to revise and start new block, create genesis block.

So I changed genesisOutputScript variable at chainparams.cpp  52 line, via [ cat genesiscoinbase.hex ]

and then changed below line's source like following..


Code:
pchMessageStart[2] = 0xb1;
        pchMessageStart[3] = 0xde;
        nDefaultPort = 2454;
        nPruneAfterHeight = 100000;

        genesis = CreateGenesisBlock(1518706741, 2084524493, 0x1e0ffff0, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
printf("genesis.GetHash = %s\n", genesis.GetHash().ToString().c_str());
printf("genesis.hashMerkleRoot = %s\n", genesis.hashMerkleRoot.ToString().c_str());
        assert(consensus.hashGenesisBlock == uint256S("0xf333b8dff21df2ec0034590afa921a09e43ff41c5c8e5ac10cd83bf17615554d"));
        assert(genesis.hashMerkleRoot == uint256S("0xc4ef14392acd1d6123ab6b4497601f2a164e50f5da77903dc7e2ad1a8fa25f2d"));

        // Note that of those with the service bits flag, most only support a subset of possible options
        vSeeds.emplace_back("something.something.com", true);

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 55);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 55);
        base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1, 55);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,176);
        base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
        base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};

        vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));

        fDefaultConsistencyChecks = false;
        fRequireStandard = true;
        fMineBlocksOnDemand = false;

        checkpointData = (CCheckpointData) {
            {
                {  0, uint256S("0x001")},
            }
        };

        chainTxData = ChainTxData{
            // Data as of block 59c9b9d3fec105bdc716d84caa7579503d5b05b73618d0bf2d5fa639f780a011 (height 1353397).
            1518706741, // * 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
        };

but after compile this with 'make' , then run ./litecoind  ,
error says,

genesis.GetHash = f333b8dff21df2ec0034590afa921a09e43ff41c5c8e5ac10cd83bf17615554d
genesis.hashMerkleRoot = c4ef14392acd1d6123ab6b4497601f2a164e50f5da77903dc7e2ad1a8fa25f2d
Error: Error: A fatal internal error occurred, see debug.log for details
Segmentation fault (core dumped)


and here is debug.log file says,

2018-02-15 15:23:10 Litecoin version v0.15.1.0-845fc69ab-dirty
2018-02-15 15:23:10 InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2018-02-15 15:23:10 Assuming ancestors of block 59c9b9d3fec105bdc716d84caa7579503d5b05b73618d0bf2d5fa639f780a011 have valid signatures.
2018-02-15 15:23:10 Setting nMinimumChainWork=00000000000000000000000000000000000000000000002ebcfe2dd9eff82666
2018-02-15 15:23:10 Using the 'standard' SHA256 implementation
2018-02-15 15:23:10 Using RdRand as an additional entropy source
2018-02-15 15:23:10 Default data directory /home/ubuntu/.litecoin
2018-02-15 15:23:10 Using data directory /home/ubuntu/.litecoin
2018-02-15 15:23:10 Using config file /home/ubuntu/.litecoin/litecoin.conf
2018-02-15 15:23:10 Using at most 125 automatic connections (1024 file descriptors available)
2018-02-15 15:23:10 Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2018-02-15 15:23:10 Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2018-02-15 15:23:10 Using 4 threads for script verification
2018-02-15 15:23:10 scheduler thread start
2018-02-15 15:23:10 HTTP: creating work queue of depth 16
2018-02-15 15:23:10 No rpcpassword set - using random cookie authentication
2018-02-15 15:23:10 Generated RPC authentication cookie /home/ubuntu/.litecoin/.cookie
2018-02-15 15:23:10 HTTP: starting 4 worker threads
2018-02-15 15:23:10 init message: Verifying wallet(s)...
2018-02-15 15:23:10 Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2018-02-15 15:23:10 Using wallet wallet.dat
2018-02-15 15:23:10 CDBEnv::Open: LogDir=/home/ubuntu/.litecoin/database ErrorFile=/home/ubuntu/.litecoin/db.log
2018-02-15 15:23:10 Cache configuration:
2018-02-15 15:23:10 * Using 2.0MiB for block index database
2018-02-15 15:23:10 * Using 8.0MiB for chain state database
2018-02-15 15:23:10 * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
2018-02-15 15:23:10 init message: Loading block index...
2018-02-15 15:23:10 Opening LevelDB in /home/ubuntu/.litecoin/blocks/index
2018-02-15 15:23:10 Opened LevelDB successfully
2018-02-15 15:23:10 Using obfuscation key for /home/ubuntu/.litecoin/blocks/index: 0000000000000000
2018-02-15 15:23:10 LoadBlockIndexDB: last block file = 0
2018-02-15 15:23:10 LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)
2018-02-15 15:23:10 Checking all blk files are present...
2018-02-15 15:23:10 LoadBlockIndexDB: transaction index disabled
2018-02-15 15:23:10 Initializing databases...
2018-02-15 15:23:10 Pre-allocating up to position 0x1000000 in blk00000.dat
2018-02-15 15:23:10 Opening LevelDB in /home/ubuntu/.litecoin/chainstate
2018-02-15 15:23:10 Opened LevelDB successfully
2018-02-15 15:23:10 Wrote new obfuscate key for /home/ubuntu/.litecoin/chainstate: 926d8d907f958c5b
2018-02-15 15:23:10 Using obfuscation key for /home/ubuntu/.litecoin/chainstate: 926d8d907f958c5b
2018-02-15 15:23:10 init message: Rewinding blocks...
2018-02-15 15:23:10  block index              18ms
2018-02-15 15:23:10 init message: Loading wallet...
2018-02-15 15:23:10 nFileVersion = 150100
2018-02-15 15:23:10 Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total
2018-02-15 15:23:10 Performing wallet upgrade to 60000
2018-02-15 15:23:10 keypool added 2000 keys (1000 internal), size=2000 (1000 internal)
2018-02-15 15:23:10 keypool reserve 1
2018-02-15 15:23:10 keypool keep 1
2018-02-15 15:23:10  wallet                  738ms
2018-02-15 15:23:10 keypool added 1 keys (0 internal), size=2000 (1000 internal)
2018-02-15 15:23:10 setKeyPool.size() = 2000
2018-02-15 15:23:10 mapWallet.size() = 0
2018-02-15 15:23:10 mapAddressBook.size() = 1
2018-02-15 15:23:10 ERROR: ReadBlockFromDisk: Errors in block header at CBlockDiskPos(nFile=0, nPos=8)
2018-02-15 15:23:10 *** Failed to read block
2018-02-15 15:23:10 Error: Error: A fatal internal error occurred, see debug.log for details


So what is the problem? What am I missing? How to fix and can make my own genesis block?

Thanks.
1715250052
Hero Member
*
Offline Offline

Posts: 1715250052

View Profile Personal Message (Offline)

Ignore
1715250052
Reply with quote  #2

1715250052
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715250052
Hero Member
*
Offline Offline

Posts: 1715250052

View Profile Personal Message (Offline)

Ignore
1715250052
Reply with quote  #2

1715250052
Report to moderator
1715250052
Hero Member
*
Offline Offline

Posts: 1715250052

View Profile Personal Message (Offline)

Ignore
1715250052
Reply with quote  #2

1715250052
Report to moderator
1715250052
Hero Member
*
Offline Offline

Posts: 1715250052

View Profile Personal Message (Offline)

Ignore
1715250052
Reply with quote  #2

1715250052
Report to moderator
Naruby
Newbie
*
Offline Offline

Activity: 25
Merit: 0


View Profile
February 15, 2018, 04:53:37 PM
 #2

1) Use https://github.com/lhartikk/GenesisH0 to generat the merkle and Genesis hash & nonce
2) fill in this values & recompile
3) delete previous chain data
4) run Forest run!
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 16, 2018, 06:13:13 AM
Last edit: February 16, 2018, 10:37:26 AM by wsxdrfv
 #3

1) Use https://github.com/lhartikk/GenesisH0 to generat the merkle and Genesis hash & nonce
2) fill in this values & recompile
3) delete previous chain data
4) run Forest run!
Thanks, but when I typed 'sudo pip install....' at terminal, system says [sudo : pip : command not found ] ....

Why unix system so complicated... really frustrating...


So I install python, then typed [ python genesis.py -a scrypt -z "Now is 2018" ]

Then error says

File "genesis.py", line 2, in <module> import scrypt
ImportError : No modile named scrypt

wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 16, 2018, 11:23:12 AM
Last edit: February 16, 2018, 02:31:25 PM by wsxdrfv
 #4

so it should first install python package before install scrypt.

anyway, I succeedeed run python genesis.py -a scrypt -z "Now is 2018-xx-xx."

and bunch of values generated. 
G14tz87
Full Member
***
Offline Offline

Activity: 321
Merit: 100



View Profile
February 16, 2018, 01:34:56 PM
 #5

By way of Implementing Search Engine Optimization, In addition, now Genesis supports Schema.org code, which lets you generate microdata in your site code. This improves your site's SEO (Search Engine Optimization) further - as does Google Authorship identification, which makes Genesis very simple. Genesis Framework has always handled the basics about SEO that's good for you, like light code for fast performance, and now even better.
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 16, 2018, 02:34:05 PM
 #6

What code should be for new source?

I found 2 codes for generate genesis block, but both fails with new source.

Here are 2.

Code:
hashGenesisBlock = uint256("0x01")
if (true && genesis.GetHash() != hashGenesisBlock)
        {
            Logprintf("recalculating params for mainnet.\n");
            Logprintf("old mainnet genesis nonce: %s\n", genesis.nNonce.ToString().c_str());
            Logprintf("old mainnet genesis hash:  %s\n", hashGenesisBlock.ToString().c_str());
            // deliberately empty for loop finds nonce value.
            for(genesis.nNonce == 0; genesis.GetHash() > bnProofOfWorkLimit; genesis.nNonce++){ }
            Logprintf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str());
            Logprintf("new mainnet genesis nonce: %s\n", genesis.nNonce.ToString().c_str());
            Logprintf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str());
        }

Code:
if (false && block.GetHash() != hashGenesisBlock)
        {
            printf("Searching for genesis block...\n");
            // This will figure out a valid hash and Nonce if you're
            // creating a different genesis block:
            uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();
            uint256 thash;
            char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
 
            loop
            {
#if defined(USE_SSE2)
                // Detection would work, but in cases where we KNOW it always has SSE2,
                // it is faster to use directly than to use a function pointer or conditional.
#if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__))
                // Always SSE2: x86_64 or Intel MacOS X
                scrypt_1024_1_1_256_sp_sse2(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
#else
                // Detect SSE2: 32bit x86 Linux or Windows
                scrypt_1024_1_1_256_sp(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
#endif
#else
                // Generic scrypt
                scrypt_1024_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
#endif
                if (thash <= hashTarget)
                    break;
                if ((block.nNonce & 0xFFF) == 0)
                {
                    printf("nonce %08X: hash = %s (target = %s)\n", block.nNonce, thash.ToString().c_str(), hashTarget.ToString().c_str());
                }
                ++block.nNonce;
                if (block.nNonce == 0)
                {
                    printf("NONCE WRAPPED, incrementing time\n");
                    ++block.nTime;
                }
            }
            printf("block.nTime = %u \n", block.nTime);
            printf("block.nNonce = %u \n", block.nNonce);
            printf("block.GetHash = %s\n", block.GetHash().ToString().c_str());
        }

1st is based on bitcoin 0.10

2nd is based on litecoin 0.8

So how code should be revised and positioned to use for new source? (0.15~)
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 17, 2018, 06:45:35 AM
 #7

So now I deleted all codes above (older code of create genesis block), now maintaining only these.

Code:
pchMessageStart[3] = 0xd3;
        nDefaultPort = 9333;
        nPruneAfterHeight = 100000;

        genesis = CreateGenesisBlock(1518778737, 1710046, 0x1e0ffff0, 1, 250 * COIN);
        //consensus.hashGenesisBlock = genesis.GetHash();
 
        assert(consensus.hashGenesisBlock == uint256S("0x0d357190f429e82365d6984079f3e3fc53877f4933ff2e8ba827a29c105a661e"));
        assert(genesis.hashMerkleRoot == uint256S("0xb7c1c74cb0c35b995bef99ccc9c4eb98dc688d97e5826a1740119fe9fa257770"));

        // Note that of those with the service bits flag, most only support a subset of possible options
        vSeeds.emplace_back("wsxdrvps.cafe24.com", true);

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,33);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,90);
        base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1,50);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,130);
        base58Prefixes[EXT_PUBLIC_KEY] = {0x02, 0x88, 0xB3, 0x1F};
        base58Prefixes[EXT_SECRET_KEY] = {0x02, 0x88, 0xAB, 0xE3};

        vFixedSeeds.clear();

        fDefaultConsistencyChecks = false;
        fRequireStandard = true;
        fMineBlocksOnDemand = false;

        checkpointData = (CCheckpointData) {
            {
                {  0, uint256S("0x001")},
            }
        };

        chainTxData = ChainTxData{
            // Data as of block 59c9b9d3fec105bdc716d84caa7579503d5b05b73618d0bf2d5fa639f780a011 (height 1353397).
            1518692559, // * 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
        };

almost same with original.

And typed 'make', and run './litecoind   
But here is result.

-----------
ubuntu@ubuntu-VirtualBox:~/Desktop/litecoin/src$ ./litecoind
litecoind: chainparams.cpp:126: CMainParams::CMainParams(): Assertion `consensus.hashGenesisBlock == uint256S("0x0d357190f429e82365d6984079f3e3fc53877f4933ff2e8ba827a29c105a661e")' failed.
Aborted (core dumped)
-------------

Now what shoud I do?
Thanks in advance.
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 17, 2018, 11:20:02 AM
 #8

1) Use https://github.com/lhartikk/GenesisH0 to generat the merkle and Genesis hash & nonce
2) fill in this values & recompile
3) delete previous chain data
4) run Forest run!
I did and run ./litecoind but it says  

litecoind: chainparams.cpp:168: CMainParams::CMainParams(): Assertion 'consensus.hashGenesisBlock == unit256s("0xfdjlkfejlfkejlfk...............")' failed.
Aborted (core dumped)



wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 17, 2018, 11:55:50 AM
 #9

1) Use https://github.com/lhartikk/GenesisH0 to generat the merkle and Genesis hash & nonce
2) fill in this values & recompile
3) delete previous chain data
4) run Forest run!
Actually, I don't know exactly whether I did is wrong or right.

from 1), What value should input? And accordingly, what value should my script should be revised?
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
February 17, 2018, 01:40:47 PM
 #10

holy.....

My ubuntu system's harddisk inside virtualbox from windows10 become full...(started 20giga )

I should enlarge the harddisk capacity for test further!

But this is incredibly hard... already googled and tried some, but failed...

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!