Skip to content

Commit

Permalink
Add all validators as entrypoint to local cluster (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin authored Apr 6, 2024
1 parent b443cfb commit de8e9e6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions local-cluster/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ pub trait Cluster {
&mut self,
pubkey: &Pubkey,
cluster_validator_info: &mut ClusterValidatorInfo,
) -> (Node, Option<ContactInfo>);
) -> (Node, Vec<ContactInfo>);
fn restart_node_with_context(
cluster_validator_info: ClusterValidatorInfo,
restart_context: (Node, Option<ContactInfo>),
restart_context: (Node, Vec<ContactInfo>),
socket_addr_space: SocketAddrSpace,
) -> ClusterValidatorInfo;
fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
Expand Down
46 changes: 29 additions & 17 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ impl LocalCluster {
let alive_node_contact_infos = self.discover_nodes(socket_addr_space, test_name);
info!(
"{} looking minimum root {} on all nodes",
min_root, test_name
test_name, min_root
);
cluster_tests::check_min_slot_is_rooted(
min_root,
Expand Down Expand Up @@ -907,23 +907,36 @@ impl Cluster for LocalCluster {
&mut self,
pubkey: &Pubkey,
cluster_validator_info: &mut ClusterValidatorInfo,
) -> (Node, Option<ContactInfo>) {
) -> (Node, Vec<ContactInfo>) {
// Update the stored ContactInfo for this node
let node = Node::new_localhost_with_pubkey(pubkey);
cluster_validator_info.info.contact_info = node.info.clone();
cluster_validator_info.config.rpc_addrs =
Some((node.info.rpc().unwrap(), node.info.rpc_pubsub().unwrap()));

let entry_point_info = {
if pubkey == self.entry_point_info.pubkey() {
self.entry_point_info = node.info.clone();
None
} else {
Some(self.entry_point_info.clone())
}
};
if pubkey == self.entry_point_info.pubkey() {
self.entry_point_info = node.info.clone();
}

let mut is_entrypoint_alive = false;
let mut entry_point_infos: Vec<ContactInfo> = self
.validators
.values()
.map(|validator| {
// Should not be restarting a validator that is still alive
assert!(validator.info.contact_info.pubkey() != pubkey);
if validator.info.contact_info.pubkey() == self.entry_point_info.pubkey() {
is_entrypoint_alive = true;
}
validator.info.contact_info.clone()
})
.collect();

(node, entry_point_info)
if !is_entrypoint_alive {
entry_point_infos.push(self.entry_point_info.clone());
}

(node, entry_point_infos)
}

fn set_entry_point(&mut self, entry_point_info: ContactInfo) {
Expand Down Expand Up @@ -951,7 +964,7 @@ impl Cluster for LocalCluster {

fn restart_node_with_context(
mut cluster_validator_info: ClusterValidatorInfo,
(node, entry_point_info): (Node, Option<ContactInfo>),
(node, entry_point_infos): (Node, Vec<ContactInfo>),
socket_addr_space: SocketAddrSpace,
) -> ClusterValidatorInfo {
// Restart the node
Expand All @@ -966,11 +979,10 @@ impl Cluster for LocalCluster {
&validator_info.ledger_path,
&validator_info.voting_keypair.pubkey(),
Arc::new(RwLock::new(vec![validator_info.voting_keypair.clone()])),
entry_point_info
.map(|entry_point_info| {
vec![LegacyContactInfo::try_from(&entry_point_info).unwrap()]
})
.unwrap_or_default(),
entry_point_infos
.into_iter()
.map(|entry_point_info| LegacyContactInfo::try_from(&entry_point_info).unwrap())
.collect(),
&safe_clone_config(&cluster_validator_info.config),
true, // should_check_duplicate_instance
None, // rpc_to_plugin_manager_receiver
Expand Down

0 comments on commit de8e9e6

Please sign in to comment.