A Deep Look Into Cosmos — the Internet of Blockchains
You may have heard the words Cosmos, Cosmos Hub, Tendermint, and Interchain being used interchangeably in some context or the other. Tendermint is a consensus algorithm which was invented by Jae Kwon and in 2014. Seeing the effectiveness of this consensus algorithm, he set out to build a more ambitious project — a way to allow multiple blockchains to communicate seamlessly with each other. Jae and his co-founder Ethan Buchman established the Interchain Foundation and did a fundraiser to build the Cosmos Network, in which the Cosmos Hub is the centerpiece.
To understand this project, we need a large amount of historical context and a deep technical understanding of how both Tendermint and Cosmos works. This post breaks down the different components and gives an objective examination of the project in it’s entirety.
A Brief History of Decentralized Applications
Blockchains enable decentralized applications (dApps) to execute autonomously. The first of these blockchains is Bitcoin, which is a simple application that enables people to transfer value to other Bitcoin users. We quickly discovered that blockchains enable a wide range of possibilities — markets for file storage, prediction markets, decentralized autonomous organizations, and so on. However, back in 2013, the only way to build these things was to build a new blockchain from scratch which served their intended purpose. Developers had two options: write the entire application, networking and consensus layer from scratch, or fork the Bitcoin codebase (messy, hard-to-read C++ code) and adapt it to their intended purpose.
Ethereum came along and created a new paradigm shift. Ethereum built a new blockchain with a Virtual Machine on its application layer, allowing developers to write applications directly onto this virtual machine instead. This was a complete game-changer — developers did not need to worry about the networking or consensus layer, and could quickly write and deploy decentralized applications. Ethereum was poised to become the “World Computer” that every dApp or smart contract would run on. However, two problems soon became pronounced: Ethereum could not scale past more than 15 transactions per second, and dApp creators were beholden to Ethereum’s implementation, unable to customize certain parts of their application like a custom consensus algorithm or new privacy features.
This is where we are in 2018. New projects are faced with the decision of building on Ethereum (platform risk, cannot scale, but easy to deploy) or building on their own blockchain (customizable, very difficult to build). A bunch of new shiny blockchains DFINITY, Thunder, Tezos, etc are making the first option more attractive by building a super scalable, well-governed, blockchain — hoping to realize the dream of building a “World Computer” that runs every dApp. On the flip side, Cosmos is taking a fundamentally different approach — they imagine a world in which every dApp is run on it’s own blockchain, and they are building the protocol to connect all these chains to create the “Internet of Blockchains”.
To understand Cosmos, we must first understand the way it works under the hood, which is driven by the Tendermint consensus algorithm.
Tendermint Consensus Algorithm
A consensus algorithm is ways for nodes in a distributed system to come to agreement about some state of the world. In public-blockchain-land, we are only concerned about algorithms that can tolerate malicious behavior, i.e “Byzantine Fault Tolerant”, or BFT. Within this class of algorithms, we have seen two families of consensus protocols — classic consensus protocols such as Paxos or PBFT, and Nakamoto Consensus like Proof-of-Work.
Tendermint builds on the work of classic consensus, meaning that unlike Proof-of-work, it provides various different guarantees such as finality on every transaction, a deterministic algorithm for block production, and synchrony assumptions. For a more extensive explanation of Tendermint, read this blog post. Below we summarize and break down some of the most important features of Tendermint:
Unlike Proof-of-work chains, blocks in Tendermint are final once there have been 2/3 signatures from the validators — they cannot be reversed or reverted. In Nakamoto chains like Bitcoin, we say that transactions are “final” after 6 confirmations, because the probability of a block being reversed via a chain reorganization is very small after 6 confirmations. However, as Kevin Sekniqi showed, the number of confirmations for a 10⁻⁵ guarantee of transaction reversion depends on the amount of mining power an adversary has. Attackers have used this fact to double spend exchanges, profiting in millions of dollars. Instead, by using a consensus algorithm with finality, we can be sure that transactions will not get rolled back after a single block.
- Safety over Liveness
Assuming a blockchain network splits into two (e.g Chinese Firewall), PoW chains will fork into two. Eventually, the chain will reorganize to select the longest chain as the canonical chain, and all the transactions on the other fork will get reversed. In Tendermint however, when there is a network partition, the protocol will choose to make no progress until 2/3 of the validators come to agreement once again. This tradeoff ensures that there is always “one source of truth” and the blockchain is always consistent.
- Partial Synchrony
A synchronous network has a known upper-bound of message delivery time. In Bitcoin, this bound is set to be approximately 10 minutes, imposing an artificial time delay in the network for all network participants to listen for a new block. On the other hand, Tendermint operates under a partial synchrony assumption, meaning that it does not rely on some fixed timing assumptions to make progress. This means that the bottleneck in the progress of the chain is the real network speed, not an artificial time delay set by the protocol — making this protocol faster than most Proof-of-work protocols.
Cosmos SDK (Software Development Kit)
After developing and testing Tendermint, Jae and Ethan built the Cosmos SDK — a software development kit for developers to quickly and simply build blockchains using the Tendermint consensus algorithm and pairing it with a sybil resistance mechanism using Proof-of-Stake. Using the Cosmos SDK, developers can easily build and deploy blockchains without worrying about the consensus layer and networking layer, only needing to focus on writing their application logic directly.
As mentioned at the start of the blog post, developers have 2 options when building their applications: write their own blockchain from scratch, or build on Ethereum (or variants of it). Building on Ethereum is quick and easy — you can piggyback on their consensus and networking layer and build your dApp on top of the EVM, but the tradeoff here is customizability. Using the Cosmos SDK, you do not have to follow the conventions of building on the EVM (Solidity, gas metering system, opcodes, limited cryptographic primitives, etc.). Instead, you have the ability to quickly deploy a Proof-of-stake Tendermint blockchain while retaining the flexibility to customize some things like validators, governance, staking, etc.
The drawback here is that building your own blockchain requires finding your own validator set. For hobbyist dApp developers, this much customizability may be overkill — it would be quicker and easier to deploy a contract on Ethereum. The team at Cosmos realized this and built an Ethereum clone using the Cosmos SDK, called Ethermint. There will be some validator set on Ethermint, and developers can reuse their exact same code on Ethereum on Ethermint, not having to worry about customizing anything else.
This post outlines some of the advantages of building dApps using the Cosmos SDK. Here we can also see a list of projects building/planning to build on the Cosmos/Tendermint ecosystem, compiled by one of the community members Asmodat.
Naturally, an important question to ask is how these Tendermint-chains can communicate with each other. In the Ethereum ecosystem, holding the base currency ETH allows users to interact with various smart contracts. However, some dApps on Ethereum like Numerai have their own currency NMR, which a user needs to hold to use some Numerai-specific operations like Staking. The best way to do this is to swap ETH for NMR in a decentralized exchange, then spend the NMR within the Numerai contract. This is even harder for cross-chain communication. If I own BTC and want to use a contract within Ethereum, I will need to send BTC to a centralized exchange (1 hour for confirmation), exchange it for ETH, withdraw ETH to a wallet, then spend it on the smart contract. There have been some specific implementations of bridges between two blockchains like the BTC Relay, but this is specific to only Bitcoin-Ethereum interoperability. Building a general protocol for all blockchains to interoperate is a much more Herculean task.
Hence the motivation behind building the Cosmos Network — the “Internet of Blockchains”, where every blockchain within the network is interoperable with another via hubs. The Cosmos team is building the first hub, which is the Cosmos Hub.
In this network, Tendermint-based projects can interoperate with one another via the Cosmos Inter-Blockchain Communication (IBC) Protocol, which uses cryptographic proofs to prove that a message was sent from a zone to another. Because of finality guarantees in the Tendermint consensus algorithm, interoperability is fairly straightforward — once a specific type of transaction is final in both blockchains, it can be assumed that a transaction was sent from one blockchain to another.
Interoperability between blockchains with different consensus algorithms is more difficult. Since no transaction is ever “final” on a Proof-of-work chain, we have to wait many confirmations before we can be confident that a transaction will not be reversed. Cosmos built a specification for Peggy, an interoperability protocol between Tendermint chains and PoW-based Ethereum. As we can see in the specification, building this requires a ‘witnesses’ and smart-contracts in Ethereum. Furthermore, the protocol requires 100 blocks to pass to be confident that a transaction will not get reversed. Using the IBC and various peg-like schemes like Peggy, Cosmos is hoping to make every blockchain interoperable.
The centerpiece of the Cosmos Network is the Cosmos Hub. The Cosmos Hub keeps a record of the total number of tokens in each zone. Because of this, zones can send tokens between each other seamlessly without the need of an exchange. The more projects that build on Cosmos and connect to the Cosmos Hub, the more useful the hub becomes since it will facilitate all communication between zones.
The Cosmos Hub itself is a blockchain where transactions represent inter-zone communication. The blockchain uses the Tendermint consensus algorithm, where validators bond (stake) the native token of the blockchain, Atoms, to have a chance to produce blocks — the more Atoms bonded, the higher the frequency at which the validator will have the right to produce blocks. These validators contribute to the network by producing blocks, and are in turn paid in newly minted Atoms by the protocol. Somewhere between 7–20% of the total Atom supply will be minted every year to be paid to validators, providing a high enough yield to be attractive for validators.
Being a validator on Cosmos is no trivial task, their responsibility to the network is to validate blocks honestly, participate in governance, and most importantly run a high-performant server with high uptime. A failure to do so will result in their bonded Atoms being slashed. To be a Cosmos validator, one needs to be in the top 100 by amount of Atoms locked up and running the hardware could cost anywhere between $100k–300k a year and will get more expensive as the blockchain gets larger. If you do not have the capital or technical expertise to run a Cosmos validator, you can also opt to delegate your Atoms to a validator, pushing up their rankings within the top 100 and in return receiving a portion of their revenue. Because of the key role validators play in the Cosmos Network (and the potential for earnings!), the validators on the Testnet are extremely active.
Cosmos validators and delegators also can participate in the governance of the network. For example, Cosmos plans to do a “Hard Spoon” of Ethereum, which takes a snapshot of all balances on the Ethereum blockchain and replicating the balances on Ethermint, a Cosmos Zone. Atom holders get to vote when to do the snapshot and how the new tokens are distributed. Validators play a special role in the governance system, in which they are required to vote on every single proposal or face their Atoms getting slashed.
Concluding Thoughts & Current State of Cosmos
As of September 2018, the Cosmos team has proven that Tendermint consensus works, launched the Cosmos-SDK, and are on track to launch the Cosmos Hub by the end of 2018. However, this launch will be without the IBC, meaning that other Tendermint-chains cannot connect to the Cosmos Hub just yet, to ensure that the Hub works first. Soon after launch, they will be rolling out the IBC and Ethermint, allowing Ethereum developers to port over to Cosmos with ease. The team also already has a specification for making Cosmos interoperable with Proof-of-work Ethereum, but that will be rolled out a few months after the IBC is released.
Having done a deep dive into Cosmos, it is clear that the success of the Cosmos Network relies on 3 big components:
- Proliferation of Tendermint-based blockchains
- Reliability and effectiveness of Cosmos Validators
- Speed of deployment & out-executing the competition
Although this list says that there are over 60+ projects in the Tendermint & Cosmos ecosystem, the number is probably overblown — 0x, which is included on the list, is still built on core Ethereum not on Tendermint. Assuming that very few projects end up building on Tendermint consensus, the first generation of the Cosmos Hub (IBC between Tendermint-chains) will be largely useless.
Secondly, there lies a huge responsibility on the shoulders of Cosmos validators. Other than maintaining the integrity of the blockchain, they control the direction of the Cosmos Network. If the incentive structure of running a Cosmos validator is broken, we may see a lack of engagement from validators, and hence a poor governance structure. However, so far this has proven to be false, where validators in the Testnet are super active to make sure that their setup works properly once the Cosmos Hub launches.
Finally, and most importantly, is the question of how quick Comsos will be able to deploy the Cosmos Hub, IBC, and further developments to connect non-Tendermint chains. Building these technologies are hard, and the team has been pushing back their deadline for launching the Cosmos Hub multiple times in the past. Jae has delivered on his promise to shave his head after missing the deadline for launching in May 2018. Shipping code quickly is particularly crucial at this time, as the scaling problems of Ethereum have given teams an opportunity to compete with it. There is a race to build out smart-contract platforms that are able to win the hearts and minds of developers through scalability, privacy, interoperability, and other features.
Other than interoperability, Cosmos also has a compelling scalability story. Instead of being beholden to a blockchain that can be clogged up by digital cats, Cosmos gives developers to have control over their own applications, where bottlenecks in other applications will not slow down theirs. This is similar to Plasma, where each Plasma application on Ethereum can have it’s own set of validators and scales well. However, there is a lot of complexity in building a Plasma application, having to encode custom “exit transactions” and “fraud proofs” to leave the Plasma chain and interoperate with the main Ethereum chain. Cosmos’ simple SDK makes this part much simpler, yet preserving the scalability aspects of Plasma. While DFINITY needs thousands of transactions per second to support hundreds of different applications, we can think of the Cosmos Network as a blockchain which is sharded by application — meaning each shard supports a single application, and needs to have much less throughput capability per shard on average.
It is still unknown how majority of dApp developers will choose to build their applications over the next few years — on large blockchains or on their own blockchains. If we see the latter, we can expect the Cosmos Hub to be extremely valuable, being the channel by which all these applications talk to each other. A valuable Cosmos Hub will naturally lend towards a valuable governance token (Atom), as these governance tokens can dictate future changes in the network such as new fee structures paid to Cosmos Hub validators and so on. As a result, we can also expect value to accrue to these Atoms if the inflation rate makes sense.
Disclaimer: This post was not sponsored and is in no way a form of promotion for any projects mentioned. Any opinions, findings, and conclusion or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of Cornell University.