Skip to content

Commit

Permalink
rpc: add more services to getClusterNodes (anza-xyz#1637)
Browse files Browse the repository at this point in the history
* rpc: add tpu_forwards/tpu_forwards_quic to getClusterNodes

* add tvu

* order

* add tpu_vote

* add serve_repair

* fix tests

* fix name in tests

* remove tvu / repair quic
  • Loading branch information
fanatid authored and samkim-crypto committed Jul 31, 2024
1 parent ba410b9 commit b9442f5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rpc-client-api/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,20 @@ pub struct RpcContactInfo {
pub pubkey: String,
/// Gossip port
pub gossip: Option<SocketAddr>,
/// Tvu UDP port
pub tvu: Option<SocketAddr>,
/// Tpu UDP port
pub tpu: Option<SocketAddr>,
/// Tpu QUIC port
pub tpu_quic: Option<SocketAddr>,
/// Tpu UDP forwards port
pub tpu_forwards: Option<SocketAddr>,
/// Tpu QUIC forwards port
pub tpu_forwards_quic: Option<SocketAddr>,
/// Tpu UDP vote port
pub tpu_vote: Option<SocketAddr>,
/// Server repair UDP port
pub serve_repair: Option<SocketAddr>,
/// JSON RPC port
pub rpc: Option<SocketAddr>,
/// WebSocket PubSub port
Expand Down
5 changes: 5 additions & 0 deletions rpc-client/src/mock_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,13 @@ impl RpcSender for MockSender {
"getClusterNodes" => serde_json::to_value(vec![RpcContactInfo {
pubkey: PUBKEY.to_string(),
gossip: Some(SocketAddr::from(([10, 239, 6, 48], 8899))),
tvu: Some(SocketAddr::from(([10, 239, 6, 48], 8865))),
tpu: Some(SocketAddr::from(([10, 239, 6, 48], 8856))),
tpu_quic: Some(SocketAddr::from(([10, 239, 6, 48], 8862))),
tpu_forwards: Some(SocketAddr::from(([10, 239, 6, 48], 8857))),
tpu_forwards_quic: Some(SocketAddr::from(([10, 239, 6, 48], 8863))),
tpu_vote: Some(SocketAddr::from(([10, 239, 6, 48], 8870))),
serve_repair: Some(SocketAddr::from(([10, 239, 6, 48], 8880))),
rpc: Some(SocketAddr::from(([10, 239, 6, 48], 8899))),
pubsub: Some(SocketAddr::from(([10, 239, 6, 48], 8900))),
version: Some("1.0.0 c375ce1f".to_string()),
Expand Down
30 changes: 30 additions & 0 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3558,6 +3558,10 @@ pub mod rpc_full {
Some(RpcContactInfo {
pubkey: contact_info.pubkey().to_string(),
gossip: contact_info.gossip().ok(),
tvu: contact_info
.tvu(Protocol::UDP)
.ok()
.filter(|addr| socket_addr_space.check(addr)),
tpu: contact_info
.tpu(Protocol::UDP)
.ok()
Expand All @@ -3566,6 +3570,22 @@ pub mod rpc_full {
.tpu(Protocol::QUIC)
.ok()
.filter(|addr| socket_addr_space.check(addr)),
tpu_forwards: contact_info
.tpu_forwards(Protocol::UDP)
.ok()
.filter(|addr| socket_addr_space.check(addr)),
tpu_forwards_quic: contact_info
.tpu_forwards(Protocol::QUIC)
.ok()
.filter(|addr| socket_addr_space.check(addr)),
tpu_vote: contact_info
.tpu_vote()
.ok()
.filter(|addr| socket_addr_space.check(addr)),
serve_repair: contact_info
.serve_repair(Protocol::UDP)
.ok()
.filter(|addr| socket_addr_space.check(addr)),
rpc: contact_info
.rpc()
.ok()
Expand Down Expand Up @@ -5327,8 +5347,13 @@ pub mod tests {
"pubkey": rpc.identity.to_string(),
"gossip": "127.0.0.1:8000",
"shredVersion": 0u16,
"tvu": "127.0.0.1:8001",
"tpu": "127.0.0.1:8003",
"tpuQuic": "127.0.0.1:8009",
"tpuForwards": "127.0.0.1:8004",
"tpuForwardsQuic": "127.0.0.1:8010",
"tpuVote": "127.0.0.1:8005",
"serveRepair": "127.0.0.1:8008",
"rpc": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PORT),
"pubsub": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PUBSUB_PORT),
"version": format!("{version}"),
Expand All @@ -5337,8 +5362,13 @@ pub mod tests {
"pubkey": rpc.leader_pubkey().to_string(),
"gossip": "127.0.0.1:1235",
"shredVersion": 0u16,
"tvu": "127.0.0.1:1236",
"tpu": "127.0.0.1:1234",
"tpuQuic": "127.0.0.1:1240",
"tpuForwards": "127.0.0.1:1239",
"tpuForwardsQuic": "127.0.0.1:1245",
"tpuVote": "127.0.0.1:1241",
"serveRepair": "127.0.0.1:1242",
"rpc": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PORT),
"pubsub": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PUBSUB_PORT),
"version": format!("{version}"),
Expand Down

0 comments on commit b9442f5

Please sign in to comment.