You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/wiki/EL/devp2p.md
+48-9
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,29 @@ This section will cover the networking protocol used by the Execution Layer (EL)
4
4
First, we will provide some background on computer networks and then we will dive into the
5
5
specifics of the EL's networking protocol.
6
6
7
+
## Peer To Peer(P2P) Communication
8
+
Peer-to-peer (P2P) communication is a decentralized networking model where participants, known as peers, communicate directly without relying on a central server. Unlike traditional client-server architectures, where a central authority controls data flow and coordination, P2P networks distribute tasks and responsibilities among all nodes.
7
9
8
-
[DevP2P](https://github.com/ethereum/devp2p) is a set of networking protocols that underpins Ethereum’s execution-layer peer-to-peer network. It was created before libp2p existed and designed specifically to serve Ethereum's early networking requirements.
10
+
P2P networks offer several advantages over centralized systems:
11
+
12
+
- Decentralization – No single point of failure, reducing the risk of outages or censorship.
13
+
- Scalability – The network can dynamically grow as more peers join.
14
+
- Fault Tolerance – Nodes can leave or fail without disrupting the entire network.
15
+
- Security & Privacy – Direct communication between peers reduces reliance on intermediaries,enhancing privacy and security.
16
+
17
+
P2P communication is the foundation of many distributed applications, enabling efficient data sharing, real-time coordination, and resilient connectivity in decentralized systems.
18
+
19
+
## Importance of P2P in Ethereum
20
+
21
+
Ethereum’s decentralized nature relies on a robust peer-to-peer (P2P) networking layer to ensure efficient transaction propagation, block distribution, and state synchronization among nodes.
22
+
**DevP2P** was specifically designed to meet Ethereum’s execution-layer networking requirements, defining protocols for node discovery, transport encryption, and capability negotiation. While **libp2p** is a more modular and general-purpose P2P framework used in other decentralized applications, devp2p remains tailored to Ethereum’s needs.
23
+
As noted in the devp2p documentation:
24
+
25
+
> _"It's hard to compare the two projects because they have different scope and are designed with different goals in mind. devp2p is an integrated system definition that wants to serve Ethereum's needs well (although it may be a good fit for other applications, too), while libp2p is a collection of programming library parts serving no single application in particular. That said, both projects are very similar in spirit and devp2p is slowly adopting parts of libp2p as they mature."_
26
+
27
+
# DevP2P
28
+
29
+
[DevP2P](https://github.com/ethereum/devp2p) is a set of networking protocols that underpins Ethereum’s execution-layer peer-to-peer network. It defines how Ethereum nodes discover peers, establish encrypted connections, and exchange blockchain data efficiently. Designed specifically to meet Ethereum’s networking needs, devp2p serves as an integrated system definition, ensuring optimized performance for Ethereum’s execution-layer communication.
- Nodes maintain a **routing table** with 256 **[k-buckets](https://en.wikipedia.org/wiki/Kademlia#Fixed-size_routing_tables)** (each holding up to 16 entries).
71
92
- A bucket stores nodes within a specific distance range (e.g., `[2^i, 2^(i+1))`).
72
93
- Nodes are sorted by last-seen time, ensuring stale nodes are replaced when the table is full.
73
94
@@ -94,17 +115,18 @@ A structured, distributed system that allows Ethereum nodes to discover peers wi
94
115
95
116
#### Discv5
96
117
97
-
discv5 enables nodes to find and connect with peers without relying on centralized directories.
98
-
Inspired by the Kademlia DHT, discv5 differs by storing only signed node records (ENR) instead of arbitrary key-value pairs. This ensures authenticity and integrity in peer discovery.
118
+
Discv5 is Ethereum’s improved decentralized peer discovery protocol, building upon the foundation of Discv4 with enhanced service discovery and security mechanisms. Like its predecessor, Discv5 enables nodes to locate and connect with peers in a decentralized manner, without relying on centralized directories. However, it introduces encrypted communication, service discovery, and adaptive routing.
119
+
120
+
Inspired by the Kademlia DHT, discv5 differs by storing only signed node records (ENR) instead of arbitrary key-value pairs. This ensures authenticity and integrity in peer discovery.This ensures authenticity and integrity in peer discovery while maintaining flexibility for protocol extensions.
99
121
100
122
-**Ethereum Node Records (ENR)**
101
123
- Each node maintains an **Ethereum Node Record (ENR)**, storing **connectivity details, cryptographic keys, and metadata**.
102
124
- ENRs are signed, self-contained, and update dynamically.
103
125
- Peers can request the latest ENR using an **ENRRequest packet**.
104
126
105
127
-**Encrypted Wire Protocol**
106
-
- Uses **AES-GCM encryption** for confidentiality and authenticity.
107
-
- Establishes **session keys via ECDH** (Elliptic Curve Diffie-Hellman).
128
+
- Uses **[AES-GCM encryption](https://en.wikipedia.org/wiki/AES-GCM-SIV)** for confidentiality and authenticity.
129
+
- Establishes **session keys via ECDH** ([Elliptic Curve Diffie-Hellman](https://en.wikipedia.org/wiki/Elliptic-curve_Diffie%E2%80%93Hellman)).
108
130
- Implements a **WHOAREYOU challenge-response mechanism** to prevent spoofing.
109
131
110
132
-**Kademlia-Based Routing & Node Table**
@@ -156,7 +178,7 @@ Inspired by the Kademlia DHT, discv5 differs by storing only signed node records
156
178
157
179
#### ECIES Encryption
158
180
159
-
- RLPx uses **Elliptic Curve Integrated Encryption Scheme (ECIES)** for secure **handshaking and session establishment**.
181
+
- RLPx uses **Elliptic Curve Integrated Encryption Scheme ([ECIES](https://cryptobook.nakov.com/asymmetric-key-ciphers/ecies-public-key-encryption))** for secure **handshaking and session establishment**.
160
182
- The cryptosystem consists of:
161
183
-**Elliptic Curve**: secp256k1
162
184
-**Key Derivation Function (KDF)**: NIST SP 800-56 Concatenation KDF
@@ -210,6 +232,21 @@ Inspired by the Kademlia DHT, discv5 differs by storing only signed node records
- Derived using Elliptic Curve Diffie-Hellman (ECDH) between a node’s long-term (static) private key and the peer’s long-term public key.
240
+
- Remains unchanged across multiple sessions with the same peer.
241
+
242
+
If an attacker compromises a node’s private key, past and future communications with that peer can be decrypted, making it vulnerable to long-term key exposure.
243
+
244
+
###### Ephemeral-Key (Forward Secrecy)
245
+
246
+
- A temporary keypair generated for each handshake, used to derive a fresh session secret.
247
+
- Computed using ECDH between ephemeral private keys exchanged during the handshake.
248
+
249
+
Since ephemeral keys are discarded after a session ends, even if an attacker later obtains a node’s long-term private key, past communications remain secure. This property is known as forward secrecy
213
250
214
251
215
252
#### Message Framing
@@ -287,3 +324,5 @@ Inspired by the Kademlia DHT, discv5 differs by storing only signed node records
287
324
|**Ethereum Snapshot Protocol (`snap`)**| Used for **state synchronization**, allowing nodes to download portions of the state trie. |
288
325
|**Light Ethereum Subprotocol (`les`)**| Supports **light clients**, enabling them to request data from full nodes without storing the full state. |
289
326
|**Portal Network (`portal`)**| A decentralized **state, block, and transaction retrieval network** for lightweight clients. |
0 commit comments