chore(rpc): Connect Peer RPC Request#2034
Conversation
There was a problem hiding this comment.
Pull Request Overview
Implements the opp2p_connectPeer JSON-RPC request, parsing the peer ID and forwarding a ConnectPeer command through the P2P subsystem.
- Adds
opp2p_connect_peerhandler in the RPC server to parse the incoming string and send aConnectPeerrequest. - Introduces a new
ConnectPeervariant inP2pRpcRequestand its correspondingconnect_peerhandler. - All existing P2P RPC routes are now symmetric for connect/disconnect operations.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/node/rpc/src/p2p.rs | Implemented opp2p_connect_peer, parsing input and sending P2pRpcRequest::ConnectPeer. |
| crates/node/p2p/src/rpc/request.rs | Added ConnectPeer enum variant and connect_peer method to dial a peer. |
Comments suppressed due to low confidence (1)
crates/node/rpc/src/p2p.rs:145
- Add unit or integration tests for
opp2p_connect_peercovering both successful connections and failure cases (invalid peer ID parsing and internal send errors).
async fn opp2p_connect_peer(&self, peer_id: String) -> RpcResult<()> {
| /// The peer id to connect. | ||
| peer_id: PeerId, | ||
| }, | ||
| /// Request to disconnect the specified peer. | ||
| DisconnectPeer { | ||
| /// The peer id to disconnect. |
There was a problem hiding this comment.
[nitpick] In the doc comment, consider changing "peer id" to "peer ID" for consistency with other code and logs.
| /// The peer id to connect. | |
| peer_id: PeerId, | |
| }, | |
| /// Request to disconnect the specified peer. | |
| DisconnectPeer { | |
| /// The peer id to disconnect. | |
| /// The peer ID to connect. | |
| peer_id: PeerId, | |
| }, | |
| /// Request to disconnect the specified peer. | |
| DisconnectPeer { | |
| /// The peer ID to disconnect. |
| } | ||
| } | ||
|
|
||
| fn connect_peer(peer_id: PeerId, gossip: &mut GossipDriver) { |
There was a problem hiding this comment.
[nitpick] Logging targets differ between the RPC server (target: "rpc") and this handler (target: "p2p::rpc"); consider unifying or documenting the distinction for consistent observability.
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I actually already had this drafted and just put up a pr with it. We want to parse the string as a multiaddress like how the optimism monorepo parses the string using go libp2p's |
Ahh understood I'll close this PR |
Description
Implements the opp2p_connectPeer rpc request.
Closes #1575