Skip to content

Commit

Permalink
renames ContactInfo to LegacyContactInfo (backport #29566) (#29898)
Browse files Browse the repository at this point in the history
* renames ContactInfo to LegacyContactInfo (#29566)

Working towards adding a new ContactInfo where new sockets can be
added in a backward compatible way.

(cherry picked from commit 8c212f5)

# Conflicts:
#	core/src/accounts_hash_verifier.rs
#	core/src/retransmit_stage.rs
#	core/tests/epoch_accounts_hash.rs
#	gossip/src/cluster_info.rs
#	gossip/src/crds_gossip_push.rs
#	validator/src/admin_rpc_service.rs

* resolves mergify merge conflicts

Co-authored-by: behzad nouri <[email protected]>
  • Loading branch information
mergify[bot] and behzadnouri authored Jan 25, 2023
1 parent c98eaa6 commit 60d67b0
Show file tree
Hide file tree
Showing 43 changed files with 281 additions and 275 deletions.
2 changes: 1 addition & 1 deletion core/benches/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
},
solana_gossip::{
cluster_info::{ClusterInfo, Node},
contact_info::ContactInfo,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
Expand Down
2 changes: 1 addition & 1 deletion core/benches/cluster_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
cluster_nodes::{make_test_cluster, new_cluster_nodes, ClusterNodes},
retransmit_stage::RetransmitStage,
},
solana_gossip::contact_info::ContactInfo,
solana_gossip::legacy_contact_info::LegacyContactInfo as ContactInfo,
solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
shred::{Shred, ShredFlags},
Expand Down
2 changes: 1 addition & 1 deletion core/benches/retransmit_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
solana_entry::entry::Entry,
solana_gossip::{
cluster_info::{ClusterInfo, Node},
contact_info::ContactInfo,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
Expand Down
5 changes: 4 additions & 1 deletion core/src/accounts_hash_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ impl AccountsHashVerifier {
mod tests {
use {
super::*,
solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo},
solana_gossip::{
cluster_info::make_accounts_hashes_message,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_runtime::{
rent_collector::RentCollector,
snapshot_utils::{ArchiveFormat, SnapshotVersion},
Expand Down
2 changes: 1 addition & 1 deletion core/src/ancestor_hashes_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ mod test {
},
solana_gossip::{
cluster_info::{ClusterInfo, Node},
contact_info::ContactInfo,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{blockstore::make_many_slot_entries, get_tmp_ledger_path, shred::Nonce},
solana_runtime::{accounts_background_service::AbsRequestSender, bank_forks::BankForks},
Expand Down
6 changes: 4 additions & 2 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ use {
min_max_heap::MinMaxHeap,
solana_client::{connection_cache::ConnectionCache, tpu_connection::TpuConnection},
solana_entry::entry::hash_transactions,
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_gossip::{
cluster_info::ClusterInfo, legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
blockstore_processor::TransactionStatusSender, token_balances::collect_token_balances,
},
Expand Down Expand Up @@ -2308,7 +2310,7 @@ mod tests {
crossbeam_channel::{unbounded, Receiver},
solana_address_lookup_table_program::state::{AddressLookupTable, LookupTableMeta},
solana_entry::entry::{next_entry, next_versioned_entry, Entry, EntrySlice},
solana_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_gossip::cluster_info::Node,
solana_ledger::{
blockstore::{entries_to_test_shreds, Blockstore},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
Expand Down
2 changes: 1 addition & 1 deletion core/src/broadcast_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {
itertools::Itertools,
solana_gossip::{
cluster_info::{ClusterInfo, ClusterInfoError},
contact_info::ContactInfo,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{blockstore::Blockstore, shred::Shred},
solana_measure::measure::Measure,
Expand Down
2 changes: 1 addition & 1 deletion core/src/broadcast_stage/broadcast_duplicates_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
crate::cluster_nodes::ClusterNodesCache,
itertools::Itertools,
solana_entry::entry::Entry,
solana_gossip::contact_info::ContactInfo,
solana_gossip::legacy_contact_info::LegacyContactInfo as ContactInfo,
solana_ledger::shred::{ProcessShredsStats, ReedSolomonCache, Shredder},
solana_sdk::{
hash::Hash,
Expand Down
2 changes: 1 addition & 1 deletion core/src/broadcast_stage/broadcast_fake_shreds_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl BroadcastRun for BroadcastFakeShredsRun {
mod tests {
use {
super::*,
solana_gossip::contact_info::ContactInfo,
solana_gossip::legacy_contact_info::LegacyContactInfo as ContactInfo,
solana_streamer::socket::SocketAddrSpace,
std::net::{IpAddr, Ipv4Addr, SocketAddr},
};
Expand Down
4 changes: 2 additions & 2 deletions core/src/cluster_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use {
rand_chacha::ChaChaRng,
solana_gossip::{
cluster_info::{compute_retransmit_peers, ClusterInfo, DATA_PLANE_FANOUT},
contact_info::ContactInfo,
crds::GossipRoute,
crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS,
crds_value::{CrdsData, CrdsValue},
legacy_contact_info::LegacyContactInfo as ContactInfo,
weighted_shuffle::WeightedShuffle,
},
solana_ledger::shred::ShredId,
Expand Down Expand Up @@ -486,7 +486,7 @@ pub fn make_test_cluster<R: Rng>(
let mut gossip_crds = cluster_info.gossip.crds.write().unwrap();
// First node is pushed to crds table by ClusterInfo constructor.
for node in nodes.iter().skip(1) {
let node = CrdsData::ContactInfo(node.clone());
let node = CrdsData::LegacyContactInfo(node.clone());
let node = CrdsValue::new_unsigned(node);
assert_eq!(
gossip_crds.insert(node, now, GossipRoute::LocalMessage),
Expand Down
3 changes: 2 additions & 1 deletion core/src/cluster_slots.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use {
itertools::Itertools,
solana_gossip::{
cluster_info::ClusterInfo, contact_info::ContactInfo, crds::Cursor, epoch_slots::EpochSlots,
cluster_info::ClusterInfo, crds::Cursor, epoch_slots::EpochSlots,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_runtime::{bank::Bank, epoch_stakes::NodeIdToVoteAccounts},
solana_sdk::{
Expand Down
4 changes: 3 additions & 1 deletion core/src/repair_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,9 @@ impl RepairService {
mod test {
use {
super::*,
solana_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_gossip::{
cluster_info::Node, legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
blockstore::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries, Blockstore,
Expand Down
4 changes: 3 additions & 1 deletion core/src/retransmit_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use {
lru::LruCache,
rayon::{prelude::*, ThreadPool, ThreadPoolBuilder},
solana_client::rpc_response::SlotUpdate,
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_gossip::{
cluster_info::ClusterInfo, legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
leader_schedule_cache::LeaderScheduleCache,
shred::{self, ShredId},
Expand Down
16 changes: 8 additions & 8 deletions core/src/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
},
solana_gossip::{
cluster_info::{ClusterInfo, ClusterInfoError},
contact_info::ContactInfo,
legacy_contact_info::{LegacyContactInfo as ContactInfo, LegacyContactInfo},
ping_pong::{self, PingCache, Pong},
weighted_shuffle::WeightedShuffle,
},
Expand Down Expand Up @@ -204,13 +204,13 @@ pub(crate) type Ping = ping_pong::Ping<[u8; REPAIR_PING_TOKEN_SIZE]>;
/// Window protocol messages
#[derive(Serialize, Deserialize, Debug)]
pub enum RepairProtocol {
LegacyWindowIndex(ContactInfo, Slot, u64),
LegacyHighestWindowIndex(ContactInfo, Slot, u64),
LegacyOrphan(ContactInfo, Slot),
LegacyWindowIndexWithNonce(ContactInfo, Slot, u64, Nonce),
LegacyHighestWindowIndexWithNonce(ContactInfo, Slot, u64, Nonce),
LegacyOrphanWithNonce(ContactInfo, Slot, Nonce),
LegacyAncestorHashes(ContactInfo, Slot, Nonce),
LegacyWindowIndex(LegacyContactInfo, Slot, u64),
LegacyHighestWindowIndex(LegacyContactInfo, Slot, u64),
LegacyOrphan(LegacyContactInfo, Slot),
LegacyWindowIndexWithNonce(LegacyContactInfo, Slot, u64, Nonce),
LegacyHighestWindowIndexWithNonce(LegacyContactInfo, Slot, u64, Nonce),
LegacyOrphanWithNonce(LegacyContactInfo, Slot, Nonce),
LegacyAncestorHashes(LegacyContactInfo, Slot, Nonce),
Pong(ping_pong::Pong),
WindowIndex {
header: RepairRequestHeader,
Expand Down
2 changes: 1 addition & 1 deletion core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ use {
ClusterInfo, Node, DEFAULT_CONTACT_DEBUG_INTERVAL_MILLIS,
DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS,
},
contact_info::ContactInfo,
crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS,
gossip_service::GossipService,
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_ledger::{
bank_forks_utils,
Expand Down
2 changes: 1 addition & 1 deletion core/src/window_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ mod test {
use {
super::*,
solana_entry::entry::{create_ticks, Entry},
solana_gossip::contact_info::ContactInfo,
solana_gossip::legacy_contact_info::LegacyContactInfo as ContactInfo,
solana_ledger::{
blockstore::{make_many_slot_entries, Blockstore},
get_tmp_ledger_path,
Expand Down
4 changes: 3 additions & 1 deletion core/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use {
accounts_hash_verifier::AccountsHashVerifier,
snapshot_packager_service::SnapshotPackagerService,
},
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_gossip::{
cluster_info::ClusterInfo, legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_runtime::{
accounts_background_service::{
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler,
Expand Down
2 changes: 1 addition & 1 deletion dos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ use {
solana_core::serve_repair::{RepairProtocol, RepairRequestHeader, ServeRepair},
solana_dos::cli::*,
solana_gossip::{
contact_info::ContactInfo,
gossip_service::{discover, get_multi_client},
legacy_contact_info::LegacyContactInfo as ContactInfo,
},
solana_measure::measure::Measure,
solana_sdk::{
Expand Down
39 changes: 20 additions & 19 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use {
cluster_info_metrics::{
submit_gossip_stats, Counter, GossipStats, ScopedTimer, TimedGuard,
},
contact_info::ContactInfo,
crds::{Crds, Cursor, GossipRoute},
crds_gossip::CrdsGossip,
crds_gossip_error::CrdsGossipError,
Expand All @@ -36,6 +35,7 @@ use {
duplicate_shred::DuplicateShred,
epoch_slots::EpochSlots,
gossip_error::GossipError,
legacy_contact_info::LegacyContactInfo as ContactInfo,
ping_pong::{self, PingCache, Pong},
socketaddr, socketaddr_any,
weighted_shuffle::WeightedShuffle,
Expand Down Expand Up @@ -267,7 +267,7 @@ pub fn make_accounts_hashes_message(
pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;

// TODO These messages should go through the gpu pipeline for spam filtering
#[frozen_abi(digest = "C1nR7B7CgMyUYo6h3z2KXcS38JSwF6y8jmZ6Y9Cz7XEd")]
#[frozen_abi(digest = "32XMrR8yTPMsw7TASQDinrbcB4bdVGyLeTvQrk95hS4i")]
#[derive(Serialize, Deserialize, Debug, AbiEnumVisitor, AbiExample)]
#[allow(clippy::large_enum_variant)]
pub(crate) enum Protocol {
Expand Down Expand Up @@ -377,7 +377,7 @@ impl Sanitize for Protocol {
fn retain_staked(values: &mut Vec<CrdsValue>, stakes: &HashMap<Pubkey, u64>) {
values.retain(|value| {
match value.data {
CrdsData::ContactInfo(_) => true,
CrdsData::LegacyContactInfo(_) => true,
// May Impact new validators starting up without any stake yet.
CrdsData::Vote(_, _) => true,
// Unstaked nodes can still help repair.
Expand Down Expand Up @@ -471,7 +471,7 @@ impl ClusterInfo {
let now = timestamp();
self.my_contact_info.write().unwrap().wallclock = now;
let entries: Vec<_> = vec![
CrdsData::ContactInfo(self.my_contact_info()),
CrdsData::LegacyContactInfo(self.my_contact_info()),
CrdsData::NodeInstance(self.instance.read().unwrap().with_wallclock(now)),
]
.into_iter()
Expand Down Expand Up @@ -524,7 +524,8 @@ impl ClusterInfo {

// TODO kill insert_info, only used by tests
pub fn insert_info(&self, contact_info: ContactInfo) {
let value = CrdsValue::new_signed(CrdsData::ContactInfo(contact_info), &self.keypair());
let value =
CrdsValue::new_signed(CrdsData::LegacyContactInfo(contact_info), &self.keypair());
let mut gossip_crds = self.gossip.crds.write().unwrap();
let _ = gossip_crds.insert(value, timestamp(), GossipRoute::LocalMessage);
}
Expand Down Expand Up @@ -1359,7 +1360,7 @@ impl ClusterInfo {

fn insert_self(&self) {
let value = CrdsValue::new_signed(
CrdsData::ContactInfo(self.my_contact_info()),
CrdsData::LegacyContactInfo(self.my_contact_info()),
&self.keypair(),
);
let mut gossip_crds = self.gossip.crds.write().unwrap();
Expand Down Expand Up @@ -1495,7 +1496,7 @@ impl ClusterInfo {
self.gossip.mark_pull_request_creation_time(peer.id, now);
}
}
let self_info = CrdsData::ContactInfo(self.my_contact_info());
let self_info = CrdsData::LegacyContactInfo(self.my_contact_info());
let self_info = CrdsValue::new_signed(self_info, &self.keypair());
let pulls = pulls
.into_iter()
Expand Down Expand Up @@ -2033,7 +2034,7 @@ impl ClusterInfo {
score
};
let score = match response.data {
CrdsData::ContactInfo(_) => 2 * score,
CrdsData::LegacyContactInfo(_) => 2 * score,
_ => score,
};
((addr, response), score)
Expand Down Expand Up @@ -3081,7 +3082,7 @@ fn filter_on_shred_version(
if crds.get_shred_version(from) == Some(self_shred_version) {
values.retain(|value| match &value.data {
// Allow contact-infos so that shred-versions are updated.
CrdsData::ContactInfo(_) => true,
CrdsData::LegacyContactInfo(_) => true,
CrdsData::NodeInstance(_) => true,
// Only retain values with the same shred version.
_ => crds.get_shred_version(&value.pubkey()) == Some(self_shred_version),
Expand All @@ -3090,7 +3091,7 @@ fn filter_on_shred_version(
values.retain(|value| match &value.data {
// Allow node to update its own contact info in case their
// shred-version changes
CrdsData::ContactInfo(node) => node.id == *from,
CrdsData::LegacyContactInfo(node) => node.id == *from,
CrdsData::NodeInstance(_) => true,
_ => false,
})
Expand All @@ -3103,7 +3104,7 @@ fn filter_on_shred_version(
match &mut msg {
Protocol::PullRequest(_, caller) => match &caller.data {
// Allow spy nodes with shred-verion == 0 to pull from other nodes.
CrdsData::ContactInfo(node)
CrdsData::LegacyContactInfo(node)
if node.shred_version == 0 || node.shred_version == self_shred_version =>
{
Some(msg)
Expand Down Expand Up @@ -3424,7 +3425,7 @@ RPC Enabled Nodes: 1"#;

fn test_crds_values(pubkey: Pubkey) -> Vec<CrdsValue> {
let entrypoint = ContactInfo::new_localhost(&pubkey, timestamp());
let entrypoint_crdsvalue = CrdsValue::new_unsigned(CrdsData::ContactInfo(entrypoint));
let entrypoint_crdsvalue = CrdsValue::new_unsigned(CrdsData::LegacyContactInfo(entrypoint));
vec![entrypoint_crdsvalue]
}

Expand Down Expand Up @@ -3627,7 +3628,7 @@ RPC Enabled Nodes: 1"#;
let cluster_info =
ClusterInfo::new(d, Arc::new(Keypair::new()), SocketAddrSpace::Unspecified);
let d = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
let label = CrdsValueLabel::ContactInfo(d.id);
let label = CrdsValueLabel::LegacyContactInfo(d.id);
cluster_info.insert_info(d);
let gossip_crds = cluster_info.gossip.crds.read().unwrap();
assert!(gossip_crds.get::<&CrdsValue>(&label).is_some());
Expand Down Expand Up @@ -4004,7 +4005,7 @@ RPC Enabled Nodes: 1"#;
node.shred_version = 42;
let epoch_slots = EpochSlots::new_rand(&mut rng, Some(node_pubkey));
let entries = vec![
CrdsValue::new_unsigned(CrdsData::ContactInfo(node)),
CrdsValue::new_unsigned(CrdsData::LegacyContactInfo(node)),
CrdsValue::new_unsigned(CrdsData::EpochSlots(0, epoch_slots)),
];
{
Expand Down Expand Up @@ -4061,7 +4062,7 @@ RPC Enabled Nodes: 1"#;
}
// now add this message back to the table and make sure after the next pull, the entrypoint is unset
let entrypoint_crdsvalue =
CrdsValue::new_unsigned(CrdsData::ContactInfo(entrypoint.clone()));
CrdsValue::new_unsigned(CrdsData::LegacyContactInfo(entrypoint.clone()));
let cluster_info = Arc::new(cluster_info);
let timeouts = cluster_info.gossip.make_timeouts(
cluster_info.id(),
Expand All @@ -4082,7 +4083,7 @@ RPC Enabled Nodes: 1"#;

#[test]
fn test_split_messages_small() {
let value = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::default()));
let value = CrdsValue::new_unsigned(CrdsData::LegacyContactInfo(ContactInfo::default()));
test_split_messages(value);
}

Expand Down Expand Up @@ -4184,7 +4185,7 @@ RPC Enabled Nodes: 1"#;
}

fn check_pull_request_size(filter: CrdsFilter) {
let value = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::default()));
let value = CrdsValue::new_unsigned(CrdsData::LegacyContactInfo(ContactInfo::default()));
let protocol = Protocol::PullRequest(filter, value);
assert!(serialized_size(&protocol).unwrap() <= PACKET_DATA_SIZE as u64);
}
Expand Down Expand Up @@ -4351,7 +4352,7 @@ RPC Enabled Nodes: 1"#;
.expect("unable to serialize default filter") as usize;
let protocol = Protocol::PullRequest(
CrdsFilter::default(),
CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::default())),
CrdsValue::new_unsigned(CrdsData::LegacyContactInfo(ContactInfo::default())),
);
let protocol_size =
serialized_size(&protocol).expect("unable to serialize gossip protocol") as usize;
Expand Down Expand Up @@ -4690,7 +4691,7 @@ RPC Enabled Nodes: 1"#;
let mut rand_ci = ContactInfo::new_rand(&mut rng, Some(keypair.pubkey()));
rand_ci.shred_version = shred_version;
rand_ci.wallclock = timestamp();
CrdsValue::new_signed(CrdsData::ContactInfo(rand_ci), &keypair)
CrdsValue::new_signed(CrdsData::LegacyContactInfo(rand_ci), &keypair)
})
.take(NO_ENTRIES)
.collect();
Expand Down
Loading

0 comments on commit 60d67b0

Please sign in to comment.