Skip to main content

Peer Discovery

Summary

Peer discovery enables a new validator or full node to join the network by connecting with other existing nodes, in order to receive consensus messages necessary to validate and keep up to the chain tip.

To participate in peer discovery, a node needs to generate a MonadNameRecord, which contains a name record and a signature over that record using its secp key.

struct MonadNameRecord {
name_record: NameRecord,
signature: SecpSignature,
}

A NameRecord contains the node's IPv4 address, port information, and a sequence number. Currently only IPv4 addresses are supported. There are two wire formats: a legacy format with a single port shared across protocols, and a newer format that supports multiple ports tagged by protocol (TCP, UDP, AuthenticatedUDP) along with a capabilities field. The newer format is used by nodes that have opted into authenticated UDP.

The IP address and ports describe the network endpoints at which other nodes in the network may contact it. A sequence number is necessary to ensure newer name records take priority over older name records. For example, when a node sees a peer's name records with a higher sequence number, it will update its routing table with the new name record.

A node specifies a few bootstrap nodes and their name records when starting up. Bootstrap nodes are not specialized nodes; any node in the network can be a bootstrap node. The node will then advertise its own name record by sending pings to other peers, where the ping message contains its own name record. The node also sends lookup request to its peers when it is missing name records of current active validators. Periodically, the node looks for new nodes or prunes excessive nodes depending on the min and max number of peers configured.