Blockchain: Understanding basics - part 1

Blockchain: Understanding basics - part 1

In this article let's try to demystify and understand the basics of the blockchain infrastructure and see how it contributes to the web3 ecosystem.

What is a blockchain?

Basically, blockchain is a Data Structure. Very similar to other data structures like databases (rows, columns, tables), text files, CSV, images, lists, and so on. Blockchain competes most closely with a database.

For an analogy, let's visualize blockchain as pages in a book
Chain = Book
Block = Page
Blocks in Chain = Pages in Book
Each page in a book contains:

  • text: content/story

  • information about the page: chapter number/title, page number

Similarly in a blockchain block, each block has:

  • contents of the block: Transaction details in cryptocurrency, or any data which we prefer to store

  • header: Metadata - data about the block. Some sort of technical info about the block, a reference to the previous block, and a fingerprint (hash) of the data for the current block

In blockchains, each block references the previous block by a computed hash value called the block’s fingerprint. The fingerprint is computed based on the contents of the block.

The concept of maintaining a reference to the previous blocks can be visualized as a linked list structure. In the linked list each node holds a reference to the next node, whereas in the blockchain each block holds a reference to the previous block.

books_and_blocks

This creates the fancy structure called the blockchain!


The fingerprint in each block is responsible for taking care of the consistency and validity of the data. If someone tries to meddle with any of the data, they have to end up regenerating all the fingerprints from that point forwards and the blockchain will look different. This is basically impossible as the process of creating fingerprints is difficult and slow. Therefore, if someone wants to re-write parts of the blockchain, it will take them a long time, and they have to catch up with and overtake the rest of the honest network. Which is not feasible.

Hence the blockchain is called immutable (as it cannot be changed).

The below image shows the inside of a blockchain block: the fingerprints are unique to the block’s contents.

block-chain-inside


Data Distribution

There are two ways of distributing data in a network: Client-Server and Peer to peer. Blockchain is built on top of the peer-to-peer model.

peer-to-peer and client-server

Client-server
This is a traditional approach where the server holds 100% of the data, and the clients connect via required protocols to access/consume the data.

Peer-to-peer
In peer-to-peer models, each peer has 100% of the data (or as close to it as possible), and updates are shared around. This is less efficient than client-server, as data is replicated many times. However, it's more robust as there is no central server that can be controlled, so closing down peer-to-peer networks is harder.

But on the contrary, the peer-to-peer model comes with its downsides. In the real world each peer on the network is gonna process and update at its own speed and latency and end up having varied states at a given timestamp. Deciding on which peer holds the valid data and which peer has stale or tampered data is ambiguous.

This conflict is resolved by a rule called the “longest chain rule” - If you see multiple blocks, treat the longest chain as legitimate. We can discuss in-depth on this conflict resolution and consensus in a separate article.


Conclusion

Blockchain is not something that is associated with only Bitcoin. Ethereum is a great variant of blockchain with smart contracts. There are significant challenges involved.
On the other hand, private or internally distributed ledgers and blockchains can be deployed to solve a wide range of problems and use cases.