Cosmos 是什么?
发布日期:2021-06-29 22:26:28 浏览次数:3 分类:技术文章

本文共 28161 字,大约阅读时间需要 93 分钟。

文章目录

一、Cosmos 简介

官网:What is Cosmos?

参考URL: https://cosmos.network/intro
白皮书:https://cosmos.network/resources/whitepaper
https://blog.csdn.net/shangsongwww/article/details/92572870
cosmos浏览器: https://www.mintscan.io/cosmos/

Cosmos 是什么? 一文了解Cosmos的来龙去脉

参考URL: https://learnblockchain.cn/2019/05/21/what-is-cosmos/
cosmos简介、整体结构及项目分布
参考URL: https://www.528btc.com/blocknews/35419.html

COSMOS 被称为「区块链的互联网」(Internet of Blockchains),是一种全新的区块链网络架构,支持不同区块链之间互操作和可扩展,从而实现不同区块链之间互联互通的目标。

Cosmos 网络由不同的独立、平行区块链组成,其中的每条区块链都通过例如 Tendermint 这样的经典拜占庭容错共识运行。Cosmos 上的区块链称为“分区(zone)”。其中的一些分区又称为"枢纽 (Hub)",不同的分区可以通过共享的枢纽来互相通信与互操作

cosmos这个项目是为了实现跨链而生的,在众多的跨链项目中,cosmos有它自己独特的特点,它把共识和P2P协议抽象出来,形成了一个单独的Tendermint的层或者叫模块。

它采用Tendermint-BFT DPoS的共识引擎来解决跨链的共识问题。 众多的区块链项目,可以通过跨区块链沟通协议(IBC)来实现不同空间(cosmos用空间这个概念来表述不同的区块链)的信息传递。

值得一提的是Cosmos-SDK,它是Cosmos团队的核心产品,其仍然是采用了ABCI应用的架构(基于Go语言来实现)。如果使用这个SDK来开发一条自己的链,就不必过于纠结于链的底层的帐户体系,共识等技术细节,只需要关心自己的区块链的应用部分,而且在这个SDK中,还开放了一些开发的API,可以通过这些API来实现一些具体的基础实现,打造个性的区块链。

Cosmos 的 SDK 软件开发工具包是基于 Golang 编程语言构建区块链应用的框架,开发者可基于 Tendermint 共识,使用高效的 Golang 语言构建自己的可扩展区块链。

这也意味着,Cosmos-sdk是一个区块链开发的框架体系,通过Cosmos Hub接插任意的区块链,从理论上讲,万链并发不是幻想。cosmos的最终想法是通过cosmos SDK来实现一套完整的生态。

Tendermint和波卡链的substrate类似,都是抽象出来用来处理跨链的一个模块。只不过一个倾向于中心接入,一个倾向于中继处理。

【翻译】官网介绍

Cosmos 介绍

Strictly speaking, Cosmos is a decentralized network of independent parallel blockchains, each powered by BFT consensus algorithms like Tendermint consensus.

严格地说,Cosmos是一个由独立的并行区块链组成的分散网络,每个区块链都由BFT共识算法(如Tendermint共识)提供支持。

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.

换言之,Cosmos是一个区块链的生态系统,可以相互扩展和互操作。在Cosmos之前,区块链是孤立的,无法相互通信。它们很难构建,每秒只能处理少量交易。Cosmos以一种新的技术视野解决了这些问题。为了理解这一愿景,我们需要回到区块链技术的基础上。

什么是区块链?(What is a Blockchain?)

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.

区块链技术的主要好处是各方无需依靠中央授权即可共享总账的能力。 区块链是去中心化的。 今天,区块链技术的第一个也是最著名的应用是比特币,一种去中心化的货币。

。。。

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.

状态机与应用程序层同层。 它定义了应用程序的状态和状态转换功能。 其他层负责在连接到网络的所有节点上的复制状态机。

What is Tendermint BFT and the ABCI

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.

直到最近,构建区块链需要从头开始构建所有三层(网络,共识和应用程序)。 以太坊通过提供虚拟机区块链简化了去中心化应用程序的开发,任何人都可以在其上以智能合约的形式部署自定义逻辑。 但是,它并没有简化区块链本身的开发。 就像比特币一样,以太坊仍然是一个整体的技术堆栈,很难从中进行分叉和定制。 这是Jae Kwon在2014年创建的Tendermint进入的地方。

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.

Tendermint BFT是一种将区块链的网络层和共识层打包到通用引擎中的解决方案,允许开发人员专注于应用程序开发,而不是复杂的基础协议。 结果,Tendermint节省了数百小时的开发时间。 请注意,Tendermint还指定在Tendermint BFT引擎中使用的拜占庭容错(BFT)共识算法的名称。 有关共识协议和BFT的历史的更多信息,请查看Tendermint联合创始人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.

Tendermint BFT引擎通过称为应用程序区块链接口(ABCI) (https://github.com/tendermint/tendermint ⟁ Tendermint Core (BFT Consensus) in Go)的套接字协议连接到应用程序。 该协议可以包装在任何编程语言中,从而使开发人员可以选择适合其需求的语言。

在这里插入图片描述But that is not all. Here are the properties that make Tendermint BFT a state-of-the-art blockchain engine:

但这还不是全部。 以下是使Tendermint BFT成为最先进的区块链引擎的属性:

  • Public or private blockchain ready:

    Tendermint BFT only handles networking and consensus for a blockchain, meaning that it helps nodes propagate transactions and validators agree on a set of transactions to append to the blockchain. It is the role of the application layer to define how the validator set is constituted. Developers can therefore build both public and private blockchains on top of the Tendermint BFT engine. 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仅处理区块链的网络连接和共识,这意味着它可以帮助节点传播交易,并且验证程序可以同意一组交易以附加到区块链上。 定义验证程序集的构成方式是应用程序层的作用。 因此,开发人员可以在Tendermint BFT引擎之上构建公共和私有区块链。 如果应用程序根据验证者所拥有的令牌数量来选择验证者,则可以将区块链表征为权益证明(PoS)。 但是,如果应用程序定义只有一组有限的预授权实体可以是验证者,则可以将区块链表征为允许或私有。 开发人员拥有自定义规则的所有自由,这些规则定义了其区块链的验证程序集如何更改。

  • High Performance: Tendermint BFT can have a block time on the order of 1 second and handle up to thousands of transactions per second.

    高性能: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).

    即时终结性:Tendermint共识算法的一个属性是即时终结性。 这意味着只要超过三分之一的验证者是诚实的(拜占庭),就永远不会创建派生。 用户可以确保一旦创建一个区块即可完成交易(在工作量证明区块链(如比特币和以太坊)中不是这种情况)。

  • Security: Tendermint consensus is not only fault tolerant, it is also accountable. If the blockchain forks, there is a way to determine liability.

    安全性:Tendermint共识不仅是容错的,而且是负责任的。 如果区块链分叉,有一种确定责任的方法。

Cosmos SDK and other application layer frameworks

Tendermint BFT reduces the development time of a blockchain from years to weeks, but building a secure ABCI-app from scratch remains a difficult task. This is why the Cosmos SDK exists.

Tendermint BFT将区块链的开发时间从数年缩短至数周,但是从头开始构建安全的ABCI应用仍然是一项艰巨的任务。 这就是Cosmos SDK存在的原因。

在这里插入图片描述

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:

Cosmos SDK是一个通用框架,可简化在Tendermint BFT之上构建安全区块链应用程序的过程。 它基于两个主要原则:

  • 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.

    模块化:Cosmos SDK的目标是创建一个模块生态系统,使开发人员可以轻松启动特定于应用程序的区块链,而不必从头开始编写其应用程序的每一个功能。 任何人都可以为Cosmos SDK创建模块,在区块链中使用现成的模块就像将它们导入应用程序一样简单。 例如,Tendermint团队正在构建Cosmos Hub所需的一组基本模块。 任何开发人员在构建自己的应用程序时都可以使用这些模块。 此外,开发人员可以创建新模块以自定义其应用程序。 随着Cosmos网络的发展,SDK模块的生态系统将会扩展,这使得开发复杂的区块链应用程序变得越来越容易。

  • 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.

    基于功能的安全性:功能限制了模块之间的安全性边界,使开发人员能够更好地考虑模块的可组合性,并限制恶意或意外交互的范围。 要深入了解功能,请单击此处(https://docs.cosmos.network/master/core/ocap.html)。

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.

Cosmos SDK还附带了一组有用的开发人员工具,用于构建命令行界面(CLI),REST服务器和各种其他常用的实用程序库。

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.

最后一点:Cosmos SDK与所有Cosmos工具一样,都是模块化的。 今天,它允许开发人员在Tendermint BFT之上构建。 但是,它可以与实现ABCI的任何其他共识引擎一起使用。 随着时间的流逝,我们预计将出现多个SDK,它们使用不同的体系结构模型构建并与多个共识引擎兼容-所有这些都在一个生态系统:Cosmos Network中。

To learn how to code applications on top of the SDK you can check out tutorials.

要了解如何在SDK上对应用程序进行编码,可以查看教程(https://tutorials.cosmos.network/)。

ETHERMINT

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 is a project that ports the Ethereum Virtual Machine into an SDK module. Ethermint works exactly like Ethereum but also benefits from all the properties of Tendermint BFT. All the existing Ethereum tools (Truffle, Metamask, etc.) are compatible with Ethermint and you can port your smart contracts over without additional work.

Cosmos SDK的伟大之处在于它的模块化特性使开发人员可以在Golang之上移植几乎任何现有的区块链代码库。 例如,Ethermint是一个将以太坊虚拟机移植到SDK模块中的项目。 Ethermint的工作原理与以太坊完全相同,但也受益于Tendermint BFT的所有属性。 所有现有的以太坊工具(Truffle,Metamask等)均与Ethermint兼容,您无需进行额外工作即可移植智能合约。

Why bother creating a blockchain with the Cosmos SDK when I can just deploy my decentralized application on top of a Virtual Machine blockchain?

当我将分散的应用程序部署在虚拟机区块链之上时,为什么还要使用Cosmos SDK创建区块链呢?

This question is justified, considering that most decentralized applications today are developed on top of Virtual Machine blockchains like Ethereum. First, it should be stated that the reason for this phenomenon is that up until now blockchains were much more difficult to develop than Smart Contracts. This is not the case anymore, thanks to the Cosmos SDK. Now, developers can easily develop entire application-specific blockchains, which have several advantages. Among others, they give more flexibility, security, performance and sovereignty. To learn more about application-specific blockchains read this post. 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.

考虑到当今大多数去中心化应用程序都是在以太坊等虚拟机区块链之上开发的,因此这个问题是合理的。 首先,应该指出的是,这种现象的原因是,到目前为止,区块链比智能合约更难开发。 多亏有了Cosmos SDK,情况已不再如此。 现在,开发人员可以轻松地开发整个特定应用程序的区块链,这具有多个优势。 其中,它们提供了更大的灵活性,安全性,性能和主权。 要了解有关特定于应用程序的区块链的更多信息,请阅读此文章(https://medium.com/@gautier_md/why-application-specific-blockchains-make-sense-32f2073bfb37)。 当然,如果您不想构建自己的区块链,仍然可以通过将智能合约部署在Ethermint上来使其与Cosmos兼容。

Connecting Blockchains Together - IBC

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.

现在,开发人员可以快速构建自定义的区块链,让我们看看如何将这些区块链连接在一起。 区块链之间的连接通过称为区块链间通信协议(IBC)的协议来实现。 IBC利用Tendermint共识的即时最终确定性属性(尽管它可以与任何“快速最终”区块链引擎一起使用),以允许异构链相互传递价值(即令牌)或数据。

ps: “fast-finality” blockchain engine 意思就是,出块的时候,区块就确定了,BFT的性质。而中本聪共识,只是越来越接近确定。

WHAT ARE HETEROGENEOUS CHAINS?

什么是异构链?

heterogeneous

美: [.hetəroʊ’dʒiniəs]
英: [.hetərəʊ’dʒiːniəs]
adj. 由很多种类组成的;各种各样的
网络 异质性;异类的;异构

Essentially it comes down to two things:

从本质上讲,它可以归结为两点:

  • 不同的层

    Different layers: Heterogeneous chains have different layers, meaning they can differ in how they implement the networking, consensus and application parts. To be compatible with IBC, a blockchain needs only follow a few requirements, the main one being that the consensus layer must have fast finality. Proof-of-Work chains (like Bitcoin and Ethereum) do not fall in this category, as they have probabilistic finality.

    不同的层:异构链具有不同的层,这意味着它们在实现网络,共识和应用程序部分的方式上可能有所不同。 为了与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.

    主权:每个区块链都由一组验证器维护,这些验证器的工作是就下一个区块提交区块链达成协议。 在工作量证明区块链中,这些验证器称为矿工。 主权区块链是具有自己的验证器集的区块链。 在许多情况下,重要的是让区块链拥有主权,因为验证者最终负责修改状态。 在以太坊中,所有应用程序都由一组通用的验证程序运行。 因此,每个申请仅具有有限的主权。

    sovereignty

    美: ['sɑvrənti]
    英: ['sɒvrɪnti]
    n. 主权;最高统治权;最高权威;独立自主
    网络 国家主权;主权国家;君权

IBC allows heterogeneous blockchains to transfer tokens and data to each other, meaning that blockchains with different applications and validator sets are interoperable. For example, it allows public and private blockchains to transfer tokens to each other. Currently, no other blockchain framework enables this level of interoperability.

IBC允许异构区块链彼此之间传递令牌和数据,这意味着具有不同应用程序和验证器集的区块链可以互操作。 例如,它允许公共和私有区块链相互之间交换令牌。 当前,没有其他区块链框架支持这种级别的互操作性。

HOW IBC WORKS

The principle behind IBC is fairly simple. Let us take an example where an account on chain A wants to send 10 tokens (let us call them ATOM) to chain B.

IBC背后的原理非常简单。 让我们以一个示例为例,链A上的一个帐户想要向链B发送10个令牌(我们称它们为ATOM)。

  • 追踪 Tracking

    Continuously, chain B receives the headers of chain A, and vice versa. This allows each chain to track the validator set of the other. In essence, each chain runs a light-client of the other.

    连续地,链B接收链A的headers ,反之亦然。 这允许每个链跟踪另一个链的验证器集。 从本质上讲,每个链都运行另一个链的轻客户端。

    A light-client is a blockchain client that only downloads the headers of the blocks. It verifies the result of its queries against these headers (see Merkle Proof). This gives users a lightweight alternative to full-nodes with good security guarantees.

    轻客户端是仅下载区块头的区块链客户端。 它针对这些标头验证查询结果(请参阅Merkle Proof)。 这为用户提供了具有良好安全性保证的轻量级替代全节点的方法。

  • 绑定 Bonding

    When the IBC transfer is initiated, the ATOM are locked up (bonded) on chain A.
    启动IBC传输后,ATOM被锁定(绑定)在链A上。
    在这里插入图片描述

  • 证明转发 Proof Relay

    Then, a proof that the 10 ATOM are bonded is relayed from chain A to chain B.
    然后,将10个ATOM绑定的证明从链A中继到链B。

  • Validation

    The proof is verified on chain B against chain A’s header and, if it is valid, then 10 ATOM-vouchers are created on chain B.
    在链B上对照链A的 header 验证该证明,如果有效,则在链B上创建10个ATOM凭证。
    在这里插入图片描述

Note that the ATOM that have been created on chain B are not real ATOM, as ATOM only exist on chain A. They are a representation on B of ATOM from chain A, along with a proof that these ATOM are frozen on chain A.

请注意,在链B上创建的ATOM不是真正的ATOM,因为ATOM仅存在于链A上。它们是链A上ATOM的B上的表示形式,以及这些ATOM冻结在链A上的证明。

A similar mechanism is used to unlock ATOM when they come back to their origin chain. For a more comprehensive description of the IBC protocol, you can look at this specification.

当ATOM返回其原始链时,可以使用类似的机制来解锁ATOM。 有关IBC协议的更全面描述,请查看此规范。(https://github.com/chaininfo/cosmos-ibc、https://github.com/cosmos/cosmos-sdk)

Designing the “Internet of Blockchains”

IBC is a protocol that allows two heterogeneous blockchains to transfer tokens to each other. From there, how do we create a network of blockchains?

IBC是一种协议,它允许两个异构区块链相互之间传递令牌。 从那里开始,我们如何创建区块链网络?

One idea is to connect each blockchain in the network with every other via direct IBC connections. The main problem with this approach is that the number of connections in the network grows quadratically with the number of blockchains. If there are 100 blockchains in the network and each needs to maintain an IBC connection with every other, that is 4950 connections. This quickly gets out of hand.

一种想法是通过直接IBC连接将网络中的每个区块链相互连接。 这种方法的主要问题是,网络中的连接数与区块链的数量成平方增长。 如果网络中有100个区块链,并且每个区块链之间都需要维持IBC连接,那么就是4950个连接。 这很快就失控了。

在这里插入图片描述

To solve this, Cosmos proposes a modular architecture with two classes of blockchain: Hubs and Zones. Zones are regular heterogenous blockchains and Hubs are blockchains specifically designed to connect Zones together. When a Zone creates an IBC connection with a Hub, it can automatically access (i.e. send to and receive from) every other Zone that is connected to it. As a result, each Zone only needs to establish a limited number of connections with a restricted set of Hubs. Hubs also prevent double spending among Zones. This means that when a Zone receives a token from a Hub, it only needs to trust the origin Zone of this token and the Hub.

为了解决这个问题,Cosmos提出了一种具有两类区块链的模块化架构:集线器和区域。 区域是常规的异构区块链,而集线器是专门设计用于将区域连接在一起的区块链。 区域创建与集线器的IBC连接时,它可以自动访问(即发送和接收)与其连接的所有其他区域。 结果,每个区域仅需要与有限的集线器建立有限数量的连接。 集线器还可以防止区域之间的双重支出。 这意味着,当区域从集线器接收到令牌时,它仅需要信任此令牌和集线器的原始区域。

The first Hub launched in the Cosmos Network is the Cosmos Hub. The Cosmos Hub is a public Proof-of-Stake blockchain whose native staking token is called the ATOM, and where transactions fees will be payable in multiple tokens. The launch of the Hub also marks the launch of the Cosmos network.

Cosmos网络中启动的第一个Hub是Cosmos Hub。 Cosmos Hub是一个公共的权益证明区块链,其本机权益令牌称为ATOM,并且交易费用将以多个令牌支付。 Hub的启动也标志着Cosmos网络的启动。

Bridging non-Tendermint chains

So far, the architecture of Cosmos we have presented shows how Tendermint-based chains can interoperate. But Cosmos is not limited to Tendermint chains. In fact, any kind of blockchain can be connected to Cosmos.

到目前为止,我们介绍的Cosmos架构显示了基于Tendermint的链如何实现互操作。 但是Cosmos 不仅限于Tendermint 链。 实际上,任何种类的区块链都可以连接到Cosmos。

We have two cases to distinguish: fast-finality chains and probabilistic-finality chains.

我们有两种情况可以区分:快速最终链和概率最终链。

FAST-FINALITY CHAINS

Blockchains that use any fast-finality consensus algorithms can connect with Cosmos by adapting IBC. For example, if Ethereum were to switch to Casper FFG (Friendly Finality Gadget), a direct connection could be established between it and the Cosmos Ecosystem by adapting IBC to work with Casper.

使用任何快速最终共识算法的区块链都可以通过调整IBC与Cosmos连接。 例如,如果以太坊要切换到Casper FFG(友好终结小工具),则可以通过使IBC与Casper配合使用,在以太坊和Cosmos生态系统之间建立直接连接。

PROBABILISTIC-FINALITY CHAINS

For blockchains that do not have fast-finality, like Proof-of-Work chains, things get a bit trickier. For these chains we use a special kind of proxy-chain called a Peg-Zone.

对于没有快速确定性的区块链,例如工作量证明链,事情会变得有些棘手。 对于这些链,我们使用一种称为钉区的特殊代理链。(https://blog.cosmos.network/the-internet-of-blockchains-how-cosmos-does-interoperability-starting-with-the-ethereum-peg-zone-8744d4d2bc3f)

A Peg-Zone is a blockchain that tracks the state of another blockchain. The Peg-Zone itself has fast-finality and is therefore compatible with IBC. Its role is to establish finality for the blockchain it bridges. Let us look at the following example.

钉区是跟踪另一个区块链状态的区块链。钉区本身具有快速确定性,因此与IBC兼容。 它的作用是为所桥接的区块链确定最终性。 让我们看下面的例子。

在这里插入图片描述Example: Ethereum Peg-Zone

We want to bridge the Proof-of-Work Ethereum blockchain to make it possible to send tokens back and forth between Ethereum and Cosmos. Because Proof-of-Work Ethereum does not have fast-finality, we need to create a Peg-Zone to act as a bridge between the two.

我们希望桥接工作量证明的以太坊区块链,以使其能够在以太坊和Cosmos之间来回发送令牌。 由于工作量证明以太坊不具有快速确定性,因此我们需要创建一个钉区以充当两者之间的桥梁。

First, the Peg-Zone needs to decide on a finality threshold for the origin chain. For example, it can consider that a given block of the origin’s chain is final when 100 blocks have been added after it.

首先,钉区需要确定源链的最终阈值。 例如,当原点链的给定区块添加到其后的100个区块中时,它可以认为是最终区块。

Second, a contract is deployed on the main Ethereum blockchain. When users want to send tokens from Ethereum to Cosmos, they start by sending tokens to this contract. Then the contract freezes the assets and after 100 blocks, a representation of these assets is released on the Peg-Zone. A similar mechanism is used to send assets back to the Ethereum chain.

其次,在主要的以太坊区块链上部署合约。 当用户想要将令牌从以太坊发送到Cosmos时,他们首先将令牌发送到该合约。 然后合同冻结资产,并在100个区块之后,在钉区释放这些资产的表示。 使用类似的机制将资产发送回以太坊链。

解决可伸缩性 Solving Scalability

Now that we can easily create and connect blockchains there is one final issue to tackle: Scalability. Cosmos leverages two types of scalability:

现在我们可以轻松地创建和连接区块链,还有一个要解决的最后问题:可伸缩性。 Cosmos利用两种类型的可伸缩性:

  • Vertical scalability: This encompasses the methods for scaling the blockchain itself. By moving away from Proof-of-Work and optimizing its components, Tendermint BFT can reach thousands of transactions per-second. The bottleneck factor is the application itself. For example, an application like a Virtual Machine (e.g. the Ethereum Virtual Machine) will impose a much lower limit on the transaction throughput than an application where transaction types and state transition functions are directly embedded in it (e.g. a standard Cosmos SDK application). This is one of the reasons why application-specific blockchains make sense (read about more reasons here).

    垂直可伸缩性:这包括扩展区块链本身的方法。通过远离工作证明和优化其组件,Tendermint BFT可以达到每秒数千个事务。瓶颈因素是应用程序本身。例如,像虚拟机这样的应用程序(例如以太坊虚拟机)对事务吞吐量的限制要比直接嵌入事务类型和状态转换函数的应用程序(例如标准的Cosmos SDK应用程序)低得多。这是特定于应用程序的区块链之所以有意义的原因之一(请阅读此处了解更多原因 https://blog.cosmos.network/why-application-specific-blockchains-make-sense-32f2073bfb37)。

  • Horizontal scalability: Even if the consensus engine and the application are highly optimized, at some point the transaction throughput of a single chain inevitably hits a wall it cannot surpass. That is the limit of vertical scaling. To go beyond it, the solution is to move to multi-chain architectures. The idea is to have multiple parallel chains running the same application and operated by a common validator set, making blockchains theoretically infinitely scalable. Details about horizontal scalability are fairly complex and out-of-scope for this intro.

    横向可伸缩性:即使共识引擎和应用程序得到了高度优化,在某个时候,单个链的事务吞吐量不可避免地会遇到它无法超越的墙。这就是垂直缩放的极限。除此之外,解决方案是转向多链体系结构。这个想法是让多个并行链运行同一个应用程序,并由一个共同的验证程序集操作,使区块链理论上无限可伸缩。关于水平可伸缩性的细节相当复杂,超出了本文介绍的范围。

Cosmos will offer very good vertical scalability at launch, which will be a major improvement over current blockchain solutions in and of itself. Later, after the completion of the IBC module, horizontal scalability solutions will be implemented.

Cosmos在发布时将提供非常好的垂直可扩展性,这将是对当前本身的区块链解决方案的重大改进。 稍后,在完成IBC模块后,水平可伸缩性解决方案将被实现。

So in the end, what is Cosmos?

Hopefully by now you have a clearer picture of the Cosmos project. Here is a quick recap of what Cosmos is in three concise points:

希望到目前为止,您对Cosmos项目有了更清晰的了解。 以下是三个简要说明,概述了Cosmos:

  1. Cosmos makes blockchains powerful and easy to develop with Tendermint BFT and the modularity of the Cosmos SDK.

    Cosmos使用Tendermint BFT和Cosmos SDK的模块化功能,使区块链功能强大且易于开发。

  2. Cosmos enables blockchains to transfer value with each other through IBC and Peg-Zones, while letting them retain their sovereignty.

    Cosmos使区块链能够通过IBC和Peg-Zones相互转移价值,同时让它们保持主权。

  3. Cosmos allows blockchain applications to scale to millions of users through horizontal and vertical scalability solutions.

    Cosmos允许区块链应用程序通过水平和垂直可扩展性解决方案扩展到数百万用户。

More than anything, Cosmos is not a product but an ecosystem built on a set of modular, adaptable and interchangeable tools. Developers are encouraged to join the effort to improve existing tools and create new ones in order to make the promise of blockchain technology a reality. These tools are the foundation needed to create the decentralized internet and global financial system of tomorrow.

最重要的是,Cosmos并非一个产品,而是基于一系列模块,可适应和可互换工具的生态系统。 鼓励开发人员共同努力改进现有工具并创建新工具,以实现区块链技术的承诺。 这些工具是创建明天的去中心化互联网和全球金融系统所需的基础。

在这里插入图片描述

二、Cosmos 的起源

2014 年,Jae Kwon 是首批在 PoS 权益证明区块链的背景下探索拜占庭容错方向的研究人员之一,他在同年发表了《Tendermint:无挖矿的共识》的白皮书。Tendermint 的基本思想是允许大量分布式节点就共识达成一致,而无需中本聪共识依赖的 PoW 工作量证明挖矿。

中本聪共识是在多个节点之间分配信任的重大突破,但有局限性,比如速度慢、要浪费网络外部的资源才能达成共识等等。Tendermint BFT 共识算法是第一个引入 staking 权益质押、验证、领导轮流选举的算法,以改善中本聪共识的局限性。

三、团队概述

根据Cosmos网站的免责声明,“Cosmos项目的开发主要由Tendermint公司负责”,这是一个私营团体,但开发资金来自瑞士非盈利组织Interchain Foundation(基金会)。可以在Tendermint官网上找到完整的Tendermint团队资料和个人背景。

四、Cosmos的整体结构

【深度知识】COSMOS架构及核心模块分析

参考URL: https://cloud.tencent.com/developer/article/1446970

  1. 网络和共识(Tendermint)

    cosmos通过Tendermint实现了一个通用层,利用这个通用层,可以实现不同的应用的接插隔离。

  2. cosmos中心(Hub)

    所谓中心,就是cosmos Hub,Cosmos网络中第一个公共区块链,通过Tendermint拜占庭共识算法运行。

    Cosmos中心通过ABCI来连接其他区块链(空间)。中心可以控制各个空间里代币。保证代币可以安全快速地从一个空间传递到另一个空间,即进行资产的跨链交易。

  3. 空间(Zones)

    空间,也就是各个独立的区块链,连接到cosmos中心后,它们就成为了cosmos的一个空间。每个空间也会和中心的状态保持一致。信息可以从一个空间发送到另外一个空间,通过默克尔证明(Merkle-proof)来表明信息已经被传送或接收。这种机制叫做“区块链间通信”,简称为“IBC”机制。

  4. 跨链通信协议(IBC)

    IBC是中心与空间之前通信的方法。假设现在有三个区块链,分别是“空间1”、“空间2”以及“中心”,如果想要“空间1”生成一个消息包,通过“中心”发送给“空间2”。为了让消息包从一个区块链转移到另一个区块链,需要在接收方区块链上发布一个证明,来明确发送方已经发起了一个消息包到指定地点。接收方要验证的这个证明,必须和发送方区块头保持一致。这种机制就类似与侧链采用的机制,它需要两个相互作用的链,通过双向传送存在证明数据元(交易),来“知晓”另一方的情况。

    IBC协议可以自然定义为两种交易的使用:一种是IBCBlockCommitTx 交易,这种交易可以让区块链向任何观察员证明其最新区块哈希值;另一种是IBCPacketTx 交易,这种交易则可以证明某个消息包确实由发送者的应用程序,通过默克尔证明机制(Merkle-proof)传送到了最新区块的哈希值上。

    通过将IBC机制分裂成两个单独的交易,即IBCBlockCommitTx交易与IBCPacketTx交易,可以让接收链的本地费用市场机制,来决定承认哪个消息包,与此同时还能确保发送方的完全自由,让其自行决定能够传出的消息包数量。

构建COSMOS网路的两大基础为Tendermint共识引擎和IBC跨链通信。

Tendermint共识引擎本质上可以理解为投票一致系统,基于著名的拜占庭一致性算法。该算法保证只要有2/3以上的节点是诚实节点,那就能保证最后的投票结果是一致的,也从而实现了实时最终一致性,避免了链分叉。基于Tendermint这个项目,任何人可以实现自己的拜占庭容错的区块链。

IBC跨链通信,是Tendermint区块链之间的通信协议,这个也是实现互操作性的基础。IBC利用了即时最终确定性的属性,允许异构的区块链间相互交换代币。

在这里插入图片描述

COSMOS中心网络基于Tendermint引擎,而COSMOS中投票节点叫做验证节点(Validator)。验证节点负责整个节点的出块和投票,在COSMOS中心网络正式上线初期会选择100个验证节点。

更详细整体结构图,如下:

在这里插入图片描述

转载地址:https://docker.blog.csdn.net/article/details/110634622 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Parabolic SAR(抛物线转向指标)
下一篇:Hibernate JPA-JPA 只查询(单表、多表)部分字段而不返回全部字段

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月30日 11时39分02秒