46. What is Tendermint, and how does it work?
Without further ado, today’s lesson begins with our main topic.
Tendermint is software designed to replicate applications consistently and securely across multiple machines. It works as long as about 1/3 of the machines running the software are down. Consistency is the process of every machine seeing the same transaction log and calculating the same state without failure.
Security and consistency is even a fundamental problem in distributed systems. Yet, it plays a key role in fault tolerance.
You have already seen the connections, have not you? The ability to tolerate machine failures, even malicious ones, is called Byzantine fault tolerance (BFT). The name itself derives from the way transactions are clustered in blocks.
We have written about Byzantine Fault Tolerance (BFT) here.
Tendermint itself consists of two components – a blockchain consensus engine and a generic application interface.
The consensus engine is called Tendermint Core. It ensures that the same transactions are recorded in the same order on every machine.
The application interface, the Application BlockChain Interface (ABCI), is responsible for passing the transactions to the application for processing. Developers therefore use Tendermint to replicate the state of BFTs in applications written in any software language and development environment.
Tendermint is easy to use, simple to understand, efficient and especially useful for many distributed applications.
The solution has two programming approaches. The first is via distributed key-value stores: Zookeeper, etcd and consul. These use a consul other than Byzantine Fault Tolerance (BFT).
The second way is simply the blockchain. This group includes cryptocurrencies (Bitcoin, Ethereum) or alternative distributed ledger projects, such as Hyperledger’s Burrow.
Another example of an application built on Tendermint is the Cosmos network.
Architecture of Tendermint
We have already mentioned that Tendermint consists of two key components: Tendermint Core and Application Blockchain Interface (ABCI). Let us now take a look at these components.
This is the core element of the entire protocol architecture. It serves as a consensus mechanism. It monitors the recording of transactions on different machines simultaneously. Through the Tendermint Core, we can record transactions on the blockchain and ensure their immutability.
The consensus mechanism of Tendermint Core is Proof-of-Stake (PoS). Randomly selected validators verify transactions across the PoS ecosystem. Blocks are only added when consensus is reached. However, we will dedicate a separate paragraph to validators in this lesson.
Application Blockchain Interface (ABCI)
ABCI is one such bridge between Tendermint and the developers who use its functionality. The Application Blockchain Interface serves as a translator for the Tendermint Core. This allows developers can build applications on the protocol in any software language.
Interestingly, developers can build projects on the Cosmos network using Tendermint Core as a bridge between Tendermint Core and the Cosmos Software Development Kit (SDK).
The way Tendermint works is simple and easy to understand. It is an asynchronous consensus protocol with Byzantine fault tolerance.
The participants in the protocol are called validators. They take turns proposing and voting on transaction blocks. The blocks are naturally passed in a chain, with one block at each level. If a block is not included in the chain, it goes to the next ’round’ and new validators receive the proposal for that block for that height. For a block to be added to the chain, Tendermint requires two phases of voting: pre-vote and pre-commit. A block is added if more than 2/3 of the validators vote for the block in the same round.
Now you need to focus on the advanced functioning of the protocol. The validators, i.e. the checkers, are not allowed to cast their vote. They may be offline at the moment or the network may simply be slow. In this case, Tendermint allows the network to determine that the validator may not be present.
Validators wait a relatively short time until they receive a complete block from an applicant before voting for it to go to the next round. This time limit makes Tendermint a less synchronous protocol. But only in this situation – the rest of the protocol is asynchronous. Validators only move forward when a block gets 2/3 of the votes.
However, Tendermint has a simplifying mechanism. What does it refer to? It uses the same mechanism to validate a block and move it to the next round.
In this situation, we assume that less than 1/3 of the validators are Byzantine. This means that Tendermint guarantees us security – blocks are not tampered with, i.e. two blocks of the same height are never added to the chain. To achieve this, the protocol introduces several blocking rules that modulate the flow. When a validator declares a block, it is blocked at the same height as the declaration. The block in question is then voted on.
Scalability and flexibility of Tendermint
The advantages of this protocol are numerous. We will now add another one, namely its high scalability. Depending on how many transactions it supports, it can expand or scale.
You have already learned at our university that many blockchains and protocols have a scalability problem. Congestion occurs when the capacity of the network cannot keep up with the amount of activity. As a result, the network becomes more and more congested, transaction speed decreases and costs increase.
Tendermint achieves its scalability through sharding. The protocol’s transactions are executed on shards or smaller databases.
Now, let us talk about flexibility. Tendermint has more flexibility than the average blockchain. All because of its modularity. This allows us to easily separate the consensus mechanism from the application interface. Developers do not have to bootstrap the ecosystem – they interact with the application interface and ABCI.
We have already mentioned that Tendermint is unique, right? We add another advantage to that – modular architecture. By default, blockchains have a monolithic structure. This means that the elements of this structure are both independent and interconnected.
A modular architecture makes it easy to update one aspect of the system without disrupting the entire system. It also allows developers to create custom programs without having to run the entire network.
Tendermint Core, which we wrote about a few paragraphs above, was designed as a modular system with an application layer. On this layer, developers build and integrate their applications. Independent of the network and consensus layers. This functionality allows developers to implement code without having to worry about side elements.
The positive elements of the Tendermint architecture are:
- Simplification of the application development process.
- The ability to develop applications in different languages.
- Seamless onboarding of different, decentralized applications.
Tendermint is a passionate protocol. At the same time, it is innovative. We can confidently say that it is an engine for blockchain that allows developers to do many interesting things. One of the most important is to create applications in any programming language.
Tendermint Core and ABCI are the core components of Tendermint. The ecosystem itself is highly scalable, integral and modular.