Skip to content

Commit

Permalink
Fix: Fix genesis.bin not found error.
Browse files Browse the repository at this point in the history
  • Loading branch information
vldm committed Nov 6, 2021
1 parent 7d5d1b2 commit 423ab86
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 29 deletions.
38 changes: 28 additions & 10 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ impl ClusterInfo {
let mut different_shred_nodes = 0usize;
let my_pubkey = self.id();
let my_shred_version = self.my_shred_version();
let nodes: Vec<_> = self
let mut nodes_sorted: Vec<_> = self
.all_peers()
.into_iter()
.filter_map(|(node, last_updated)| {
Expand All @@ -799,13 +799,32 @@ impl ClusterInfo {
}

let node_version = self.get_node_version(&node.id);
if my_shred_version != 0 && (node.shred_version != 0 && node.shred_version != my_shred_version) {
if my_shred_version != 0
&& (node.shred_version != 0 && node.shred_version != my_shred_version)
{
different_shred_nodes = different_shred_nodes.saturating_add(1);
None
} else {
if is_spy_node {
shred_spy_nodes = shred_spy_nodes.saturating_add(1);
}
let ip_addr = node.gossip.ip();
let slot = self
.gossip
.read()
.unwrap()
.crds
.get(&CrdsValueLabel::SnapshotHashes(node.id))
.and_then(|x| x.value.snapshot_hash())
.and_then(|x| x.hashes.iter().map(|(s, _)| *s).max());
Some((slot, ip_addr, node, node_version, last_updated))
}
})
.collect();
nodes_sorted.sort_by_key(|(slot, ..)| slot.unwrap_or_default());

let nodes: Vec<_> = nodes_sorted.iter()
.map(|(slot, ip_addr, node, node_version , last_updated)| {
fn addr_to_string(default_ip: &IpAddr, addr: &SocketAddr) -> String {
if ContactInfo::is_valid_address(addr) {
if &addr.ip() == default_ip {
Expand All @@ -817,16 +836,15 @@ impl ClusterInfo {
"none".to_string()
}
}
let ip_addr = node.gossip.ip();
Some(format!(
"{:15} {:2}| {:5} | {:44} |{:^9}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {}\n",
format!(
"{:15} {:2}| {:5} | {:44} |{:^9}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {}\n",
if ContactInfo::is_valid_address(&node.gossip) {
ip_addr.to_string()
} else {
"none".to_string()
},
if node.id == my_pubkey { "me" } else { "" }.to_string(),
now.saturating_sub(last_updated),
now.saturating_sub(*last_updated),
node.id.to_string(),
if let Some(node_version) = node_version {
node_version.to_string()
Expand All @@ -841,14 +859,14 @@ impl ClusterInfo {
addr_to_string(&ip_addr, &node.repair),
addr_to_string(&ip_addr, &node.serve_repair),
node.shred_version,
))
}
})
slot.map(|x|x.to_string())
.unwrap_or_default(),
)})
.collect();

format!(
"IP Address |Age(ms)| Node identifier \
| Version |Gossip| TPU |TPUfwd| TVU |TVUfwd|Repair|ServeR|ShredVer\n\
| Version |Gossip| TPU |TPUfwd| TVU |TVUfwd|Repair|ServeR|ShredVer|LastSnapshot\n\
------------------+-------+----------------------------------------------+---------+\
------+------+------+------+------+------+------+--------\n\
{}\
Expand Down
2 changes: 1 addition & 1 deletion download-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn download_genesis_if_missing(
genesis_package: &Path,
use_progress_bar: bool,
) -> Result<PathBuf, String> {
if !genesis_package.exists() {
if !genesis_package.is_file() {
let tmp_genesis_path = genesis_package.parent().unwrap().join("tmp-genesis");
let tmp_genesis_package = tmp_genesis_path.join("genesis.tar.bz2");

Expand Down
2 changes: 1 addition & 1 deletion evm-utils/evm-state/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Storage {

pub fn backup(&self) -> Result<PathBuf> {
let backup_dir = self.location.as_ref().join(BACKUP_SUBDIR);
info!("backup storage data into {}", backup_dir.display());
info!("EVM Backup storage data into {}", backup_dir.display());

let mut engine = BackupEngine::open(&BackupEngineOptions::default(), &backup_dir)?;
if engine.get_backup_info().len() > KEEP_N_BACKUPS {
Expand Down
45 changes: 28 additions & 17 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ fn rpc_bootstrap(

let mut blacklisted_rpc_nodes = HashSet::new();
let mut gossip = None;
let mut retry = 0;
const RETRY_RPC_REQUEST_COUNT: usize = 10;
loop {
if gossip.is_none() {
*start_progress.write().unwrap() = ValidatorStartProgress::SearchingForRpcService;
Expand All @@ -854,7 +856,14 @@ fn rpc_bootstrap(
snapshot_output_dir,
);
if rpc_node_details.is_none() {
return;
if retry == RETRY_RPC_REQUEST_COUNT {
error!("Cannot find rpc node with active snapshot.");
return;
}
retry += 1;

warn!("No rpc found retring.");
continue;
}
let (rpc_contact_info, snapshot_hash) = rpc_node_details.unwrap();

Expand All @@ -872,22 +881,6 @@ fn rpc_bootstrap(
Err(err) => Err(format!("Failed to get RPC node version: {}", err)),
}
.and_then(|_| {
let genesis_hash = download_then_check_genesis_hash(
&rpc_contact_info.rpc,
ledger_path,
validator_config.expected_genesis_hash,
bootstrap_config.max_genesis_archive_unpacked_size,
bootstrap_config.no_genesis_fetch,
use_progress_bar,
);

if let Ok(genesis_hash) = genesis_hash {
if validator_config.expected_genesis_hash.is_none() {
info!("Expected genesis hash set to {}", genesis_hash);
validator_config.expected_genesis_hash = Some(genesis_hash);
}
}

if let Some(expected_genesis_hash) = validator_config.expected_genesis_hash {
// Sanity check that the RPC node is using the expected genesis hash before
// downloading a snapshot from it
Expand All @@ -902,6 +895,24 @@ fn rpc_bootstrap(
));
}
}
let genesis_hash = download_then_check_genesis_hash(
&rpc_contact_info.rpc,
ledger_path,
validator_config.expected_genesis_hash,
bootstrap_config.max_genesis_archive_unpacked_size,
bootstrap_config.no_genesis_fetch,
use_progress_bar,
);

match genesis_hash {
Ok(genesis_hash) => {
if validator_config.expected_genesis_hash.is_none() {
info!("Expected genesis hash set to {}", genesis_hash);
validator_config.expected_genesis_hash = Some(genesis_hash);
}
}
Err(err) => return Err(format!("Cannot download or open genesis: {}", err)),
}

if let Some(snapshot_hash) = snapshot_hash {
let mut use_local_snapshot = false;
Expand Down

0 comments on commit 423ab86

Please sign in to comment.