Repository navigation
feat(rpc): serve /eth/v1/node/peers, /peers/{peer_id} and /peer_count - #747
Draft
MegaRedHand wants to merge 3 commits into
Draft
MegaRedHand wants to merge 3 commits into
MegaRedHand wants to merge 3 commits into
Conversation
ethPandaOps' contributoor polls GET /eth/v1/node/peers once a minute against our beacon nodes and got a 404, and any Beacon API consumer expects the endpoint. The p2p actor already owns the connected-peer set, so it now mirrors it into a shared PeerTableController (same pattern as MetaDataController): p2p is the sole writer, inserting on a peer's first connection and removing on its last close, and RPC reads it per request through BeaconIdentity. Only connected peers are tracked, so state is always "connected"; other state filters match nothing and peer_count reports 0 for them. The ENR is the record discovery supplied before the dial (kept in the dial loop's bookkeeping, no new requests), and null for inbound peers and --bootnodes dials.
MegaRedHand
added a commit
that referenced
this pull request
Nov 2, 2026
…#747) ethPandaOps' contributoor polls GET /eth/v1/node/peers once a minute against our beacon nodes and got a 404, and any Beacon API consumer expects the endpoint. The p2p actor already owns the connected-peer set, so it now mirrors it into a shared PeerTableController (same pattern as MetaDataController): p2p is the sole writer, inserting on a peer's first connection and removing on its last close, and RPC reads it per request through BeaconIdentity. Only connected peers are tracked, so state is always "connected"; other state filters match nothing and peer_count reports 0 for them. The ENR is the record discovery supplied before the dial (kept in the dial loop's bookkeeping, no new requests), and null for inbound peers and --bootnodes dials. Cherry-picked from feat/beacon-node-peers at e12b8fd.
MegaRedHand
added a commit
that referenced
this pull request
Nov 2, 2026
ethPandaOps' contributoor subscribes to head_v2 and the gloas topics, and ethlambda accepted every one of them without ever sending any, so the lab's gloas views stayed empty for our nodes on Sepolia. head_v2 goes out next to every head (pre-gloas with payload_status "full") and again for the same block when its payload status goes from empty to full. The block event gains builder_index and block_hash for gloas blocks. The chain actor publishes execution_payload and execution_payload_available on envelope import. Bids, proposer preferences, payload attestation messages and accepted envelopes are validated in ethlambda-p2p and never reach the actor, and p2p does not depend on the crate owning the event bus, so p2p reports them through a GossipEventSink trait in ethlambda-network-api that EventBus implements. The API handlers that accept the same objects publish on the bus they already hold. Cherry-picked from feat/beacon-gloas-events at 8274123. Adapted onto #747: the p2p crate imports both `GossipEventSink` and the peer table types.
This branch has not been deployed
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.
Summary
Serves the Beacon API's
GET /eth/v1/node/peers,GET /eth/v1/node/peers/{peer_id}andGET /eth/v1/node/peer_count. ethPandaOps' contributoor (xatu sentry) polls/peersevery minute and got a 404.Design notes
ethlambda-network-apigainsPeerTableController(Arc<RwLock<HashMap>>),ConnectedPeerandPeerDirection, mirroringMetaDataController. Strings only, so the crate stays free of libp2p types.ConnectionEstablishedwithnum_established == 1, remove onConnectionClosedwithnum_established == 0. RPC reads it at request time via a newBeaconIdentity.peers: Option<PeerTableController>; absent means an empty list.stateis alwaysconnected. Astatefilter for another valid state returns an empty list, andpeer_countreports"0"for the other states. Documented indocs/rpc.md.last_seen_p2p_addressis the first connection's remote address, with/p2p/<peer id>appended if absent.directionis the first connection's, as inconnected_peers.enr:DiscoveredPeernow carries the record'senr:string; the dial loop keeps it per peer (peer_enrs, dropped inforget_discovered_peer) and it is read at connect.nullfor inbound peers and--bootnodesdials. No new network requests.state/directionaccept repeated and comma-separated values (values of one parameter are alternatives, parameters are AND-combined); peers are sorted by peer id for stable output;/peers/{peer_id}validates the id as non-empty base58 (the RPC crate has no libp2p), so a malformed id is a 400 and a well-formed unknown one a 404./lean/v0) untouched.Test plan
cargo fmt --allcargo clippy -p ethlambda-network-api -p ethlambda-p2p -p ethlambda-rpc -p ethlambda --all-targets --profile release-fast -- -D warningscargo test -p ethlambda-rpc --profile release-fast --lib -- beacon::node(15 passed): list, state/direction/both filters, invalid value 400,meta.count, null ENR,/peers/{id}hit/miss/malformed,peer_countquoting, absent tablecargo test -p ethlambda-network-api --profile release-fast --lib(3 passed)curl :5052/eth/v1/node/peers