Skip to content

Commit

Permalink
replace solana_sdk::pubkey with solana_pubkey in gossip (#4234)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey authored Jan 6, 2025
1 parent 990551f commit f27dda7
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 59 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-net-utils = { workspace = true }
solana-perf = { workspace = true }
solana-pubkey = { workspace = true }
solana-rayon-threadlimit = { workspace = true }
solana-rpc-client = { workspace = true }
solana-runtime = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion gossip/benches/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
crds_gossip_pull::{CrdsTimeouts, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
crds_value::CrdsValue,
},
solana_sdk::pubkey::Pubkey,
solana_pubkey::Pubkey,
std::{collections::HashMap, time::Duration},
test::Bencher,
};
Expand Down
37 changes: 17 additions & 20 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ pub struct Node {

impl Node {
pub fn new_localhost() -> Self {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
Self::new_localhost_with_pubkey(&pubkey)
}

Expand Down Expand Up @@ -3187,16 +3187,13 @@ mod tests {
#[test]
fn test_gossip_node() {
//check that a gossip nodes always show up as spies
let (node, _, _) = ClusterInfo::spy_node(solana_sdk::pubkey::new_rand(), 0);
let (node, _, _) = ClusterInfo::spy_node(solana_pubkey::new_rand(), 0);
assert!(ClusterInfo::is_spy_node(
&node,
&SocketAddrSpace::Unspecified
));
let (node, _, _) = ClusterInfo::gossip_node(
solana_sdk::pubkey::new_rand(),
&"1.1.1.1:0".parse().unwrap(),
0,
);
let (node, _, _) =
ClusterInfo::gossip_node(solana_pubkey::new_rand(), &"1.1.1.1:0".parse().unwrap(), 0);
assert!(ClusterInfo::is_spy_node(
&node,
&SocketAddrSpace::Unspecified
Expand All @@ -3211,7 +3208,7 @@ mod tests {
let node = Node::new_localhost_with_pubkey(&keypair.pubkey());
ClusterInfo::new(node.info, keypair, SocketAddrSpace::Unspecified)
});
let entrypoint_pubkey = solana_sdk::pubkey::new_rand();
let entrypoint_pubkey = solana_pubkey::new_rand();
let data = test_crds_values(entrypoint_pubkey);
let stakes = HashMap::from([(Pubkey::new_unique(), 1u64)]);
let timeouts = CrdsTimeouts::new(
Expand Down Expand Up @@ -3337,7 +3334,7 @@ mod tests {
fn test_cluster_spy_gossip() {
let thread_pool = ThreadPoolBuilder::new().build().unwrap();
//check that gossip doesn't try to push to invalid addresses
let (spy, _, _) = ClusterInfo::spy_node(solana_sdk::pubkey::new_rand(), 0);
let (spy, _, _) = ClusterInfo::spy_node(solana_pubkey::new_rand(), 0);
let cluster_info = Arc::new({
let keypair = Arc::new(Keypair::new());
let node = Node::new_localhost_with_pubkey(&keypair.pubkey());
Expand Down Expand Up @@ -3380,7 +3377,7 @@ mod tests {
let keypair = Arc::new(Keypair::new());
let d = ContactInfo::new_localhost(&keypair.pubkey(), timestamp());
let cluster_info = ClusterInfo::new(d, keypair, SocketAddrSpace::Unspecified);
let d = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
let d = ContactInfo::new_localhost(&solana_pubkey::new_rand(), timestamp());
let label = CrdsValueLabel::ContactInfo(*d.pubkey());
cluster_info.insert_info(d);
let gossip_crds = cluster_info.gossip.crds.read().unwrap();
Expand Down Expand Up @@ -3429,7 +3426,7 @@ mod tests {
num_quic_endpoints: DEFAULT_NUM_QUIC_ENDPOINTS,
};

let node = Node::new_with_external_ip(&solana_sdk::pubkey::new_rand(), config);
let node = Node::new_with_external_ip(&solana_pubkey::new_rand(), config);

check_node_sockets(&node, IpAddr::V4(ip), VALIDATOR_PORT_RANGE);
}
Expand All @@ -3452,7 +3449,7 @@ mod tests {
num_quic_endpoints: DEFAULT_NUM_QUIC_ENDPOINTS,
};

let node = Node::new_with_external_ip(&solana_sdk::pubkey::new_rand(), config);
let node = Node::new_with_external_ip(&solana_pubkey::new_rand(), config);

check_node_sockets(&node, ip, port_range);

Expand Down Expand Up @@ -3837,7 +3834,7 @@ mod tests {
node_keypair,
SocketAddrSpace::Unspecified,
);
let entrypoint_pubkey = solana_sdk::pubkey::new_rand();
let entrypoint_pubkey = solana_pubkey::new_rand();
let entrypoint = ContactInfo::new_localhost(&entrypoint_pubkey, timestamp());
cluster_info.set_entrypoint(entrypoint.clone());
let (pings, pulls) = cluster_info.new_pull_requests(&thread_pool, None, &HashMap::new());
Expand Down Expand Up @@ -3917,7 +3914,7 @@ mod tests {
node_keypair,
SocketAddrSpace::Unspecified,
);
let entrypoint_pubkey = solana_sdk::pubkey::new_rand();
let entrypoint_pubkey = solana_pubkey::new_rand();
let mut entrypoint = ContactInfo::new_localhost(&entrypoint_pubkey, timestamp());
entrypoint
.set_gossip(socketaddr!("127.0.0.2:1234"))
Expand All @@ -3926,7 +3923,7 @@ mod tests {

let mut stakes = HashMap::new();

let other_node_pubkey = solana_sdk::pubkey::new_rand();
let other_node_pubkey = solana_pubkey::new_rand();
let other_node = ContactInfo::new_localhost(&other_node_pubkey, timestamp());
assert_ne!(other_node.gossip().unwrap(), entrypoint.gossip().unwrap());
cluster_info.ping_cache.lock().unwrap().mock_pong(
Expand Down Expand Up @@ -3982,7 +3979,7 @@ mod tests {
for i in 0..10 {
// make these invalid for the upcoming repair request
let peer_lowest = if i >= 5 { 10 } else { 0 };
let other_node_pubkey = solana_sdk::pubkey::new_rand();
let other_node_pubkey = solana_pubkey::new_rand();
let other_node = ContactInfo::new_localhost(&other_node_pubkey, timestamp());
cluster_info.insert_info(other_node.clone());
let value = CrdsValue::new_unsigned(CrdsData::LowestSlot(
Expand Down Expand Up @@ -4046,7 +4043,7 @@ mod tests {
// Simulate getting entrypoint ContactInfo from gossip with an entrypoint1 shred version of
// 0
let mut gossiped_entrypoint1_info =
ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
ContactInfo::new_localhost(&solana_pubkey::new_rand(), timestamp());
gossiped_entrypoint1_info
.set_gossip(entrypoint1_gossip_addr)
.unwrap();
Expand Down Expand Up @@ -4075,7 +4072,7 @@ mod tests {
// Simulate getting entrypoint ContactInfo from gossip with an entrypoint2 shred version of
// !0
let mut gossiped_entrypoint2_info =
ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
ContactInfo::new_localhost(&solana_pubkey::new_rand(), timestamp());
gossiped_entrypoint2_info
.set_gossip(entrypoint2_gossip_addr)
.unwrap();
Expand Down Expand Up @@ -4128,7 +4125,7 @@ mod tests {

// Simulate getting entrypoint ContactInfo from gossip
let mut gossiped_entrypoint_info =
ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
ContactInfo::new_localhost(&solana_pubkey::new_rand(), timestamp());
gossiped_entrypoint_info
.set_gossip(entrypoint_gossip_addr)
.unwrap();
Expand All @@ -4155,7 +4152,7 @@ mod tests {
Arc::new(Keypair::new()),
SocketAddrSpace::Unspecified,
));
let entrypoint_pubkey = solana_sdk::pubkey::new_rand();
let entrypoint_pubkey = solana_pubkey::new_rand();
let entrypoint = ContactInfo::new_localhost(&entrypoint_pubkey, timestamp());
cluster_info.set_entrypoint(entrypoint);

Expand Down
2 changes: 1 addition & 1 deletion gossip/src/contact_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl ContactInfo {
pub fn new_rand<R: rand::Rng>(rng: &mut R, pubkey: Option<Pubkey>) -> Self {
let delay = 10 * 60 * 1000; // 10 minutes
let now = solana_sdk::timing::timestamp() - delay + rng.gen_range(0..2 * delay);
let pubkey = pubkey.unwrap_or_else(solana_sdk::pubkey::new_rand);
let pubkey = pubkey.unwrap_or_else(solana_pubkey::new_rand);
let mut node = ContactInfo::new_localhost(&pubkey, now);
let _ = node.set_gossip((Ipv4Addr::LOCALHOST, rng.gen_range(1024..u16::MAX)));
node
Expand Down
4 changes: 2 additions & 2 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ mod tests {
fn test_label_order() {
let v1 = VersionedCrdsValue::new(
CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
&solana_pubkey::new_rand(),
0,
))),
Cursor::default(),
Expand All @@ -1553,7 +1553,7 @@ mod tests {
);
let v2 = VersionedCrdsValue::new(
CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
&solana_pubkey::new_rand(),
0,
))),
Cursor::default(),
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/crds_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
crds_value::{CrdsValue, CrdsValueLabel},
},
indexmap::IndexMap,
solana_sdk::pubkey::Pubkey,
solana_pubkey::Pubkey,
};

type CrdsTable = IndexMap<CrdsValueLabel, VersionedCrdsValue>;
Expand Down
22 changes: 11 additions & 11 deletions gossip/src/crds_gossip_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ pub(crate) mod tests {
Err(CrdsGossipError::NoPeers)
);
let now = 1625029781069;
let new = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), now);
let new = ContactInfo::new_localhost(&solana_pubkey::new_rand(), now);
ping_cache
.lock()
.unwrap()
Expand All @@ -925,7 +925,7 @@ pub(crate) mod tests {
let peers: Vec<_> = req.unwrap().into_iter().map(|(node, _)| node).collect();
assert_eq!(peers, vec![new.contact_info().unwrap().clone()]);

let offline = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), now);
let offline = ContactInfo::new_localhost(&solana_pubkey::new_rand(), now);
let offline = CrdsValue::new_unsigned(CrdsData::ContactInfo(offline));
crds.write()
.unwrap()
Expand Down Expand Up @@ -963,12 +963,12 @@ pub(crate) mod tests {
)));
let node = CrdsGossipPull::default();
crds.insert(entry, now, GossipRoute::LocalMessage).unwrap();
let old = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0);
let old = ContactInfo::new_localhost(&solana_pubkey::new_rand(), 0);
ping_cache.mock_pong(*old.pubkey(), old.gossip().unwrap(), Instant::now());
let old = CrdsValue::new_unsigned(CrdsData::ContactInfo(old));
crds.insert(old.clone(), now, GossipRoute::LocalMessage)
.unwrap();
let new = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 0);
let new = ContactInfo::new_localhost(&solana_pubkey::new_rand(), 0);
ping_cache.mock_pong(*new.pubkey(), new.gossip().unwrap(), Instant::now());
let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(new));
crds.insert(new, now, GossipRoute::LocalMessage).unwrap();
Expand Down Expand Up @@ -1023,7 +1023,7 @@ pub(crate) mod tests {
node_crds
.insert(entry, now, GossipRoute::LocalMessage)
.unwrap();
let new = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), now);
let new = ContactInfo::new_localhost(&solana_pubkey::new_rand(), now);
ping_cache.mock_pong(*new.pubkey(), new.gossip().unwrap(), Instant::now());
let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(new));
node_crds
Expand Down Expand Up @@ -1061,7 +1061,7 @@ pub(crate) mod tests {

let now = now + CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS;
let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
&solana_pubkey::new_rand(),
now,
)));
dest_crds
Expand Down Expand Up @@ -1123,13 +1123,13 @@ pub(crate) mod tests {
.insert(entry, 0, GossipRoute::LocalMessage)
.unwrap();
let mut ping_cache = new_ping_cache();
let new = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), 1);
let new = ContactInfo::new_localhost(&solana_pubkey::new_rand(), 1);
ping_cache.mock_pong(*new.pubkey(), new.gossip().unwrap(), Instant::now());
let new = CrdsValue::new_unsigned(CrdsData::ContactInfo(new));
node_crds.insert(new, 0, GossipRoute::LocalMessage).unwrap();

let mut dest_crds = Crds::default();
let new_id = solana_sdk::pubkey::new_rand();
let new_id = solana_pubkey::new_rand();
let same_key = ContactInfo::new_localhost(&new_id, 0);
let new = ContactInfo::new_localhost(&new_id, 1);
ping_cache.mock_pong(*new.pubkey(), new.gossip().unwrap(), Instant::now());
Expand Down Expand Up @@ -1224,7 +1224,7 @@ pub(crate) mod tests {
let thread_pool = ThreadPoolBuilder::new().build().unwrap();
let mut node_crds = Crds::default();
let entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
&solana_pubkey::new_rand(),
0,
)));
let node_label = entry.label();
Expand All @@ -1234,7 +1234,7 @@ pub(crate) mod tests {
.insert(entry, 0, GossipRoute::LocalMessage)
.unwrap();
let old = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
&solana_pubkey::new_rand(),
0,
)));
node_crds
Expand Down Expand Up @@ -1360,7 +1360,7 @@ pub(crate) mod tests {
let node_crds = RwLock::<Crds>::default();
let node = CrdsGossipPull::default();

let peer_pubkey = solana_sdk::pubkey::new_rand();
let peer_pubkey = solana_pubkey::new_rand();
let peer_entry = CrdsValue::new_unsigned(CrdsData::ContactInfo(
ContactInfo::new_localhost(&peer_pubkey, 0),
));
Expand Down
Loading

0 comments on commit f27dda7

Please sign in to comment.