Discard pre hard fork persisted tower if hard-forking (#13536)
* Discard pre hard fork persisted tower if hard-forking * Relax config.require_tower * Add cluster test * nits * Remove unnecessary check Co-authored-by: Ryo Onodera <ryoqun@gmail.com> Co-authored-by: Carl Lin <carl@solana.com>
This commit is contained in:
@ -40,5 +40,15 @@ pub trait Cluster {
|
||||
fn get_contact_info(&self, pubkey: &Pubkey) -> Option<&ContactInfo>;
|
||||
fn exit_node(&mut self, pubkey: &Pubkey) -> ClusterValidatorInfo;
|
||||
fn restart_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
|
||||
fn create_restart_context(
|
||||
&mut self,
|
||||
pubkey: &Pubkey,
|
||||
cluster_validator_info: &mut ClusterValidatorInfo,
|
||||
) -> (solana_core::cluster_info::Node, Option<ContactInfo>);
|
||||
fn restart_node_with_context(
|
||||
cluster_validator_info: ClusterValidatorInfo,
|
||||
restart_context: (solana_core::cluster_info::Node, Option<ContactInfo>),
|
||||
) -> ClusterValidatorInfo;
|
||||
fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
|
||||
fn exit_restart_node(&mut self, pubkey: &Pubkey, config: ValidatorConfig);
|
||||
}
|
||||
|
@ -615,7 +615,11 @@ impl Cluster for LocalCluster {
|
||||
node
|
||||
}
|
||||
|
||||
fn restart_node(&mut self, pubkey: &Pubkey, mut cluster_validator_info: ClusterValidatorInfo) {
|
||||
fn create_restart_context(
|
||||
&mut self,
|
||||
pubkey: &Pubkey,
|
||||
cluster_validator_info: &mut ClusterValidatorInfo,
|
||||
) -> (solana_core::cluster_info::Node, Option<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();
|
||||
@ -627,10 +631,28 @@ impl Cluster for LocalCluster {
|
||||
self.entry_point_info = node.info.clone();
|
||||
None
|
||||
} else {
|
||||
Some(&self.entry_point_info)
|
||||
Some(self.entry_point_info.clone())
|
||||
}
|
||||
};
|
||||
|
||||
(node, entry_point_info)
|
||||
}
|
||||
|
||||
fn restart_node(&mut self, pubkey: &Pubkey, mut cluster_validator_info: ClusterValidatorInfo) {
|
||||
let restart_context = self.create_restart_context(pubkey, &mut cluster_validator_info);
|
||||
let cluster_validator_info =
|
||||
Self::restart_node_with_context(cluster_validator_info, restart_context);
|
||||
self.add_node(pubkey, cluster_validator_info);
|
||||
}
|
||||
|
||||
fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo) {
|
||||
self.validators.insert(*pubkey, cluster_validator_info);
|
||||
}
|
||||
|
||||
fn restart_node_with_context(
|
||||
mut cluster_validator_info: ClusterValidatorInfo,
|
||||
(node, entry_point_info): (Node, Option<ContactInfo>),
|
||||
) -> ClusterValidatorInfo {
|
||||
// Restart the node
|
||||
let validator_info = &cluster_validator_info.info;
|
||||
cluster_validator_info.config.account_paths =
|
||||
@ -641,12 +663,11 @@ impl Cluster for LocalCluster {
|
||||
&validator_info.ledger_path,
|
||||
&validator_info.voting_keypair.pubkey(),
|
||||
vec![validator_info.voting_keypair.clone()],
|
||||
entry_point_info,
|
||||
entry_point_info.as_ref(),
|
||||
&cluster_validator_info.config,
|
||||
);
|
||||
|
||||
cluster_validator_info.validator = Some(restarted_node);
|
||||
self.validators.insert(*pubkey, cluster_validator_info);
|
||||
cluster_validator_info
|
||||
}
|
||||
|
||||
fn exit_restart_node(&mut self, pubkey: &Pubkey, validator_config: ValidatorConfig) {
|
||||
|
Reference in New Issue
Block a user