干货丨详解以太坊2.0如何与1.0合并
注:原文作者是以太坊2.0协调员Danny Ryan(djrtwo),在这篇文章中,他详细介绍了以太坊1.0将如何与以太坊2.0合并,根据他的介绍,在eth1+eth2组合客户端中,eth2客户端可以处理PoS和分片共识的复杂性,而附属eth1客户端可以成为一个eth1引擎,它可以处理状态、交易、虚拟机等事物的复杂性。
Note: The original author, Danny Ryan (djrtwo), Coordinator of Taiga 2.0, in which he described in detail how Etai Hall 1.0 would be merged with Ethaya 2.0. According to him, in the eth1+eth2 combination client, the eth2 client could handle the complexity of PoS and the division consensus, while the subsidiary eth1 client could be an eth1 engine that could handle the complexity of state, trade, virtual machines, etc.
(图片来自:tuchong.com)
(photo from: tuchong.com)
以太坊1.0和以太坊2.0客户端的关系
自从Vitalik在2019年12月提出一个早期eth1 <-> eth2 合并替代方案之后,研究人员一直在进行积极讨论,以从软件的角度来考虑这种合并的可能形式,而对于原型设计的期望,也是愈发变得更强。我们的愿景是创建一个混合体,其中核心共识工作是由以太坊2.0客户端(以下简称eth2客户端)管理,而状态/区块则由一个以太坊1.0引擎(以下简称eth1引擎)管理,而它们一起构成了eth1+eth2组合客户端。
Since Vitalik proposed an early Eth1 & lt;-> eth2 merger alternative in December 2019, researchers have been actively discussing the possible form of such integration from a software perspective, and expectations for prototype design have grown stronger. Our vision is to create a hybrid where the core consensus work is managed by the Ether 2.0 client (hereinafter eth2 client), while the status/block is managed by a Teth 1.0 engine (hereinafter >b>eth1 engine), which together constitutes the Eth1+eth2 client combination.
本文旨在更明确地区分eth2客户端和附属eth1引擎之间的职责,以便为会话、规范编写及原型提供更好的基础。注意,文章并不会定义协议的具体细节(例如eth1 客户端调用eth2引擎的精确方法),并且文中包含的任何示例,都只是用于帮助描述及后续讨论。
The aim of this paper is to distinguish more clearly the responsibilities between the eth2 client and the attached eth1 engine in order to provide a better basis for conversation, norm-setting and prototype. Note that the article does not define the details of the protocol (e.g. the precise method of the eth1 client calling the eth2 engine) and that any examples contained in the text are intended only to help describe and follow up the discussion.
而要理解本文的内容,前提条件是需要你基本熟悉以太坊2.0以及无状态以太坊的概念。
To understand the content of this paper, you need to be very familiar with the concept of Etherm 2.0 and the Innocence Etherm.
分工明确
eth1+eth2的合并目的,是在升级的以太坊2.0共识环境中利用现有以太坊1.0的状态、生态系统以及软件。
The purpose of the merger of eth1+eth2 is to make use of the status, ecosystems and software of the evasive 1.0 in the upgraded ephemeral 2.0 consensus environment.
概括地说,我们今天所认为的eth2客户端会处理核心PoS以及分片共识。本质上,eth2协议及eth2客户端被设计成非常擅于在一堆“东西”上产生及达成共识,而这些东西,就是很多充满数据和(最终)状态的分片链。与当今eth1的PoW共识层相比,eth2的“共识层”要先进的多,同时也复杂的多。
In summary, what we believe today is that the Eth2 client handles the core PoS as well as the division consensus. In essence, the Eth2 protocol and the Eth2 client are designed to be very good at generating and reaching consensus on a bunch of "things" that are a lot of data-filled (final) segment chains. The Eth2 “consensus layer” is much more advanced and complex than the PoW consensus layer in Eth1 today.
今天,eth1客户端具有相对简单且较薄的共识层,它只有一条链,并且PoW可处理协议外硬件中的大部分复杂性。eth1客户端的大多数复杂性及优化,都位于用户层(包括状态存储/管理、状态同步、虚拟机执行、交易处理、交易池等)。
Today, the eth1 client has a relatively simple and thin consensus layer, which has only one chain, and the PoW can handle most of the complexity of extra-agreement hardware. Most of the complexity and optimization of the eth1 client is located on the user level (including state storage/management, state synchronization, virtual machine execution, transaction processing, trading pool, etc.).
当eth1作为一个分片被纳入eth2时,这种关注点分离就可实现很好的配对,eth2客户端可以处理PoS和分片共识的复杂性,而附属eth1客户端可以成为eth1引擎,它可以处理状态、交易、虚拟机以及更接近用户层事物的复杂性。
When Eth1 is included as a segment in Eth2, this focus can be well matched, and the Eth2 client can handle the complexity of PoS and the division consensus, while the affiliated Eth1 client can be the Eth1 engine, which can handle the complexity of state, trade, virtual machines and things closer to the user level.
最小的改变,实现本地通信
如何将eth1和eth2客户端软件组合在一起,有很多可能的途径(比如完全合并、将eth1作为库导入、通过两者之间的通信协议等),但在本文当中,我们会重点介绍一个最具微创性和和模块化的方法 —— 一种eth2客户端与简化eth1引擎之间的本地通信协议。
There are many possible ways to combine Eth1 and Eth2 client software (e.g. full integration, import of Eth1 as a library, adoption of communication protocols between them, etc.), but in this paper we highlight one of the most creative and modular approaches - a local communication protocol between the Eth2 client and the simplified Eth1 engine.
考虑到eth1和eth2客户端实现的多样性,这种方法可以防止客户端软件在任一侧锁定,允许客户端团队保持独立,并专注于他们自己的研发工作,使软件项目在很大程度上保持稳定,以便进行快速原型制作。
Taking into account the diversity of eth1 and eth2 clients, such an approach would prevent client software from being locked on either side, allow client teams to remain independent and focus on their own research and development efforts, and allow software projects to remain largely stable for rapid prototype production.
那它会是什么样子的呢?
What would it look like?
大致上,一个eth1+eth2组合客户端会是下面这个样子的:
Basically, an eth1+eth2 combination client would be as follows:
其中eth2引擎和eth1引擎一起运行,通过eth2客户端驱动的RPC进行本地通信。
The Eth2 engine runs with the Eth1 engine and communicates locally via the eth2 client-driven RPC.
两者都会维护自己的p2p接口,连接到对等方并处理与每个特定域相关的网络协议。
Both maintain their own p2p interfaces, connect to peers and process network protocols related to each particular domain.
以太坊2.0客户端
1. 信标链和信标状态 (构建系统其余部分的核心共识对象);
1. The beacon chain and beacon status (constructing core consensual objects in the rest of the system);
2. 分片链(1、eth1分片链,2、很多仅限数据的分片链);
2. Fracture chains (1, Eth1, 2, many data-only Fracture chains);
3. Mempool操作[未显示](证明(Attestation)、存款(deposit)、退出出口( exit)等)
Mempol operation [not shown] (evidence (Attestation), deposit (deposit), exit (exit) etc.)
4. P2P接口(1、共识层信息,2、包括eth1分片区块gossip);
4. P2P interface (one, consensus layer information,2 including eth1 block gossip);
5. RPC到eth1引擎 (所有调用都由eth2客户端驱动);
5. to eth1 engine (all calls are driven by eth2 clients);
以太坊1.0引擎
1. EVM虚拟机(eth1分片区块的执行与验证);
1. EVM virtual machine (execution and validation of Eth1 blocks);
2. eth1状态(今天以太坊中的用户层eth1状态);
2. Eth1 status (today with user level Eth1 status in Taim);
3. 交易存储池Mempool(用户交易mempool,为区块生产做准备);
3. Mempool (user-trading mempool to prepare block production);
4. P2P接口(1、今天以太坊上的交易gossip,2、状态同步,3、没有eth1分片区块gossip);
4. P2P interface (one, today's deal with Gossip, 2, synchronised, 3, no eth1 block Gossip);
5. 来自eth2客户端的RPC (所有调用都由eth2客户端驱动);
5. 从核心共识的角度来看,eth2客户端负责并推动信标链、数据分片链以及eth1分片链的构建。eth2客户端通过RPC直接提供有关eth1引擎关于eth1分片链和核心共识(信标链/状态)的任何知识。 From the point of view of the core consensus, the Eth2 client is responsible for and facilitates the construction of the beacon chain, the data segment chain, and the Eth1 subsystem. The Eth2 client directly provides any knowledge of the Eeth1 engine about the Eth1 subsystem and the core consensus (beacon chain/status) via RPC. 具体来说,附加的eth1引擎必须能够访问eth2客户端,因为它不能维护自己的共识。在今天以太坊的PoW中,eth1客户端检查工作量证明,形成一个树状结构,并运行分叉选择规则来查找链的顶端。在eth2中,这些机制要大不相同,这需要对eth2的核心共识有深入的了解。eth2客户端提供有关eth1分片链头部(head)的最新信息,以便eth1引擎可以维护eth1状态的准确视图。 Specifically, the additional Eth1 engine must be able to access the Eth2 client because it cannot maintain its own consensus. In PoW, the Eth1 client's workload today proves that a tree structure is formed and the fork selection rules are run to find the top of the chain. In Eth2, these mechanisms are very different, which requires an in-depth understanding of the Eth2 core consensus. The Eth2 client provides up-to-date information on the head of the Eth1 branch, so that the Eth1 engine can maintain an accurate view of the Eth1 state. 由于eth1引擎完全依赖eth2客户端推动共识,因此我们提议eth2客户端与eth1引擎之间的通信,都是eth2客户端调用的eth1引擎上的所有方法(例如addBlock, getBlockProposal等)。这将强制执行一个leader/follower关系,以降低系统推理的复杂性,并限制eth1引擎所需的业务逻辑。 Since the Eth1 engine relies entirely on the Eth2 client to promote consensus, we propose that communication between the Eth2 client and the Eth1 engine be all the methods on the Eth1 engine (e.g. addBlock, getBlockProposal, etc.) that Eth2 client call. This will enforce a leader/follower relationship to reduce the complexity of system reasoning and limit the business logic required for the Eth1 engine. 从eth2客户端和核心共识的角度来看,eth1分片链的处理,几乎与所有其他分片链(分叉选择、交联、区块结构、签名等)完全相同。主要区别在于,可以针对eth1引擎执行分片区块内容,因此eth1分片区块数据的格式必须与eth1相关,并且必须针对此成功执行进行额外的验证。 From the point of view of the Eth2 client and the core consensus, the Eth1 subsystem is treated almost exactly the same as all other subsystems (fork selection, connection, block structure, signature, etc.). The main difference is that the content of the block can be implemented for the Eth1 engine, so that the format of the Eth1 block data must be related to Eth1 and additional validation must be performed for successful implementation. eth2有一种与核心共识相关的状态,这就是所谓的“信标状态”(beacon-state)。信标状态数据很小(大约只有10-40MB,取决于验证者集的大小),它包含了理解核心共识及如何处理分片链所需的所有信息。事实上,要处理分片链中与共识相关的部分,客户端必须能够访问信标状态(例如,运行分片链分叉选择的最新交联crosslink、验证分片链签名的当前验证集或shuffling随机分配)。 Eth2 has a status related to the core consensus, the so-called "beacon-state" (beacon-state). The beacon status data are very small (about 10-40MB, depending on the size of the verification body) and contain all the information needed to understand the core consensus and how to deal with the segment chain. In fact, to deal with the consensus-related parts of the segment chain, the client must be able to access the beacon status (e.g., the latest interconnection selected by the running segment for the segmental segment, the current authentication set for the authentication of the signature of the segment chain or the random distribution of shuffling). eth2的状态不会一直和用户层状态交互,其交互最多的是分片链数据的可用性。实际的用户层数据根位于该分片链数据中,对于eth1分片链,则为当前以太坊用户状态根。 The status of eth2 does not always interact with the status of the user layer, most often with the availability of the fractal chain data. The actual stratum data are located in the fractal data chain and, for eth1 the current dyke is the root of the user status. 下面讨论了和eth2客户端相关的eth1状态的不同情况: The differences in the eth1 status associated with the eth2 client are discussed below: 核心eth2协议可以在没有附加eth1引擎的情况下运行。单独的eth2客户端可以遵循信标链和分片链(包括eth1分片)。而没有eth1引擎,客户端将无法执行无状态eth1分片区块,因此无法完全验证它们或从中获取任何有用的用户信息。不过,根据对eth2核心共识和验证者的假设,eth1分片链的头部(head)仍然可以安全地找到。 Core Eth2 protocols can run without an Eth1 engine. Separate Eth2 clients can follow beacon chains and fractional chains (including Eth1 fractions). Without Eth1, the client will not be able to execute the statusless Eth subsections and therefore cannot fully verify them or obtain any useful user information from them. However, based on the Eth2 Core Consensus and the assumption of the certifier, the head of the Eth1 chain (head) can still be found safely. 要运行一个验证者节点,必须使用附加的eth1引擎运行eth2客户端。这可以通过无状态的方式完成(即不在本地存储整个eth1状态),因此eth1分片区块具有可用于执行的验证数据(witness)。信标委员会可以通过对eth1引擎进行无状态调用,来检查分片区块数据的可用性及关于eth1的数据有效性。 To run a confirmer node, an additional Eth1 engine must be used to run the Eth2 client. This can be done in a stateless manner (i.e. not to store the entire Eth1 state locally), so the Eth1 block has the validation data (witness) that can be executed. The beacon board can check the availability and validity of the Eth1 data by calling the Eth1 engine in a stateless manner. 除了验证者外,很多用户/应用程序节点也可能使用无状态或半状态的eth1引擎运行。使用瘦eth2客户端,来跟随eth1分片链的头部,并以无状态或半无状态的方式与其交互。 Many users/application nodes, in addition to the Certifier, may also operate with an inert or semi-state Eth1 engine. 要运行可产生eth1 分片区块的验证者,必须使用附加的eth1引擎和完整的eth1状态运行eth2协议(研发者们正在探索无状态的区块产生方法,但为简单起见,我们不对其进行讨论)。然后,可以使用本地状态和交易存储池(TX mempool)按需形成新的有效区块(在下文中有更多讨论)。 To run a certifier that can produce eth1 fragments, it is necessary to use the additional eth1 engine and the complete eth1 active eth2 protocol (researchers are exploring ways of creating an unstated block, but we will not discuss it for the sake of simplicity). Then, the local state and transaction reservoir (TX mempol) can be used to create new active blocks as needed (discussed further below). 除验证者外,很多用户/应用程序节点也可能使用完全有状态的eth1引擎运行,例如区块浏览器、存档节点、状态提供者等。 In addition to the certifier, many users/application nodes may run using fully state eth1 engines, such as block browsers, archive nodes, status providers, etc. 为简单起见,eth2和eth1最初会维护它们各自独立的网络堆栈和协议。为了响应责任转移(例如eth1分片区块gossip),开发者已不赞成使用某些现有的eth1协议(例如eth1分片区块gossip),取而代之的是eth2协议。在初始原型设计阶段之后,或者在更进一步的阶段,可能需要将eth1协议迁移到libp2p以统一网络堆栈,但这不是必须的。 In response to the transfer of responsibility (e.g., the Eth1 sub-block Gossip), developers are no longer in favour of using some of the existing Eth1 protocols (e.g., the Eth1 sub-block Gossip) and replacing them with the Eth2. After the initial prototype design phase, or at a later stage, the Eth1 protocol may need to be relocated to libp2p to unify the network stack, which is not necessary. eth2客户端和eth1引擎可以访问相同的discv5 DHT,但是可独立地找到具有适当功能的对等节点并独立地维护连接。 The Eth2 client and the Eth1 engine can access the same discv5 DHT, but can independently identify the appropriate functional peer nodes and independently maintain the connection. eth1+eth2组合客户端会使用一个ENR,因为节点位于具有多个功能的逻辑网络标识之后。 The eth1+eth2 portfolio client uses an ENR because nodes are located after a logical network identification with multiple functions. eth1功能(状态、交易等)由ENR中的现有eth(或新eth1)key表示。 The eth1 function (status, transaction, etc.) is represented by the existing eth (or new eth1)key in ENR. eth2功能(核心共识)在ENR中用eth2 key表示。 The eth2 function (core consensus) is expressed in ENR in eth2 key. 每种协议的存在,都意味着节点能够且愿意识别底层网络协议的类别。 The existence of each protocol means that nodes are able and willing to identify the type of bottom network protocol. 1、eth2请求/响应(1、状态,2、信标区块同步,3、分片区块同步); 2、核心共识gossip(1、Beacon区块,2、证明,3、分片区块,包括eth1分片, 4、其它验证者操作); 1. Eth2 requests/responses (1, status, 2, synchronisation of beacon blocks, 3, synchronisation of sub-blocks); 2, Core Consensus Gossip (1, Beacon blocks, 2, certification, 3, sub-blocks including Eth1, 4, other authentication operations); 1、eth1 wire协议的子集 (1、交易gossip,2、同步方法,例如getnodedata或新方法, 3、获取收据receipt) Subsets of the eth1wire protocol (1, transaction Gossip, 2, synchronous methods, e.g., Getnodedata or new methodology, 3, receipt obtained) 2、NOT(与区块哈希、区块头或体相关的消息); NOT (information related to block Hashi, block head or body); eth2专门用于处理分片区块的生产、gossip以及验证。我们的目标是让eth1分片成为标准分片,并尽可能与其余分片保持一致。关于核心共识,与其他分片相比,eth1区块的主要区别在于针对eth1引擎执行/验证区块内容的能力, Eth2 is dedicated to the production, Gossip and validation of the fragments. Our goal is to make the Eth1 fragments standard and, as far as possible, consistent with the remaining fragments. With regard to the core consensus, the main difference in the Eth1 block is the ability to execute/ verify the content of the blocks for the Eth1 engine. 当验证者正在将eth1分片区块叉联到信标链时,eth2客户端将再次调用eth1引擎来执行和验证该区块。 The Eth2 client will again call the Eth1 engine to execute and verify the Eth1 block when the verifier is connecting it to the beacon chain. 当有状态的eth1 + eth2组合节点收到新的eth1分片区块时,eth2客户端将再次调用eth1引擎,以验证该区块并更新本地状态存储。 The Eth2 client will again call the Eth1 engine to verify the block and update the local state storage when the Eth1 + Eth2 combined node receives a new Eth1 block. eth1引擎几乎会以当前以太坊相同的方式,维护用户交易gossip以及eth1交易储存池。同样的网络协议和本地机制,可以用于gossip及存储池的维护,为区块的生产做好准备。 The same network protocols and local mechanisms can be used for the maintenance of the Gosip and storage pools to prepare blocks for production. 主要的区别在于如何确定已用交易的知识,以及如何将存储池用于区块生产,但这些可以说是位于存储池外部的一个层中。 The main difference is how to determine the knowledge that has been traded and how to use the reservoir for block production, but these can be said to be located in a layer outside the reservoir. eth1分片区块是从附属eth2客户端提供给eth1引擎的。包含在这些区块中的交易,应该以类似于当前以太坊主网PoW区块的方式从存储池中清除。 The Eth1 sub-blocks are provided to the Eth1 engine from an affiliated Eth2 client. The transactions contained in these blocks should be removed from the storage pool in a manner similar to the current PoW block on the Taijin main network. eth1分片区块是根据附属eth2客户端,通过存储池mempool的内容生成的。此RPC方法和基础功能类似于getWork,但将返回完整的区块内容,而不仅仅是一个哈希值。 Eth1 sub-blocks are derived from the contents of the attached Eth2 client and are generated by the memory pool mempol. This 在eth2协议中,所有区块(信标区块、分片区块、eth1分片区块)必须由PoS验证者根据核心共识进行生产及签名。为此,eth2客户端最终要负责所有区块的生产。 In the Eth2 agreement, all blocks (beacon blocks, blocks, blocks of Eth1) must be produced and signed by the PoS certifying officer on the basis of a core consensus. For this purpose, the Eth2 client is ultimately responsible for the production of all blocks . 对于信标区块和非eth1分片区块,eth2客户端具有生成有效区块所需的一切。 For beacon blocks and non-eth1 sub-blocks, the Eth2 client has everything necessary to generate a valid block. 对于eth1分片区块,eth2客户端立即/随时访问eth1状态、交易和其它底层eth1结构,以生成有效区块。相反,当指定验证者生成eth1区块时,eth2客户端从eth1引擎请求一个可行的eth1区块数据(TX、状态根等)。然后,eth2客户端将此eth1区块数据打包到完整的分片区块中(添加slot、positer_index、positer_signature等),并将该区块广播至网络。 For the Eth1 block, the Eth2 client immediately/at all times has access to the Eth1 state, trading and other bottom-eth1 structures in order to generate a valid block. On the contrary, the Eth2 client requests a viable Eth1 block data from the Eth1 engine (TX, status root, etc.). The Eth2 client then wraps the Eth1 data into a complete block (adds slot, poiter_index, poiter_signature, etc.) and broadcasts the block to the network. eth1引擎之所以能够生成有效/可行的eth1区块数据,是因为它采用了今天以太坊主网所使用的相同方式来管理eth1交易存储池,并且它通过eth2客户端的更新来维护eth1头状态的最新信息。 The Eth1 engine is able to generate valid/feasible Eth1 block data because it manages the Eth1 trading pool in the same way as is used today in the Taijin network, and it maintains up-to-date information on the Eth1 status through the update of the Eth2 client. 如果这一总体设计被大家认同,那接下来的步骤包括: If this general design is accepted, the next steps will include: 1. 确保有关eth2客户端驱动eth1引擎的假设与现有eth1软件一致,并且不会给现有eth1软件带来意外的负担; 1. To ensure that the assumptions regarding the Eth2 client-driven Eth1 engine are consistent with the existing Eth1 software and do not impose an unexpected burden on the existing Eth1 software; 2. 更明确地定义用于驱动eth1引擎的通信协议,例如new_head(block)、validate_block_transition(block)、get_proposal(parent_root)等; 2. A clearer definition of the communication protocols used to drive the Eth1 engine, such as new_head (block), valueate_block_translation(lock), Get_proposal(parent_rot) etc.; 3. 定义网络组件,例如需要eth1协议的哪一个子集,如何具体使用ENR; Definition of network components, e.g. which subset of the ENR is required for the Eth1 protocol and how ENR will be used; 4. 扩展以太坊2.0 阶段1 规范 Extension Ether 2.0 Phase 1 5. 原型! 5. Prototype!共识
状态
1、没有eth1引擎的eth2客户端
2、带无状态eth1引擎的eth2客户端
3、带有状态eth1引擎的eth2客户端
网络
ENR
Wire协议
1、eth2协议
2、eth1协议
3、为什么eth2客户端会处理eth1区块gossip ?
交易gossip和存储池mempool
区块生产
下一步该怎么走?
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论