Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: AlexMerced on April 26, 2013, 12:47:46 AM



Title: The Genesis Block
Post by: AlexMerced on April 26, 2013, 12:47:46 AM
I'm editing the SmallChange Source code and here is how it looks like:

-uint256 hashGenesisBlock("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2");
-static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); // Litecoin: starting difficulty is 1 / 2^12
+uint256 hashGenesisBlock("0x384b060671f4a93948e9c168216dadb0ca2fbc54aa11c86b0345b6af1c59b2f5");
+static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); // starting difficulty is 1 / 2^12

I'm assuming I should change the genesis block, but how do I know what to put there, can I change it to anything?


Title: Re: The Genesis Block
Post by: Remember remember the 5th of November on April 26, 2013, 05:23:41 AM
The genesis block creation is not as simple as changing the letters to be anything.

I have written a Genesis block creator in C, but it won't work for scrypt i.e Litecoin based cryptos. https://bitcointalk.org/index.php?topic=181981.0 however it will give you an insight on how it's done.
It's also not just a matter of changing "uint256 hashGenesisBlock("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2");" there are many more things that need to be edited.


Title: Re: The Genesis Block
Post by: AlexMerced on April 26, 2013, 11:19:01 AM
Thank you very much!

I know there's more to change that's just the first instance I ran into where this is an issue.

Thanks for the thread, still kind of confused but ill keep working at it, if anyone else has any insight on how to create a LTC genesis block it would be much appreciated.


Title: Re: The Genesis Block
Post by: Peter Todd on April 26, 2013, 04:04:17 PM
Thanks for the thread, still kind of confused but ill keep working at it, if anyone else has any insight on how to create a LTC genesis block it would be much appreciated.

I know I'm being rude here, but if you need to ask for help creating a genesis block for your alt-coin, you have no business creating an alt-coin.

If you just want to have fun and learn how crypto-currencies work, that's fine. Just recognize that you are a long way from being competent enough to be doing this seriously.


Title: Re: The Genesis Block
Post by: AlexMerced on April 26, 2013, 05:08:52 PM
Thanks for the thread, still kind of confused but ill keep working at it, if anyone else has any insight on how to create a LTC genesis block it would be much appreciated.

I know I'm being rude here, but if you need to ask for help creating a genesis block for your alt-coin, you have no business creating an alt-coin.

If you just want to have fun and learn how crypto-currencies work, that's fine. Just recognize that you are a long way from being competent enough to be doing this seriously.

I get that, and I am doing this for fun, I'm not really working on the idea that I'll actually compete with any of the main altcoins... I just really want to do it to see what's involved. Now that's out of the way, any advice to point me in the right direction.


Title: Re: The Genesis Block
Post by: Remember remember the 5th of November on April 26, 2013, 05:19:59 PM
Thanks for the thread, still kind of confused but ill keep working at it, if anyone else has any insight on how to create a LTC genesis block it would be much appreciated.

I know I'm being rude here, but if you need to ask for help creating a genesis block for your alt-coin, you have no business creating an alt-coin.

If you just want to have fun and learn how crypto-currencies work, that's fine. Just recognize that you are a long way from being competent enough to be doing this seriously.

I get that, and I am doing this for fun, I'm not really working on the idea that I'll actually compete with any of the main altcoins... I just really want to do it to see what's involved. Now that's out of the way, any advice to point me in the right direction.
Well, I modified my genesis block generator to work with scrypt, I am able to create the PoW hash for scrypt and the merkle hash correctly, just not sure how to get the other hash, the genesis block hash. Apparently they are two different things.

EDIT:After reading up on scrypt, I think I figured out how to do it.


Title: Re: The Genesis Block
Post by: AlexMerced on April 26, 2013, 05:50:19 PM
awesome, do I use the same script you linked to above, and how do I run the program, do I have to take it into a compiler or is there an executable?

(I'm learning a lot of this as I go along, but I'm determined to learn it so be patient with me, I realize how stupid my questions probably sound.)


Title: Re: The Genesis Block
Post by: grue on April 26, 2013, 06:26:32 PM
awesome, do I use the same script you linked to above, and how do I run the program, do I have to take it into a compiler or is there an executable?

(I'm learning a lot of this as I go along, but I'm determined to learn it so be patient with me, I realize how stupid my questions probably sound.)
he says it's in C, so you'll need gcc, mingw or visual c++.


Title: Re: The Genesis Block
Post by: Peter Todd on April 26, 2013, 07:00:03 PM
I get that, and I am doing this for fun, I'm not really working on the idea that I'll actually compete with any of the main altcoins... I just really want to do it to see what's involved. Now that's out of the way, any advice to point me in the right direction.

Good to hear.

In addition to everyone else's responses, take a look at contrib/pyminer in the Bitcoin-QT repository. It's a Python implementation of a miner - possibly easier to understand than a C implementation. Changing it to mine a genesis block rather than mine shares would be educational.


Title: Re: The Genesis Block
Post by: scintill on April 26, 2013, 09:57:10 PM
Good to hear.

In addition to everyone else's responses, take a look at contrib/pyminer in the Bitcoin-QT repository. It's a Python implementation of a miner - possibly easier to understand than a C implementation. Changing it to mine a genesis block rather than mine shares would be educational.

Additionally I would suggest the stepping-stones of hardcoding a "live" genesis block's information, getting that all to hash together correctly, then replacing the hardcoded parts gradually, and finally adding mining if you would like.  It is of course up to you and depends on what existing resources you can find, how much you want to do "from scratch", and what languages/libraries you are familiar with.


Title: Re: The Genesis Block
Post by: AlexMerced on April 26, 2013, 09:58:37 PM
I'm going to download the compiler from codeblocks.org and I'll try this stuff out, excited


Title: Re: The Genesis Block
Post by: markm on April 27, 2013, 07:29:55 AM
Back when I was making genesis blocks for oodles of altcoins for the Galactic Milieu project, it used to be that when the program crapped out saying the genesis block hash was wrong, it would show the current genesis block's hash (the hash it claimed was wrong).

Back then there was, near the top of main.cpp, a definition of what the expected genesis block was to be. That is what it was comparing to the actual hash of the actual genesis block we had coded in ourselves for our new coin.

So, we'd take the current hash the error complained about and plug it in as the expected hash to compare against.

So basically you run it once to find out what your actual new genes block's hash actually is, then code that in as the correct genesis block hash to expect and run again.

Of course since nowadays you want a nice high difficulty as initial difficulty, it could take many hours or days or weeks to actually compute a genesis block hash that is actually difficult enough to match the starting difficulty of the coin, but that is just a matter of pointing enough hashing power at it and waiting for however long it takes.

-MarkM-


Title: Re: The Genesis Block
Post by: Remember remember the 5th of November on April 27, 2013, 07:45:36 AM
Back when I was making genesis blocks for oodles of altcoins for the Galactic Milieu project, it used to be that when the program crapped out saying the genesis block hash was wrong, it would show the current genesis block's hash (the hash it claimed was wrong).

Back then there was, near the top of main.cpp, a definition of what the expected genesis block was to be. That is what it was comparing to the actual hash of the actual genesis block we had coded in ourselves for our new coin.

So, we'd take the current hash the error complained about and plug it in as the expected hash to compare against.

So basically you run it once to find out what your actual new genes block's hash actually is, then code that in as the correct genesis block hash to expect and run again.

Of course since nowadays you want a nice high difficulty as initial difficulty, it could take many hours or days or weeks to actually compute a genesis block hash that is actually difficult enough to match the starting difficulty of the coin, but that is just a matter of pointing enough hashing power at it and waiting for however long it takes.

-MarkM-

Does it even matter what the initial difficulty of the genesis block is? I mean, since you can change the code you can really control what happens and whatnot.


Title: Re: The Genesis Block
Post by: js2082 on April 27, 2013, 06:30:39 PM
It doesn't matter I think, once you computed the genesis block and just enter the time and nonce and it will find it next time immediately. Just the take some time initially to find the corresponding nonce.


Title: Re: The Genesis Block
Post by: AlexMerced on April 27, 2013, 08:45:52 PM
Remember the 5th of November: is this the version of your script that works with Scrypt now? http://pastebin.com/nhuuV7y9

also I'm starting to piece together the steps, but is there an articles somewhere that explains the whole logic of this process, I think I get the idea which is...

- Run a script to general Genesis Block/Merkel Hash

- Code the results into the clients code

- Mine the Genesis Block

Where I am really confused is sort of the why of all this, like why is this done this way?


Title: Re: The Genesis Block
Post by: twobits on April 28, 2013, 08:06:21 AM


Where I am really confused is sort of the why of all this, like why is this done this way?

Simple it was never the intent of the code to support different chains.

Multicoin was a code fork awhile back that changed this to some extent.  It was capable of running the different alt coins available at the time just by changing the configurations you used it with, not not recompiling.  You could thus use it to pretty easily make a different coin by just creating a new config file.

https://github.com/twobits/MultiCoin-2bit


Title: Re: The Genesis Block
Post by: AlexMerced on April 28, 2013, 02:35:19 PM
That's a good idea, I still want to finish this particular code edit and compile to learn the steps to do so I just keep getting on confused on which genesis block variables I need to generate and how

I've had some say just change it and the software will figure it out, others say I need to run a script but what do I alter in the script so I don't end up with the same block as another coin. Also the hashing the time stamp I'm still trying to get my head around. If I can figure this out I should be ok, I just don't want to
Make any changes here till I get it so I don't break anything.