Networking Layer
Networking Layer
The two brains inside one Ethereum node
Every modern Ethereum node has two separate programs running:
1️⃣ Execution Client (EL)
π Think “WHAT happened?”
-
Handles:
-
Transactions
-
Smart contract execution
-
Account balances
-
EVM
-
-
Examples: Geth, Nethermind, Erigon
2️⃣ Consensus Client (CL)
π Think “DO we all agree this happened?”
-
Handles:
-
Blocks
-
Validators
-
Attestations
-
Finality (PoS logic)
-
-
Examples: Prysm, Lighthouse, Teku
π‘ These two must talk to each other, but they also talk to other nodes.
That’s why networking looks complex.
Why TWO P2P networks?
Because different data has different needs.
| Layer | What it gossips | Why |
|---|---|---|
| Execution P2P | Transactions | Need fast spread |
| Consensus P2P | Blocks, attestations | Need global agreement |
So Ethereum uses:
-
Execution-layer P2P network
-
Consensus-layer P2P network
Separate highways π§
Step 1: How a new node finds friends (Discovery)
Question:
How does a brand-new node find anyone at all?
Answer: Bootnodes + Discovery
Think like this:
-
You install Ethereum
-
You know nobody
-
Ethereum ships with a few phone numbers hardcoded → bootnodes
Discovery uses UDP (WHY?)
UDP = fast + cheap + no connection
Perfect for:
-
“Hey, I exist”
-
“Who else is here?”
❌ Not for real conversations
✅ Only for finding peers
Discovery flow (very important)
After this:
π “Okay, I know people now”
What is ENR (Ethereum Node Record)?
Think of ENR as a node’s visiting card:
-
Public key
-
IP address
-
Ports
-
Supported protocols
-
Consensus info (for CL)
Nodes exchange ENRs to know how to talk.
Step 2: Real conversations (DevP2P / libP2P)
Discovery only introduces people.
Now real talking starts.
Execution Layer networking (EL)
Stack:
Why TCP here?
Because now nodes:
-
exchange transactions
-
need reliability
-
need encryption
-
need session management
RLPx (secure channel)
RLPx does:
-
cryptographic handshake
-
key exchange
-
encrypted communication
Then nodes say “hello” π
Hello message includes:
-
client type
-
protocol version
-
supported sub-protocols
Only common protocols are used.
What does Execution layer gossip?
Only this now:
✅ Pending transactions
❌ Blocks (moved to consensus layer after PoS)
Consensus Layer networking (CL)
Consensus does NOT use DevP2P.
It uses:
Much more modern.
Why libP2P?
Because consensus needs:
-
high-speed gossip
-
topic-based messaging
-
better scalability
Used in:
-
IPFS
-
Filecoin
-
Ethereum consensus
Two communication styles in CL
1️⃣ Gossip (one → many)
Used for:
-
Beacon blocks
-
Attestations
-
Slashings
Fast spread π₯
2️⃣ Request–Response (one → one)
Used for:
-
“Give me block X”
-
“Give me blocks from slot A to B”
Precise data π―
Why SSZ instead of RLP?
Think performance.
SSZ:
-
Fixed offsets
-
Easy partial decoding
-
Built for Merkle trees
-
Unique encoding (no ambiguity)
Perfect for consensus + hashing.
Step 3: Execution ↔ Consensus communication (Engine API)
Now the most important mental model
Execution and Consensus are like two apps on the same machine talking via local RPC.
They do NOT gossip with each other over the internet.
When node is NOT block producer
Let’s walk slowly
1️⃣ Consensus client receives block (from gossip)
2️⃣ Checks:
-
sender valid?
-
metadata correct?
3️⃣ Sends block’s execution payload to execution client
4️⃣ Execution client:
-
runs transactions
-
checks state hashes
5️⃣ Says back:
-
“Yes valid” or “Invalid”
6️⃣ Consensus:
-
adds block
-
attests
-
gossips attestation
When node IS block producer (important)
1️⃣ Consensus client learns:
“You are the proposer”
2️⃣ Consensus → Execution:
“Create a block”
3️⃣ Execution client:
-
pulls transactions from mempool
-
executes them
-
builds execution payload
4️⃣ Consensus client:
-
wraps it into beacon block
5️⃣ Beacon block is gossiped
6️⃣ Other nodes validate → attest → finalize
Comments
Post a Comment