准备翻译一下Cosmos的介绍。
What is Cosmos?
Strictly speaking, Cosmos is a decentralized network of independent parallel blockchains, each powered by BFT consensus algorithms like Tendermint consensus.
In other words, Cosmos is an ecosystem of
blockchains
that can scale and interoperate with each other. Before Cosmos, blockchains were siloed and unable to communicate with each other. They were hard to build and could only handle a small amount of transactions per second. Cosmos solves these problems with a new technical vision. In order to understand this vision we need to go back to the fundamentals of blockchain technology.
A blockchain can be described as a digital ledger maintained by a set of validators that remains correct even if some of the validators (less than a third) are malicious. Each party stores a copy of the ledger on their computer and updates it according to the rules defined by the protocol when they receive blocks of transactions. The goal of blockchain technology is to make sure the ledger is correctly replicated, meaning that each honest party sees the same version of the ledger at any given moment.
The main benefit of blockchain technology is the ability for parties to share a ledger without having to rely on a central authority. Blockchains are decentralized. The first and most famous application of blockchain technology today is Bitcoin, a decentralized currency.
Now that we have a better understanding of what a blockchain is from a high-level perspective, let us look at the definition of blockchain with a more technical angle. A blockchain is a deterministic state machine replicated on
full-nodes
that retains consensus safety as long as less than a third of its maintainers are Byzantine. Let’s break this down.
A state machine is just a fancy word for a program that holds a state and modifies it when it receives inputs. There is a state, which can represent different things depending on the application (e.g. token balances for a cryptocurrency), and transactions, that modify the state (e.g. by subtracting balances from one account and adding them to another).
Deterministic means that if you replay the same transactions from the same genesis state, you will always end up with the same resultant state.
Consensus safety refers to the fact that every honest node on which the state machine is replicated should see the same state at the same time. When nodes receive blocks of transactions, they verify that it is valid, meaning that each transaction is valid and that the block itself was validated by more than two thirds of the maintainers, called validators. Safety will be guaranteed as long as less than a third of validators are Byzantine, i.e. malicious.
From an architecture standpoint, blockchains can be divided into three conceptual layers:
Application: Responsible for updating the state given a set of transactions, i.e. processing transactions.
Networking: Responsible for the propagation of transactions and consensus-related messages.
Consensus: Enables nodes to agree on the current state of the system.
The state machine is the same as the
application layer
. It defines the state of the application and the state-transition functions. The other layers are responsible for replicating the state machine on all the nodes that connect to the network.
To understand how Cosmos fits in the blockchain ecosystem, we need to go back to the beginning of the blockchain story. The first blockchain was Bitcoin, a peer-to-peer digital currency created in 2008 that used a novel consensus mechanism known as
Proof-of-Work (PoW)
. It was the first decentralized application on a blockchain. Soon, people started to realize the potential of decentralized applications and the desire to build new ones emerged in the community.
At the time, there were two options to develop decentralized applications: either fork the bitcoin codebase or build on top of it. However, the bitcoin codebase was very monolithic; all three layers—networking, consensus and application — were mixed together. Additionally, the Bitcoin scripting language was limited and not user-friendly. There was a need for better tools.
In 2014, Ethereum came in with a new proposition for building decentralized applications. There would be a single blockchain where people would be able to deploy any kind of program. Ethereum achieved this by turning the Application layer into a virtual machine called the Ethereum Virtual Machine (EVM). This virtual machine was able to process programs called
smart contracts
that any developer could deploy to the Ethereum blockchain in a permissionless fashion. This new approach allowed thousands of developers to start building decentralized applications (dApps). However, limitations to this approach soon became apparent and still persist to this day.
The first limitation is
scaling
- decentralized applications built on top of Ethereum are inhibited by a shared rate of 15 transactions per second. This is due to the fact that Ethereum still uses Proof-of-Work and that Ethereum dApps compete for the limited resources of a single blockchain.
The second limitation is the relatively low flexibility granted to developers. Because the EVM is a sandbox that needs to accommodate all use cases, it optimizes for the average use case. This means that developers have to make compromises on the design and efficiency of their application (for example, requiring use of the account model in a payments platform where a UTXO model may be preferred). Among other things, they are limited to a few programming languages and cannot implement automatic execution of code.
The third limitation is that each application is limited in
sovereignty
, because they all share the same underlying environment. Essentially, this creates two layers of governance: that of the application, and that of the underlying environment. The former is limited by the latter. If there is a bug in the application, nothing can be done about it without the approval of the governance of the Ethereum platform itself. If the application requires a new feature in the EVM, it again has to rely entirely on the governance of the Ethereum platform to accept it.
These limitations are not specific to Ethereum but to all blockchains trying to create a single platform that would fit all use cases. This is where Cosmos comes into play.
The vision of Cosmos is to make it easy for developers to build blockchains and break the barriers between blockchains by allowing them to transact with each other. The end goal is to create an Internet of Blockchains, a network of blockchains able to communicate with each other in a decentralized way. With Cosmos, blockchains can maintain sovereignty, process transactions quickly and communicate with other blockchains in the ecosystem, making it optimal for a variety of use cases.
This vision is achieved through a set of open source tools like
Tendermint
, the Cosmos SDK and IBC designed to let people build custom, secure, scalable and interoperable blockchain applications quickly. Let us take a closer look at some of the most important tools in the ecosystem as well as the technical architecture of the Cosmos network. Note that Cosmos is an open source community project initially built by the Tendermint team. Everyone is welcome to build additional tools to enrich the greater developer ecosystem.
Until recently, building a blockchain required building all three layers (Networking, Consensus, and Application) from the ground up. Ethereum simplified the development of decentralized applications by providing a Virtual-Machine blockchain on which anyone could deploy custom logic in the form of Smart Contracts. However, it did not simplify the development of blockchains themselves. Much like Bitcoin, Go-Ethereum remains a monolithic tech stack that is difficult to fork from and customize. This is where Tendermint, created by Jae Kwon in 2014, came in.
Tendermint BFT is a solution that packages the networking and consensus layers of a blockchain into a generic engine, allowing developers to focus on application development as opposed to the complex underlying protocol. As a result, Tendermint saves hundreds of hours of development time. Note that Tendermint also designates the name of the byzantine fault tolerant (BFT)
consensus algorithm
used within the Tendermint BFT engine. For more on the history of consensus protocols and BFT you can check this cool podcast by Tendermint co-founder Ethan Buchman.
The Tendermint BFT engine is connected to the application by a socket protocol called the Application Blockchain Interface (ABCI). This protocol can be wrapped in any programming language, making it possible for developers to choose a language that fits their needs.
But that is not all. Here are the properties that make Tendermint BFT a state-of-the-art blockchain engine:
准备好公共或私有区块链: Tendermint BFT 只处理区块链的网络和共识,这意味着它帮助节点传播交易和验证者就一组交易达成一致以附加到区块链。应用层的作用是定义验证器集的构成方式。因此,开发人员可以在 Tendermint BFT 引擎之上构建公共和私有区块链. If the application defines that validators are elected based on how many tokens they have at stake, then the blockchain can be characterised as Proof-of-Stake (PoS). If however the application defines that only a restricted set of pre-authorized entities can be validators, then the blockchain can be characterised as permissioned or private. Developers have all the freedom to customize the rules that define how the validator set of their blockchain changes.
高性能: Tendermint BFT 的出块时间约为 1 秒,每秒可处理多达数千笔交易。
Instant finality: A property of the Tendermint consensus algorithm is instant finality. This means that forks are never created as long as more than a third of the validators are honest (byzantine). Users can be sure their transactions are finalized as soon as a block is created (which is not the case in Proof-of-Work blockchains like Bitcoin and Ethereum).
Security: Tendermint consensus is not only fault tolerant, it is also accountable. If the blockchain forks, there is a way to determine liability.
Tendermint BFT 将区块链的开发时间从数年缩短到数周,但从头开始构建安全的 ABCI 应用程序仍然是一项艰巨的任务。这就是为什么
宇宙软件开发工具包
存在。
The Cosmos SDK is a generalized framework that simplifies the process of building secure blockchain applications on top of Tendermint BFT. It is based on two major principles:
Modularity: The goal of the Cosmos SDK is to create an ecosystem of modules that allows developers to easily spin up application-specific blockchains without having to code each bit of functionality of their application from scratch. Anyone can create a module for the Cosmos SDK, and using ready built modules in your blockchain is as simple as importing them into your application. For example, the Tendermint team is building a set of basic modules that are needed for the Cosmos Hub. These modules can be used by any developer as they build their own application. Additionally, developers can create new modules to customize their application. As the Cosmos network develops, the ecosystem of SDK modules will expand, making it increasingly easier to develop complex blockchain applications.
Capabilities-based security: Capabilities constrain the security boundaries between modules, enabling developers to better reason about the composability of modules and limit the scope of malicious or unexpected interactions. For a deeper look at capabilities click here.
The Cosmos SDK also comes with a set of useful developer tools for building command line interfaces (CLI), REST servers and a variety of other commonly used utility libraries.
One final remark: the Cosmos SDK, like all Cosmos tools, is designed to be modular. Today, it allows developers to build on top of Tendermint BFT. However, it can be used with any other consensus engines that implements the ABCI. As time goes by, we expect multiple SDKs to emerge, built with different architecture models and compatible with multiple consensus engines - all within a single ecosystem: the Cosmos Network.
To learn how to code applications on top of the SDK you can check out tutorials.
The great thing about the Cosmos SDK is that its modularity allows developers to port virtually any existing blockchain codebase already in Golang on top of it. For example,
Ethermint
是一个将以太坊虚拟机移植到 SDK 模块中的项目。Ethermint 的工作原理与以太坊完全一样,但也受益于 Tendermint BFT 的所有属性。所有现有的以太坊工具(Truffle、Metamask 等)都与 Ethermint 兼容,您无需额外工作即可移植智能合约。
当我可以在虚拟机区块链上部署我的分散应用程序时,为什么还要费心使用 Cosmos SDK 创建区块链?
考虑到当今大多数去中心化应用程序都是在以太坊等虚拟机区块链之上开发的,因此这个问题是有道理的。首先,应该说明的是,出现这种现象的原因是,到目前为止,区块链比智能合约更难开发。多亏了 Cosmos SDK,情况不再如此。现在,开发人员可以轻松开发整个特定于应用程序的区块链,这有几个优点。其中,它们提供了更多的灵活性、安全性、性能和主权。要了解有关特定于应用程序的区块链的更多信息,请阅读这篇文章. Of course, if you don’t want to build your own blockchain, you can still make your Smart Contracts compatible with Cosmos by deploying them on Ethermint.
Now that developers have a way to quickly build customized blockchains, let us see how to connect these blockchains together. The connection between blockchains is achieved through a protocol called Inter-Blockchain Communication protocol (IBC). IBC leverages the instant finality property of Tendermint consensus (although it can work with any “fast-finality” blockchain engine) to allow heterogeneous chains to transfer value (i.e. tokens) or data to each other.
Essentially it comes down to two things:
*不同的层:*异构链具有不同的层,这意味着它们在实现网络*、共识和应用程序部分的方式上可能有所不同。为了与 IBC 兼容,区块链只需要遵循几个要求,主要是共识*层必须具有快速确定性。工作量证明链(如比特币和以太坊)不属于这一类,因为它们具有概率终结性。
Sovereignty: Every blockchain is maintained by a set of validators whose job is to agree on the next block to commit to the blockchain. In Proof-of-Work blockchains these validators are called miners. A sovereign blockchain is a blockchain with its own validator set. In many instances it is important for blockchains to be sovereign, as validators are ultimately responsible for modifying the state. In Ethereum, applications are all run by a common set of validators. Because of this, each application only has limited sovereignty.
IBC 允许异构区块链相互传输代币和数据,这意味着具有不同应用程序和验证器集的区块链是可互操作的。例如,它允许公共和私有区块链相互转移代币。目前,没有其他区块链框架能够实现这种级别的互操作性。
IBC 背后的原理相当简单。让我们举一个例子,让我们举一个例子,一个上的一个账户想要发送 10 个代币(让我们称他们为
原子
) 到链 B。
链B 继续接收链A 的链,允许反之亦然。这每个链追踪另一个的验证器集运行。本质上,每条条。
轻客户端
另一个。
当IBC借发起时,ATOM被锁定(
保税
) 在链 A 上。
然后,将 0 个 ATOM 的证明从链 A 绑定到链 B。
该证明在链 B 上根据链 A 的标头进行验证,如果有效,则在 B 上创建 10 个 ATOM 链证书。
请注意,在 B 上创建的 ATOM 非真正的 ATOM,因为 ATOM 只存在于 A 链上。
当 ATOM 返回其原始链时,使用类似的机制来可以它们。有关 IBC 协议的更全面描述,您查看此规范。
IBC 是一种允许完整的链相互转移的币种。从那里,我们如何创建链网络?
一种方法是通过直接 IBC 将网络中的多个链连接连接起来。这种方法的主要问题是网络中的数量与数量的链数量成二次连接。如果网络中有 100 个。块链,每一段链都需要保持一个IBC连接,有4950个连接。
为了解决问题,Cosmos 提出了一种区块链的解决方案:
集线器
和区域。Zones 是常规的异构区块链,Hub 是专门设计用于将 Zones 连接在一起的区块链。当一个区域创建一个与集线器的 IBC 连接时,它可以自动访问(即发送和接收)连接到它的每个其他区域。因此,每个区域只需要与一组受限制的集线器建立有限数量的连接。集线器还可以防止区域之间的双重支出。这意味着当一个 Zone 从一个 Hub 收到一个 token 时,它只需要信任这个 token 的 origin Zone 和 Hub。
Cosmos 网络中推出的第一个 Hub 是 Cosmos Hub。Cosmos Hub 是一个公开的权益证明区块链,其原生权益代币称为 ATOM,其中
交易费
将以多个代币支付。Hub的推出也标志着 Cosmos 网络的推出。
偶然,我们展示的 Cosmos 架构展示了基于 Tendermint 的链是如何互操作的。但 Cosmos 只能是 Tendermint 链。事实上,任何类型的区块链都可以连接到 Cosmos。
我们有两种情况需要:快速讨论和演讲链。
使用任何终结快速共识算法的区块链都可以通过调整IBC与宇宙连接。例如,如果以太坊要切换到卡斯帕FFG(场所的终局小工具),则可以通过使IBC与卡斯帕一起工作,在它与宇宙生态系统之间建立直接连接。
对于这些,我们使用了一种称为 Peg-Zone的代理。
一种
定位区
是一个查寻另一个区块链状态的区块链。Peg-Zone有很好的结果,因此与IBC。它的作用是桥接的区块链建立的最终目标。让看下
我们希望桥接工作量证明以太坊区块链,使在以太坊和Cosmos之间来回发送代可能。因为工作量证明以太坊没有快速交通性,我们需要创建一个Peg-Zone来主题币之类的脚步。
首先,Peg-Zone 需要确定源链的某个值。例如,它可以认为源链的给定块在其后添加了 100 个块时是最终的。
当用户想从以太坊区块链上。 -Zone 上发布这些资产的代表。类似的用于将资产送回以太坊链的机制。
有趣的是,PEG-区还允许用户将存在于宇宙上的任何代币发送到以太坊链(宇宙代币在以太坊链上将表示为ERC20).Tendermint团队目前正在为名为佩吉的以太坊链开发 Peg-Zone 实现。
Peg-Zones需要针对自己的接桥的特定进行定制。建立一个以太坊简单的Peg-Zone,因为以太坊是基于账户的并且有一个智能合约。然而,如何建立比特币Peg-Zone创投圈。构建类似比特币的钉区本介绍的范围,但要知道实时是可能的。如果您想知道有关钉区的更多信息,可以查看此规范。
现在我们可以轻松创建和连接部分链,还有一个最后需要解决的问题:可扩展性。宇宙利用两种类型的扩展性:
**垂直可扩展性:*包括扩展性区块链技术的方法,通过大量工作量证明优化了组件,Tendermint BFT 达到了多种笔交易。物质是应用程序*技巧。例如,可以与嵌入交换。和状态直接转换功能的应用程序(例如标准Cosmos SDK 应用程序)拟制,像虚拟机这样的应用程序(以太坊程序虚拟机)对流量的限制要广泛。特定于应用程序的部分链原因一个(在)这里阅读更多原因)。
**横向扩展:**它是一个问题引擎和引擎应用的高度优化,单链应用在同一时间也越过了。一个公共操作器,使性链时间具有无限可扩展性。有关水平可扩展性的详细信息相当复杂且超出了本验证介绍的范围。
Cosmos 将提供非常完善的横向扩展解决方案,这将是对当前部分性解决方案的解释。稍后,在 IBC 完成后,将全面实施横向扩展解决方案。
希望现在您对 Cosmos 项目有了更清晰的了解。 以下是关于 Cosmos 的三个简单点的快速回顾:
Cosmos Tendermint BFT 和 Cosmos SDK 的应用使区块功能唯一且开发。
Cosmos 使区块链能够通过 IBC 和 Peg-Zones 相互转移价值,同时让他们自己的王国链。
Cosmos 允许区块链应用程序通过水平和垂直可扩展性解决方案扩展到数百万用户。
最重要的是,Cosmos 不是一个,可以在多个产品、自己和可更换工具上的系统。鼓励开发人员共同节省生态现有工具并创建新工具,这些实验室工具是未来创建的去中心化互联网和全球金融体系的基础。
阅读宇宙出版
