Pages:
Author

Topic: Why is it necessary to mine the genesis block? (Read 427 times)

member
Activity: 189
Merit: 16
With a new blockchain started in 2021, even if the genesis block is precomputed with a non-zero difficulty, it may still be feasible for someone with considerable mining power to just compute the first X blocks again and replace the block history...

Not quite. Mining the first 32000 blocks (difficulty 1) would take a little more than 1 second with a S19 pro; however, you still would need 51% to replace all of the blocks.

If you started clandestinely mining an alternative chain from the beginning, you needed 101% of the mining power used for the public chain in order to completely replace it. If you started later, you needed even more. But with the insane amounts of mining power professional miners on a large blockchain have, compared with the mining power the average blockchain started by some random developer would likely have, this is not completely out of sight.
legendary
Activity: 3444
Merit: 10558
And later, Satoshi hardcoded Genesis Block data in the client to prevent that kind of attack. But he forgot about adding that transaction to the database, so it became unspendable.

So, I assume that devs can't hardcode this transaction into the client right now without performing a hardfork?
That's correct but it is not about "forgetting", Satoshi may have intentionally avoided adding that transaction to the UTXO database because the genesis block (i.e. block 0) was technically "premined" before the client was released a couple of days later whereas block 1 was mined after release.
legendary
Activity: 4298
Merit: 3209
With a new blockchain started in 2021, even if the genesis block is precomputed with a non-zero difficulty, it may still be feasible for someone with considerable mining power to just compute the first X blocks again and replace the block history...

Not quite. Mining the first 32000 blocks (difficulty 1) would take a little more than 1 second with a S19 pro; however, you still would need 51% to replace all of the blocks.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
And later, Satoshi hardcoded Genesis Block data in the client to prevent that kind of attack. But he forgot about adding that transaction to the database, so it became unspendable.

So, I assume that devs can't hardcode this transaction into the client right now without performing a hardfork?
member
Activity: 189
Merit: 16
It is necessary to prevent Genesis Block overwriting. Satoshi timestamped Genesis Block with the NY Times message to prove that this block was not mined earlier. In old versions, Genesis Block was not any special case in code. You just started from zero hash and built on top of it. But then, everyone could overwrite the whole chain, including the Genesis Block. And later, Satoshi hardcoded Genesis Block data in the client to prevent that kind of attack. But he forgot about adding that transaction to the database, so it became unspendable.

So, you can start with no Genesis Block at all, just build on top of zero hash and you will get simpler code. But then, overwriting all blocks will be possible, including the first block in the chain.

With a new blockchain started in 2021, even if the genesis block is precomputed with a non-zero difficulty, it may still be feasible for someone with considerable mining power to just compute the first X blocks again and replace the block history, if the incentive for doing so is large enough. So, I doubt that the risk of overwriting blocks can be fully eliminated just by having a precomputed genesis block. It may be a part of an effective strategy, though.
jr. member
Activity: 102
Merit: 5
GameBit - The Network
As far as I know you don't mine the genesis block, you hardcode it.

Exactly, to calculate the genesis hash you need write your own code within your bitcoin clone. It's a bit complicated for beginners Wink
Cheers
It is only complicated for those who have no idea how bitcoin and specifically blocks and mining them works. Otherwise the only difference between Genesis block and any other block is that Genesis block's previous block hash is empty! Everything else is the same.

Need to be say, that its the first block. Without it the new chain wouldnt start and it would connect to the chain, which was used or forked from the source before. Indeed its a difference to the original genesis block which was mined before, but not to the following block yes. Normaly the developers calculate it on their own without getting it listed in a code block.
legendary
Activity: 3444
Merit: 10558
As far as I know you don't mine the genesis block, you hardcode it.

Exactly, to calculate the genesis hash you need write your own code within your bitcoin clone. It's a bit complicated for beginners Wink
Cheers
It is only complicated for those who have no idea how bitcoin and specifically blocks and mining them works. Otherwise the only difference between Genesis block and any other block is that Genesis block's previous block hash is empty! Everything else is the same.
jr. member
Activity: 102
Merit: 5
GameBit - The Network
As far as I know you don't mine the genesis block, you hardcode it.

Exactly, to calculate the genesis hash you need write your own code within your bitcoin clone. It's a bit complicated for beginners Wink
Cheers
hero member
Activity: 667
Merit: 1529
Yes, today the chain is strong and overwriting it is hard. But at the beginning, nothing protected the network from overwriting blocks, even Satoshi mentioned that "The software is still alpha and experimental. There's no guarantee the system's state won't have to be restarted at some point if it becomes necessary, although I've done everything I can to build in extensibility and versioning". Of course in early versions, the longest chain was counted as "valid", but later it was changed to the "heaviest" chain. So, Satoshi always wanted to define "Bitcoin" as "the chain with the most Proof of Work". And in case of disagreement, the Genesis Block with the most proof of work would be treated as the starting point. So, by mining Genesis Block, overwriting everything is just more difficult.

Also, if more than one person is involved in coin creation, then it is possible to use Proof of Work to decide which Genesis Block should be used. Just N people can buy the newspaper on selected date (for example today), include message from it, and start running their PCs to mine the Genesis Block with the most Proof of Work. After some time (for example 24 hours), the best block could be selected and hardcoded into mining software.
legendary
Activity: 3444
Merit: 10558
Yes, but if you can overwrite the Genesis Block, then you can start the whole chain earlier. So, for example, instead of starting from 2009-01-03, you could start from 1970-01-01. And then, you could pretend that the whole chain existed earlier. So, this block was hardcoded to prevent pretending that Bitcoin was invented before by someone else than Satoshi.
You keep saying "overwrite" but the bitcoin blockchain is immutable and not a single block can change specially when they are deep. It doesn't matter what the "text" in signature script of a block says, you still have to mine n+1 blocks when the main chain has n blocks to be able to overwrite any of the blocks.

The only purpose that this text serves is that it proves that "Satoshi" didn't mine genesis block in 1970-01-01!
legendary
Activity: 2954
Merit: 4158
Yes, but if you can overwrite the Genesis Block, then you can start the whole chain earlier. So, for example, instead of starting from 2009-01-03, you could start from 1970-01-01. And then, you could pretend that the whole chain existed earlier. So, this block was hardcoded to prevent pretending that Bitcoin was invented before by someone else than Satoshi.
The inclusion of the scriptsig's message was a reference to the article so yes, that is what Satoshi intended; proving that he started the chain no earlier than the date but it has nothing to do with who invented what, and when was it invented. The genesis block is not important, you can just attack by reorganizing everything after the genesis block and it would achieve the same thing. It is definitely better to have a pre-defined starting point for a blockchain though.

Genesis block was hardcoded for the start, if I'm not wrong. Here's the snippet of the code.
Code:
  //
    // Init with genesis block
    //
    if (mapBlockIndex.empty())
    {
        if (!fAllowNew)
            return false;


        // Genesis Block:
        // GetHash()      = 0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
        // hashMerkleRoot = 0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
        // txNew.vin[0].scriptSig     = 486604799 4 0x736B6E616220726F662074756F6C69616220646E6F63657320666F206B6E697262206E6F20726F6C6C65636E61684320393030322F6E614A2F33302073656D695420656854
        // txNew.vout[0].nValue       = 5000000000
        // txNew.vout[0].scriptPubKey = 0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704 OP_CHECKSIG
        // block.nVersion = 1
        // block.nTime    = 1231006505
        // block.nBits    = 0x1d00ffff
        // block.nNonce   = 2083236893
        // CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
        //   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
        //     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
        //     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
        //   vMerkleTree: 4a5e1e

        // Genesis block
        char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig     = CScript() << 486604799 << CBigNum(4) << vector((unsigned char*)pszTimestamp, (unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue       = 50 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG;
        CBlock block;
        block.vtx.push_back(txNew);
        block.hashPrevBlock = 0;
        block.hashMerkleRoot = block.BuildMerkleTree();
        block.nVersion = 1;
        block.nTime    = 1231006505;
        block.nBits    = 0x1d00ffff;
        block.nNonce   = 2083236893;
hero member
Activity: 667
Merit: 1529
Yes, but if you can overwrite the Genesis Block, then you can start the whole chain earlier. So, for example, instead of starting from 2009-01-03, you could start from 1970-01-01. And then, you could pretend that the whole chain existed earlier. So, this block was hardcoded to prevent pretending that Bitcoin was invented before by someone else than Satoshi.
legendary
Activity: 3444
Merit: 10558
But then, everyone could overwrite the whole chain, including the Genesis Block.
To "overwrite" the whole chain, one requires the majority hashrate (51% attack) so that they can build a chain that can be longest. With or without a hardcoded genesist block, this attack is always possible as long as one can acquire that much of the hashrate.
hero member
Activity: 667
Merit: 1529
It is necessary to prevent Genesis Block overwriting. Satoshi timestamped Genesis Block with the NY Times message to prove that this block was not mined earlier. In old versions, Genesis Block was not any special case in code. You just started from zero hash and built on top of it. But then, everyone could overwrite the whole chain, including the Genesis Block. And later, Satoshi hardcoded Genesis Block data in the client to prevent that kind of attack. But he forgot about adding that transaction to the database, so it became unspendable.

So, you can start with no Genesis Block at all, just build on top of zero hash and you will get simpler code. But then, overwriting all blocks will be possible, including the first block in the chain.
legendary
Activity: 2954
Merit: 4158
And I'm asking again:  What do you mean by saying "valid"? A proof of work is proof only if it's necessary. For example finding hash that doesn't exceed a certain target. Is your proof of work valid if you don't find such hash? You may have worked, but not enough to "prove" something. Satoshi worked, but there wasn't any purpose to do so. There wasn't something to be proved and thus, it's wrong to say that he mined the genesis block.
I think I have touched on the validity of a block above?

Proof of work is a concept that proves that someone has expended resources in exchange for finding a hash that meets a target. Satoshi's genesis block proves exactly this and I'm sure he didn't get it by chance.

You really don't have to make the genesis block valid, it is after all just something for your subsequent blocks to reference. You can test it out and construct it without meeting the target but I'm not sure whether it would fail with any validation or not.  There is really no issues as long as you can exclude it from any (if any) PoW checks.
legendary
Activity: 2114
Merit: 1292
There is trouble abrewing
bitcoin's genesis block is defined this way that Satoshi decided to also mine that block too so that block zero also has a valid proof of work.
And I'm asking again:  What do you mean by saying "valid"?
valid means when you compute the hash of genesis block the result is indeed lower than the target (which is minimum value for block 0).

Quote
A proof of work is proof only if it's necessary.
proof of work is just proof that you have worked!
meaning by publishing the nonce (and the combination that is the header) you prove that you have actually performed some work to find that combination so that the hash of it is lower than the target. it is not possible to guess such a combination.

Quote
For example finding hash that doesn't exceed a certain target. Is your proof of work valid if you don't find such hash?
you won't have any proof if the hash is not lower than the target, it might as well be an arbitrary hash.

Quote
Satoshi worked, but there wasn't any purpose to do so. There wasn't something to be proved and thus, it's wrong to say that he mined the genesis block.
that's a different question. Satoshi probably mined genesis block because it is still a valid bitcoin block and he also had enough time to mine it since there was no competition or anything like that.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
You only have to do that if your blockchain is empty (like his), like Satoshi did in the early days.
What difference would it make if it wasn't empty? I'm forking Bitcoin Core and I'm wondering if I can just enter a random hash, since you wrote that it doesn't check it. Also, by the way if you know it, where's the function that performs SHA256 to the genesis conditions and returns the hash?

bitcoin's genesis block is defined this way that Satoshi decided to also mine that block too so that block zero also has a valid proof of work.
And I'm asking again:  What do you mean by saying "valid"? A proof of work is proof only if it's necessary. For example finding hash that doesn't exceed a certain target. Is your proof of work valid if you don't find such hash? You may have worked, but not enough to "prove" something. Satoshi worked, but there wasn't any purpose to do so. There wasn't something to be proved and thus, it's wrong to say that he mined the genesis block.

You can make exceptions for certain blocks, but it is better if you don't.
If you're referring to Bitcoin, it does have an exception. The output of block 0 can't be spent.
legendary
Activity: 4298
Merit: 3209
Why do I have to mine the genesis block?...
Isn't mining necessary only when we want to proof a work? There's no proof of work on the genesis block, only the initial conditions to start the chain.

You can make exceptions for certain blocks, but it is better if you don't.
legendary
Activity: 2114
Merit: 1292
There is trouble abrewing
the real answer is that you don't have to do anything, bitcoin's genesis block is defined this way that Satoshi decided to also mine that block too so that block zero also has a valid proof of work. otherwise if you are changing stuff you can also change this little detail so that the software uses an arbitrary block 0 with no proof of work.
there is also no reason to validate block 0 proof of work.
legendary
Activity: 2954
Merit: 4158
It really does skip the validation checks for genesis block, at least for mainnet and signet, and I'm sure that's how testnet works too. mainnet signet
Yeah. In the earlier versions, the validation logic doesn't exclude the genesis block or at least that is my understanding of the code.

Do review the codes and let me know if I'm missing something.
Pages:
Jump to: