Introduction#
In my work, I mainly participate in the design and implementation of cross-chain projects. Because some of the company's solutions are based on the Cosmos blockchain, I have made some modifications to the underlying chain development based on the Cosmos SDK in a project that lasted for more than a year. I have gained some understanding of its technical implementation. However, due to the tight development schedule, I have not been able to have a systematic understanding of the architecture design of Cosmos and the Tendermint consensus mechanism.
After the project was completed, I finally had time to read "Blockchain Architecture and Implementation: A Detailed Explanation of Cosmos". This article is my own understanding and summary of Cosmos and Tendermint.
Development of Blockchain Technology#
Before discussing the specific Cosmos blockchain, let's review the development of blockchain and the mainstream blockchain technologies in the industry.
Technological Limitations#
Blockchain has been developing for more than a decade, from the initial Bitcoin to the once popular EOS, and then to the now mainstream Ethereum. Each has its own characteristics but also has its limitations.
- The Bitcoin or Ethereum-based approach requires relatively high technical expertise in implementing P2P networks, cryptography, consensus algorithms, etc.
- The underlying chains based on the PoW (Proof of Work) mechanism consume more and more computational power (electricity), which is not resource and environmentally friendly.
- As the number and scale of on-chain applications increase, the performance bottleneck of the chain becomes more apparent.
- With the increasing complexity of business scenarios and growing demands, the consensus algorithms of the chain also need to adapt to specific scenarios.
- The underlying architectures of different chains differ greatly, and different chains are isolated from each other, making it difficult to achieve cross-chain communication, which is a challenging problem for cross-chain technology solutions.
Technological Developments#
To address the above problems, the industry has proposed various technical solutions.
- Due to the resource consumption of PoW, many chains have adopted the PoS (Proof of Stake) mechanism, such as EOS's DPoS and Ethereum's recent upgrade to PoS, which have become more mature.
- To solve the limitations of underlying chains, the development has gradually shifted from building separate chains for individual applications, similar to Bitcoin, to building ÐApps using smart contracts.
- To address performance limitations, Bitcoin Cash has increased block capacity, EOS has increased TPS (Transactions Per Second), and Ethereum has implemented sharding to process on-chain transactions in parallel.
- In terms of cross-chain technology, hash locking has been applied in Bitcoin and Algorand projects, and there are also solutions such as notaries and relay chains.
Cosmos Blockchain Framework#
Overview#
Cosmos is an open-source blockchain framework developed by Tendermint. Its goal is to solve various problems encountered in the development of blockchain technology and provide a high-performance, highly scalable, and easy-to-develop blockchain framework. The open-source repository can be found here:
Cosmos can be seen as a multi-chain network aimed at realizing the vision of an "Internet of Blockchains," with Tendermint and Cosmos SDK as its technical means and implementation path.
To address resource consumption and transaction issues, Cosmos adopts a combination of BFT (Byzantine Fault Tolerance) and PoS (Proof of Stake). In order to reduce the threshold for building blockchains and developing blockchain-based applications, Cosmos adopts a more general project construction approach, making chain development based on Cosmos more modular and engineered. It mainly consists of three parts: Tendermint Core, IBC, and Cosmos SDK.
Cosmos SDK Components#
Although it is called an "SDK," which may cause some misunderstandings, thinking that it is just a library/component for interacting with the chain, Cosmos SDK can be considered as a complete architecture. Developers can quickly build their own blockchains using it, and it is an important part of the Cosmos ecosystem. The open-source repository can be found here:
Cosmos SDK mainly implements some common modules in blockchains, such as account systems, transactions, on-chain governance, etc. Developers can easily build new functional modules based on it.
The main modules include:
- Account and transaction-related modules
- auth: System account management
- bank: On-chain asset transfer
- Auxiliary modules
- genutil: Genesis block
- supply: Total asset management
- crisis: Invariant management for all modules
- params: Parameter management for all modules
- On-chain governance module
- gov: On-chain governance mechanism
- upgrade: Chain upgrade
- PoS module
- staking: On-chain asset staking
- slashing: Punishment for malicious validators
- evidence: Punishment for active misbehavior of validators
- mint: On-chain asset minting
- distribution: Block reward management
- IBC protocol module
- ibc/core: Cross-chain communication functionality
As you can see, the design of the Cosmos SDK framework is based on the Object-Capability Model security concept, with a highly modular design. Each module has its own storage space and only exposes necessary interfaces to the outside.
Cosmos SDK has a specific role called Keeper, which is responsible for maintaining and updating the state. Through this management method, the specific implementation details of the modules are hidden from each other, and they only interact with each other through the keeper. Each module is only updated by the keeper, effectively ensuring the consistency of the on-chain state.
Tendermint Components#
Tendermint is the core component of Cosmos. It is a high-performance underlying consensus engine for blockchains. In terms of architecture, it mainly consists of three parts: peer-to-peer network communication layer, consensus protocol layer, and upper-layer application layer, with the consensus protocol layer being the key part.
Tendermint does not care about the specific transaction details during consensus. It simply packages transactions as bytes into blocks and achieves consensus through mechanisms among nodes. It requires the state update of the upper-layer application to be a deterministic process, starting from the same initial state, achieving consensus on the order of transactions in the entire network (i.e., all normal nodes process a sequence of messages in the same order), and the state of the upper-layer application should also remain consistent among the entire network. The blockchain will contain digital fingerprints of the upper-layer application for verification.
Tendermint consensus can support sub-second block generation in blockchain networks with hundreds of nodes. It provides the feature of block finality, which means that once a block is confirmed, all previous blocks cannot be modified, ensuring the security of the blockchain network.
After block submission, the Tendermint consensus protocol layer interacts with the upper layer through ABCI (Application Blockchain Interface), which is an abstraction of the interaction between the application layer and the consensus layer. It completes transaction processing and returns results. The block execution process is divided into multiple steps, and the upper-layer application has autonomy to define business interaction logic and implement it through specific interfaces (such as implementing validator filtering logic or reusing Tendermint Core's consensus protocol and peer-to-peer network communication to meet chain business requirements).
For specific details and mechanisms of the Tendermint consensus algorithm, you can read the following paper:
Its unique mechanisms bring significant advantages in the blockchain consensus process.
First, Tendermint is derived from the PBFT (Practical Byzantine Fault Tolerance) SMR (State Machine Replication) algorithm, but it simplifies its mechanism. Its consensus is mainly based on blocks rather than user requests, and it unifies the regular PBFT process with the view change process in terms of mechanisms, making it easier to understand and implement.
It provides a solid infrastructure and a good user experience. It is one of the earliest underlying systems that can support sub-second block generation in blockchain networks with hundreds of nodes. It also ensures the security of the blockchain network by guaranteeing that all previous blocks cannot be modified through block finality.
The communication between nodes in Tendermint is achieved through the Gossip protocol, which does not require full connectivity between nodes. Instead, it uses the gossip peer-to-peer network for communication, which can effectively reduce communication costs between nodes and improve network fault tolerance.
The specific implementation details and mechanisms of the Tendermint algorithm will be explained in detail in subsequent articles.
IBC Protocol Component#
The IBC protocol is a special module in the Cosmos SDK. It mainly provides Cosmos with cross-chain capabilities. Its main principle is to prove its own on-chain events to other chains through cryptographic techniques. It can be understood as both cross-chain parties acting as light clients for each other, and the communication/transactions between the two chains are implemented through relayers.
There are many details in this part, and it is more related to cross-chain. A separate article will be dedicated to explaining it in detail.
Conclusion#
This article is the first in the Cosmos and Tendermint consensus series, mainly introducing the development of blockchain technology, the core components of the Cosmos blockchain framework, such as Tendermint and Cosmos SDK, and providing an overview of the principles and mechanisms of the Tendermint consensus protocol. Due to the length limitation, the focus is on conceptual explanations and process summaries, without specific technical implementation details and code explanations, which will be supplemented in subsequent articles on the Tendermint consensus algorithm/mechanism and Cosmos SDK code implementation.
References#
-
"Blockchain Architecture and Implementation: A Detailed Explanation of Cosmos - Wen Long/Jia Yin"
-
-
-
Distributed Systems and Blockchain Consensus Mechanism · Pseudoyu
-
-