Skip to content

Commit 5fb631e

Browse files
RazorClientraa-dev
authored andcommitted
cherry picking razorclient commit 2
-- Feat: Added recommendations
1 parent 7092f76 commit 5fb631e

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

docs/wiki/EL/devp2p.md

+48-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,29 @@ This section will cover the networking protocol used by the Execution Layer (EL)
44
First, we will provide some background on computer networks and then we will dive into the
55
specifics of the EL's networking protocol.
66

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

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

1031
## Core Components
1132

@@ -26,7 +47,7 @@ The pre-defined keys include:
2647

2748
| Key | Description |
2849
|:------------|:-----------------------------------------------------|
29-
| `id` | Identity scheme name (e.g., "v4") |
50+
| `id` | Identity scheme name (Default: "v4") |
3051
| `secp256k1` | Compressed secp256k1 public key (33 bytes) |
3152
| `ip` | IPv4 address (4 bytes) |
3253
| `tcp` | TCP port (big-endian integer) |
@@ -66,8 +87,8 @@ A structured, distributed system that allows Ethereum nodes to discover peers wi
6687
- The "v4" identity scheme is used to verify node authenticity.
6788
- Peers can request a node’s latest ENR via an **ENRRequest** packet.
6889

69-
- **Kademlia Table**
70-
- Nodes maintain a **routing table** with 256 **k-buckets** (each holding up to 16 entries).
90+
- **[Kademlia Table](https://en.wikipedia.org/wiki/Kademlia)**
91+
- 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).
7192
- A bucket stores nodes within a specific distance range (e.g., `[2^i, 2^(i+1))`).
7293
- Nodes are sorted by last-seen time, ensuring stale nodes are replaced when the table is full.
7394

@@ -94,17 +115,18 @@ A structured, distributed system that allows Ethereum nodes to discover peers wi
94115

95116
#### Discv5
96117

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

100122
- **Ethereum Node Records (ENR)**
101123
- Each node maintains an **Ethereum Node Record (ENR)**, storing **connectivity details, cryptographic keys, and metadata**.
102124
- ENRs are signed, self-contained, and update dynamically.
103125
- Peers can request the latest ENR using an **ENRRequest packet**.
104126

105127
- **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)).
108130
- Implements a **WHOAREYOU challenge-response mechanism** to prevent spoofing.
109131

110132
- **Kademlia-Based Routing & Node Table**
@@ -156,7 +178,7 @@ Inspired by the Kademlia DHT, discv5 differs by storing only signed node records
156178

157179
#### ECIES Encryption
158180

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**.
160182
- The cryptosystem consists of:
161183
- **Elliptic Curve**: secp256k1
162184
- **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
210232
| `aes-secret` | `keccak256(ephemeral-key || shared-secret)` |
211233
| `mac-secret` | `keccak256(ephemeral-key || aes-secret)` |
212234

235+
##### Static-Shared-Secret vs. Ephemeral-Key
236+
237+
###### Static-Shared-Secret
238+
239+
- 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
213250

214251

215252
#### Message Framing
@@ -287,3 +324,5 @@ Inspired by the Kademlia DHT, discv5 differs by storing only signed node records
287324
| **Ethereum Snapshot Protocol (`snap`)** | Used for **state synchronization**, allowing nodes to download portions of the state trie. |
288325
| **Light Ethereum Subprotocol (`les`)** | Supports **light clients**, enabling them to request data from full nodes without storing the full state. |
289326
| **Portal Network (`portal`)** | A decentralized **state, block, and transaction retrieval network** for lightweight clients. |
327+
328+

0 commit comments

Comments
 (0)