Tendermint is used to replicate an application on many different machines in a secure and consistent way. This is very important because Tendermint works even if 33% of the machines fail in arbitrary ways. In this situation, all the non-faulty machines see the same transaction log and compute the same state.
Secure and consistent replication is a very fundamental problem in distributed systems. This plays a very important role in the fault tolerance of several applications. We can mention currencies, elections, infrastructure and many other systems in different fields.
The Byzantine fault tolerance (BFT) is related to the ability to tolerate machines that fail in arbitrary ways, even if they become malicious. The BFT theory has several years, but it has been applied to software in the last years and became known after being used by blockchain technology.
Tendermint is built by a blockchain consensus engine and a generic application interface. The consensus engine is known as Tendermint Core and it controls that the transactions are recorded on every machine in the same order. The app interface is called the Application BlockChain Interface (ABCI), and it enables transactions to be processed in different programming languages.
Compared to other systems, Tendermint has been designed to be easy to use and simple to understand.
Tendermint is similar to other classes of software: distributed key-values stores, such as Zookeeper, etcd and consul, and blockchain technology, including cryptocurrencies.
What About Zookeeper, etcd and Consul?
Zookeeper, etcd and consul are related to a key-value store atop a BTF consensus algorithm. At the moment, Zookeeper is using a version of Paxos called Zookeeper Atomic Broadcast. Instead etcd and Consul use the Raft consensus algorithm.
A cluster contains between 3 to 5 machines and is able to tolerate crash failures in up to ½ of the machines. However, a single Byzantine fault is able to destroy the system.
In sum, Tendermint is Byzantine Fault Tolerant, so that means that it can tolerate up to a 1/3 of failures. And these failures are able to include an arbitrary behaviour (including hacks and other similar attacks). Additionally, it does not specify a particular application, it focuses on arbitrary state machine replication.
Furthermore, Tendermint has emerged with Bitcoin, Ethereum and other virtual currencies. The goal is to provide a more efficient and secure consensus algorithm than the one that Bitcoin (BTC) is using. Bitcoin uses a Proof of Work algorithm, also known as PoW in which miners process transactions.
Tendermint, has evolved to be a general purpose blockchain consensus engine that has been created to host arbitrary application states. It can be used as a plug and play replacement for consensus engines of other blockchain software.
That means that it is possible to take the Ethereum code base and run it as a ABCI application that uses Tendermint consensus.
Other Blockchain Projects
Fabric works in a similar way to Tendermint but it requires all application behaviour to run in potentially docker containers known as ‘chaincode.’ It is possible to use this docker-based behaviour as a ABCI application in Tendermint.
Another blockchain project is Burrow and an implementation of the Ethereum Virtual Machine and Ethereum transaction mechanics. But it is important to mention that it has additional features such as name-registry, permissions and native contracts.
ABCI General Overview
All blockchains have had a monolithic design. Each blockchain stack is a single program that is able to handle the concerns of decentralized ledgers. This includes P2P connectivity, the mempool, and more.
Using a monolithic architecture makes it difficult to reuse components of the code. If there is an interest of using it, then there would be complex maintenance procedures for forks of the codebase.
But this is not the only problem experienced by monolithic designs. It limits the user with the language of the blockchain stack. Tendermint works in a different way, they work by decoupling the consensus engine and P2P layers from the details of the application state of the particular blockchain app.
What Is ABCI?
In order to understand how Tendermint Core works, we need to make an analogy with Bitcoin. The famous virtual currency works with nodes that that maintain a fully Unspent Transaction Output (UTXO) database.
If instead, a person wants to create a Bitcoin-like system using ABCI Tendermint Core, it would have to share blocks and transactions between nodes, and establishing a canonical / immutable order of transactions (blockchain).
Additionally, the application would have to Maintain the UTXO database, validate cryptographic signatures of transactions, prevent transactions from spending non-existent transactions and allow clients to query the UTXO database.
In this way, Tendermint is able to decompose the blockchain design and offer a very simple API between the application and consensus process. The ABCI has 3different types of message that are delivered from the core to the application.
The most important message in the app is the DeliverTx. Each of the transactions in the blockchain are delivered with that message.
The CheckTx message is similar to the DeliverTx, but it only works for validating transactions. The mempool used by Tendermint Core check if the transactions are valid or not with the CheckTx and then relays the valid transactions to its peers.
Another message is known as Commit, that is used to compute a cryptographic commitment to the application state. For example, an inconsistence in updating that state will appear as blockchain forks and catching whole class of programming errors.
Determinism Is Important
It is important for blockchain transaction processing logics to be deterministic. If they are not, then consensus would not be reached among the nodes.
Solidity, the language used on Ethereum’s network is a completely deterministic programming language. But it is also possible to create deterministic apps using other languages such as Java or C++, among others.
It is important to avoid sources of non-determinism such as the following:
- Random number generators (without deterministic seeding)
- Race conditions on threads (or avoiding threads altogether)
- The system clock
- Uninitialized memory (in unsafe programming languages like CorC++)
- Floating point arithmetic
- Language features that are random
In this article we explained that Tendermint is an easy-to-understand, BFT consensus protocol. The participants are known as validators and they take turns proposing blocks of transactions and voting on them.
In order to commit a block, two stages of voting are required. If a block is committed it means that it has more than 2/3 of validators that pre-committed for the same block during the same round.
Some validators may fail to commit a block for different reasons. For example, the proposer may be offline or the network may be working slow. And Tendermint allows them to establish that a validator should not be taken into account.
If one-third of the validators are Byzantine, then Tendermint is able to guarantee that the safety will never be violated.
Not all validators will have the same ‘weight’ in the consensus protocol. We are indeed thinking about proportions of the total voting power, something that may not be distributed in a uniform way across the individual validators.
Additionally, Tendermint is able to replicate arbitrary applications. It is possible to define a currency and denominate the voting power in the same currency. The system is then known as Proof-of-Stake (PoS).