feat(mesh): stable libp2p identity (deploy-ready PeerIds for cross-DC bootnodes)#30
Merged
Merged
Conversation
The mesh used `Keypair::generate_ed25519()` — a fresh random libp2p identity on every boot, so the node's PeerId changed on each restart. That makes cross-DC discovery impractical: bootnode multiaddrs are `/ip4/<host>/tcp/<port>/p2p/<PeerId>`, and a PeerId that rotates every restart can't be pinned in peers' configs. Derive the ed25519 transport key deterministically from the operator key (keccak256(key ‖ "surplus-mesh-libp2p-v1") as the ed25519 seed — a separate domain-tagged hash, never the raw k256 secret). The PeerId is now stable across restarts AND computable offline, so `SURPLUS_MESH_BOOTNODES` can be configured once. Boot now logs the peer_id + listen addr for building those multiaddrs. Verified: builds --features chain,mesh; the 3-node mesh_clob e2e still passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prereq for the fleet HTTP→mesh cutover. The mesh used
Keypair::generate_ed25519()— a random libp2p identity per boot, so a node's PeerId changed on every restart. Cross-DC discovery is impractical that way: bootnode multiaddrs are/ip4/<host>/tcp/<port>/p2p/<PeerId>, and a rotating PeerId can't be pinned in peers' configs.Fix: derive the ed25519 transport key deterministically from the operator key (
keccak256(key ‖ "surplus-mesh-libp2p-v1")as the seed — a domain-tagged hash, never the raw k256 secret). PeerId is now stable across restarts and computable offline, soSURPLUS_MESH_BOOTNODESis a one-time config. Boot logs thepeer_id+ listen addr for building the multiaddrs.Verified: builds
--features chain,mesh; the 3-nodemesh_clobe2e still passes.🤖 Generated with Claude Code