Have you ever considered that a blockchain is not a monolith but more a whole made of parts?
So, what are these parts?
The main components of a blockchain are:
- A state storage.
- A processing unit
- A transaction linked list.
- A consensus process.
- An inter node communication protocol.
- An interface to applications.
In 2009, when bitcoin was introduced to the world, it stored a very simple data model to implement a ledger consisting of an account balance. A data model replicating the familiar bank account. This account allows deposits and withdrawals to be performed on it. The bitcoin network can be envisioned as a digital bank storing bitcoin accounts. After, the phenomenal success this technology encountered on the marketplace, some developers started to wonder how this technology can be improved.
In 2014 Vitalik, a young developer introduced Ethereum, a programmable blockchain. By expanding the instruction set of the main interpreter and by developing a programming language to let developers make applications, Vitalik created a more versatile blockchain, inventing a new term: the smart contracts. Basically, a smart contract is a piece of code to be replicated and interpreted on each node of the network. With this new technology, developers where given a more versatile data model no longer limited to a simple account balance. A data structure usual to programming languages like, structures, arrays, mapped arrays, etc. This data structure can be massaged by the smart contract code through a programming interface.
A processing unit
Since the beginning, with the bitcoin implementation, a virtual machine is mainly used as a processing engine. At first, in the case of bitcoin, the instruction set is limited to few instructions. This restriction also reduces the footprint to malicious account manipulations. With the appearance of Ethereum, also appeared an expansion of the instruction set and a more sophisticated virtual machine interpreter. A main advantage of using a virtual machine is to act as a sandbox to limit what operations are possible on an Ethereum node (i.e. server). For example, the instruction set prevent smart contracts (i.e. programs) to write or read files on the host. The only allowed operations are the one to be performed in the memory reserved to a smart contract and not elsewhere. Other blockchain processing unit are based on Java with the very same characteristics. Both Ethereum and Java virtual machine interpreters run pieces of code in a sandbox limiting what is permitted to be performed by a program.
With Hyperledger Fabric a new paradigm allows a different approach. The sandbox, in that case, is a Docker container. This technology introduced in 2013 provides the equivalent of a virtual machine without the overhead. We are not talking here of software interpreters also named virtual machines but more of low level implemented virtual machines based on hardware processor instructions set. Docker container rely on operating system sandboxes like LXC on lInux or Hyper-V on Windows. In a nutshell, this technology allows compiled or interpreted programs to run in a safe sandbox without interfering with other piece of software running on a host. Thus, each chaincode is provided with a Docker container to execute its either compiled or interpreted code.
Thus, the two main technologies used to execute blockchain code is:
- Compiled code running in a container. For example, the GO language.
A transaction linked list
This is the linked list which also gave the name blockchain to this type of technology. All transactions are mostly packaged as blocks and these blocks are linked together. Each block as a backlink to its predecessor. Such a link would be easily manipulated if it were not the case of the hash value of the transaction’s content. To prevent malicious manipulation of the transaction list, a hash value of each block is maintained. Each block also contains the hash value of the precedent block. Changing any block in this list would also change the hash value and hence indicate that the list was pirated.
A consensus Process
Hackers can include fraudulent transactions, and if money is involved, some may want to take advantage of the system. If you put together a group of network participants who doesn’t know and even trust each other, then you must find a mechanism to determine what is good and what is bad. This is precisely what the consensus mechanism is intended for. An automated process decides what is to be included into the blockchain and what the order of the transactions should be. In the case of bitcoin and ethereum networks, a group of network participants named miners fulfill this role. The specialized nodes have to resolve a puzzle, the first who comes to a satisfying result will be allowed to include a new block to the blockchain and be rewarded for the work. This process is called proof of work. Other means also exist like, proof of stake, proof of elapse time, etc. All these processes are in place to determine who will decide of the right order and what is included and what is discarded.
An inter node communication protocol
Network participant need a certain protocol to communicate together. They also need a protocol to discover each other. Some network requires to know the address of the neighbor nodes to be specified into a configuration file others uses a discovery mechanism to discover who to talk to. In a blockchain network, nodes are linked together with a peer to peer links. This means that all broadcasted transactions are transmitted from node to node to the very last one.
An interface to applications
A good way to perceive blockchains is to envision them as the equivalent of databases. Hence they need a front-end application service. Blockchains provide an API to communicate with. Most of the blockchains applications are three tiers. The blockchain is the storage tier, the application server, the second tier and the client, usually a browser is the third tier.