Add RepairWeight to track votes seen in gossip for weighted repair (#10903)

* Add RepairWeight

Co-authored-by: Carl <carl@solana.com>
This commit is contained in:
carllin 2020-07-06 22:49:40 -07:00 committed by GitHub
parent 119949d4d8
commit 3f6042d8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1252 additions and 9 deletions

View File

@ -348,6 +348,12 @@ impl HeaviestSubtreeForkChoice {
self.add_votes(&new_votes, epoch_stakes, epoch_schedule);
}
pub fn stake_voted_at(&self, slot: Slot) -> Option<u64> {
self.fork_infos
.get(&slot)
.map(|fork_info| fork_info.stake_voted_at)
}
fn propagate_new_leaf(&mut self, slot: Slot, parent: Slot) {
let parent_best_slot = self
.best_slot(parent)
@ -525,13 +531,6 @@ impl HeaviestSubtreeForkChoice {
);
}
#[cfg(test)]
fn stake_voted_at(&self, slot: Slot) -> Option<u64> {
self.fork_infos
.get(&slot)
.map(|fork_info| fork_info.stake_voted_at)
}
#[cfg(test)]
fn set_stake_voted_at(&mut self, slot: Slot, stake_voted_at: u64) {
self.fork_infos.get_mut(&slot).unwrap().stake_voted_at = stake_voted_at;

View File

@ -41,6 +41,7 @@ pub mod progress_map;
pub mod pubkey_references;
pub mod repair_response;
pub mod repair_service;
pub mod repair_weight;
pub mod repair_weighted_traversal;
pub mod replay_stage;
mod result;

View File

@ -71,6 +71,8 @@ pub struct RepairStats {
pub shred: RepairStatsGroup,
pub highest_shred: RepairStatsGroup,
pub orphan: RepairStatsGroup,
pub get_best_orphans_us: u64,
pub get_best_shreds_us: u64,
}
#[derive(Default, Debug)]
@ -177,6 +179,7 @@ impl RepairService {
let mut repair_timing = RepairTiming::default();
let mut last_stats = Instant::now();
let duplicate_slot_repair_statuses = HashMap::new();
Self::initialize_epoch_slots(
blockstore,
&cluster_info,

1239
core/src/repair_weight.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ use std::{
pub const MAX_ORPHAN_REPAIR_RESPONSES: usize = 10;
pub const DEFAULT_NONCE: u32 = 42;
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum RepairType {
Orphan(Slot),
HighestShred(Slot, u64),

View File

@ -353,7 +353,8 @@ impl Blockstore {
let mut walk = TreeWalk::from(forks);
while let Some(visit) = walk.get() {
let slot = visit.node().data;
if self.meta(slot).unwrap().is_some() {
if self.meta(slot).unwrap().is_some() && self.orphan(slot).unwrap().is_none() {
// If slot exists and is not an orphan, then skip it
walk.forward();
continue;
}