Skip to content

refactor(p2p): move node name registry into P2PServer#342

Draft
conache wants to merge 2 commits intolambdaclass:mainfrom
conache:move-node-registry-module
Draft

refactor(p2p): move node name registry into P2PServer#342
conache wants to merge 2 commits intolambdaclass:mainfrom
conache:move-node-registry-module

Conversation

@conache
Copy link
Copy Markdown
Contributor

@conache conache commented May 1, 2026

🗒️ Description / Motivation

The PeerId -> node_name lookup lived in a global RwLock<HashMap<PeerId, &'static str>> populated once at startup. This PR moves it into P2PServer so the actor owns its own state.

What Changed

  • crates/net/p2p/src/lib.rs: the registry is now a field on the P2P actor's state struct, with a small helper to resolve a peer's name.
  • crates/net/p2p/src/metrics.rs: no longer owns the registry — its peer-event helpers take the resolved name directly.
  • bin/ethlambda/src/main.rs: the loader now returns the map and hands it off to P2P::spawn at startup; it also logs how many entries it loaded.

Correctness / Behavior Guarantees

  • Metric label values (lean_connected_peers{client="..."}) are unchanged for valid configs.
  • Bad rows in validator-config.yaml (unparseable secp256k1 privkeys) used to be silently dropped; they now emit a warn! per drop and are still skipped. No new panics, no new failure paths.
  • No consensus-layer impact (fork choice, attestations, STF, signatures untouched).

Tests Added / Run

  • make fmt
  • make lint
  • make test

Related Issues / PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move node name registry to each module

1 participant