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:
parent
119949d4d8
commit
3f6042d8b3
|
@ -348,6 +348,12 @@ impl HeaviestSubtreeForkChoice {
|
||||||
self.add_votes(&new_votes, epoch_stakes, epoch_schedule);
|
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) {
|
fn propagate_new_leaf(&mut self, slot: Slot, parent: Slot) {
|
||||||
let parent_best_slot = self
|
let parent_best_slot = self
|
||||||
.best_slot(parent)
|
.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)]
|
#[cfg(test)]
|
||||||
fn set_stake_voted_at(&mut self, slot: Slot, stake_voted_at: u64) {
|
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;
|
self.fork_infos.get_mut(&slot).unwrap().stake_voted_at = stake_voted_at;
|
||||||
|
|
|
@ -41,6 +41,7 @@ pub mod progress_map;
|
||||||
pub mod pubkey_references;
|
pub mod pubkey_references;
|
||||||
pub mod repair_response;
|
pub mod repair_response;
|
||||||
pub mod repair_service;
|
pub mod repair_service;
|
||||||
|
pub mod repair_weight;
|
||||||
pub mod repair_weighted_traversal;
|
pub mod repair_weighted_traversal;
|
||||||
pub mod replay_stage;
|
pub mod replay_stage;
|
||||||
mod result;
|
mod result;
|
||||||
|
|
|
@ -71,6 +71,8 @@ pub struct RepairStats {
|
||||||
pub shred: RepairStatsGroup,
|
pub shred: RepairStatsGroup,
|
||||||
pub highest_shred: RepairStatsGroup,
|
pub highest_shred: RepairStatsGroup,
|
||||||
pub orphan: RepairStatsGroup,
|
pub orphan: RepairStatsGroup,
|
||||||
|
pub get_best_orphans_us: u64,
|
||||||
|
pub get_best_shreds_us: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
|
@ -177,6 +179,7 @@ impl RepairService {
|
||||||
let mut repair_timing = RepairTiming::default();
|
let mut repair_timing = RepairTiming::default();
|
||||||
let mut last_stats = Instant::now();
|
let mut last_stats = Instant::now();
|
||||||
let duplicate_slot_repair_statuses = HashMap::new();
|
let duplicate_slot_repair_statuses = HashMap::new();
|
||||||
|
|
||||||
Self::initialize_epoch_slots(
|
Self::initialize_epoch_slots(
|
||||||
blockstore,
|
blockstore,
|
||||||
&cluster_info,
|
&cluster_info,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,7 @@ use std::{
|
||||||
pub const MAX_ORPHAN_REPAIR_RESPONSES: usize = 10;
|
pub const MAX_ORPHAN_REPAIR_RESPONSES: usize = 10;
|
||||||
pub const DEFAULT_NONCE: u32 = 42;
|
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 {
|
pub enum RepairType {
|
||||||
Orphan(Slot),
|
Orphan(Slot),
|
||||||
HighestShred(Slot, u64),
|
HighestShred(Slot, u64),
|
||||||
|
|
|
@ -353,7 +353,8 @@ impl Blockstore {
|
||||||
let mut walk = TreeWalk::from(forks);
|
let mut walk = TreeWalk::from(forks);
|
||||||
while let Some(visit) = walk.get() {
|
while let Some(visit) = walk.get() {
|
||||||
let slot = visit.node().data;
|
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();
|
walk.forward();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue