Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: AlexMerced on April 27, 2013, 09:03:21 PM



Title: More Genesis Block Discussion
Post by: AlexMerced on April 27, 2013, 09:03:21 PM
This is a seperate discussion from the one about how to generate a Genesis Block here:

https://bitcointalk.org/index.php?topic=187888.0

This thread I want to past the parts of the code that cover the genesis block for discussion of what the code is doing so I can better understand the process. I am using the SmallChange source code who's commit really well shows you all the edits you need to make a new Altcoin, I've been able to make all the changes except the pieces below which I am still trying to understand before I do any major tinkering (all the following snippets are found in main.cpp)...

to see the small change source edits go here: https://github.com/bfroemel/smallchange/commit/947a0fafd8d033f6f0960c4ff0748f76a3d58326

Code:
1971 	1974 	         pchMessageStart[1] = 0xc1;
1972 1975         pchMessageStart[2] = 0xb7;
1973 1976         pchMessageStart[3] = 0xdc;
1974   -        hashGenesisBlock = uint256("0xf5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f");
   1977 +        hashGenesisBlock = uint256("0xa50faf35e1dddf4a076a907fbcef6d9d1595390cdb1c818a35dae53b67ad0aa8");

In this part I guess it just relates to generating the Gblock and puting in the number there.

Code:
1992 	  	-
1993   -        // Genesis Block:
1994   -        // CBlock(hash=12a765e31ffd4059bada, PoW=0000050c34a64b415b6b, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=97ddfbbae6, nTime=1317972665, nBits=1e0ffff0, nNonce=2084524493, vtx=1)
1995   -        //   CTransaction(hash=97ddfbbae6, ver=1, vin.size=1, vout.size=1, nLockTime=0)
1996   -        //     CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d0104404e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536)
1997   -        //     CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
1998   -        //   vMerkleTree: 97ddfbbae6
1999   -
   1995 +    
   1996 +  // Genesis block:
   1997 +  // block.nTime = 1366559428
   1998 +  // block.nNonce = 2085386442
   1999 +  // block.GetHash = 384b060671f4a93948e9c168216dadb0ca2fbc54aa11c86b0345b6af1c59b2f5
   2000 +  // CBlock(hash=384b060671f4a93948e9, PoW=00000951e146b0026411, ver=1,
   2001 +  //  hashPrevBlock=00000000000000000000, hashMerkleRoot=5a2e19825b,
   2002 +  //  nTime=1366559428, nBits=1e0ffff0, nNonce=2085386442, vtx=1)
   2003 +  // CTransaction(hash=5a2e19825b, ver=1, vin.size=1, vout.size=1, nLockTime=0)
   2004 +  // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d010441746f646f3a207265706c616365207769746820736f6d657468696e67207468617420656e7375726573206e6f207072656d696e696e6720746f6f6b20706c616365)
   2005 +  // CTxOut(error)
   2006 +  // vMerkleTree: 5a2e19825b
   2007 +        


I'm assuming there are all the variables, but what is what and would I get them all from running a genesis block generating script.

Code:
  // Genesis block
-        const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";
+        const char* pszTimestamp = "todo: replace with something that ensures no premining took place";
         CTransaction txNew;
         txNew.vin.resize(1);
         txNew.vout.resize(1);
         txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
-        txNew.vout[0].nValue = 50 * COIN;
-        txNew.vout[0].scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
+        txNew.vout[0].nValue = 0;
+        txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG; // a privkey for that 'vanity' pubkey would be interesting ;)

This is the part that confuses me the most, what does the sentence have to do to it. Is the genesis block a numerical version of that phrase and they need to match?

Code:
2013 	  	-        block.nTime    = 1317972665;
   2021 +        block.nTime    = 1366559428;
2014 2022         block.nBits    = 0x1e0ffff0;
2015   -        block.nNonce   = 2084524493;
   2023 +        block.nNonce   = 2085386442;
2016 2024
2017 2025         if (fTestNet)
2018 2026         {
2019   -            block.nTime    = 1317798646;
2020   -            block.nNonce   = 385270584;
   2027 +            block.nTime    = 1366559428;
   2028 +            block.nNonce   = 386402991;
2021 2029         }
2022 2030
2023 2031         //// debug print
2024 2032         printf("%s\n", block.GetHash().ToString().c_str());
2025 2033         printf("%s\n", hashGenesisBlock.ToString().c_str());
2026 2034         printf("%s\n", block.hashMerkleRoot.ToString().c_str());
2027   -        assert(block.hashMerkleRoot == uint256("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9"));
   2035 +        assert(block.hashMerkleRoot == uint256("0x5a2e19825b4162f68602039040f1e05d9f924ff00a3aff7327ca6abd6f3279bc"));
2028 2036  


here seems to be just more plugging in of the variables from above


Title: Re: More Genesis Block Discussion
Post by: twobits on April 28, 2013, 08:10:22 AM
The phrase is hashed into the block.

It is meant to be a proof of date.   It is mean to be some fact that would not have been known before the date in it, to prove the block was made on of after that date.


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on April 28, 2013, 02:25:41 PM
Do I just change the phrase and the software will hash it, or do I need to Pre hash the text?


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on April 29, 2013, 01:15:34 PM
Quote
   1996    +  // Genesis block:
     1997    +  // block.nTime = 1366559428
     1998    +  // block.nNonce = 2085386442
     1999    +  // block.GetHash = 384b060671f4a93948e9c168216dadb0ca2fbc54aa11c86b0345b6af1c59b2f5
     2000    +  // CBlock(hash=384b060671f4a93948e9, PoW=00000951e146b0026411, ver=1,
     2001    +  //  hashPrevBlock=00000000000000000000, hashMerkleRoot=5a2e19825b,
     2002    +  //  nTime=1366559428, nBits=1e0ffff0, nNonce=2085386442, vtx=1)
     2003    +  // CTransaction(hash=5a2e19825b, ver=1, vin.size=1, vout.size=1, nLockTime=0)
     2004    +  // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d010441746f646f3a207265706c616365207769746820736f6d657468696e672074686 17420656e7375726573206e6f207072656d696e696e6720746f6f6b20706c616365)
     2005    +  // CTxOut(error)
     2006    +  // vMerkleTree: 5a2e19825b

Let me rephrase the question, of the variables above, when creating an altcoin how many of them HAVE to be changes, if they need to be changes how many of them are arbrtitrary how many need to be generated by some other process.


Title: Re: More Genesis Block Discussion
Post by: twelph on May 01, 2013, 02:08:24 AM
Bump because I would like to know this as well.


Title: Re: More Genesis Block Discussion
Post by: solracx on May 02, 2013, 01:43:23 AM
Do I just change the phrase and the software will hash it, or do I need to Pre hash the text?

Choose a date.
Change the text.
Start with nonce = 0.
Have it calculate the new block.
Get the block hash and make it the merkel root.

Done.


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 02, 2013, 02:19:33 AM
here's another quote about the same deal for peoples reference:

Quote
I got most of the coding done, it's mainly the gensis block is where I'm stuck at, if anyone would like to help pm me,

... the guy working with beertokens and WEEDS set-up a tool where anybody can create a genesis block fairly easily ... multi-coin and etc

https://bitcointalk.org/index.php?topic=24209.msg300830#msg300830 (https://bitcointalk.org/index.php?topic=24209.msg300830#msg300830)

https://github.com/sacarlson/MultiCoin/blob/master/create_new_genisis_block.txt (https://github.com/sacarlson/MultiCoin/blob/master/create_new_genisis_block.txt)


for people who need advice compiling in windows...

install openssl-1.0.1d or e, then make sure the include dir is in the build script.
For windows build you see details here:
https://bitcointalk.org/index.php?topic=149479.0



Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 02, 2013, 02:22:36 AM
Do I just change the phrase and the software will hash it, or do I need to Pre hash the text?

Choose a date.
Change the text.
Start with nonce = 0.
Have it calculate the new block.
Get the block hash and make it the merkel root.

Done.

sounds easy enough, most people discuss doing this using linux which I'm not as familiar with. Should I be ok doing this in codeblocks, basically changing the variables as you mention then building the code and running it? I also have VC++ but havn't learned how to use it yet mainly been using codeblocks so far.


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 02, 2013, 12:36:51 PM
http://www.epochconverter.com/

this will give you the epoc time for

block_nTime=


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 03, 2013, 12:29:47 PM
lightenup gave me this advice for generating a genesis block:

Quote
Well, change something in the genesis block data and observe the assertion when you start the node software.

For actual genesis block generation look at what happens after the assertion in the code:
Code:

       assert(block.hashMerkleRoot == uint256("0x5a2e19825b4162f68602039040f1e05d9f924ff00a3aff7327ca6abd6f3279bc"));

        // If genesis block hash does not match, then generate new genesis hash.
        if (false && block.GetHash() != hashGenesisBlock)
        {


So you'd need to change this if(false && ... ) to if (true && ...) s.t. the node software tries to find the genesis hash.


Concerning your previous question: you need to lookup base58. It appears that the letter S is encoded as 62 and s (smaller case S) is 63, 64 would be a T a.s.o. .. I just counted away from the original Litecoin code base where it has been an L.


So using all the other advice can someone confirm the following for me:

- Step 1 Set the nonce value to 0 and change the Timestamp to a recent headling
- change the false&& to true&&
- Compile the software
- When It attempts to find the block and see if it does not match the timestamp if will begin mining the new genesis block
- Once it does this successfully example the block.dat and get the hash
- hardcode the hash into the code
- job complete

Is this about right?


Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 05, 2013, 12:35:38 PM
What I did so far:

Change pszTimestamp to a sentence from newspaper
change block.nTime to current time

compile

run compiled source with -testnet -noirc

now u see some lines and a crash
Code:
b115383690ee67ebeef9a7e754342638cd7bbf488561998e6d1bc1ed367484f6 // Block derived from pszTimestamp
b8fa883689f099d3942ff73439d9f55d60a5e257b0d69a8f0f6ab4572ecff415 // Genesisblock (invalid cuz its already coded wrong)
bd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9 // MerkleRoot (Valid because its newly calculated

corresponding to code:
Code:
        //// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0xbd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9"));

update main.cpp with the mentioned merkleroot (it crashed because of the last assert) and run again

you should have already changed the false to true in
Code:
        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)

so it will find a genesis block for your string

after a long time you get:
Code:
nonce 003C1000: hash = e8525d8ae8a74a33dbc4b06a64c97ced84dfd29628b3e9e4197c7030cc4a09d3 (target = 00000ffff0000000000000000000000000000000000000000000000000000000)
block.nTime = 1367704866
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33
CBlock(hash=fafdbfc957ea6867a074, PoW=000000b1398554a520b5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=bd58bf217a, nTime=1367704866, nBits=1e0ffff0, nNonce=3939341, vtx=1)
  CTransaction(hash=bd58bf217a, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043741442e6e6c20342f352042657672696a64696e6773646167207a6f6e6e69672c20646161726e61206f6f6b207a6f6d657273207761726d)
    CTxOut(error)
  vMerkleTree: bd58bf217a
xx: main.cpp:2070: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed.
Aborted (core dumped)

Now you have the valid Genesisblock and nNonce:
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33

Update your code with these values and your ready to go!



Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 05, 2013, 02:25:13 PM
What I did so far:

Change pszTimestamp to a sentence from newspaper
change block.nTime to current time

compile

run compiled source with -testnet -noirc

now u see some lines and a crash
Code:
b115383690ee67ebeef9a7e754342638cd7bbf488561998e6d1bc1ed367484f6 // Block derived from pszTimestamp
b8fa883689f099d3942ff73439d9f55d60a5e257b0d69a8f0f6ab4572ecff415 // Genesisblock (invalid cuz its already coded wrong)
bd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9 // MerkleRoot (Valid because its newly calculated

corresponding to code:
Code:
        //// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0xbd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9"));

update main.cpp with the mentioned merkleroot (it crashed because of the last assert) and run again

you should have already changed the false to true in
Code:
        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)

so it will find a genesis block for your string

after a long time you get:
Code:
nonce 003C1000: hash = e8525d8ae8a74a33dbc4b06a64c97ced84dfd29628b3e9e4197c7030cc4a09d3 (target = 00000ffff0000000000000000000000000000000000000000000000000000000)
block.nTime = 1367704866
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33
CBlock(hash=fafdbfc957ea6867a074, PoW=000000b1398554a520b5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=bd58bf217a, nTime=1367704866, nBits=1e0ffff0, nNonce=3939341, vtx=1)
  CTransaction(hash=bd58bf217a, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043741442e6e6c20342f352042657672696a64696e6773646167207a6f6e6e69672c20646161726e61206f6f6b207a6f6d657273207761726d)
    CTxOut(error)
  vMerkleTree: bd58bf217a
xx: main.cpp:2070: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed.
Aborted (core dumped)

Now you have the valid Genesisblock and nNonce:
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33

Update your code with these values and your ready to go!



nice, where am I putting -testnet -noirc, is that in command line or make file?


Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 05, 2013, 03:11:24 PM
In command line..

Don't really think it matters much, as long as you delete ur wallet u should be able to start over again any time. However you can tweak the test setting  for testimg purposes (see what difficulty does etc..).

I'm now mining my own coin :-p

However i haven't actually found the genesis block. I expected it to be in my wallet with a transaction, but it isn't..


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 05, 2013, 04:23:44 PM
In command line..

Don't really think it matters much, as long as you delete ur wallet u should be able to start over again any time. However you can tweak the test setting  for testimg purposes (see what difficulty does etc..).

I'm now mining my own coin :-p

However i haven't actually found the genesis block. I expected it to be in my wallet with a transaction, but it isn't..

From what I read I think some will create a script that automatically mines the genesis block to save time, otherwise I guess it takes awhile, I guess for Saotoshi it took 6 days

Keep me updated on your progress in this thread!

What's the name of your coin?


Title: Re: More Genesis Block Discussion
Post by: Gavin Andresen on May 05, 2013, 04:31:40 PM
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 05, 2013, 04:53:03 PM
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


I'm trying to learn been studying furiously


Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 05, 2013, 05:35:42 PM
Gavin, you can probably a question i'm having.. I "mined" the genesis block, and it shows op in the daemon when I query it with getblockhash 0. I also see that it contains exactly 1 transaction like it's supposed to.

 What I don't get is that "mining" (generating sounds better) the genesis block happens before you actually create a wallet so that one transaction is not "in" my wallet.

 I assume this is caused by the txNew lines in LoadBlockIndex:

Code:
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 50 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
        CBlock block;

This was changes in the Smallchange code to:
Code:
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 0;
        txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG; // a privkey for that 'vanity' pubkey would be interesting ;)

I'm assuming that this code creates a transaction from the genesis block to a wallet address. In Litecoin this is
Code:
CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;

In SmallChange this is changed to 0x0 but that doesn't matter because the value is 0 anyway.

I copied that smallchange code however and changed the value to 10.

Now when I look at the genesis block I get:
Code:
    "tx" : [
        "d966cccce1ccfab008bac6ab9ef6c4c223b77847fb6924d837639997ef21d29f"
    ],
even though the transaction failed in the generation:
Code:
hashMerkleRoot=d966cccce1, nTime=1367758074, nBits=1e0ffff0, nNonce=924421, vtx=1)
  CTransaction(hash=d966cccce1, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043d6e7974696d657320352d35204f66662d7468652d43756666204f62616d61204c696e652050757420552e532e20696e2042696e64206f6e205379726961)
    CTxOut(error)

when I try to read the transaction i get
Code:
error: {"code":-5,"message":"No information available about transaction"}

Now for the question...

How can I populate this line
Code:
txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG;

If I don't have a wallet yet? Or do you simply create the wallet first, retrieve the address and start again?

Thanks



Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 05, 2013, 06:54:19 PM
OK Think I found the answer.. Gavin if you could confirm I understand it that would be very nice :D

The key used in the source at
Code:
txNew.vout[0].scriptPubKey 

Is the public ECDSA key for that address right?

So all you have to do is create a public/private ECDSA keypair and convert the public key to an address using:
Version = 1 byte of 0 (zero); on the test network, this is 1 byte of 111 // Or whatever is set in base58.h
Key hash = Version concatenated with RIPEMD-160(SHA-256(public key))
Checksum = 1st 4 bytes of SHA-256(SHA-256(Key hash))
Xxxcoin Address = Base58Encode(Key hash concatenated with Checksum)

To import the private key in my new wallet I would have to follow these steps:
Code:
1 - Take a private key 
   0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
2 - Add a 0x80 byte in front of it
   800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
3 - Perform SHA-256 hash on the extended key
   8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592
4 - Perform SHA-256 hash on result of SHA-256 hash
   507A5B8DFED0FC6FE8801743720CEDEC06AA5C6FCA72B07C49964492FB98A714
5 - Take the first 4 bytes of the second SHA-256 hash, this is the checksum
   507A5B8D
6 - Add the 4 checksum bytes from point 5 at the end of the extended key from point 2
   800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D
7 - Convert the result from a byte string into a base58 string using Base58Check encoding. This is the Wallet Import Format
   5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ

Does that sum it up?

Thanks


Title: Re: More Genesis Block Discussion
Post by: marcus_of_augustus on May 06, 2013, 04:30:36 AM
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


I agree, I was thinking this also .... people are free to experiment but who would want to put trust in a blockchain that was began by someone who was not yet fully competent to create their own genesis block is probably the free market answer ...


Title: Re: More Genesis Block Discussion
Post by: AlexMerced on May 06, 2013, 11:09:08 AM
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


I agree, I was thinking this also .... people are free to experiment but who would want to put trust in a blockchain that was began by someone who was not yet fully competent to create their own genesis block is probably the free market answer ...

I get that but who said I'm trying to compete with bitcoin, as I've said before I'm doing this to learn more about bitcoin and also to commemorate f.a. Hayek.


Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 06, 2013, 11:59:27 AM
I agree, I was thinking this also .... people are free to experiment but who would want to put trust in a blockchain that was began by someone who was not yet fully competent to create their own genesis block is probably the free market answer ...

So what then? I thought this forum was meant for people to ask questions, apparently I was wrong in that assumption. I'm trying to understand how it all works. Best way for me to learn is to actually do stuff (If you ever developed anything you'd know you don't learn that from books ;-)).

I just checked somethings.. the last two altcoins were created by peopl with less than 20 posts on this forum.. Does that mean they are geniusses? I'd rather put my trust in someone that asks things if he's not sure, than in someone who doesnt..

As for that matter, let's say I am developing an altcoin to be released, wouldn't you rather have it released by someone who's been asking around?

So far I managed to do almost everything without asking for help, but even that one question I asked is still unanswered on the forum..


Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 06, 2013, 12:05:58 PM
OK Think I found the answer.. Gavin if you could confirm I understand it that would be very nice :D

The key used in the source at
Code:
txNew.vout[0].scriptPubKey 

Is the public ECDSA key for that address right?

To answer yet again my own question: It is... And the steps I provided are correct..

Below a simple python script to generate the WIF and Wallet address (courtesy of a number of ppl on the forum)
Code:
import hashlib, binascii

t='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

def numtowif(numpriv):
 # for bitcoin (80=128)
 # for testcoin (EF==239 == testnet)
 step1 = 'EF'+hex(numpriv)[2:].strip('L').zfill(64)
 step2 = hashlib.sha256(binascii.unhexlify(step1)).hexdigest()
 step3 = hashlib.sha256(binascii.unhexlify(step2)).hexdigest()
 step4 = int(step1 + step3[:8] , 16)
 return ''.join([t[step4/(58**l)%58] for l in range(100)])[::-1].lstrip('1')

def wiftonum(wifpriv):
 return sum([t.index(wifpriv[::-1][l])*(58**l) for l in range(len(wifpriv))])/(2**32)%(2**256)

def validwif(wifpriv):
 return numtowif(wiftonum(wifpriv))==wifpriv

def pubtoaddr(numpub):
 pubkey1=hex(numpub)[2:].strip('L').zfill(130)
 #print pubkey1
 pubkey2=hashlib.sha256(binascii.unhexlify(pubkey1)).hexdigest()
 #print pubkey2
 pubkey3=hashlib.new('ripemd160',binascii.unhexlify(pubkey2)).hexdigest()
 #print pubkey3
 # for bitcoin (0)
 #pubkey3b='00'+pubkey3
 # for testcoin (111)
 pubkey3b='6f'+pubkey3
 #print pubkey3b
 pubkey4=hashlib.sha256(binascii.unhexlify(pubkey3b)).hexdigest()
 #pubkey4=hashlib.sha256(binascii.unhexlify(pubkey3b)).hexdigest()
 #print pubkey4
 pubkey5=hashlib.sha256(binascii.unhexlify(pubkey4)).hexdigest()
 #print pubkey5
 pubkey5a=pubkey5[:8]
 #print pubkey5a
 pubkey6=pubkey3b+pubkey5a
 #print pubkey6
 #print pubkey6[:2]
 pubnum=int(pubkey6,16)
 #print pubnum
 pubnumlist=[]
 while pubnum!=0: pubnumlist.append(pubnum%58); pubnum/=58
 address=''
 for l in ['123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'[x] for x in pubnumlist]:
  address=l+address
 if pubkey6[:2]=='00':
  address='1'+address
 return address

print "wallet import format"
print numtowif(0x5e4a8229e81a434b0646dcdbeb4b03083e2bd05af26fcf2e4e4aa37eacb2913b)
print "wallet public address"
print pubtoaddr(0x04580e17442b4465fbf1eb8a039855343739f69f83222c3c6590c219dcd2d883bff96ebf6198ddb9a75baffffbc1be62f05261d7dfec58d8a06cf3809c6cefe620)

Might have to be adapted a bit for your purpose depending on what's in base58.cpp

Also a nice script to generate ECDSA keypairs (for testing purposes only!)

Code:
#!/usr/bin/env python
"""
Generate an ECDSA keypair and Bitcoin-compatible payment address.
Requires Brian Warner's excellent python-ecdsa library.


http://github.com/aristus/bitcoin-printer
"""
from ecdsa.ecdsa import Public_key, int_to_string
from ecdsa.ellipticcurve import CurveFp, Point
from binascii import hexlify
import hashlib
ripehash = hashlib.new('ripemd160')


# ***WARNING*** This is possibly insecure! ***WARNING***
from random import SystemRandom
randrange = SystemRandom().randrange


## Bitcoin has an adorable encoding scheme that includes numbers and letters
## but excludes letters which look like numbers, eg "l" and "O"
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)
def b58encode(v):
  long_value = 0L
  for (i, c) in enumerate(v[::-1]):
    long_value += (256**i) * ord(c)
  result = ''
  while long_value >= __b58base:
    div, mod = divmod(long_value, __b58base)
    result = __b58chars[mod] + result
    long_value = div
  result = __b58chars[long_value] + result
  nPad = 0
  for c in v:
    if c == '\0': nPad += 1
    else: break
  return (__b58chars[0]*nPad) + result

def generate_btc_address():
    # secp256k1, not included in stock ecdsa
    _p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2FL
    _r = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L
    _b = 0x0000000000000000000000000000000000000000000000000000000000000007L
    _a = 0x0000000000000000000000000000000000000000000000000000000000000000L
    _Gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798L
    _Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8L
    curve_256 = CurveFp(_p, _a, _b)
    generator = Point(curve_256, _Gx, _Gy, _r)

    secret = randrange(1, generator.order())
    pubkey = Public_key(generator, generator * secret)
    step1 = '\x04' + int_to_string(pubkey.point.x()) + \
        int_to_string(pubkey.point.y())
    step2 = hashlib.sha256(step1).digest()
    ripehash.update(step2)
    step4 = '\x00' + ripehash.digest()
    step5 = hashlib.sha256(step4).digest()
    step6 = hashlib.sha256(step5).digest()
    chksum = step6[:4]
    addr = step4 + chksum
    addr_58 = b58encode(addr)
    return (
        hex(secret)[2:-1],
        hexlify(step1),
        hexlify(addr),
        addr_58
    )


if __name__ == '__main__':
    secret, pubkey, addr, addr_58 = generate_btc_address()
    print 'secret: ', secret
    print 'pubkey: ', pubkey
    print 'address:', addr
    print 'addr_58:', addr_58



Title: Re: More Genesis Block Discussion
Post by: marcus_of_augustus on May 07, 2013, 10:56:03 AM
Doesn't mean I'm not liking this thread ....  :)


Title: Re: More Genesis Block Discussion
Post by: tyrion70 on May 07, 2013, 11:04:47 AM
Doesn't mean I'm not liking this thread ....  :)
:P good! In the meanwhile I'm getting the hang of it.. The thing that I have the most problems with is the language itself.. Never did anything with c++.. It's not too hard, but you have to get to know the syntax and variable definitions..


Title: Re: More Genesis Block Discussion
Post by: shakezula on May 09, 2013, 11:08:02 PM


after a long time you get...


How long? What kind of processing power?


Title: Re: More Genesis Block Discussion
Post by: shakezula on May 10, 2013, 12:23:36 AM
OK, scratch that. Now I have mined a Genesis block, set up some .conf info--how do I mine my new coin? Everything I get from ./coinname getinfo looks right, but I get error 500 when trying to connect minerd...

Whats the next step?


Title: Re: More Genesis Block Discussion
Post by: joehop67 on May 16, 2013, 08:50:13 PM
Okay So I know this thread is a bit old but I need some help. I tried the steps to get the genesis block (Change nonce to 0 and change "if (false && block.GetHash()" to "if (true && block.GetHash()") I did all that and compiled it and it ran for about half an hour before displaying this error: "litecoind: main.cpp:2061: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed." Also tried with SmallChange and got the same result.

Any idea how I could fix this? 


Title: Re: More Genesis Block Discussion
Post by: Meizirkki on August 12, 2013, 11:21:07 PM
The key used in the source at
Code:
[s]txNew.vout[0].scriptPubKey [/s]
Is the public ECDSA key for that address right?
I generated an ecdsa key pair, placed the public key in there like litecoin:
Quote
txNew.vout[0].scriptPubKey = CScript() << ParseHex("04f93d54b7873cad866b9d9670717ce5c2d11715e27e35ae55d0b4ee2eb106c9e49d5e8e874b536 04f9c8ae6620b65f685ef9ca90af4686b7f5e0257ae26fd4ce0") << OP_CHECKSIG;
Private key from the pair I changed to WIF and imported to satoshi client with importprivkey call. No coins are showing up. This is the genesis block from debug.log:
Quote
block.nTime = 877077343
block.nNonce = 2346298
block.GetHash = 49cc7e4d0c6fb00ae3aea9aecf4a7d307c908d5d7e247c6874cf8244e286911a
CBlock(hash=49cc7e4d0c6fb00ae3aea9aecf4a7d307c908d5d7e247c6874cf8244e286911a, input=0100000000000000000000000000000000000000000000000000000000000000000000009470a34f0ff567feff10effc36ede7a52d9bf02675b92923d55a43f0466a7e975f234734f0ff0f1e3acd2300, PoW=000009daf88f3a7f9aab10a2d65d32ecc85243395210b941c944a6c7c22b4e5b, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=977e6a46f0435ad52329b97526f09b2da5e7ed36fcef10fffe67f50f4fa37094, nTime=877077343, nBits=1e0ffff0, nNonce=2346298, vtx=1)
  CTransaction(hash=977e6a46f0435ad52329b97526f09b2da5e7ed36fcef10fffe67f50f4fa37094, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 04ffff001d01042c4b6164756e76616c7461616a617420707973c3a479747469206c69696b656e7 465656e207374616469737361)
    CTxOut(nValue=514000000.00000000, scriptPubKey=04f93d54b7873cad866b9d9670717c)
  vMerkleTree: 977e6a46f0435ad52329b97526f09b2da5e7ed36fcef10fffe67f50f4fa37094
What am I missing? :-\

EDIT: Nevermind! I just had to mine another block and it showed up.


Title: Re: More Genesis Block Discussion
Post by: awais3344 on February 24, 2014, 07:07:22 AM
this is quite an old thread, but I think it would be best place to post for help.

I changed the ntime to current epoch time, and changed nnonce to 0.

Now i compiled and run the qt. it says assertion failed src\main.cpp line 2870

expression: hash == hashgenesisblock.

Okay, so i went to appdata folder, and then there is qt folder. but there is an empty db.log file, and there is no debug.log file. I run the wallet even through testnet and noirc, still no debug.log file appears. can anyone help?


Title: Re: More Genesis Block Discussion
Post by: apple_talk on February 25, 2014, 10:49:40 PM
What I did so far:

Change pszTimestamp to a sentence from newspaper
change block.nTime to current time

compile

run compiled source with -testnet -noirc

now u see some lines and a crash
Code:
b115383690ee67ebeef9a7e754342638cd7bbf488561998e6d1bc1ed367484f6 // Block derived from pszTimestamp
b8fa883689f099d3942ff73439d9f55d60a5e257b0d69a8f0f6ab4572ecff415 // Genesisblock (invalid cuz its already coded wrong)
bd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9 // MerkleRoot (Valid because its newly calculated

corresponding to code:
Code:
        //// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0xbd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9"));

update main.cpp with the mentioned merkleroot (it crashed because of the last assert) and run again

you should have already changed the false to true in
Code:
        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)

so it will find a genesis block for your string

after a long time you get:
Code:
nonce 003C1000: hash = e8525d8ae8a74a33dbc4b06a64c97ced84dfd29628b3e9e4197c7030cc4a09d3 (target = 00000ffff0000000000000000000000000000000000000000000000000000000)
block.nTime = 1367704866
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33
CBlock(hash=fafdbfc957ea6867a074, PoW=000000b1398554a520b5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=bd58bf217a, nTime=1367704866, nBits=1e0ffff0, nNonce=3939341, vtx=1)
  CTransaction(hash=bd58bf217a, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043741442e6e6c20342f352042657672696a64696e6773646167207a6f6e6e69672c20646161726e61206f6f6b207a6f6d657273207761726d)
    CTxOut(error)
  vMerkleTree: bd58bf217a
xx: main.cpp:2070: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed.
Aborted (core dumped)

Now you have the valid Genesisblock and nNonce:
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33

Update your code with these values and your ready to go!




Complied & got following error...
root@PC:~/Desktop/litecoin-master-0.8/src# ABCcoind -testnet -noirc -debug -debugnet
ABCcoind: main.cpp:2820: bool InitBlockIndex(): Assertion `block.hashMerkleRoot == uint256("0x")' failed.
Aborted (core dumped)


in Test folder "debug.log" file
2014-02-25 19:40:36 ABCcoin version v0.8.6.2-g85f303d-beta ()
2014-02-25 19:40:36 Using OpenSSL version OpenSSL 1.0.1e 11 Feb 2013
2014-02-25 19:40:36 Default data directory /home/user/.ABCcoin
2014-02-25 19:40:36 Using data directory /home/user/.ABCcoin
2014-02-25 19:40:36 Using at most 125 connections (1024 file descriptors available)
2014-02-25 19:40:36 Using 3 threads for script verification
2014-02-25 19:40:36 init message: Verifying wallet...
2014-02-25 19:40:36 dbenv.open LogDir=/home/user/.ABCcoin/database ErrorFile=/home/user/.ABCcoin/db.log
2014-02-25 19:40:36 Bound to [::]:2095
2014-02-25 19:40:36 Bound to 0.0.0.0:2095
2014-02-25 19:40:36 init message: Loading block index...
2014-02-25 19:40:36 Opening LevelDB in /home/user/.ABCcoin/blocks/index
2014-02-25 19:40:36 Opened LevelDB successfully
2014-02-25 19:40:36 Opening LevelDB in /home/user/.ABCcoin/chainstate
2014-02-25 19:40:36 Opened LevelDB successfully
2014-02-25 19:40:36 LoadBlockIndexDB(): last block file = 0
2014-02-25 19:40:36 LoadBlockIndexDB(): transaction index disabled
2014-02-25 19:40:36 Initializing databases...
2014-02-25 19:40:36 76f8df0283035323c583d14526d80fa06c22d8bfc0a4c564aa0e6549f4fbc4f5
2014-02-25 19:40:36 0000000000000000000000000000000000000000000000000000000000000000
2014-02-25 19:40:36 1eecade19537e2891642e0995c119941d4dcf384b60ae013fcadf7b97a8cd5a9


I even deleted Complied, change block.nTime, same output on screen & debug values also same. What could be wrong?


Title: Re: More Genesis Block Discussion
Post by: Meizirkki on March 01, 2014, 06:20:31 AM
Iirc you now have the valid merkleroot from the debug:
Quote
2014-02-25 19:40:36 1eecade19537e2891642e0995c119941d4dcf384b60ae013fcadf7b97a8cd5a9


Which you need to put in place of the previous merkleroot you deleted. After you recompile and run the code, it should start hashing a genesis block for you. (if you have the function in place and enabled)


Title: Re: More Genesis Block Discussion
Post by: apple_talk on March 01, 2014, 05:53:02 PM
OK, scratch that. Now I have mined a Genesis block, set up some .conf info--how do I mine my new coin? Everything I get from ./coinname getinfo looks right, but I get error 500 when trying to connect minerd...

Whats the next step?

I am also having same question, got everything but now how do I get new coin.

./ABCcoind  -server -rpcallowip=*


root@ABCcoin:~/ABC/src# ./ABCcoind  getinfo
{
    "version" : 80602,
    "protocolversion" : 70003,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 0,
    "timeoffset" : 0,
    "connections" : 0,
    "proxy" : "",
    "difficulty" : 0.00024414,
    "testnet" : false,
    "keypoololdest" : 1393660893,
    "keypoolsize" : 98,
    "paytxfee" : 0.00000000,
    "mininput" : 0.00001000,
    "unlocked_until" : 0,
    "errors" : ""
}

root@ABCcoin:~/ABC/src# ./ABCcoind  getmininginfo
{
    "blocks" : 0,
    "currentblocksize" : 1000,
    "currentblocktx" : 0,
    "difficulty" : 0.00024414,
    "errors" : "",
    "generate" : true,
    "genproclimit" : 2,
    "hashespersec" : 0,
    "networkhashps" : 0,
    "pooledtx" : 0,
    "testnet" : false
}

Minerd.exe -a scrypt -o http://192.168.1.116:20120 -u ABCcoinrpc -p test --no-stratum --no-longpoll -t 1
[2014-03-01 09:29:35] 1 miner threads started, using 'scrypt' algorithm.
[2014-03-01 09:29:35] HTTP request failed: The requested URL returned error: 500 Internal Server Error
[2014-03-01 09:29:35] json_rpc_call failed, retry after 30 seconds
[2014-03-01 09:30:05] HTTP request failed: The requested URL returned error: 500 Internal Server Error

Port is correct & listening.


Title: Re: More Genesis Block Discussion
Post by: awais3344 on March 02, 2014, 09:08:06 AM
i ran my coin daemon on 2 pcs. And used daemon=1 and addnode=xx.xx.xx.xx (other pc's ip with running daemon)

they never connect.


Title: Re: More Genesis Block Discussion
Post by: Meizirkki on March 02, 2014, 10:08:52 PM
iirc you can use a --connect=IP argument with the daemon. That should get your nodes to connect to each other.

And apple_talk, you need at least 2 peers in your coins network to mine.


Title: Re: More Genesis Block Discussion
Post by: defaced on March 02, 2014, 10:57:56 PM
someone cast res on this thread.


Title: Re: More Genesis Block Discussion
Post by: awais3344 on March 03, 2014, 09:41:53 AM
iirc you can use a --connect=IP argument with the daemon. That should get your nodes to connect to each other.

And apple_talk, you need at least 2 peers in your coins network to mine.

I did use -connect and it says couldn't connect to host server.


Title: Re: More Genesis Block Discussion
Post by: Meizirkki on March 03, 2014, 11:09:10 AM
iirc you can use a --connect=IP argument with the daemon. That should get your nodes to connect to each other.

And apple_talk, you need at least 2 peers in your coins network to mine.

I did use -connect and it says couldn't connect to host server.
Are you sure you have set the ports right?


Title: Re: More Genesis Block Discussion
Post by: awais3344 on March 03, 2014, 04:52:45 PM
iirc you can use a --connect=IP argument with the daemon. That should get your nodes to connect to each other.

And apple_talk, you need at least 2 peers in your coins network to mine.

I did use -connect and it says couldn't connect to host server.
Are you sure you have set the ports right?

yeah i cloned doge. which has port 22555 by default


Title: Re: More Genesis Block Discussion
Post by: apple_talk on March 05, 2014, 03:11:16 PM
i ran my coin daemon on 2 pcs. And used daemon=1 and addnode=xx.xx.xx.xx (other pc's ip with running daemon)

they never connect.

Thanks it works :) need 2 PCs


Title: Re: More Genesis Block Discussion
Post by: apple_talk on March 05, 2014, 03:13:53 PM
What is public ECDSA key ?

https://bitcointalk.org/index.php?topic=494319.msg5447917

Thanks


Title: Re: More Genesis Block Discussion
Post by: awais3344 on March 05, 2014, 05:44:19 PM
i ran my coin daemon on 2 pcs. And used daemon=1 and addnode=xx.xx.xx.xx (other pc's ip with running daemon)

they never connect.

Thanks it works :) need 2 PCs

didnt work for me   :-\ but have fun  :)


Title: Re: More Genesis Block Discussion
Post by: Lloydie on March 19, 2014, 02:06:05 PM
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.

Did anyone reinvent the WHEEL lately? 


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 06, 2014, 06:50:29 PM
Using following code in main.cpp if using n-Scrypt (X11), it gives error when compiling. Any suggestion?

Code:
if (true && 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());


               }



Error when compiling:


main.cpp: In function ‘bool InitBlockIndex()’:
main.cpp:2996:35: error: ‘SCRYPT_SCRATCHPAD_SIZE’ was not declared in this scope
                   char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
                                   ^
main.cpp:3012:91: error: ‘scratchpad’ was not declared in this scope
                       scrypt_1024_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
                                                                                           ^
main.cpp:3012:101: error: ‘scrypt_1024_1_1_256_sp_generic’ was not declared in this scope
                       scrypt_1024_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
                                                                                                     ^



Title: Re: More Genesis Block Discussion
Post by: voileipa on April 06, 2014, 08:30:35 PM
Here is a python script for generating the parameters needed for sha256/scrypt genesis block

https://github.com/lhartikk/GenesisH0


Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 06, 2014, 08:39:08 PM
Using following code in main.cpp if using n-Scrypt (X11), it gives error when compiling. Any suggestion?

What value have you set for the scratchpad size?


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 06, 2014, 11:24:45 PM
Thanks Guys.

here is main.cpp file.

Code:
http://pastebin.com/TSemSTkK

The generating code works fine for scrypt, but for some reason not n-scrypt (X11). I have included complete code of main.cpp.

It seems the GenesisH0 needs update to support X11 scrypt.


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 07, 2014, 03:13:45 PM
Ran on Ubuntu 13.10 64bit

/GenesisH0# python genesis.py  -z "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks" -n 2083236893 -t 1231006505
Traceback (most recent call last):
  File "genesis.py", line 2, in <module>
    import scrypt
ImportError: No module named scrypt

what package I need using APT-GET, thanks


UPDATE:-
Never mind, needed python-pip installed first.
sudo apt-get install python-pip
pip install scrypt construct
and then genesis.py scrypt runs.




but, using these values in X11 scrypt does not work. fine for litecoin scrypt.
Wondering is it possible maybe get scrypt updated to support X11, which is becoming standard now.


Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 07, 2014, 04:44:18 PM
Well you obviously need python implementation of scrypt...

Are trying to make your own coin? I strongly recommend that you learn a bit of c++
so that you know what kind of questions to ask when obstacles present themselves.

Especially since people might even invest their hard-earned money in the coin you have rolled.



Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 07, 2014, 04:52:35 PM
Well you obviously need python implementation of scrypt...

Are trying to make your own coin? I strongly recommend that you learn a bit of c++
so that you know what kind of questions to ask when obstacles present themselves.

Especially since people might even invest their hard-earned money in the coin you have rolled.



yes I do have some experience & knowledge in C++, perl. I know code is looking for declared global or local variable SCRYPT_SCRATCHPAD_SIZE,


Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 07, 2014, 05:50:52 PM
Try including scrypt.h

edit. I took a look at Vertcoin source, and there you have

main.cpp 4745:
Code:
unsigned long int scrypt_scratpad_size_current_block = ((1 << (GetNfactor(pblock->nTime) + 1)) * 128 ) + 63;
            
char scratchpad[scrypt_scratpad_size_current_block];

Looks like n-scrypt resizes scratchpad per block.
Your best bet is to study Vertcoin or some other similar coin and make changes accordingly.


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 07, 2014, 06:37:24 PM
Try including scrypt.h

edit. I took a look at Vertcoin source, and there you have

main.cpp 4745:
Code:
unsigned long int scrypt_scratpad_size_current_block = ((1 << (GetNfactor(pblock->nTime) + 1)) * 128 ) + 63;
            
char scratchpad[scrypt_scratpad_size_current_block];

Looks like n-scrypt resizes scratchpad per block.
Your best bet is to study Vertcoin or some other similar coin and make changes accordingly.


use the above python script
got values & hash, updated main.cpp & checkpoint.cpp

removed genesis generating code from main.cpp
Compile the code.

Ran it...

root@PC:~/src# ./vicoind
vicoind: main.cpp:3050: bool InitBlockIndex(): Assertion `hash == hashGenesisBlock' failed.
Aborted (core dumped)


so I guess you are right, the scrypt does not support X11 scrypt coin. I looked at the code of the scrypt it is few lines, is it possible to modify it, maybe you can help out.


Code:
import hashlib, binascii, struct, array, os, time, sys, optparse
import scrypt

from construct import *


def main():
  options = get_args()

  # https://en.bitcoin.it/wiki/Difficulty
  bits = get_bits(options)
  target = get_target(options)

  input_script = create_input_script(options.timestamp)
  output_script = create_output_script(options.pubkey)

  # hash merkle root is the double sha256 hash of the transaction(s)
  tx = create_transaction(input_script, output_script)
  hash_merkle_root = hashlib.sha256(hashlib.sha256(tx).digest()).digest()
  print_block_info(options, hash_merkle_root)

  block_header = create_block_header(hash_merkle_root, options.time, bits, options.nonce)
  genesis_hash, nonce = generate_hash(block_header, options.scrypt, options.nonce, target)
  announce_found_genesis(genesis_hash, nonce)


def get_args():
  parser = optparse.OptionParser()
  parser.add_option("-t", "--time", dest="time", default=int(time.time()),
                   type="int", help="the (unix) time when the genesisblock is created")
  parser.add_option("-z", "--timestamp", dest="timestamp", default="The Times 03/Jan/2009 Chancellor on brink of second bailout for banks",
                   type="string", help="the pszTimestamp found in the coinbase of the genesisblock")
  parser.add_option("-n", "--nonce", dest="nonce", default=0,
                   type="int", help="the first value of the nonce that will be incremented when searching the genesis hash")
  parser.add_option("-s", "--scrypt", dest="scrypt", default=False, action="store_true",
                    help="calculate genesis block using scrypt")
  parser.add_option("-p", "--pubkey", dest="pubkey", default="04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f",
                   type="string", help="the pubkey found in the output script")

  (options, args) = parser.parse_args()
  return options


def get_bits(options):
  return 0x1e0ffff0 if options.scrypt else 0x1d00ffff


def get_target(options):
  return 0x0ffff0 * 2**(8*(0x1e - 3)) if options.scrypt else 0x00ffff * 2**(8*(0x1d - 3))


def create_input_script(psz_timestamp):
  script_prefix = '04ffff001d0104' + chr(len(psz_timestamp)).encode('hex')
  return (script_prefix + psz_timestamp.encode('hex')).decode('hex')


def create_output_script(pubkey):
  script_len = '41'
  OP_CHECKSIG = 'ac'
  return (script_len + pubkey + OP_CHECKSIG).decode('hex')


def create_transaction(input_script, output_script):
  transaction = Struct("transaction",
    Bytes("version", 4),
    Byte("num_inputs"),
    StaticField("prev_output", 32),
    UBInt32('prev_out_idx'),
    Byte('input_script_len'),
    Bytes('input_script', len(input_script)),
    UBInt32('sequence'),
    Byte('num_outputs'),
    Bytes('out_value', 8),
    Byte('output_script_len'),
    Bytes('output_script', 0x43),
    UBInt32('locktime'))

  tx = transaction.parse('\x00'*(127 + len(input_script)))
  tx.version = struct.pack('<I', 1)
  tx.num_inputs = 1
  tx.prev_output = struct.pack('<qqqq', 0,0,0,0)
  tx.prev_out_idx = 0xFFFFFFFF
  tx.input_script_len = len(input_script)
  tx.input_script = input_script
  tx.sequence = 0xFFFFFFFF
  tx.num_outputs = 1
  tx.out_value = struct.pack('<q' ,0x000000012a05f200) #50 coins
  tx.output_script_len = 0x43
  tx.output_script = output_script
  tx.locktime = 0
  return transaction.build(tx)


def create_block_header(hash_merkle_root, time, bits, nonce):
  block_header = Struct("block_header",
    Bytes("version",4),
    Bytes("hash_prev_block", 32),
    Bytes("hash_merkle_root", 32),
    Bytes("time", 4),
    Bytes("bits", 4),
    Bytes("nonce", 4))

  genesisblock = block_header.parse('\x00'*80)
  genesisblock.version = struct.pack('<I', 1)
  genesisblock.hash_prev_block = struct.pack('<qqqq', 0,0,0,0)
  genesisblock.hash_merkle_root = hash_merkle_root
  genesisblock.time = struct.pack('<I', time)
  genesisblock.bits = struct.pack('<I', bits)
  genesisblock.nonce = struct.pack('<I', nonce)
  return block_header.build(genesisblock)


# https://en.bitcoin.it/wiki/Block_hashing_algorithm
def generate_hash(data_block, is_scrypt, start_nonce, target):
  print 'Searching for genesis hash..'
  nonce = start_nonce
  last_updated = time.time()
  difficulty = float(0xFFFF) * 2**208 / target
  update_interval = int(1000000 * difficulty)

  while True:
    sha256_hash, header_hash = generate_hashes_from_block(data_block, is_scrypt)
    last_updated = calculate_hashrate(nonce, update_interval, difficulty, last_updated)
    if is_genesis_hash(header_hash, target):
      return (sha256_hash, nonce)
    else:
     nonce = nonce + 1
     data_block = data_block[0:len(data_block) - 4] + struct.pack('<I', nonce)


def generate_hashes_from_block(data_block, is_scrypt):
  sha256_hash = hashlib.sha256(hashlib.sha256(data_block).digest()).digest()[::-1]
  header_hash = scrypt.hash(data_block,data_block,1024,1,1,32)[::-1] if is_scrypt else sha256_hash
  return sha256_hash, header_hash


def is_genesis_hash(header_hash, target):
  return int(header_hash.encode('hex_codec'), 16) < target


def calculate_hashrate(nonce, update_interval, difficulty, last_updated):
  if nonce % update_interval == update_interval - 1:
    now = time.time()
    hashrate = round(update_interval/(now - last_updated))
    generation_time = round(difficulty * pow(2, 32) / hashrate / 3600, 1)
    sys.stdout.write("\r%s hash/s, estimate: %s h"%(str(hashrate), str(generation_time)))
    sys.stdout.flush()
    return now
  else:
    return last_updated


def print_block_info(options, hash_merkle_root):
  print "algorithm: " + ("scrypt" if options.scrypt else "sha256")
  print "merkle hash: " + hash_merkle_root[::-1].encode('hex_codec')
  print "pszTimestamp: " + options.timestamp
  print "pubkey: " + options.pubkey
  print "time: " + str(options.time)
  print "bits: " + str(hex(get_bits(options)))


def announce_found_genesis(genesis_hash, nonce):
  print "genesis hash found!"
  print "nonce: " + str(nonce)
  print "genesis hash: " + genesis_hash.encode('hex_codec')


# GOGOGO!
main()


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 07, 2014, 06:39:00 PM
Now something like
https://github.com/evan82/darkcoin/blob/master/src/main.cpp
uses same setup as well?



Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 07, 2014, 06:50:53 PM
It looks like InitBlockIndex() is the same in Darkcoin, so you could try running that and see if you get the values.


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 07, 2014, 08:08:49 PM
It looks like InitBlockIndex() is the same in Darkcoin, so you could try running that and see if you get the values.

Got same result using darkcoin as well.

their must be easy way to change the python scrypt in include X11 info as well.


Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 07, 2014, 10:00:38 PM
Ok. I had yet another look at this. I thought scrypt-n is one of the  x11 algorithms but apparently it is not.. :-[
Because of that, the genesis block-producing code that you posted will not work, as it is for "standard scrypt".

When I have little more time I'll see if I can figure it out.

But first let's be clear; are you after X11 or scrypt-N coin?






Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 07, 2014, 10:10:25 PM
Ok. I had yet another look at this. I thought scrypt-n is one of the  x11 algorithms but apparently it is not.. :-[
Because of that, the genesis block-producing code that you posted will not work, as it is for "standard scrypt".

When I have little more time I'll see if I can figure it out.

But first let's be clear; are you after X11 or scrypt-N coin?


X11

btw, I used the existing code... copied working X11 hash/root/timestamp from another coin, it worked like charm. So it is just the matter of script generating that needs update.



Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 08, 2014, 12:00:46 AM
Edit:

For the sake of possible future readers, rather than handing them a fully baked solution, I will just give outline of the procedure. Y'know. give man a fish / teach him to fish and so on...

So if you want to get a new genesis block out of Darkcoin that uses X11 or any coin at all that has been forked out of Bitcoin, here are the steps, most of which can be inferred from this thread also.

You need to change szTimesstamp and nTime. Zero the nonce, merkle root and old genesis block. Compile and run. Boom. Here's the genesis block and merkle root as they come from the printf statements in InitBlockIndex().

If you substitute them into the code, your gen block will be accepted, but you will run into this:
Code:
hash doesn't match nBits.

The code snippet (see above) that begins with
Code:
if (true && block.GetHash() != hashGenesisBlock)

will help you to find the right hash for nBits. You just need to read what it does. It is looping an algorithm and increasing nonce to find a block that satisfies the difficulty. I.e. it is mining. Is it running scrypt? No it isn't, this is X11, so get rid of all that. Where do you get the X11 algorithm? Take a look at the error message you're getting.

That should be enough...



Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 08, 2014, 02:24:19 AM
appreciate  :)
I will try it shortly.


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 08, 2014, 07:04:41 AM
did not work, it failed.


Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 08, 2014, 07:07:18 AM
did not work, it failed.

Worked for me. What error report?


Title: Re: More Genesis Block Discussion
Post by: defaced on April 08, 2014, 01:09:07 PM
Edit:

For the sake of possible future readers, rather than handing them a fully baked solution, I will just give outline of the procedure. Y'know. give man a fish / teach him to fish and so on...

So if you want to get a new genesis block out of Darkcoin that uses X11 or any coin at all that has been forked out of Bitcoin, here are the steps, most of which can be inferred from this thread also.

You need to change szTimesstamp and nTime. Zero the nonce, merkle root and old genesis block. Compile and run. Boom. Here's the genesis block and merkle root as they come from the printf statements in InitBlockIndex().

If you substitute them into the code, your gen block will be accepted, but you will run into this:
Code:
hash doesn't match nBits.

The code snippet (see above) that begins with
Code:
if (true && block.GetHash() != hashGenesisBlock)

will help you to find the right hash and nBits. You just need to read what it does. It is looping an algorithm and increasing nonce to find a block that satisfies the difficulty. I.e. it is mining. Is it running scrypt? No it isn't, this is X11, so get rid of all that. Where do you get the X11 algorithm? Take a look at the error message you're getting.

That should be enough...



I think this is the best way to handle it. Teaching people to fish that is.


Title: Re: More Genesis Block Discussion
Post by: apple_talk on April 08, 2014, 08:42:48 PM
did not work, it failed.

Worked for me. What error report?

PM you error message yesterday.

btw, found X11 relate gen code, not sure if this is valid...

Code:
if (true && block.GetHash() != hashGenesisBlock)
        {
            printf("Searching for genesis block...\n");
            uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();
            uint256 thash;

            loop
            {
                thash = block.GetHash();
                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.nVersion = %u \n", block.nVersion);
            printf("block.GetHash = %s\n", block.GetHash().ToString().c_str());
        }
        //// debug print
        uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x"));


Title: Re: More Genesis Block Discussion
Post by: YarkoL on April 08, 2014, 09:10:45 PM
apple_talk:
replied to your pm


btw, found X11 relate gen code, not sure if this is valid...


Why not try and see?  ;D


Title: Re: More Genesis Block Discussion
Post by: joblessminer on April 09, 2014, 05:08:57 PM

I think this is the best way to handle it. Teaching people to fish that is.

Haha... you are part of some jealous assh#ole herd, I see assh## like you never help anyone & can't stand anyone else helping out as well.



If anyone needs help with genesis please contact me, I will help out for free.


Title: Re: More Genesis Block Discussion
Post by: anush3070 on April 15, 2014, 09:21:21 AM
Hello,

You can use this Code to find Genesis Block for N-Scrypt, Insert it before ///debug print comment which would be near hashMerkleRoot and compile ^_^:

Code:
              if (true &&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;

                  unsigned long int scrypt_scratpad_size_current_block = ((1 << (GetNfactor(block.nTime) + 1)) * 128 ) + 63;
                  char scratchpad[scrypt_scratpad_size_current_block];

                  loop
                  {
                 // Generic scrypt
                      scrypt_N_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad, GetNfactor(block.nTime));

                      if (thash <= hashTarget)
                      {
                     printf ("found it!\n");
                          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;
                      }
                  }
               }


Title: Re: More Genesis Block Discussion
Post by: nesticely on April 18, 2014, 08:17:48 AM
I have the following problem - when I compile daemon based on fehcoin (with pszTimestamp, block.nTime etc. changes) and I run it, I get empty nNonce:
Code:
Loading block index...
CBlock(hash=c18a2e48349763b42b90ac00881abee846203b789a2d86aacb2cd2aa5161c66f, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=25cc2e3283b86f225057d0eaa0eaa0003b891de79828f59bb4fc0b290ab897e2, nTime=1388419211, nBits=1f00ffff, nNonce=0, vtx=1, vchBlockSig=)
  Coinbase(hash=25cc2e3283, nTime=1375995262, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 04ffff001d020f272957687920776f756c6420796f75206e65656420426974207768656e20796f7520686176652053776167)
    CTxOut(empty)
  vMerkleTree: 25cc2e3283
block.GetHash() == c18a2e48349763b42b90ac00881abee846203b789a2d86aacb2cd2aa5161c66f
block.hashMerkleRoot == 25cc2e3283b86f225057d0eaa0eaa0003b891de79828f59bb4fc0b290ab897e2
block.nTime = 1388419211
block.nNonce = 0

block.nNonce = 0 Why is this happening?


Title: Re: More Genesis Block Discussion
Post by: anush3070 on April 18, 2014, 08:22:01 AM
I have the following problem - when I compile daemon based on fehcoin (with pszTimestamp, block.nTime etc. changes) and I run it, I get empty nNonce:
Code:
Loading block index...
CBlock(hash=c18a2e48349763b42b90ac00881abee846203b789a2d86aacb2cd2aa5161c66f, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=25cc2e3283b86f225057d0eaa0eaa0003b891de79828f59bb4fc0b290ab897e2, nTime=1388419211, nBits=1f00ffff, nNonce=0, vtx=1, vchBlockSig=)
  Coinbase(hash=25cc2e3283, nTime=1375995262, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 04ffff001d020f272957687920776f756c6420796f75206e65656420426974207768656e20796f7520686176652053776167)
    CTxOut(empty)
  vMerkleTree: 25cc2e3283
block.GetHash() == c18a2e48349763b42b90ac00881abee846203b789a2d86aacb2cd2aa5161c66f
block.hashMerkleRoot == 25cc2e3283b86f225057d0eaa0eaa0003b891de79828f59bb4fc0b290ab897e2
block.nTime = 1388419211
block.nNonce = 0

block.nNonce = 0 Why is this happening?

Do This Modification in the Code:

Hello,

You can use this Code to find Genesis Block for N-Scrypt, Insert it before ///debug print comment which would be near hashMerkleRoot and compile ^_^:

Code:
              if (true &&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;

                  unsigned long int scrypt_scratpad_size_current_block = ((1 << (GetNfactor(block.nTime) + 1)) * 128 ) + 63;
                  char scratchpad[scrypt_scratpad_size_current_block];

                  loop
                  {
                 // Generic scrypt
                      scrypt_N_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad, GetNfactor(block.nTime));

                      if (thash <= hashTarget)
                      {
                     printf ("found it!\n");
                          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;
                      }
                  }
               }


Title: Re: More Genesis Block Discussion
Post by: nesticely on April 18, 2014, 06:06:04 PM
I have the following problem - when I compile daemon based on fehcoin (with pszTimestamp, block.nTime etc. changes) and I run it, I get empty nNonce:
Code:
Loading block index...
CBlock(hash=c18a2e48349763b42b90ac00881abee846203b789a2d86aacb2cd2aa5161c66f, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=25cc2e3283b86f225057d0eaa0eaa0003b891de79828f59bb4fc0b290ab897e2, nTime=1388419211, nBits=1f00ffff, nNonce=0, vtx=1, vchBlockSig=)
  Coinbase(hash=25cc2e3283, nTime=1375995262, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 04ffff001d020f272957687920776f756c6420796f75206e65656420426974207768656e20796f7520686176652053776167)
    CTxOut(empty)
  vMerkleTree: 25cc2e3283
block.GetHash() == c18a2e48349763b42b90ac00881abee846203b789a2d86aacb2cd2aa5161c66f
block.hashMerkleRoot == 25cc2e3283b86f225057d0eaa0eaa0003b891de79828f59bb4fc0b290ab897e2
block.nTime = 1388419211
block.nNonce = 0

block.nNonce = 0 Why is this happening?

Do This Modification in the Code:

Hello,

You can use this Code to find Genesis Block for N-Scrypt, Insert it before ///debug print comment which would be near hashMerkleRoot and compile ^_^:

Code:
              if (true &&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;

                  unsigned long int scrypt_scratpad_size_current_block = ((1 << (GetNfactor(block.nTime) + 1)) * 128 ) + 63;
                  char scratchpad[scrypt_scratpad_size_current_block];

                  loop
                  {
                 // Generic scrypt
                      scrypt_N_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad, GetNfactor(block.nTime));

                      if (thash <= hashTarget)
                      {
                     printf ("found it!\n");
                          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;
                      }
                  }
               }

thank ;D ;D ;D


Title: Re: More Genesis Block Discussion
Post by: hadi on May 26, 2014, 09:36:59 AM

Hey...
My x11 source code is
Code:
        //// debug print
        uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7"));
        block.print();
        assert(hash == hashGenesisBlock);

i cant get hashGenesisBlock.
after compiling with true time and hash,just recieve this error " failed to read block "
what i do ?


Title: Re: More Genesis Block Discussion
Post by: voileipa on May 26, 2014, 10:01:46 AM

Hey...
My x11 source code is
Code:
        //// debug print
        uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7"));
        block.print();
        assert(hash == hashGenesisBlock);

i cant get hashGenesisBlock.
after compiling with true time and hash,just recieve this error " failed to read block "
what i do ?
At first you should check the debug log for more specific error information.


Title: Re: More Genesis Block Discussion
Post by: PereguineBerty on May 26, 2014, 08:27:05 PM
See what you guys mean with X11 errors. I've played around with Scrypt in the past and it's pretty much plain sailing but with x11 PoS it's been an absolute nightmare so far...

Even after getting what appears to be valid merkle root, nonce and genesis hash, it still fails when running on both testnet and main-net with this error:

Code:
Assertion `block.GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)' failed.

I've taken Yarkol's advice and it has been pretty helpful but if the debug.log clearly states these values and no other errors, then I'm a loss as to why the genesis blocks aren't being created.

Code:
Opened LevelDB successfully
CBlock(hash=000030b4df1fca238412d3acb536f920fb3fe4fc2b1255c40e78d54ac791e1ac, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000,
hashMerkleRoot=00f5217426974f0aae85ef32ed69f99543993ebb8e995c4089febecd87f5e1b5, nTime=1401124588, nBits=1f00ffff, nNonce=29392, vtx=1, vchBlockSig=)
  Coinbase(hash=00f5217426, nTime=1401124588, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 00012a4154686973206973206f6e652070656173616e7473207265766f6c742074686174204272757373656c732063616e6e6f74206a757374206272757368206173696465)
    CTxOut(empty)
  vMerkleTree: 00f5217426
block.GetHash() == 000030b4df1fca238412d3acb536f920fb3fe4fc2b1255c40e78d54ac791e1ac
block.hashMerkleRoot == 00f5217426974f0aae85ef32ed69f99543993ebb8e995c4089febecd87f5e1b5
block.nTime = 1401124588
block.nNonce = 29392
CBlock(hash=000030b4df1fca238412d3acb536f920fb3fe4fc2b1255c40e78d54ac791e1ac, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000,
hashMerkleRoot=00f5217426974f0aae85ef32ed69f99543993ebb8e995c4089febecd87f5e1b5, nTime=1401124588, nBits=1f00ffff, nNonce=29392, vtx=1, vchBlockSig=)
  Coinbase(hash=00f5217426, nTime=1401124588, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 00012a4154686973206973206f6e652070656173616e7473207265766f6c742074686174204272757373656c732063616e6e6f74206a757374206272757368206173696465)
    CTxOut(empty)
  vMerkleTree: 00f5217426

The testnet (the output above) and main-net genesis hashes have been added into main.h but it still fails to run?



Title: Re: More Genesis Block Discussion
Post by: hadi on May 27, 2014, 10:17:54 AM
i dont know why i have not " block.GetHash() == 000030b4df1fca238412d3acb536f920fb3fe4fc2b1255c40e78d54ac791e1ac" section in my debug.log in x11 algorytm.


here is my main.cpp


Code:
// Only add the genesis block if not reindexing (in which case we reuse the one already on disk)
    if (!fReindex) {
        // Genesis Block:
        // CBlock(hash=12a765e31ffd4059bada, PoW=0000050c34a64b415b6b, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=97ddfbbae6, nTime=1317972665, nBits=1e0ffff0, nNonce=2084524493, vtx=1)
        //   CTransaction(hash=97ddfbbae6, ver=1, vin.size=1, vout.size=1, nLockTime=0)
        //     CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d0104404e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536)
        //     CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
        //   vMerkleTree: 97ddfbbae6

        // Genesis block        
        const char* pszTimestamp = "Coindesk 27/May/2014 Facebook-Integrated Wallet Makes Sending Bitcoin as Easy as Messaging";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 50 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
        CBlock block;
        block.vtx.push_back(txNew);
        block.hashPrevBlock = 0;
        block.hashMerkleRoot = block.BuildMerkleTree();
        block.nVersion = 1;
        block.nTime    = 1401181723;
        block.nBits    = 0x1e0ffff0;
        block.nNonce   = 0;

        if (fTestNet)
        {
            block.nTime    = 1401181723;
            block.nNonce   = 3861367235;
        }

        //// debug print
        uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e"));
        block.print();
        assert(hash == hashGenesisBlock);

        // Start new block file
        try {
            unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION);
            CDiskBlockPos blockPos;
            CValidationState state;
            if (!FindBlockPos(state, blockPos, nBlockSize+8, 0, block.nTime))
                return error("LoadBlockIndex() : FindBlockPos failed");
            if (!block.WriteToDisk(blockPos))
                return error("LoadBlockIndex() : writing genesis block to disk failed");
            if (!block.AddToBlockIndex(state, blockPos))
                return error("LoadBlockIndex() : genesis block not accepted");
        } catch(std::runtime_error &e) {
            return error("LoadBlockIndex() : failed to initialize block database: %s", e.what());
        }
    }

    return true;
}



and my wallet closed with Failed to read block and my debug.log is

Code:
2014-05-27 09:31:24 


2014-05-27 09:31:24 DarkCoin version v0.9.4.8-gd1aadc8-beta (Sun, 25 May 2014 14:08:31 -0700)
2014-05-27 09:31:24 Using OpenSSL version OpenSSL 1.0.1g 7 Apr 2014
2014-05-27 09:31:24 Default data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 09:31:24 Using data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 09:31:24 Using at most 125 connections (2048 file descriptors available)
2014-05-27 09:31:24 Using 4 threads for script verification
2014-05-27 09:31:24 init message: Verifying wallet...
2014-05-27 09:31:24 dbenv.open LogDir=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\database ErrorFile=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\db.log
2014-05-27 09:31:24 Bound to [::]:47258
2014-05-27 09:31:24 Bound to 0.0.0.0:47258
2014-05-27 09:31:24 init message: Loading block index...
2014-05-27 09:31:24 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\blocks\index
2014-05-27 09:31:24 Opened LevelDB successfully
2014-05-27 09:31:24 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\chainstate
2014-05-27 09:31:24 Opened LevelDB successfully
2014-05-27 09:31:24 LoadBlockIndexDB(): last block file = 0
2014-05-27 09:31:24 LoadBlockIndexDB(): transaction index disabled
2014-05-27 09:31:24 Initializing databases...
2014-05-27 09:31:24 39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7
2014-05-27 09:31:24 00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6
2014-05-27 09:31:24 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 09:46:05




2014-05-27 09:46:05 DarkCoin version v0.9.4.8-gd1aadc8-beta (Sun, 25 May 2014 14:08:31 -0700)
2014-05-27 09:46:05 Using OpenSSL version OpenSSL 1.0.1g 7 Apr 2014
2014-05-27 09:46:05 Default data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 09:46:05 Using data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 09:46:05 Using at most 125 connections (2048 file descriptors available)
2014-05-27 09:46:05 Using 4 threads for script verification
2014-05-27 09:46:05 init message: Verifying wallet...
2014-05-27 09:46:05 dbenv.open LogDir=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\database ErrorFile=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\db.log
2014-05-27 09:46:05 Bound to [::]:47258
2014-05-27 09:46:05 Bound to 0.0.0.0:47258
2014-05-27 09:46:05 init message: Loading block index...
2014-05-27 09:46:05 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\blocks\index
2014-05-27 09:46:05 Opened LevelDB successfully
2014-05-27 09:46:05 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\chainstate
2014-05-27 09:46:05 Opened LevelDB successfully
2014-05-27 09:46:05 LoadBlockIndexDB(): last block file = 0
2014-05-27 09:46:05 LoadBlockIndexDB(): transaction index disabled
2014-05-27 09:46:05 Initializing databases...
2014-05-27 09:46:05 39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7
2014-05-27 09:46:05 00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6
2014-05-27 09:46:05 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 09:46:05 CBlock(hash=39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7, input=0100000000000000000000000000000000000000000000000000000000000000000000005e772513d42435d9871208955bb543a61e4e44f4e7ea0f99f8a3c237205a612526558453f0ff0f1e00000000, PoW=39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e, nTime=1401181478, nBits=1e0ffff0, nNonce=0, vtx=1)
2014-05-27 09:46:05   CTransaction(hash=25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 04ffff001d01044c5a436f696e6465736b2032372f4d61792f323031342046616365626f6f6b2d496e74656772617465642057616c6c6574204d616b65732053656e64696e6720426974636f696e2061732045617379206173204d6573736167696e67)
    CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
  vMerkleTree: 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 10:04:49




2014-05-27 10:04:49 DarkCoin version v0.9.4.8-gd1aadc8-beta (Sun, 25 May 2014 14:08:31 -0700)
2014-05-27 10:04:49 Using OpenSSL version OpenSSL 1.0.1g 7 Apr 2014
2014-05-27 10:04:49 Default data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 10:04:49 Using data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 10:04:49 Using at most 125 connections (2048 file descriptors available)
2014-05-27 10:04:49 Using 4 threads for script verification
2014-05-27 10:04:49 init message: Verifying wallet...
2014-05-27 10:04:49 dbenv.open LogDir=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\database ErrorFile=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\db.log
2014-05-27 10:04:49 Bound to [::]:47258
2014-05-27 10:04:49 Bound to 0.0.0.0:47258
2014-05-27 10:04:49 init message: Loading block index...
2014-05-27 10:04:49 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\blocks\index
2014-05-27 10:04:49 Opened LevelDB successfully
2014-05-27 10:04:49 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\chainstate
2014-05-27 10:04:49 Opened LevelDB successfully
2014-05-27 10:04:49 LoadBlockIndexDB(): last block file = 0
2014-05-27 10:04:49 LoadBlockIndexDB(): transaction index disabled
2014-05-27 10:04:49 Initializing databases...
2014-05-27 10:04:49 39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7
2014-05-27 10:04:49 00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6
2014-05-27 10:04:49 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 10:04:49 CBlock(hash=39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7, input=0100000000000000000000000000000000000000000000000000000000000000000000005e772513d42435d9871208955bb543a61e4e44f4e7ea0f99f8a3c237205a612526558453f0ff0f1e00000000, PoW=39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e, nTime=1401181478, nBits=1e0ffff0, nNonce=0, vtx=1)
2014-05-27 10:04:49   CTransaction(hash=25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 04ffff001d01044c5a436f696e6465736b2032372f4d61792f323031342046616365626f6f6b2d496e74656772617465642057616c6c6574204d616b65732053656e64696e6720426974636f696e2061732045617379206173204d6573736167696e67)
    CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
  vMerkleTree: 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 10:09:53


2014-05-27 10:09:53 DarkCoin version v0.9.4.8-gd1aadc8-beta (Sun, 25 May 2014 14:08:31 -0700)
2014-05-27 10:09:53 Using OpenSSL version OpenSSL 1.0.1g 7 Apr 2014
2014-05-27 10:09:53 Default data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 10:09:53 Using data directory C:\Users\hadixxx7\AppData\Roaming\DarkCoin
2014-05-27 10:09:53 Using at most 125 connections (2048 file descriptors available)
2014-05-27 10:09:53 Using 4 threads for script verification
2014-05-27 10:09:53 init message: Verifying wallet...
2014-05-27 10:09:53 dbenv.open LogDir=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\database ErrorFile=C:\Users\hadixxx7\AppData\Roaming\DarkCoin\db.log
2014-05-27 10:09:53 Bound to [::]:47258
2014-05-27 10:09:53 Bound to 0.0.0.0:47258
2014-05-27 10:09:53 init message: Loading block index...
2014-05-27 10:09:53 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\blocks\index
2014-05-27 10:09:53 Opened LevelDB successfully
2014-05-27 10:09:53 Opening LevelDB in C:\Users\hadixxx7\AppData\Roaming\DarkCoin\chainstate
2014-05-27 10:09:53 Opened LevelDB successfully
2014-05-27 10:09:53 LoadBlockIndexDB(): last block file = 0
2014-05-27 10:09:53 LoadBlockIndexDB(): transaction index disabled
2014-05-27 10:09:53 Initializing databases...
2014-05-27 10:09:53 39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7
2014-05-27 10:09:53 39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7
2014-05-27 10:09:53 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 10:09:53 CBlock(hash=39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7, input=0100000000000000000000000000000000000000000000000000000000000000000000005e772513d42435d9871208955bb543a61e4e44f4e7ea0f99f8a3c237205a612526558453f0ff0f1e00000000, PoW=39a05234cb649f06386c80fa1469b84d4e8fc806d2e91f3348cdaa6ef72e26d7, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e, nTime=1401181478, nBits=1e0ffff0, nNonce=0, vtx=1)
2014-05-27 10:09:53   CTransaction(hash=25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 04ffff001d01044c5a436f696e6465736b2032372f4d61792f323031342046616365626f6f6b2d496e74656772617465642057616c6c6574204d616b65732053656e64696e6720426974636f696e2061732045617379206173204d6573736167696e67)
    CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
  vMerkleTree: 25615a2037c2a3f8990feae7f4444e1ea643b55b95081287d93524d41325775e
2014-05-27 10:09:53 Pre-allocating up to position 0x1000000 in blk00000.dat
2014-05-27 10:09:53 ERROR: CheckProofOfWork() : hash doesn't match nBits
2014-05-27 10:09:53 ERROR: CBlock::ReadFromDisk() : errors in block header
2014-05-27 10:09:53 *** Failed to read block
2014-05-27 10:09:55 ERROR: LoadBlockIndex() : genesis block not accepted
2014-05-27 10:09:55 Shutdown : In progress...
2014-05-27 10:09:55 StopNode()
2014-05-27 10:09:55 Flushed 0 addresses to peers.dat  16ms
2014-05-27 10:09:55 Committing 0 changed transactions to coin database...
2014-05-27 10:09:55 Shutdown : done

any idea about working ? i recompile it over 10 times


Title: Re: More Genesis Block Discussion
Post by: YarkoL on May 27, 2014, 11:19:02 AM
@PereguineBerty

It's hard to say what the issue exactly is, but hardly a x11 error
if you haven't got past the hash identity assertion yet.

Maybe you could start by simplifying this a little

Code:
!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)

i.e scrap the ternary operator, feed straight values into it so
you can begin to track down why the block hash isn't the same as
your gen block hash


Title: Re: More Genesis Block Discussion
Post by: PereguineBerty on May 27, 2014, 08:10:25 PM
Thanks for the info YarkoL.

I managed to get it working fine today. After doing the same thing a long time ago with Scrypt, I recollect it taking a while to grind through a range of hashes and nonces. Thought this was going to happen again and it threw me off the trail because all the correct stuff was there instantly and it seemed too good to be true, so I ignored it (stupidly) :)

Got issues with segmentation faults and missing setgenerate RPC commands now. Oh happy days!!!



Title: Re: More Genesis Block Discussion
Post by: YarkoL on May 27, 2014, 08:17:39 PM

Yeah X11 is more cpu-friendly  :)


Title: Re: More Genesis Block Discussion
Post by: PereguineBerty on May 27, 2014, 08:23:28 PM
Hehe.. detecting a subtle hint of sarcasm there :)


Title: Re: More Genesis Block Discussion
Post by: e1ghtSpace on June 14, 2014, 09:26:46 PM
Can someone please help me?
This is what I have in main.cpp:
Code:
        const char* pszTimestamp = "14 June 2014 Soceroos lose to Chile 3-1 in FIFA world cup";
        CTransaction txNew;
        txNew.nTime = 1402712622;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 0 << CBigNum(42) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].SetEmpty();
        CBlock block;
        block.vtx.push_back(txNew);
        block.hashPrevBlock = 0;
        block.hashMerkleRoot = 0;
        block.nVersion = 0;
        block.nTime    = 0;
        block.nBits    = 0;
        block.nNonce   = 0;

        //// debug print
        assert(block.hashMerkleRoot == uint256("0x0"));
        block.print();
        assert(block.GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet));
        assert(block.CheckBlock());

And in debug.log all I get is:
Code:
CBlock(hash=694b3a55a61339b43c01421b13f710e22e33a7eabda1cd48103bb9f376081d16, ver=0, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=0000000000000000000000000000000000000000000000000000000000000000, nTime=0, nBits=00000000, nNonce=0, vtx=1, vchBlockSig=)
  Coinbase(hash=b89a899f43, nTime=1402712622, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 00012a393134204a756e65203230313420536f6365726f6f73206c6f736520746f204368696c6520332d3120696e204649464120776f726c6420637570)
    CTxOut(empty)
  vMerkleTree:

What did I do wrong? (i'm trying to replace 0x0 with the Merkle Root)


Title: Re: More Genesis Block Discussion
Post by: YarkoL on June 14, 2014, 11:46:48 PM
try moving the block.print() statement
before the assertion


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 21, 2014, 09:33:38 PM
I hope someone can help me out with my pb

I got genesisblock on testnet, I try to test mining my testnet coins. I use 2 computers with each one ubuntu VM and different IP. I launch daemon and I try to get my PCs connected

I use the following cmd:
Quote
./myCoind -testnet

with following config:

Quote
rpcuser=user
rpcpassword=pass
server=1
addnode=ip_PC1
addnode=ip_PC2
rpcport=xxxxx
listen=1

My pb is i can't get connections with PC1 and PC2.

Quote
"walletversion" : 60000,
    "balance" : 0.00000000,
    "newmint" : 0.00000000,
    "stake" : 0.00000000,
    "blocks" : 0,
    "timeoffset" : 0,
    "moneysupply" : 0.00000000,
    "connections" : 0,
    "proxy" : "",
    "ip" : "0.0.0.0",
    "difficulty" : {

In debug.log I have

Quote
trying connection ip_PC1:xxxxx lastseen=0.9hrs
connection timeout
trying connection ip_PC1:xxxxx lastseen=0.9hrs
connection timeout
trying connection ip_PC1:xxxxx lastseen=0.9hrs
connection timeout

I don't know if i need to configure port forward in VM or my internet box.
There is something I can check that will help me spot where the pb is coming from ?


thnks


Title: Re: More Genesis Block Discussion
Post by: haggis on June 21, 2014, 09:37:06 PM
Can they ping each other? Ports blocked?


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 21, 2014, 09:43:37 PM
Can they ping each other? Ports blocked?

Yes I can ping each other public ip

btw in getinfo ip 0.0.0.0 is normal ?

thnks


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 24, 2014, 04:32:01 PM
Someone ??


Title: Re: More Genesis Block Discussion
Post by: YarkoL on June 24, 2014, 06:03:38 PM
The all-zero ip just tells that you're not being
seen by your peer. Could be variety of reasons for that,
and you aren't very clear about your configuration (two pc's
with vm's - are the nodes in vm's?)

In any case you don't need to add both nodes to the conf
files, just the other one. And your debug.log indicates that
your nodes have seen each other 0.9 hours ago, so something
has caused them to drop the connection.


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 24, 2014, 07:56:07 PM
The all-zero ip just tells that you're not being
seen by your peer. Could be variety of reasons for that,
and you aren't very clear about your configuration (two pc's
with vm's - are the nodes in vm's?)

In any case you don't need to add both nodes to the conf
files, just the other one. And your debug.log indicates that
your nodes have seen each other 0.9 hours ago, so something
has caused them to drop the connection.

Thanks for your answer.

My configuration is 2 PC with different public IP
PC1 and PC2 are using ubuntu on VM
I try to connect those 2 VMs. In config file,  those 2 IP in addnode are public IP from PC1 and PC2

The 0.9 hours I think is a default value because in log there is never connection


Title: Re: More Genesis Block Discussion
Post by: coinsolidation on June 24, 2014, 08:06:32 PM
start pc1 daemon, tail -f the debug.log
start pc2 daemon, see if any entry occurs in debug.log above


Title: Re: More Genesis Block Discussion
Post by: YarkoL on June 24, 2014, 08:22:29 PM
.
My configuration is 2 PC with different public IP
PC1 and PC2 are using ubuntu on VM
I try to connect those 2 VMs. In config file,  those 2 IP in addnode are public IP from PC1 and PC2

What I always do is to connect pc daemon with VM daemon.
Those will have different addresses, so I think the public ip's
do not reach down to vm's.

Try ifconfig on either of the ubuntus
and see what ip you get.


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 24, 2014, 08:27:47 PM
This is what i get on ubuntu VM wiht ifconfig

Quote
pk@pk-VirtualBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:3d:b5:a4  
          inet addr:192.168.1.56  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe3d:b5a4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:25144 errors:0 dropped:1 overruns:0 frame:0
          TX packets:19341 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:29876661 (29.8 MB)  TX bytes:3014061 (3.0 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4863 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4863 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:543609 (543.6 KB)  TX bytes:543609 (543.6 KB)

You think I need to forward data ?


What I don't understand is that, when I open a daemon of a random coin on either of the VMs they can connect easily to the network of the random coin and start synchronisation.


Title: Re: More Genesis Block Discussion
Post by: YarkoL on June 24, 2014, 08:31:19 PM

Try connecting to 192.168.1.56 either from
your pc or the other vm. Just get the other ip from
ifconfig or ipconfig (windows) also. Typically they
are of the form 192.168.1.x


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 24, 2014, 08:44:34 PM

Try connecting to 192.168.1.56 either from
your pc or the other vm. Just get the other ip from
ifconfig or ipconfig (windows) also. Typically they
are of the form 192.168.1.x

I can ping between host (PC1) local ip (192.168.1.84) and vm (VM1) local ip (192.168.1.54) that is running on host. This is Ok for both PC1/VM1 and PC2/VM2

But of course I can't cross ping local IPs between those 2 pcs because they are on different LAN.


 :-\


Title: Re: More Genesis Block Discussion
Post by: coinsolidation on June 24, 2014, 08:54:15 PM
Perhaps an obvious question, but you can ping google.com from both virtual machines yes?


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 24, 2014, 09:00:59 PM
Perhaps an obvious question, but you can ping google.com from both virtual machines yes?

Yes of course I can browse internet and ping google on VM. I also used a daemon of a working coin and synchronisation working well on VM



Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 24, 2014, 09:09:39 PM
I can get connection in daemon if I try to use local IPs of 2 pc ?


Title: Re: More Genesis Block Discussion
Post by: Restincoin on June 25, 2014, 05:27:25 PM
my daemon work now, i needed to forward ports  in my router and check vm is in bridge mode

thank you guys for help in debugging
 


Title: Re: More Genesis Block Discussion
Post by: DonQuijote on July 20, 2014, 12:08:58 AM
Thanks for sharing with us.
Its very useful information


Title: Re: More Genesis Block Discussion
Post by: DELTA9 on August 22, 2014, 09:25:58 AM
Working on a new coin (I know, too many already). I have had success mining a genesis block for a scrypt coin, but running into trouble now with X11. Is the process very different? I have changed the merklehash and now my wallet daemon runs without any errors on my local machine, but I am getting an assertion error after compiling on my VPS. Assertion 'hash == hashGenesisBlock' failed. I have been trying to get this working for days but can't seem to figure out what I am doing wrong.


Title: Re: More Genesis Block Discussion
Post by: YarkoL on August 23, 2014, 12:02:11 AM
Working on a new coin (I know, too many already). I have had success mining a genesis block for a scrypt coin, but running into trouble now with X11. Is the process very different? I have changed the merklehash and now my wallet daemon runs without any errors on my local machine, but I am getting an assertion error after compiling on my VPS. Assertion 'hash == hashGenesisBlock' failed. I have been trying to get this working for days but can't seem to figure out what I am doing wrong.

If the code compiles on one machine, it
should work on another.
Check and compare that you have the same
merkleroot,
nonce,
timestamp,
hashGenesisBlock

and of course the same algo


Title: Re: More Genesis Block Discussion
Post by: cisahasa on June 23, 2015, 12:14:26 PM
im trying to create peercoin genesis block and got it done quite easily
im using the 0.8.6 based source
but sometimes cant find it beacuse nonce reseting back to zero, why this is happening?
where is the part of source doing this:

2015-06-22 08:06:15 n=4095M hash=fbf2af49cbd6dfdb2bc61e5ac2a0f2f7847b14d122345b1d7afccfab9ef2d7a5
2015-06-22 08:06:17 n=0M hash=be71678a2a5a4c073f71e87f22816de6e567135cc23c3079118f089dd6c622c5

after 4095M nonces drop back to 0

where is the part of the sourcecode doing this?
i tried to find answer related to value 0xffff, but did not get it yet why this is happening


Title: Re: More Genesis Block Discussion
Post by: l8nit3 on July 30, 2015, 03:08:38 AM
Hello all, I'm attempting to compile a cloned version of fastcoin (NOT FOR REALEASE, JUST LEARNING). Ive managed to get as far as obtaining my merkle hash. However, now that im at the part of generating a genesis block by changing if (false && block.GetHash() != hashGenesisBlock) to if (true && block.GetHash() != hashGenesisBlock) Ive run into a roadblock. It seems the dev team who created fastcoin has heavily modified their source, and i am missing that particular line of code in main.cpp lol. Any chance someone knows what they may have changed it too? (or is willing to take a look?) Or is it more likely that it was just removed as a method of stopping people from cloning their source to a new chain?


Title: Re: More Genesis Block Discussion
Post by: YarkoL on July 30, 2015, 06:28:54 AM
Hello all, I'm attempting to compile a cloned version of fastcoin (NOT FOR REALEASE, JUST LEARNING). Ive managed to get as far as obtaining my merkle hash. However, now that im at the part of generating a genesis block by changing if (false && block.GetHash() != hashGenesisBlock) to if (true && block.GetHash() != hashGenesisBlock) Ive run into a roadblock. It seems the dev team who created fastcoin has heavily modified their source, and i am missing that particular line of code in main.cpp lol. Any chance someone knows what they may have changed it too? (or is willing to take a look?) Or is it more likely that it was just removed as a method of stopping people from cloning their source to a new chain?

Take a look at some other coins source to
familiarize yourself what the genesis block producing code looks
like. It is indeed in the fastcoin source, but the condition under
which it runs is different.



Title: Re: More Genesis Block Discussion
Post by: tearodactyl on May 04, 2017, 06:37:59 PM
Updated 2017 Genesis Block information http://practicecoin.com/index.php/2017/04/19/genesis-block/


Title: Re: More Genesis Block Discussion
Post by: freemanjackal on June 16, 2017, 05:01:19 PM
i was able to compile and make some modifications, but when i execute litecoind, it obviously give me the error genesisblock does not match, everything fine until there,
what i am not being able to find the debug.log file, it supposes it is created a .litecoin folder where the log file should it be, but the .litecoin folder in home it is not being created...
so i would like some enlightment in this part, anyone could help me? thanks


Title: Re: More Genesis Block Discussion
Post by: vlom on July 27, 2017, 03:23:31 PM
What I did so far:

Change pszTimestamp to a sentence from newspaper
change block.nTime to current time

compile

run compiled source with -testnet -noirc

now u see some lines and a crash
Code:
b115383690ee67ebeef9a7e754342638cd7bbf488561998e6d1bc1ed367484f6 // Block derived from pszTimestamp
b8fa883689f099d3942ff73439d9f55d60a5e257b0d69a8f0f6ab4572ecff415 // Genesisblock (invalid cuz its already coded wrong)
bd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9 // MerkleRoot (Valid because its newly calculated

corresponding to code:
Code:
        //// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0xbd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9"));

update main.cpp with the mentioned merkleroot (it crashed because of the last assert) and run again

you should have already changed the false to true in
Code:
        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)

so it will find a genesis block for your string

after a long time you get:
Code:
nonce 003C1000: hash = e8525d8ae8a74a33dbc4b06a64c97ced84dfd29628b3e9e4197c7030cc4a09d3 (target = 00000ffff0000000000000000000000000000000000000000000000000000000)
block.nTime = 1367704866
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33
CBlock(hash=fafdbfc957ea6867a074, PoW=000000b1398554a520b5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=bd58bf217a, nTime=1367704866, nBits=1e0ffff0, nNonce=3939341, vtx=1)
  CTransaction(hash=bd58bf217a, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043741442e6e6c20342f352042657672696a64696e6773646167207a6f6e6e69672c20646161726e61206f6f6b207a6f6d657273207761726d)
    CTxOut(error)
  vMerkleTree: bd58bf217a
xx: main.cpp:2070: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed.
Aborted (core dumped)

Now you have the valid Genesisblock and nNonce:
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33

Update your code with these values and your ready to go!



i have to reactivate this topic. i am playing with coin-cloning an now i am stuck at the MerkleRoot-part.

The app crashes and in terminal i got this:

Code:
Assertion failed: (block.hashMerkleRoot == uint256("0x")), function LoadBlockIndex, file main.cpp, line 2031.
Abort trap: 6

and according to this how-to (https://gist.github.com/mhsjlw/8130158de01071aa8c87) i should find the hash in a log file. but in the only corresponding log file i found i only have this.

Quote
c6e32eac75316aa6be562726b219fac84560439fea1c819550fb95abbeb23582
5813d4cfab0eeda94a15d11c5e7d6895e667fbbe67c59ef9a1b3bc232c9a0b7f
c12f442c067f5c64e58e294d423c36b42201801a55ed551fa0d4da57b1810651

the how-to says i should have something like this:

Quote
Thanks to tyrion's amazingly helpful post, we can decipher this debug out put as so:

b1753ec3845a48ddc4618bc595af6dc89dac328cd48f9f8db178df5dd3b302fc Block hashed using the non-existent Merkel, based on the pzTimestamp from main.cpp
0000000000000000000000000000000000000000000000000000000000000000 Genesis block, no good because all the nNonces are set to 0 in main.cpp
2fc1b7ef46270c053711fbae934cf7f83378efd4b3e158079451d9c6c90e4700 Valid Merkel Hash, generated using the epoch time in main.cpp


or is one off the three lines above the hash i need?

thank you.

EDIT: i got it, reformatting the text from the how-to solves the problem.... the third line is the hash i need.


Title: Re: More Genesis Block Discussion
Post by: maiiyeuchong on November 06, 2017, 01:03:59 AM
I need to help. I have created a coin for myself, but when sent, can not receive. Why wallet contacted the system it has multiple ports connected to it
http://fs5.directupload.net/images/171105/uncttku6.png
http://fs5.directupload.net/images/171105/i8qqsing.png
http://fs1.directupload.net/images/171105/el82all8.png


Title: Re: More Genesis Block Discussion
Post by: Bobby_Atlas on December 27, 2017, 06:32:13 PM
Is there any options or script or maybe somebody know how to midify Genesis H0 to get Genesis block for blake256 algo?


Title: Re: More Genesis Block Discussion
Post by: Bobby_Atlas on December 28, 2017, 02:21:25 AM
Guys really need your help, i've downloaded linked above script, added blake-256 hashing algo there, but how to tell that script to use extranonce and nversion as options while it generates merkle and hash?


Will be really appriciated for help and give bounty on coin start!


Title: Re: More Genesis Block Discussion
Post by: Tokenista on August 25, 2018, 07:35:55 AM
Ethereum Smart Contract pre-compiled
https://github.com/satansdeer/ethereum-token-tutorial


Title: Re: More Genesis Block Discussion
Post by: realdantreccia on March 03, 2022, 09:58:08 PM
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


Shots fired @BillyMarkus!!! That's part of the devtome guide. BOOO GAVIN BOOO!

https://www.devtome.com/doku.php?id=scrypt_altcoin_cloning_guide&rev=1391981820#genesis_blocks