Beyond the LAN
To find a peer you need a peer.
Every peer-to-peer network has the same chicken-and-egg problem, and the
universal answer is to ship entry points in the binary — IPFS does it,
Ethereum does it, BitTorrent does it. rootmode does it in
DEFAULT_BOOTSTRAP.
crates/rootmode-p2p/src/lib.rs
pub const DEFAULT_BOOTSTRAP: &[&str] = &[
"/dns4/bootstrap.rootmode.ai/tcp/4001",
];
With that filled in, docker compose up joins the
network and starts receiving jobs, and opening the client lists what people
are serving. Neither needs configuring.
ROOTMODE_BOOTSTRAP overrides the list at runtime for both
binaries — which is how you test a private network without touching the
source.
The list is empty until you run bootstrap nodes and add their addresses.
Until then there's no open network to join, only the local-network discovery
above. That's an operational step, not a code one: stand up one or more
nodes on stable public addresses, then paste what they print into the
constant and rebuild.
The /p2p/12D3Koo… suffix is optional. Including it means libp2p
refuses to talk to anything else at that address, which is stronger. Leaving
it out means the address is a DNS name you can re-key without reissuing
builds — at the cost that a hostile node in that position could show you a
biased view of who's on the network. It still couldn't read your jobs, forge a
worker, or defeat a pinned peer: every peer authenticates with its own key and
every result is checked against its hash.