Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Haw on November 07, 2017, 07:36:03 PM



Title: Possibility of a very low next block hash
Post by: Haw on November 07, 2017, 07:36:03 PM
I’ve just started reading about the math of Bitcoin.

If I look at the blockhashes of the Bitcoin blocks we start the f with blocks of a few leading zeros, and right now (latest block at the time of writing is #493508) we’re at 18 leading zeros.

Since the hash algorithm may create an almost random number from the input, so for the function sha256(sha256(previous_blockhash+nonce)), there must be a theoretical chance that the next valid blockhash is much much smaller, say 20 or more leading zeros.

Is this possible or is there something in the algorithm that forbids this?

If possible, what would happen if the next block hash is much much smaller that the previous one? Does it make mining of the next block more difficult, or does the next valid block hash only have to be smaller that the set difficulty and not smaller that the previous hash?

If the next difficulty is decreased, there must also be a possibility that we’ve missed a couple of valid hashblocks, so we could have mined more bitcoins at the previous difficulty. Yes?


Title: Re: Possibility of a very low next block hash
Post by: DannyHamilton on November 07, 2017, 08:20:56 PM
Since the hash algorithm may create an almost random number from the input, so for the function sha256(sha256(previous_blockhash+nonce)),

That's not exactly the right formula.

It is actually:
SHA256(SHA256(Current_block_header))

Where the current block header includes 6 pieces of information:

  • Version
  • previous_block_hash
  • merkle_root
  • timestamp
  • difficulty_target (expressed in a format named "bits")
  • nonce

there must be a theoretical chance that the next valid blockhash is much much smaller, say 20 or more leading zeros.

Absolutely.  Nothing wrong with that.  The result only needs to be less than the current target. It doesn't matter how much less.

Is this possible or is there something in the algorithm that forbids this?

Nope.  Nothing forbids it.

If possible, what would happen if the next block hash is much much smaller that the previous one?

It wouldn't matter.  All that matters is that the hash is smaller than the current difficulty target.  The values of the hashes of the previous blocks in the chain have no bearing on that.

Does it make mining of the next block more difficult,

Nope.  Each hash of the next block has an equal chance of being any value between 0 and 2256.  As long as that value is less than the target value (and the rest of the block is valid), it will be accepted.

or does the next valid block hash only have to be smaller that the set difficulty and not smaller that the previous hash?

Correct.

If the next difficulty is decreased, there must also be a possibility that we’ve missed a couple of valid hashblocks, so we could have mined more bitcoins at the previous difficulty. Yes?

No.

Each block has a specific block subsidy (currently 12.5 BTC).  That subsidy is adjusted every 210000 blocks regardless of how long it took to create those blocks.  The difficulty is adjusted every 2016 blocks, regardless of how long it takes to create those blocks.

Note:  Difficulty doesn't always increase.

Difficulty is adjusted to keep the block generation close to an average of 10 minutes per block.  If it takes more than 20160 minutes to solve 2016 blocks, then blocks are happening too slowly, so the difficulty is DECREASED to speed up block creation.


Title: Re: Possibility of a very low next block hash
Post by: Haw on November 07, 2017, 08:25:04 PM
Thanks


Title: Re: Possibility of a very low next block hash
Post by: haltingprobability on November 07, 2017, 11:19:21 PM
@OP: Yes, that can happen. It is called a golden nonce (https://en.bitcoin.it/wiki/Nonce).