Ep. 18 [Block-creation]Block-Threshold

in #bitcoin7 years ago (edited)

Note:
Gain a fundamental understanding of Cryptocurrency in an easy way. Before continue reading the story, I recommend to take a couple of minutes and read through the prior article again in order to refresh your present knowledge. The more often you read through the stories, the more confident you will get with the technology behind cryptocurrencies like Bitcoin. Take your time, to understand cryptocurrencies, as a Steemian it's worth it. The pictures are drawn by @RatzFratz, thanks for that!
If something in the story is not clear to you, don’t hesitate to ask. There are several people who might have the same question. So shoot me a comment, if something is unclear. Me and other readers will appreciate it

----

In the last episode we took a closer look about the block-component "reference".



In this episode I want to continue with the next important block-component, the Threshold

In Episode 14 we defined:

"Threshold: This number is given automatically from the Bitcoin-Software. You can see this threshold as a limitation for the possible Block-Numbers..."

Lets dive deeper into it:

So in Episode 2.1  we saw that a new valid block is being attached to the blockchain every 10 minutes. But here we have to ask ourselves, how is this 10 minutes timeframe being achieved, as the Bitcoin-Network in decentralised and there is no central "referee", who takes care of this rule.

Well, there is no need for a central 'referee':

Like we mentioned in the prior episodes, a new Bitcoin-Node is downloading also the Bitcoin-protocol. The Bitcoin-protocol is a set of rules, which the Bitcoin-Node follows. Among other things, these rules determine "How a legit transaction shall look like" or "what components does a block-candidate have to include in order to be valid" etc.

In Episode 09 we saw that, the Bitcoin-Nodes constantly exchange blocks and transactions with each other in order to stay up-to-date.

)

On of these rules states, what is the maximum block-number a block can have, in order to be seen as a valid block by the Bitcoin-Node and thus the Bitcoin-Node attaches it to its own blockchain. This limitation for the block-number is the threshold we are talking about. The Bitcoin-Node is actually calculating the threshold for itself. So it's not a static number which it takes from the Bitcoin-protocol. But the independent calculation is based on rules from the protocol. The other day we saw, that a block-number is the hash of the block-header. we also saw that, the hash is random. That means that a miner can not determine a specific hash when he creates a block. In other words, the best chance for the miner to get a specific hash, is "trial error". So just producing as many hashes through little changes in the input(therefore we have the "nonce" in the block-header), til the hash(=block-number) fits within the threshold(=limitation).

So the threshold in the block-header is the limitation for the block-number(=hash) of the block-candidate, so that the block will be accepted by the other Bitcoin-Nodes. 

Note: Here I want to mention again that there is no central "referee" who determines the "valid" threshold. That means a miner is choosing the Bitcoin-protocol, on which his block-creation is based on, which he thinks is also used by the other Bitcoin-Nodes - So that his block-candidate will be seen as valid as it is based on the same rules the other Bitcoin-Nodes regard as valid and thus follow.

Example:

In order to keep the example simple, we assume that a hash(=block-number) always consists of 5 binar digits (=binar=2 possibilities= "0" & "1"),  like for example "10010".

Now the threshold. We said the threshold is the limitation for a valid block-number, in order to be seen as valid by other Bitcoiin-Nodes.

Lets say the threshold is "00111".

Now in order to not exceed the threshold of "00111", our hash must have a "0" on the first two positions.

As we claimed before, a miner can not produce a specific hash, but he needs to produce as many hashes randomly til it reaches a desired number. There are to possibilities for the first digit-position. In a binary system it will be either "0" or "1". So the chance of getting a "0" on the 1st position is 50%. On the second position we have the same probability -> also 50% for a "0". The digit on the 3rd position is irrelevant, as the 3rd. position of the threshold is "1". So it doesn't matter if our hash will have a "0" or a "1" in the 3rd position as both comply with "<=1" and thus not exceed the limitation.

So the probability that a miner produce a hash which have a "0" on the first two digit-positions and thus doesn't exceed the threshold is:

50% x 50% = 25%

Or in probabilistic words: The miner needs to produce 4 hashes (= 4 block-candidates), in order to get a block-candidate with a valid block-number.

This example is a simplification and is only there to show clearly the interaction between "threshold" and "hashes" without a central referee.


In the next episode we will talk about:

  • How the threshold is being calculated in order to fulfill the rule "1 block every 10 minutes"?
  • How many hashes are being really produced in the Bitcoin-Network?