Expand description
§kona-peers
Networking Utilities ported from reth.
Much of this module is ported from https://github.com/paradigmxyz/reth/blob/0e087ae1c35502f0b8d128c64e4c57269af20c0e/crates/net/peers/src/lib.rs.
This module manages and converts Ethereum network entities such as node records, peer IDs, and Ethereum Node Records (ENRs)
§Node Record Overview
Ethereum uses different types of “node records” to represent peers on the network.
The simplest way to identify a peer is by public key. This is the PeerId type, which usually
represents a peer’s secp256k1 public key.
A more complete representation of a peer is the NodeRecord type, which includes the peer’s
IP address, the ports where it is reachable (TCP and UDP), and the peer’s public key. This is
what is returned from discovery v4 queries.
The most comprehensive node record type is the Ethereum Node Record (discv5::Enr), which is
a signed, versioned record that includes the information from a NodeRecord along with
additional metadata. This is the data structure returned from discovery v5 queries.
When we need to deserialize an identifier that could be any of these three types (PeerId,
NodeRecord, and discv5::Enr), we use the AnyNode type, which is an enum over the
three types. AnyNode is used in reth’s admin_addTrustedPeer RPC method.
In short, the types are as follows:
PeerId: A simple public key identifier.NodeRecord: A more complete representation of a peer, including IP address and ports.discv5::Enr: An Ethereum Node Record, which is a signed, versioned record that includes additional metadata. Useful when interacting with discovery v5, or when custom metadata is required.AnyNode: An enum overPeerId,NodeRecord, anddiscv5::Enr, useful in deserialization when the type of the node record is not known.
Structs§
- Boot
Nodes - Bootnodes for OP Stack chains.
- Boot
Store - On-disk storage for
Enrs. - Node
Record - Represents an ENR in discovery.
- OpStack
Enr - The unique L2 network identifier
- Peer
Monitoring - Specifies how to monitor peer scores and ban poorly performing peers.
Enums§
- AnyNode
- A peer that can come in
EnrorNodeRecordform. - Boot
Node - A boot node can be added either as a string in either ‘enode’ URL scheme or serialized from
Enrtype. - Dial
Opts Error - An error that can occur when converting an
AnyNodetoDialOpts. - EnrValidation
- Validates the
Enrfor the OP Stack. - Node
Record Parse Error - Possible error types when parsing a
NodeRecord - OpStack
EnrError - The error type that can be returned when trying to convert an
Enrto anOpStackEnr. - Peer
IdConversion Error - An error that can occur when converting a
PeerIdto alibp2p::PeerId. - Peer
Score Level - The peer scoring level is used to determine how peers are scored based on their behavior.
Statics§
- OP_
RAW_ BOOTNODES - OP stack mainnet boot nodes.
- OP_
RAW_ TESTNET_ BOOTNODES - OP stack testnet boot nodes.
Functions§
- enr_
to_ multiaddr - Converts an
Enrinto aMultiaddr. - local_
id_ to_ p2p_ id - Converts an uncoded
PeerIdto alibp2p::PeerId. These two types represent the same underlying concept (secp256k1 public key) but using different encodings (the localPeerIdis the uncompressed representation of the public key, while the “p2plib”libp2p::PeerIdis a more complex representation, involving protobuf encoding and bitcoin encoding, defined here: https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md). - peer_
id_ to_ secp256k1_ pubkey - Converts an uncompressed
PeerIdto asecp256k1::PublicKeyby prepending thePeerIdbytes with theSECP256K1_TAG_PUBKEY_UNCOMPRESSEDtag.
Type Aliases§
- PeerId
- Alias for a peer identifier.