Blockchain Byte - Week 22 : Chaining the Block

Blockchain Byte - Week 22 : Chaining the Block
Photo by Tezos on Unsplash

Table of Contents

  1. Recap
  2. What is a Block?
  3. Block Identification
  4. Block Hash
  5. Block Header
  6. Reference to Previous Block Hash


Last week we explained how nodes validate & verify transactions in a Blockchain. In a Blockchain, transactions are added to the public ledger by nodes in the below order:

  1. Nodes independently verify each transaction
  2. Nodes independently aggregate or group transactions into new blocks
  3. Nodes independently verify new blocks
  4. Nodes independently add these blocks to a "chain"

We explained step 1 & started with step 2 on blocks which we will elaborate below.

(Before reading further, I highly recommend you read Weeks 12 & 13 related to Hashing & Public Key cryptography - links below).

Week 12

Week 13

What is a Block?

A block is a data structure (like an excel sheet with fields for data) where transactions are included and aggregated.

It contains fields for

  1. Identifying the block (Block Hash & Block Header)
  2. Incorporating transactions into the block (Block Body)

Block Identification

The fields under this are :

  1. Block Hash
  2. Block Header

Block Hash

Last week, I mentioned that blocks are akin to transaction batches where multiple transactions are bunched or grouped together to form a batch. In traditional core banking systems, a batch of transactions is normally represented by a Batch ID which is a unique set of characters generated by the system automatically to identify that batch. No two batches can have the same Batch ID.

Similarly for a block, there is a cryptographic hash which is uniquely identifiable only to that block which is generated using hashing algorithms. This hash is always unique and like a fingerprint. No two blocks will have the same hash and a hash is generated as soon as a block is created.

If a block is tampered with (by either modifying the transaction amount or beneficiary key), it's hash changes and hence the block hash is a powerful detector to identify any block tampering.


Block Header

A Block header consists of below fields (also called metadata) :

  1. The previous block hash
  2. Fields related to mining
  3. Merkle Root Tree - a unique hash of all the transactions in the block combined

The below diagram makes it more clear :


Let us deep dive into each of the above :

Reference to Previous Block Hash

In traditional core banking systems, transactions are passed in an environment where ledgers, transactions and data are stored in one platform. This creates a linkage between the data in the system where new transactions link to the relevant ledgers which updates the balances of these ledgers from time to time. Hence, movement of funds can be kept track of from the beginning till its current state by checking all the entries related to that fund movement.

In a Blockchain, the underlying platform and ledgers are all decentralized and maintained at individual nodes. However, that does not lessen the importance of keeping track of funds and movement of value & ownership. Now, how are transactions which are passed at various points in time in different blocks linked to previous transactions? This is done by linking these blocks to each other. So how are these blocks linked?

We saw above that blocks are identified through their block hash. So, to link Block 1 to Block 2, Block 2 has a field in the block header called "Previous Block Hash" where the hash of Block 1 will be filled in. This ensures that the block header of Block 2 contains the hash of Block 1. This is how blocks are "chained with each other" and hence the name BLOCKCHAIN.

Let us visualize the above example :


One thing to note is that the decentralized ledger does not keep track of account balances at all. It only records each and every transaction that is verified & approved. It only keeps track of each and every transaction broadcasted within the blockchain network. But how does the wallet show our balances?

The wallet identifies all the transactions that ever took place on the network connected to the keys related to that wallet & consolidates them into the data structure of the wallet and shows the balance. This balance consolidation & verification is performed based on the links to previous transactions.

To summarize,

  1. The blockchain network orders transactions by grouping them into blocks.
  2. Each Block is represented by a unique Block ID
  3. Each block contains a definite number of transactions and a Block header
  4. Each Block is linked to the previous block through the "previous block hash" in the Block header.

Next week we will explore

  1. Mining related fields &
  2. Merkle Tree