Add new gossip structure for supporting repairs (#4205)
* Add Epoch Slots to gossip * Add new gossip structure to support Repair * remove unnecessary clones * Setup dummy fast repair in repair_service * PR comments
This commit is contained in:
@ -18,7 +18,7 @@ use crate::contact_info::ContactInfo;
|
||||
use crate::crds_gossip::CrdsGossip;
|
||||
use crate::crds_gossip_error::CrdsGossipError;
|
||||
use crate::crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS;
|
||||
use crate::crds_value::{CrdsValue, CrdsValueLabel, Vote};
|
||||
use crate::crds_value::{CrdsValue, CrdsValueLabel, EpochSlots, Vote};
|
||||
use crate::packet::{to_shared_blob, Blob, SharedBlob, BLOB_SIZE};
|
||||
use crate::repair_service::RepairType;
|
||||
use crate::result::Result;
|
||||
@ -41,6 +41,7 @@ use solana_sdk::signature::{Keypair, KeypairUtil, Signable, Signature};
|
||||
use solana_sdk::timing::{duration_as_ms, timestamp};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::cmp::min;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
|
||||
@ -200,7 +201,7 @@ impl ClusterInfo {
|
||||
let mut entry = CrdsValue::ContactInfo(my_data);
|
||||
entry.sign(&self.keypair);
|
||||
self.gossip.refresh_push_active_set(stakes);
|
||||
self.gossip.process_push_message(&[entry], now);
|
||||
self.gossip.process_push_message(vec![entry], now);
|
||||
}
|
||||
|
||||
// TODO kill insert_info, only used by tests
|
||||
@ -296,12 +297,19 @@ impl ClusterInfo {
|
||||
self.gossip_leader_id = *leader_id;
|
||||
}
|
||||
|
||||
pub fn push_epoch_slots(&mut self, id: Pubkey, root: u64, slots: HashSet<u64>) {
|
||||
let now = timestamp();
|
||||
let mut entry = CrdsValue::EpochSlots(EpochSlots::new(id, root, slots, now));
|
||||
entry.sign(&self.keypair);
|
||||
self.gossip.process_push_message(vec![entry], now);
|
||||
}
|
||||
|
||||
pub fn push_vote(&mut self, vote: Transaction) {
|
||||
let now = timestamp();
|
||||
let vote = Vote::new(&self.id(), vote, now);
|
||||
let mut entry = CrdsValue::Vote(vote);
|
||||
entry.sign(&self.keypair);
|
||||
self.gossip.process_push_message(&[entry], now);
|
||||
self.gossip.process_push_message(vec![entry], now);
|
||||
}
|
||||
|
||||
/// Get votes in the crds
|
||||
@ -1133,7 +1141,7 @@ impl ClusterInfo {
|
||||
fn handle_push_message(
|
||||
me: &Arc<RwLock<Self>>,
|
||||
from: &Pubkey,
|
||||
data: &[CrdsValue],
|
||||
data: Vec<CrdsValue>,
|
||||
) -> Vec<SharedBlob> {
|
||||
let self_id = me.read().unwrap().gossip.id;
|
||||
inc_new_counter_info!("cluster_info-push_message", 1, 0, 1000);
|
||||
@ -1141,7 +1149,7 @@ impl ClusterInfo {
|
||||
.write()
|
||||
.unwrap()
|
||||
.gossip
|
||||
.process_push_message(&data, timestamp());
|
||||
.process_push_message(data, timestamp());
|
||||
if !prunes.is_empty() {
|
||||
inc_new_counter_info!("cluster_info-push_message-prunes", prunes.len());
|
||||
let ci = me.read().unwrap().lookup(from).cloned();
|
||||
@ -1294,7 +1302,7 @@ impl ClusterInfo {
|
||||
}
|
||||
ret
|
||||
});
|
||||
Self::handle_push_message(me, &from, &data)
|
||||
Self::handle_push_message(me, &from, data)
|
||||
}
|
||||
Protocol::PruneMessage(from, data) => {
|
||||
if data.verify() {
|
||||
|
Reference in New Issue
Block a user