|
1 |
| -//// |
2 |
| -Source: |
3 |
| -https://github.com/ethereum/devp2p/blob/master/rlpx.md#node-discovery |
4 |
| -https://github.com/ethereum/wiki/wiki/%C3%90%CE%9EVp2p-Wire-Protocol |
5 |
| -https://github.com/ethereum/wiki/wiki/Ethereum-Wire-Protocol |
6 |
| -https://github.com/ethereum/wiki/wiki/Adaptive-Message-IDs |
7 |
| -License: Not defined yet |
8 |
| -Added By: @fjrojasgarcia |
9 |
| -//// |
| 1 | +<<第十六章#,上一章:Vyper:面向合约的编程语言>> |
10 | 2 |
|
11 | 3 | [[communications_between_nodes]]
|
12 |
| -== Communications between nodes - A simplified vision |
| 4 | +== 节点间的通信 —— 一个简单的视角 |
13 | 5 |
|
14 |
| -Ethereum nodes communicate among themselves using a simple wire protocol forming a virtual or overlay _well-formed network_. |
15 |
| -To achieve this goal, this protocol called *ÐΞVp2p*, uses technologies and standards such as *RLP*. |
| 6 | +以太坊节点之间通过简单的线路协议进行通信,形成一个虚拟或覆盖良好的网络 |
| 7 | +为实现这一目标,该协议称为*ÐΞVp2p*,使用*RLP*等技术和标准。 |
16 | 8 |
|
17 | 9 | [[transport_protocol]]
|
18 |
| -=== Transport protocol |
19 |
| -In order to provide confidentiality and protect against network disruption, *ÐΞVp2p* nodes use *RLPx* messages, an encrypted and authenticated _transport protocol_. |
20 |
| -*RLPx* utilizes a routing algorithm similar to *Kademlia*, which is a distributed hash table (*DHT*) for decentralized peer-to-peer computer networks. |
| 10 | +=== 传输协议 |
21 | 11 |
|
22 |
| -*RLPx*, as an underlying transport protocol, allows among other, _"Node Discovery and Network Formation"_. |
23 |
| -Another remarkable feature of *RLPx* is the support of _multiple protocols_ over a single connection. |
| 12 | +为了提供机密性并防止网络中断,*ÐΞVp2p*节点使用*RLPx*消息,一种加密且经过身份验证的_transport协议。 |
| 13 | +*RLPx*使用类似于*Kademlia*的路由算法,*Kademlia*是用于分散的对等计算机网络的分布式哈希表(* DHT *)。 |
| 14 | +*RLPx*,作为底层传输协议,允许_“节点发现和网络形成”_。 |
| 15 | +*RLPx*的另一个显著特征是通过单个连接支持_多个协议_。 |
24 | 16 |
|
25 |
| -When *ÐΞVp2p* nodes communicate via Internet (as they usually do), they use TCP, which provides a connection-oriented medium, but actually *ÐΞVp2p* nodes communicate in terms of packets, using the so-called facilities (or messages) provided by the underlying transport protocol *RLPx*, allowing them to communicate sending and receiving packets. |
| 17 | +当*ÐΞVp2p*节点通过Internet进行通信时(通常情况下),它们使用TCP,它提供面向连接的介质,但实际上*ÐΞVp2p*节点通过使用底层传输协议*RLPx*所提供的所谓设施(或消息),以数据包通信,允许它们通信发送和接收数据包。 |
26 | 18 |
|
27 |
| -Packets are _dynamically framed_, prefixed with an _RLP_ encoded header, encrypted and authenticated. Multiplexing is achieved via the frame header which specifies the destination protocol of a packet. |
| 19 | +数据包是 _动态构建_ _dynamicically framed_,前缀为_RLP_编码标头,经过加密和验证。通过帧头实现多路复用,帧头指定分组的目的协议。 |
28 | 20 |
|
29 |
| -==== Encrypted Handshake |
30 |
| -Connections are established via a handshake and, once established, packets are encrypted and encapsulated as frames. |
| 21 | +==== 加密握手 |
31 | 22 |
|
32 |
| -This handshake will be carried out in two phases, the first phase involves the keys exchange and the second phase will perform authentication, and as a part of *DEVp2p*, will also exchange the capabilities of each node. |
| 23 | +通过握手建立连接,并且一旦建立,就将数据包加密并封装为帧。 |
33 | 24 |
|
34 |
| -==== Security - Basic considerations |
| 25 | +此握手将分两个阶段进行,第一阶段涉及密钥交换,第二阶段将执行身份验证,作为*DEVp2p*的一部分,还将交换每个节点的功能。 |
35 | 26 |
|
36 |
| -All cryptographic operations are based on *secp256k1* and each node is expected to maintain a static private key which is saved and restored between sessions. |
| 27 | +==== 安全 - 基本考虑因素 |
37 | 28 |
|
38 |
| -Until encryption is implemented, packets have a timestamp property to reduce the window of time for carrying out replay attacks. |
39 |
| -It is recommended that the receiver only accepts packets created within the last 3 seconds. |
| 29 | +所有加密操作都基于*secp256k1*,并且每个节点都应该维护一个静态私钥,该私钥在会话之间保存和恢复。 |
40 | 30 |
|
41 |
| -Packets are signed. Verification is performed by recovering the public key from the signature and checking that it matches an expected value. |
| 31 | +在实施加密之前,数据包具有时间戳属性,以减少执行重放攻击的时间窗口。 |
| 32 | +建议接收方只接受最近3秒内创建的数据包。 |
| 33 | + |
| 34 | +数据包被签名。通过从签名中恢复公钥并检查它是否与预期值匹配来执行验证。 |
42 | 35 |
|
43 | 36 | [[devp2p_messages_subprotocols]]
|
44 |
| -=== ÐΞVp2p messages and Sub-protocols |
45 |
| -With *RLP* we can encode different types of payloads, whose types are determined by the integer value used in the first entry of the RLP. |
46 |
| -In this way, *ÐΞVp2p*, the _basic wire protocol_, support _arbitrary sub-protocols_. |
| 37 | +=== ÐΞVp2p 消息和子协议 |
| 38 | +使用*RLP*,我们可以编码不同类型的数据,其类型由RLP的第一个条目中使用的整数值确定。 |
| 39 | +这样,*ÐΞVp2p*,_基础线路协议_ _basic wire protocol_,支持_任意的子协议_。 |
| 40 | + |
| 41 | +`0x00-0x10`之间的_Message IDs_保留用于*ÐΞVp2p*消息。因此,假定_sub-protocols_的消息ID从“0x10”开始。 |
47 | 42 |
|
48 |
| -_Message IDs_ between `0x00-0x10` are reserved for *ÐΞVp2p* messages. Therefore, the message IDs of _sub-protocols_ are assumed to be from `0x10` onwards. |
| 43 | +未在对等节点之间共享的子协议是_忽略的_。 |
| 44 | +如果共享相同(同名)子协议的多个版本,则数字最高的胜出。 |
49 | 45 |
|
50 |
| -Sub-protocols that are not shared between peers are _ignored_. |
51 |
| -If multiple versions of the same (equal name) sub-protocol are shared, _the numerically highest wins_. |
| 46 | +==== 基本建立通信 - 基本ÐΞVp2p消息 |
52 | 47 |
|
53 |
| -==== Basic establishment of communication - Basic ÐΞVp2p message |
| 48 | +作为一个非常基本的例子,当两个对等节点发起他们的通信时,每个对等节点用另一个称为*“Hello”*的特殊*ÐΞVp2p*消息来迎接另一个,该消息由“0x00”消息ID标识。 |
| 49 | +通过这个特定的*ÐΞVp2p* *“Hello”*消息,每个节点将向其对等的相关数据公开,从而允许通信以非常基本的级别开始。 |
54 | 50 |
|
55 |
| -As a very basic example, when two peers initiate their communication, each one greets the other with a special *ÐΞVp2p* message called *"Hello"*, which is identified by the `0x00` message ID. |
56 |
| -Through this particular *ÐΞVp2p* *"Hello"* message, each node will disclose to its peer relevant data that will allow the communication to begin at a very basic level. |
| 51 | +在此步骤中,每个对等方将知道有关其对等方的以下信息。 |
57 | 52 |
|
58 |
| -In this step, each peer will know the following information about his peer. |
| 53 | +- P2P协议的实现*版本*。现在必须是'1`。 |
| 54 | +- *客户端软件标识*,作为人类可读的字符串(例如`Ethereum(++)/ 1.0.0`)。 |
| 55 | +- 对等节点的*capability name*为长度为3的ASCII字符串。当前支持的能力名称为“eth”和“shh”。 |
| 56 | +- 对等节点的*capability version*为正整数。目前支持的版本是`eth`为`34`,`shh`为`1`。 |
| 57 | +- 客户端正在侦听的*端口*。如果为“0”则表示客户端没有收听。 |
| 58 | +- *节点的唯一标识*指定为512位散列。 |
59 | 59 |
|
60 |
| -- The implemented *version* of the P2P protocol. Now must be `1`. |
61 |
| -- The *client software identity*, as a human-readable string (e.g. `Ethereum(++)/1.0.0`). |
62 |
| -- Peer *capability name* as an ASCII string of length 3. Currently supported capability names are `eth` and `shh`. |
63 |
| -- Peer *capability version* as a positive integer. Currently supported versions are `34` for `eth`, and `1` for `shh`. |
64 |
| -- The *port* that the client is listening on. If `0` it indicates the client is not listening. |
65 |
| -- The *Unique Identity of the node* specified as a 512-bit hash. |
| 60 | +==== 断开连接 - 基本ÐΞVp2p消息 |
| 61 | +要执行有序的断开连接,要断开连接的节点将发送名为*“Disconnect”*的*ÐΞVp2p*消息,该消息由_“0x01”_消息ID标识。此外,节点使用参数*“reason”*指定断开的原因。 |
66 | 62 |
|
67 |
| -==== Disconnection - Basic ÐΞVp2p message |
68 |
| -To carry out an ordered disconnection, the node that wants to disconnect, will send a *ÐΞVp2p* message called *"Disconnect"*, which is identified by the _"0x01"_ message id. Furthermore, the node specifies the reason for the disconnection using the parameter *"reason"*. |
| 63 | +* “reason”*参数可以取值从“0x00”到“0x10”,例如“0x00”表示原因*“请求断开连接”*和“0x04”表示*“太多对等节点”*。 |
69 | 64 |
|
70 |
| -The *"reason"* parameter can take values from `0x00` to `0x10`, e.g. `0x00` represents the reason *"Disconnect requested"* and `0x04` represents *"Too many peers"*. |
| 65 | +==== 状态 - 以太坊子协议示例 |
71 | 66 |
|
72 |
| -==== Status - Ethereum sub-protocol example |
73 |
| -This sub-protocol is identified by the `+0x00` message-id. |
| 67 | +该子协议由`+0x00`消息-id标识。 |
74 | 68 |
|
75 |
| -This message should be sent after the initial handshake and prior to any Ethereum related messages and inform of its current state. |
| 69 | +此消息应在初始握手之后和任何与以太坊相关的消息之前发送,并通知其当前状态。 |
76 | 70 |
|
77 |
| -To do this, the node disclose to its peer the following data; |
| 71 | +为此,节点向其对等方公开以下数据; |
78 | 72 |
|
79 |
| -- The *Protocol version*. |
80 |
| -- The *Network Id*. |
81 |
| -- The *Total Difficulty of the best chain*. |
82 |
| -- The *Hash of the best known block*. |
83 |
| -- The *Hash of the Genesis block*. |
| 73 | +- *Protocol version* |
| 74 | +- *Network Id* |
| 75 | +- *Total Difficulty of the best chain* |
| 76 | +- *Hash of the best known block* |
| 77 | +- *Hash of the Genesis block* |
84 | 78 |
|
85 | 79 | [[known_current_networks]]
|
86 |
| -===== Known current network Ids |
87 |
| -About networks ids here is a list of those currently known; |
88 |
| - |
89 |
| -- 0: *Olympic*; Ethereum public pre-release testnet |
90 |
| -- 1: *Frontier*; Homestead, Metropolis, the Ethereum public main network |
91 |
| -- 1: *Classic*; The (un)forked public Ethereum Classic main network, chain ID 61 |
92 |
| -- 1: *Expanse*; An alternative Ethereum implementation, chain ID 2 |
93 |
| -- 2: *Morden*; The public Ethereum testnet, now Ethereum Classic testnet |
94 |
| -- 3: *Ropsten*; The public cross-client Ethereum testnet |
95 |
| -- 4: *Rinkeby*: The public Geth Ethereum testnet |
96 |
| -- 42: *Kovan*; The public Parity Ethereum testnet |
97 |
| -- 77: *Sokol*; The public POA testnet |
98 |
| -- 99: *POA*; The public Proof of Authority Ethereum network |
99 |
| -- 7762959: *Musicoin*; The music blockchain |
100 |
| - |
101 |
| -==== GetBlocks - Another sub-protocol example |
102 |
| -This sub-protocol is identified by the `+0x05` message-id. |
103 |
| - |
104 |
| -With this message the node requests its peer the specified blocks each by its own hash. |
105 |
| - |
106 |
| -The way to request the nodes is through a list with all the hashes of them, taking the message the following form; |
| 80 | +===== 已知的当前网络ID |
| 81 | +这里是目前已知的网络ID列表: |
| 82 | + |
| 83 | +- 0: *Olympic*; 以太坊公共预发布测试网 |
| 84 | +- 1: *Frontier*; Homestead,Metropolis,以太坊公共主网 |
| 85 | +- 1: *Classic*; (un)forked 公共以太坊Classic主网络,链ID 61 |
| 86 | +- 1: *Expanse*; 另一个以太坊实现,链ID 2 |
| 87 | +- 2: *Morden*; 公共以太坊测试网,现在是以太坊经典测试网 |
| 88 | +- 3: *Ropsten*; 公共跨客户端以太坊测试网 |
| 89 | +- 4: *Rinkeby*: 公共Geth以太坊测试网 |
| 90 | +- 42: *Kovan*; 公共Parity以太坊测试网 |
| 91 | +- 77: *Sokol*; 公共POA测试网 |
| 92 | +- 99: *POA*; 公共权威证明(PoA)以太网网络 |
| 93 | +- 7762959: *Musicoin*; 音乐区块链 |
| 94 | + |
| 95 | +==== GetBlocks - 另一个子协议示例 |
| 96 | +该子协议由`+ 0x05` message-id标识。 |
| 97 | + |
| 98 | +通过此消息,节点通过其自己的哈希向其对等方请求指定的块。 |
| 99 | + |
| 100 | +请求节点的方式是通过包含它们所有哈希值的列表,将消息采用以下形式; |
| 101 | + |
107 | 102 | ....
|
108 | 103 | [+0x05: P, hash_0: B_32, hash_1: B_32, ...]
|
109 | 104 | ....
|
110 | 105 |
|
111 |
| -The requesting node must not have a response message containing all the requested blocks, in which case it must request again those that have not been sent by its peer. |
| 106 | +请求节点必须没有包含所有请求的块的响应消息,在这种情况下,它必须再次请求那些尚未由其对等方发送的消息。 |
| 107 | + |
| 108 | +=== 节点标识和声誉 |
| 109 | +*ÐΞVp2p*节点的标识是*secp256k1*公钥。 |
| 110 | + |
| 111 | +客户端可以自由标记新节点并使用节点ID作为_决定节点的信誉_的方法。 |
112 | 112 |
|
113 |
| -=== Node identity and reputation |
114 |
| -The identity of a *ÐΞVp2p* node is a *secp256k1* public key. |
| 113 | +他们可以存储给定ID的评级并相应地给予优先权。 |
115 | 114 |
|
116 |
| -Clients are free to mark down new nodes and use the node ID as a means of _determining a node's reputation_. |
| 115 | +<<第十八章#,下一章:以太坊标准>> |
117 | 116 |
|
118 |
| -They can store ratings for given IDs and give preference accordingly. |
| 117 | +image::images/thanks.jpeg["赞赏译者",height=400,align="center"] |
0 commit comments