Blockchain Data Management

In my last blog, I have briefed on basics of Blockchain. In this blog, I will try to cover details on how actual data gets stored/managed on chain of blocks.

As you all know Blockchains are of distributed architectures, which follows peer-to-peer network and essentially inherits all advantages of peer to peer network like performance, avoiding single point failure etc.

Below diagram shows a high level overview of Peer-to-Peer network.

peer-to-peer-network

Here each and every node is connected with each other and share the resources, so there is no dependency on centralized machine, like traditional client server architecture.

Data management on chain:
Here, we will try to understand how data gets managed on blockchain and what are contents of individual block on a blockchain.

All transactions are grouped in a unit and the unit is referred as a block, please refer image below.
block-chain-02

In the above image, there are blocks with actual transaction data on it, apart from transaction data there are few other standard properties on every block which are as follows:

1. Index: Index is nothing but a sequential block number.
2. Timestamp: Time on which block data is added.
3. Hash: It’s a unique hash value for the data. It is generated using mathematical functions. Every block has different hash values which directly communicates with the data (i.e. if data gets changed then hash value also will get changed)
4. Previous Hash: It contains hash value of previous block, which is to get backward reference

In my previous blog, I had mentioned that Blockchains’ key trait is immutability. Let see how it works.

Immutability over Blockchain:
We know that all of the Traditional databases are built for CRUD (Create, Read, Update and Delete) operations. On the other hand, blockchain only allows appending and retrieve, so once added data cannot be deleted and updated.

In blockchain, any node which has access to ledger can check and verify if the ledger has been tampered or any transaction in any block has been changed. This is mainly done by calculating hash value of the block data and then comparing with previous hash value stored in next block.

Below example will help us to understand it more…

Ex: Below is the blockchain, where latest block is Block#555

block-chain-03

Here peer or node can calculate the hash value of block#554 and can check if the previous hash value of block#555 is same as the hash value of block#554. If it’s not the same then it is declared as tampered. The below image depicts the verification flow.

block-chain-04

In case of tampered data and failure of validation, rejection of a block will happen by all the nodes.

Blockchain leverages consensus (general agreement) mechanism for validating the transactions

Blockchain Consensus
It’s a protocol by which peer agrees with the state of the ledger, it ensures all peers in network have exactly the same copy of the ledger and fraudulent transactions are kept out of the ledger. It also guarantees to record transaction in chronological order.

Below is a brief explanation of the common consensus protocols.

Common Consensus Protocols:
1. Proof of work:
Proof of Work (PoW), as the name states, it is the validation of the work that happened and proving it is correct. This is the way of consensus to make sure the authenticity of the chain is good.

The main drawback of using PoW is that it requires more electric power and high computing hardware which is expensive.
2. Proof of stake:
Proof of Stake (PoS) is an alternate way of verifying and validating the transaction or block. PoS pick the validator by the amount of stake validator has and respective age of the stake. In PoS, the validators earns the part or whole of the transaction fee.

PoS eliminates the main challenges from PoW and believed to have an advantage as there is no need of expensive hardware and also energy efficient as it won’t consume high electricity as PoW does.
3. Tendermint:
The Tendermint is an open-source project to address the speed, scalability, and environmental issues of Bitcoin’s Proof-of-Work consensus algorithm. It uses BFT (Byzantine fault-tolerant consensus) algorithm.

Bitcoin and Ethereum blockchain networks uses Proof of work.

Further reading…
Everledger manages diamonds on blockchain. They maintain details of over 1000 diamonds on blockchain. For more details, you can visit this link http://everledger.io

  • Pingback: Basics of Blockchain – Cuelogic Blog()

  • Fantastic information,Thanks. Tendermint is a solution to the block-chain consensus problem that does not require mining by adapting an existing solution to the Byzantine Generals Problem.