Skip to content

P2P ​

This page describes the current version

The network code and its limits can change between v0.x versions.

With --p2p, Cinder joins the Ethereum mainnet network. The node uses the network for three tasks:

  • It downloads the blocks that it needs to reach the head of the consensus client.
  • It serves headers, bodies, receipts and pooled transactions to other nodes.
  • It receives transactions, checks them and relays them.

Cinder implements devp2p in C: discv4, RLPx, the p2p protocol and the eth protocol, versions 68 and 69. It does not implement discv5 or the snap protocol yet. For the flags, read Configuring.

Discovery ​

Cinder finds peers with node discovery v4 (discv4). It signs each UDP packet with its node key. It uses the Ping, Pong, FindNode, Neighbors, ENRRequest and ENRResponse packets.

  • The node key. The node keeps its secp256k1 key in the file nodekey in the database directory. So the enode of the node stays the same after a restart. The node prints its enode when it starts, with <this host> in place of the IP address.
  • DNS node list. The node reads the mainnet node list in DNS (EIP-1459, the enrtree:// list for mainnet, as reth does). It reads the list at most once every 30 minutes and takes up to 1 000 nodes each time. Before this list (#56), a crawl from the bootnodes alone found only 3 to 7 nodes. The node does not use a DNS answer that is longer than 4 096 bytes or that has the truncation flag.
  • Node file. The node keeps the nodes that it knows in the file p2p-nodes in the database directory. After a restart, it uses them as crawl seeds, together with the bootnodes.
  • Crawl. When the node has no more peer candidates, a discovery thread starts a crawl at a random known node. For up to 4 seconds (15 seconds when the node has fewer than 4 peers) it bonds with nodes and asks them for their neighbours. It does this at most once every 30 seconds. A crawl gives up to 4 096 dial candidates: the nodes that answered first, then the nodes from DNS, then the good peers of before. The crawl accepts a Pong only when it quotes a Ping that the crawl sent to that IP address and UDP port. It accepts Neighbors only from a node that it sent FindNode to in the last 20 seconds, with at most 16 nodes for each FindNode, as reth.
  • Fork filter. The node asks each bonded node for its node record (ENR, EIP-868). The records in the DNS list have this data too. The eth entry of a record has the fork ID of the node. The node dials only nodes with a fork ID that agrees with its own (EIP-2124 rules). It dials nodes without an eth entry last. About half of the nodes that a crawl finds are on other chains: in a test crawl on 2026-10-13, 1 480 of 4 096 nodes were on our fork and 2 153 on another (the rest had no eth entry or did not answer).
  • Answers. On its UDP port, the node answers Ping with Pong. It answers FindNode with up to 12 of the nodes that it knows, but only to a node with an endpoint proof: that node answered a Ping of Cinder with a valid Pong from the same IP address and UDP port in the last 12 hours, as the discv4 spec says. When a node without this proof sends Ping, Cinder sends Pong and a Ping of its own (at most 10 such Pings a second). The node ignores a packet whose expiration time is in the past. One IP address can send 60 packets a minute, as in reth. It does not answer ENRRequest yet, and it does not publish a node record with an eth entry (#61). Some clients dial only nodes whose record has a matching eth entry, so fewer nodes dial Cinder.
  • Fixed peers. With --peer ENODE, the dialer connects only to the given nodes. Discovery still runs, but the node does not dial the nodes that it finds.
  • Address and port. Discovery uses IPv4 only. If the UDP port is in use, discovery uses a random port.

RLPx and the handshake ​

A connection to a peer uses RLPx. The node does these steps:

  1. Handshake. The ECIES handshake in the EIP-8 format. The node also accepts the older format. AES-NI hardware does the encryption.
  2. Hello. The node offers eth/68 and eth/69 and uses the highest version that both sides have. After a Hello of version 5 or later, all messages use Snappy compression.
  3. Status. The node sends its Status and reads the Status of the peer. It checks the network ID and the genesis hash. Of the EIP-2124 fork ID, it compares only the 4-byte fork hash. The node drops a peer with a different fork hash. This check is simpler than the EIP-2124 rules of the fork filter in discovery. #61 makes the two checks the same.

The Status exchange has a limit of 10 seconds. At most 16 other messages can come before the Status of the peer.

The Status of the node announces the chain head. For eth/68, the Status has the total difficulty at The Merge. For eth/69, it has the range of blocks for which the node has history. The range starts at the block where the node started to keep bodies.

32 dialer threads do handshakes in parallel over IPv4, because most nodes are full or cannot be reached. Together they start at most 50 new dials each second. With --peer, one dialer thread does this work. The default limits are the limits of reth: 100 outbound peers (--p2p-peers) and 30 inbound peers (--p2p-inbound). The node keeps at most 160 peers in total. For the flags and their defaults, read Configuring.

Time and size limits for peers ​

For a connected peer, each message that the node sends must go out in 20 seconds.

The fetcher requests headers and bodies from one peer at a time (#355):

  • While the fetcher waits for an answer, the node reads all peers, with the limits below. Thus the other peers get their answers, for example to a Ping. In each pass, the node reads the requested peer first.
  • The answer must come in 10 seconds. A read that started can continue for 2 seconds more. Else the node drops the peer and sends the request to another peer. reth changes its request time limit between 2 and 20 seconds.
  • When the frame header of the answer is there, the rest of the answer must come at 256 KiB each second or faster. reth has no such rate.
  • An answer can have at most 10 MiB, as the message limit of reth.
  • When the node keeps a peer after a request without an answer, it reads the late answer and ignores it, as reth does.

0.9.6 and earlier waited up to 20 seconds for an answer and read only the requested peer in that time. The other peers got no answers, and peers that wait 15 seconds for a Pong could disconnect.

One thread reads the requests, announcements and transactions of all peers (#342):

  • The thread starts to read a message only when its full frame header (32 bytes) is there. The node drops a peer whose frame header is not complete in 1 second.
  • The rest of the message must come in 250 ms plus the time for its size at 256 KiB each second. A message can have at most 2.5 MiB. The node drops a peer that sends slower than this or sends a larger message.
  • The thread reads from each peer for at most 50 ms in each pass (at least one message), and then reads from the other peers. The first peer of a pass changes each time. If the messages of a peer took more than 50 ms in one pass, the next pass reads that peer last.

0.9.6 and earlier read each message with a limit of 5 seconds and continued to read from the same peer while it had more data.

Dial order and backoff ​

After a dial fails, the node does not dial that node again for some time. The time depends on the cause:

CauseTime
The node is unreachable, or the connection fails1 hour
Too many peers, before the handshake or right after it10 minutes
A different network or fork24 hours
A different error30 minutes

A successful dial removes the backoff. A peer that completes the handshake and then sends a header or a block to the node is a good peer. The node dials good peers first, the most recent first. The file p2p-nodes keeps the backoffs and the good peers, so they stay after a restart. After a restart, the node dials the good peers of the file before its first crawl. A file of an older version loads without them.

A peer that has neither the wanted head nor the next block of the chain of that head for 20 rounds in a row is behind the chain. The node drops it and does not dial it again for 10 minutes. Its slot goes to a better peer.

Each minute, the node writes a summary line to its log. The line gives the peers, the dials by result, the nodes in backoff by cause, the candidates that the node did not dial because of a backoff, and the number of good nodes.

Inbound peers ​

The node listens for TCP connections on its P2P port. The listener accepts IPv6 and IPv4. Discovery uses the same port number over UDP. The node does the handshake as the recipient and then the same Hello and Status steps.

Slow inbound connections do not stop the node from accepting other inbound peers (#312):

  • The listener reads the first handshake message (auth) of up to 64 connections at the same time, with a limit of 5 seconds for each. When there are 64, the oldest one closes.
  • 8 threads do the rest of the handshakes. When all 8 are busy, the thread that has had its connection for the longest time closes it.
  • Each address (for IPv6, each /64 network) can have 2 connections in each of these steps.
  • As in reth, an address that is not loopback or private can open one new connection in 30 seconds. A full inbound handshake (auth, Hello and Status) must end in 20 seconds.
  • The node refuses an inbound peer that it banned.

A correct handshake ends in less than a second. 0.9.6 and earlier did all inbound handshakes on one thread, one at a time.

Open the P2P port for TCP and UDP in the firewall, and forward it on the router if the node is behind NAT. Without inbound peers, the node has only the outbound peers that it dials, and on mainnet most nodes are full. With few peers, a new node can take a long time to fetch blocks (#57). If the node has no peers, read Troubleshooting.

What the node fetches ​

Cinder starts from a database that it imported from reth. When the consensus client names a head that the node does not have, the forkchoice update returns SYNCING. The node remembers that head as the wanted head. Then it downloads the missing blocks. This is the backfill.

The fetcher ​

A fetcher thread does the network work:

  1. It asks a peer for the block number of the wanted head. If the peer does not have the block, the fetcher tries the next peer.
  2. It gets the headers down from the wanted head by their hashes. This hash chain is the chain of the head from the consensus client. It holds at most 2^20 blocks (about 145 days of blocks).
  3. It requests the headers after the head of the node, 64 headers for each request. It uses the peers in turn.
  4. It checks that each header links to the one before it. The first header must link to the head of the node. It imports only a block that has the hash of the hash chain at its number.
  5. It requests the bodies and checks each body against its header: the transactions root, the withdrawals root and the ommers hash. The transaction list must also have the form that the block decode accepts (#391). A body with a transaction type that this version does not know is not a bad body, because a later fork can add such a type (#392). When the roots of the header match, the node logs transaction type N that this version does not know (0 or above 4) at block #M, stops the download before that block and keeps the peer. The stop ends when the wanted chain has another block at that number.
  6. It puts the checked blocks in a queue of up to 512 blocks.

The checks in steps 4 and 5 make sure that a peer can delay the node but cannot make a valid block look invalid, and cannot give a block of another chain. The signal that makes the catch-up go back to an older block also comes from the hash chain, not from a peer. The fetcher drops a peer that fails a request. A peer that gives no block of the hash chain in 20 rounds in a row goes off the peer list for 10 minutes (read Dial order and backoff). A block from the peer sets the count to zero again.

While no peer has a new head of the consensus client, the catch-up continues on the hash chain of the previous head. If the consensus client left that chain, its blocks can be the head of the node for a short time.

A node that is more than about 145 days behind does not catch up over P2P. For such a node, use --backfill-rpc (below) or a new database. The node uses the hash chain from 0.9.7.

Import between requests ​

The engine loop takes blocks from the queue between Engine API requests. In each round, it first serves the requests that are ready. Then it imports up to 8 blocks. A request that arrives during the import waits until the import is complete. For each block it does the same steps as for engine_newPayload, then makes the block the head. When the node reaches the wanted head, the forkchoice update returns VALID and the backfill stops.

If a block is not valid, or an engine error occurs, the node logs the block and pauses the backfill for 10 seconds.

This version does not implement the Amsterdam fork. With --amsterdam-time, the catch-up imports the blocks before the first Amsterdam block, keeps its peers and stops. The --backfill-rpc catch-up also stops at that block. For the option, read Unsupported forks.

After a restart, the node can answer SYNCING for some minutes. Read SYNCING for a long time after a restart.

Backfill from a node instead of the network ​

With --backfill-rpc URL, the node downloads the missing blocks from another node over JSON-RPC (debug_getRawBlock) instead of from peers. It imports up to 4 blocks in each round. Use --p2p or --backfill-rpc, not both. When you give both flags, the node uses the network.

The node checks the body of each block against its header before it executes the block: no ommers, the transactions root and the withdrawals root. The node accepts an answer of at most 256 MiB from that node (#316). The status of a body that does not agree is INVALID (block body does not match its header), and the node keeps no verdict for the block hash. Read block body does not match its header.

What the node serves ​

The node answers these requests from its database:

RequestAnswer
GetBlockHeadersCanonical headers by number or hash, with skip and reverse. An unknown block ends the list.
GetBlockBodiesThe bodies. The node skips an unknown block.
GetReceiptsFor eth/68 the consensus encodings. For eth/69 the list of type, status, cumulative gas and logs.
GetPooledTransactionsThe admitted transactions of the pool, up to 2 MB.

An answer from the database stops at 1 024 items or about 2 MB. The node keeps bodies and receipts only from the block where it started, so it cannot serve older blocks. If the database has no history tables, the answers are empty. The node does not answer other requests.

The transaction pool ​

The pool keeps the transactions that the node saw on the network or received from eth_sendRawTransaction (local transactions). It uses the limits and rules of the pool of reth (#313, #325, #338):

  • Pending part. At most 65 536 entries: the admitted transactions that can go into the next block, the transactions that a reorg put back, and the sidecars of mined blob transactions. A transaction is pending only when the transactions of its sender before it are in the pool or in a block, and when their costs and its cost together fit the balance of the sender.
  • Queued part. The other admitted transactions, for example a transaction with a nonce gap: at most 10 000 transactions and 20 MiB. When this part is full, the oldest transaction leaves first, also a local one.
  • Each sender. At most 16 transactions, pending and queued. A transaction with the nonce of the account always goes in. Local transactions have no limit for each sender.
  • A full pending part. First, the sidecars of mined blob transactions leave. Then the pool removes the transactions with a fee cap below the base fee of the next block, also local ones. Then the transactions that a reorg put back and that are not checked yet leave. Then the pool removes the transaction with the lowest tip at that base fee. It removes only the last transaction of a sender, and a local transaction only when the pending part has no other transaction to remove. A new transaction with a tip at or below the lowest tip does not go in. eth_sendRawTransaction then gives the error -32003 txpool is full, as reth.
  • Not checked yet. Transactions from peers wait for the checks in a queue of at most 4 096 transactions and 64 MiB. A new one pushes out the oldest unchecked one.
  • Announced hashes. At most 25 600 hashes. A new one pushes out the oldest hash.
  • Mined blob transactions. The pool keeps the sidecars of at most 4 096 mined blob transactions. The oldest leaves first.

Transactions and hashes from peers never push an admitted or a local transaction out of the pool. 0.9.6 and earlier kept the newest 65 536 entries of all kinds, and the oldest entry left first.

Transactions from peers ​

Peers send full transactions (Transactions, PooledTransactions) and announce hashes (NewPooledTransactionHashes). The node asks for the transactions of the hashes that it does not know. It looks at the first 4 096 hashes of an announcement and asks for at most 256 unknown hashes of it. The other hashes stay unknown, so that a different announcement can ask for them. One GetPooledTransactions request asks for at most 128 KiB of announced size, as in reth.

A transaction from a peer goes into the pool at once, without checks. So the mempool prewarm can use it at once (see below). A validation thread then checks it:

  • It uses the admission checks of reth, in the order of reth. First the stateless checks: decoding and signature, size and initcode limits, the block gas limit, fees, chain ID, intrinsic gas, the blob count and the EIP-7825 gas limit. Then the account of the sender at the chain head, blocks that are not written yet included: code, nonce and balance. The blob sidecar check is the last check.
  • After a switch to a branch below the database head, the writer can take time to write the new branch. During that time, the checks read the new branch: the undo records of the database blocks above the fork base, then the blocks of the new branch, as JSON-RPC does (#185). The state and the new branch come from one read transaction, so both reads see the same database snapshot and use one reader slot (#278). In 0.9.6 and earlier, a commit of the writer between two separate opens stopped the round. Thus the node checks a transaction that a reorg put back on the new branch, also before the write. If the node cannot read the undo records, the checks wait at most 2 seconds and then run on the database head. The nonce of a reorged-out transaction is spent there. Thus on the database head, "nonce too low" does not remove a transaction: the node keeps it unchecked in the pool. An internal counter (stale_kept) counts these transactions. The 60-second txpool log line shows it as "kept unchecked N" (#281). 0.9.6 and earlier did not show this counter. When the writer wrote the new branch, the node checks the kept transactions again on that branch (#277). It admits a transaction that is valid there and serves it. A transaction that is not valid there leaves the pool. The node keeps at most 4096 such transactions. After that, "nonce too low" on the database head removes the transaction. Up to 0.9.5 (fixed in 0.9.6), the checks waited 2 seconds and then ran on the database head. They removed the reorged-out transactions, with their blob sidecars.
  • After a switch to a written ancestor of the database head, the checks read that ancestor at once (#162). Up to 0.9.5 (fixed in 0.9.6), they waited 2 seconds and then ran on the database head.
  • The checks take the transactions in the order in which they became unchecked. Up to 0.9.5 (fixed in 0.9.6), a batch could move past some transactions, and the node then did not check them (#277).
  • It applies the pool rules of reth. A transaction from the same sender with the same nonce replaces the old one only if both fees rise by 10% (100% for blob transactions). The fee must be at least the minimum protocol base fee (7 wei). Then the limits above put the transaction in the pending or the queued part, or refuse it.
  • A transaction that fails leaves the pool.

After each change of the canonical chain, the pool removes the transactions below the canonical nonce of their sender, as reth's pool does (from 0.9.5, #178). Examples: a replacement that went into a block through another node, or a sender whose nonce an EIP-7702 authorization moved. A reorg puts back the transactions of the removed blocks. A reorg that removes more than 64 blocks puts back none and uses only the block hashes (#186). A blob transaction that a reorg puts back keeps its sidecar, and engine_getBlobs serves it at once (#184).

The validation thread runs at a low priority (nice 10). It pauses while the node executes or writes a block. On mainnet the node admits about 90% of the gossiped transactions. The others are mostly already mined (nonce too low) or have no funds.

Transactions from JSON-RPC ​

eth_sendRawTransaction uses the same checks. It also applies the fee cap of --rpc-txfeecap, which does not apply to transactions from peers. The answer has the error codes and texts of reth.

Blob transactions ​

The pool accepts blob transactions in their network form, with the sidecar. The node checks the blob count, the sidecar form for the fork, the versioned hashes and the KZG proofs. Before Osaka the proofs are EIP-4844 proofs. From Osaka they are EIP-7594 cell proofs.

Relay ​

The node announces each admitted transaction to every peer with NewPooledTransactionHashes. This includes the transactions from eth_sendRawTransaction. Peers then ask for the transactions with GetPooledTransactions. The node announces at most 1 024 hashes in one round.

Mined transactions ​

The pool follows the canonical chain, as the pool of reth does. When a block becomes part of the canonical chain, its transactions leave the pool. This is the same for a block from engine_newPayload, a block from peers and a kept payload. A valid block that the consensus client does not select does not change the pool. The pool keeps the sidecar of a mined blob transaction, because the consensus client can ask for the blobs of new blocks with engine_getBlobs. The node does not offer, serve or build that transaction again.

A block can also make other pool transactions stale. For example, a replacement that went into the block through another node, or an EIP-7702 authorization that moved the nonce of a sender. After the response, the pool removes each transaction with a nonce below the new nonce of its sender, as the pool of reth does. The node takes the new nonces from the state changes of the blocks that it executed.

After each block that the node executes, the pool also gets the new balance of each account that the block changed. Pending transactions that no longer fit the balance go to the queued part. A block that the node reads from the database, and does not execute, gives no balances.

At a reorg, the transactions of the blocks that leave the canonical chain come back to the pool, if the new blocks do not have them. They come back unchecked, after the response to the forkchoice update. The validation thread then checks them on the new head, as gossiped transactions, and drops the ones that fail. It does this also while the writer has not written the new branch yet (read the checks above). A blob transaction comes back only if the pool kept its sidecar. A reorg that removes more than 64 blocks puts no transaction back, as in reth.

How the pool helps block latency ​

The pool also makes blocks faster to execute:

  • Mempool prewarm. Between blocks, a background thread executes new pool transactions on the head state, 256 at a time, and reads the trie paths of what they write. When a block with these transactions arrives, its state is already in memory. The runs keep the nonce and balance checks of execution, so a pool transaction with a nonce gap does not run. No run starts after a block comes. The thread runs at nice 10 and pauses while the node executes or writes a block. --no-warm turns it off.
  • Prewarm order. The thread takes the pool transactions in the order in which they became new in the pool. A transaction that a recheck or a reorg gave back to the pool is new again. The thread skips a transaction that is larger than its buffer. 0.9.6 and earlier could skip some transactions after such a change and did not prewarm them. A transaction larger than the buffer stopped the prewarm there (#284).
  • Senders. For a transaction that the pool admitted, the node takes the sender from the pool and does not recover it again.

For more, read Block pipeline.

Check the network without a node ​

cinder-p2p-probe --discover 10 tests the network part alone. It crawls discv4 for 10 seconds and then tries the nodes that it found, one at a time. For each node it does the handshake, downloads the latest headers and bodies, and checks them against each other. It stops at the first node that passes.

The project does not run the Hive devp2p test suites yet (#8).