Block Of Blockchain What You Might Not Know

Anatomy Of A Block Of Blockchain

You probably already know that blocks are the essential blocks that build up Blockchain.

All in all, what precisely is inside the block?

The web isn’t just hardware, it’s also made up of words. Basically, a block is a literal block whose main purpose is to record transactions.

A block comprises of block header and block body.

Block Of Blockchain
Block Of Blockchain

The block header is composed of three sets of information:

  • The first set is the hash value of the previous block, which is used to associate the block with its previous block.
  • The second set is the information that related to miners competing for mining, that is – difficulty, timestamp, and Nonce – a random value.
  • The third set is the root hash value calculated from the block body, that is, the Merkle tree root (aka hash tree root).
Block fields definition

The block body contains pieces of transaction information and forms a special tree data structure.

For instance, in the event that there are 4 transaction information in the block body, 4 hash values ​​are generated, and then they match each other and keep on generating new hash values ​​to turn into a node of the tree. Rehash this cyclic process continuously, and finally get a root hash value, which is the top-level hash value, resulting in a hash tree.

Block used referenced hash to connect previous block

Each block in a blockchain contains three main components:

  • First, the block contains the stored transactions. For instance, information on monetary transactions, including the identification of the payer’s e-wallet, the payee’s e-wallet, and the transfer amount.
  • Second, each block contains a hash. This code is generated based on the information in the current block, like a unique fingerprint for each block.
  • Third, each block contains a referenced hash of the previous block it is associated with. The referenced hash (or the previous block hash) is the chain that associates the blocks to each other. Each new block in the chain is confirmed by computer consensus on the ledger before the transaction is finalized and added to the chain.

The Main Part Of Block Structure

Block Height
Block with height of 47114

In this simplified example block, we can see that its list contains four lists of transactions.

Glance back at our past post on Paper Blockchain Model , each block is a piece of paper that lists transactions for each day in a ledger format.

As a matter of fact, Bitcoin blocks contain 1,500 to 2,000 transactions for every block, but this number varies between different blockchains and relies on the block size limit.

The block size is usually limited to avoid congestion on the network.

The current Bitcoin block size limit is one megabyte, this is to reduce the threat of spam and potential Denial-of-Service (DoS) attacks on the network.

Each block has a unique number or its height. A Block Height  refers to a specific location in the blockchain, measured by the number of confirmed blocks it has before it.

The number 47114 in the above example block is its height. Since the blockchain is linear, the height of the next block can be incremented again. So, you can only have one block at a given height.

The block also contains a timestamp, a random value called Nonce, some other information, and the hash of the previous block in the chain, which we will discuss in detail.

Block Validity Vs Miner

Now we have to discuss one of the most important concepts in blockchain – Validity.

Not all blocks are created equal, by far the most of blocks are invalid.

Yet, what precisely does this mean? Then we need to talk about what a Bitcoin miner is!

Finding a valid block is the hard work that those miners do while mining. The so-called difficulty of the blockchain is essentially only an inconsistent setting to determine the difficulty of creating a new block.

This is the place where all the new block value comes from!

In the event that anybody could also create a new block and link it to the blockchain, creating a new block would be worthless. Also, there will never be a consensus on the network on which blocks should be put on the blockchain.

Creating a new block means the miner has to do a lot of work, which is called Proof-of-Work (PoW). By finding a valid block, the miner proves that his work is finished.

For blockchains like Bitcoin and Ethereum, the difficulty level can be changed to ensure that new block is created consistently.

So how can everything work?

A block is defined as valid provided that the hash value of the entire block is consistent, the hash value is only a numerical value, and its value must be lower than the threshold number set by the blockchain difficulty.

When we hash the entire block, we get a unique signature for all the information it contains. Assuming that you change the information in any block, it will essentially change the original hash, as we mentioned in the past post – Hash Function .

Block validity with valid hash

The way you want to determine if this block is valid, you just need to check whether the hash of this block is below the difficulty threshold!

We can see that the hash value of the above sample block – “02ef0ab2da” is greater than the set difficulty threshold “0010000000“, so this block is invalid.

In our example, we need the first three digits of the hash to be zero for the block to be considered valid. Just like we saw in the hash of the previous sample block – “0008df23e5“.

The higher the difficulty, the lower the number of hash outputs must be for a block to be valid. Since the hash is random, lower values ​​are more difficult to find. It’s like throwing dice, it’s more difficult to throw a 2 or less than a 3 or more.

Blockchain Difficulty
Blockchain Difficulty vs D16 Dice

You can think of each hashed number as a rolling D16 Polyhedral Dice. To get the three zeros we want, you need to throw three D16 dice and get three ones (since there are no zeros on the dice). You can imagine that you need to throw the dice an infinite number of times, about 4,000 times for this to happen.

For a block to achieve this, we can only change the block’s information and can rehash the change, again and again, to check whether we happen to get a valid hash.

Yet, what information can you change in the block? It contains all the important transaction information that you can’t change!

NONCE The Random Value

The block validity of the hash is closely related to the difficulty threshold. Only the hash less than the difficulty threshold is valid; otherwise, the hash is invalid and must be recalculated.

Since the difficulty threshold is very small, the chance of the hash being smaller than this value is incredibly small, and it may be calculated 1 billion times before it is counted as one hit. This is the main reason why mining takes so long and slow.

As mentioned earlier, the hash of the current block is determined by the block header. If a new hash is to be calculated for the same block, it means that the block header should continue to change, and in any case, computing various hashes is impossible!

All the values ​​in the block header are fixed. To make the block header change, Satoshi Nakamoto purposely added a random item called Nonce.

The Nonce is a random value and is the key part of the Proof-of-Work, and its only function is to allow miners to arbitrarily change the value of the block header in the current block. Miners keep changing the Nonce value, expecting to luck out and make the hash of the block header output less than the difficulty threshold.

Once miners find the Nonce value that causes the block hash to fall below the difficulty threshold, the block is finally considered valid and can be appended to the current blockchain.

The Only Way Of Checking Block Validity

How do nodes in the blockchain confirm the validity of new blocks?

Block Validity
Valid Block with previous block hash

When other nodes on the network receive a valid Block X, they can check its validity by using a hash function and make sure its hash is below the difficulty threshold.

Once its validity is confirmed, Block X is added to the blockchain at the height of X, and work starts with the next Block X+1, which will include the previous Block X hash in its information, this guarantees the continuity of the blockchain.

A reference to the previous block hash value prevents the block from being tampered with!

For instance, Block X and Block X+1 are sequential blocks in a block ledger. The hash value of Block X is “xyz“; the hash value of Block X+1 is “abc“, and its referenced (previous block) hash value is “xyz“.

Block generates new hash after tampered

If someone modifies the information of Block X, it will generate a new hash “def“. However, since the referenced hash of Block X+1 still records the old hash “xyz” of Block X; the referenced hash of Block X+1 does not match the hash of Block X today, thus indicating that the chain has been Changed.

This has major implications for blockchain. If someone modifies a Block X, the hash of that Block X changes. For the following Block X+1 (child block) to still be connected to this Block X (because the child Block X+1 contains the hash of the previous Block X), this person must modify all the following blocks in turn (X+1, X+2, …); otherwise, the changed Block X will be removed from the blockchain.

Due to the reasons mentioned above, the calculation of the hash is very time-consuming. Unless someone controls more than 51% of the computing power of the entire network, it is impossible to modify multiple blocks at the same time in a short period, so this is almost impossible.

In our very early post, we mentioned Decentralized Ledgers and its consensus mechanism 

Relying on this consensus mechanism, the blockchain guarantees its security and reliability. Once a new block is added to the blockchain, it cannot be tampered with.

Miner Competition

In our discussion, we just showed that we need to find a hash value that starts with three zeros.

At present on the Bitcoin blockchain, miners must find hashes starting with 19 zeros. It’s the same difficulty as throwing a 36-sided dice and getting all 6s.

The Nonce is extremely challenging to find; and currently, it can only be done one by one through the exhaustive method. According to the protocol, Nonce is a 32-bit field, its value can be up to 21.47 billion.

In order to complete the verification faster than other, miners compete with one another using the hashing power. It can be understood that the miner starts from 0 and has been calculating few million times to meet the conditions to get a valid Nonce value.

Once the Valid Nonce is found, the block is validated and add to the blockchain and there by receive the mining reward.

The mining rewards are substantial, as of May 2020, the reward for finding a block in the Bitcoin network is 6.25 BTC, or about $250,000. So it’s no wonder that there’s a lot of competition!

1 Comment

  1. Israel lady

    Very good post. I absolutely appreciate this website. Stick with it!

Leave a Reply

Your email address will not be published.