11th Aug 2021

Holochain : Beginner’s Guide

Blockchain

Written By, Bhawik Chawda

Overview

We all know, the first blockchain bitcoin, was constructed to be consensus-based where all its nodes (miners of the bitcoin) had to agree on the transaction, which makes the transaction trustworthy, but slow and inefficient.
As of now bitcoin can maximum handle 7 transactions per second which is not acceptable for the global transaction system.

The scalability problem of bitcoin has given various new blockchain solutions and one of them is ‘HOLOCHAIN’.
It introduces the concept of agent-centric (computer’s, cloud etc) which owns their own chain which means that millions and millions of chain can communicate with each other and transactions are recorded on each chain. So, let’s see what exactly a Holochain is.

What is Holochain ?

It is an open source application development framework for building fully peer-to-peer applications, it means that it owns and controls your data with no intermediary.It allows you to create truly serverless applications with high level of reliability, scalability and performance.
In this, every user runs the application on their own device and creates, stores their own data and communicates directly to another user.The security of an application is secured by cryptography and peer accountability.

structure-of-holochain

source

IMPORTANT KEY POINTS:

  • Conventional centralized architecture is no doubt easy to maintain and understand but they all create central points of failure.
  • Users of the holochain application are in charge of their own identity and data.
  • In holochain application data, storage, security are all distributed across the network which reduces the central point of failure.
  • Data comes from various sources, there is no single global database.

Architecture of Holochain

Now lets understand how holochain applications are structured, basically they are made up of loosely coupled components.

architecture-of-holochain

source

  • There is one module called ‘Zome’ which specifies the core logic of the application. It discloses its public function to the holochain environment such as the validation function which validates each data that zome defines, others functions are declared by the developers.
  • One or more zomes are combined to form ‘DNA’ which defines the basic functionality and rules of an application.
  • Clients on the user devices communicate with the DNA’s API’s with remote procedure call (RPC) interface, front end can be written in any language and tools.
  • DNA’s are hosted in the user’s conductor, a runtime that executes the DNA’s code, manages storage and data flow.

Source chain

In holochain, each user creates and stores their own data in a journal called ‘Source Chain’ which is immutable once written and also cryptographically signed by the authors.

Every action of the users are stored in a source chain as element which consist of headers and entry. Again each entry has a type which means what you are going to record such as a message, pictures etc or action such as transaction, votes.

Header is the cryptographically hashed of previous element data, which ensures the integrity of the data. Every element is linked with the hash of previous elements’ data.

The first three entries are known as genesis entries and they are special system types which consist of the hash of DNA, agent joining proof’s and agent ID.

source-chain

source

  • The hash of DNA : It is because DNA’s executable code constitutes the rules of an application and this shows that your holochain runtime agrees to follow these rules.
  • Agent’s joining proof : When any agent tries to join the DNA’s peer-to-peer network it shares this entry with the peer who decides whether the agent should be allowed to join or not.
  • Agent ID : This consists of the agent’s public key for digital identity.

Distributed hash table (DHT)

In the Holochain network, source chain headers and public entries are shared with a random selection of a peer.

distributed-hash-table

source

In the holochain network, every DNA has its own private and encrypted network of peers where they communicate with each other about new peers, data breaches, security etc.
This network holds the distributed hash table of all public data which is basically a key/value pair.

holochain-network

source

  • Each agent receives its DHT address based on its public key, also each data receives its DHT address based on its hash.
  • Agents decide the size of a neighbourhood they want to be authority for and commits to keep track of all the peers and stores data whose address falls in that neighbourhood.
  • Whenever agents create a new entry or want to query a piece of data then agents look in their own list of peers and compare their address with the data address.
  • If there are no authorities found for any data address then peer communicates with the top candidates.
  • If a candidate found the authority of the data address they responded with confirmation of storage (in case of publishing) or requested data (in case of query) else it will look in their own peer and suggest peers who are more likely to have authority and this process keeps on repeating until authorities are found.

Conclusion

Here we come to the end of our Holochain Guide. In this we have discovered about Holochain, what makes it different from blockchain, and why it is more scalable. We also went into the Holochain architecture and DHT (Distributed hash table) to understand how it works and what makes Holochain apps so great!

Reference

https://developer.holochain.org/concepts/1_the_basics/

Written By,

Blockchain Developer at Yudiz Solutions Pvt. Ltd