Skip to content

Commit

Permalink
use signed repair request variants (#28283)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbiseda authored Oct 10, 2022
1 parent 2929c8f commit 15050b1
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 245 deletions.
6 changes: 0 additions & 6 deletions core/src/ancestor_hashes_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ impl AncestorHashesService {
repair_stats,
outstanding_requests,
identity_keypair,
&root_bank,
) {
request_throttle.push(timestamp());
repairable_dead_slot_pool.take(&slot).unwrap();
Expand Down Expand Up @@ -719,7 +718,6 @@ impl AncestorHashesService {
repair_stats: &mut AncestorRepairRequestsStats,
outstanding_requests: &RwLock<OutstandingAncestorHashesRepairs>,
identity_keypair: &Keypair,
root_bank: &Bank,
) -> bool {
let sampled_validators = serve_repair.repair_request_ancestor_hashes_sample_peers(
duplicate_slot,
Expand All @@ -738,7 +736,6 @@ impl AncestorHashesService {
.add_request(AncestorHashesRepairType(duplicate_slot), timestamp());
let request_bytes = serve_repair.ancestor_repair_request_bytes(
identity_keypair,
root_bank,
pubkey,
duplicate_slot,
nonce,
Expand Down Expand Up @@ -1164,7 +1161,6 @@ mod test {
} = ManageAncestorHashesState::new(vote_simulator.bank_forks);

let RepairInfo {
bank_forks,
cluster_info: requester_cluster_info,
cluster_slots,
repair_validators,
Expand All @@ -1181,7 +1177,6 @@ mod test {
&mut repair_stats,
&outstanding_requests,
&requester_cluster_info.keypair(),
&bank_forks.read().unwrap().root_bank(),
);
assert!(ancestor_hashes_request_statuses.is_empty());

Expand All @@ -1200,7 +1195,6 @@ mod test {
&mut repair_stats,
&outstanding_requests,
&requester_cluster_info.keypair(),
&bank_forks.read().unwrap().root_bank(),
);

assert_eq!(ancestor_hashes_request_statuses.len(), 1);
Expand Down
30 changes: 11 additions & 19 deletions core/src/repair_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ impl RepairService {
let mut add_votes_elapsed;

let root_bank = repair_info.bank_forks.read().unwrap().root_bank();
let sign_repair_requests_feature_epoch =
ServeRepair::sign_repair_requests_activated_epoch(&root_bank);

let repairs = {
let new_root = root_bank.slot();

Expand Down Expand Up @@ -331,16 +328,6 @@ impl RepairService {
repairs
.iter()
.filter_map(|repair_request| {
let sign_repair_request = ServeRepair::should_sign_repair_request(
repair_request.slot(),
&root_bank,
sign_repair_requests_feature_epoch,
);
let maybe_keypair = if sign_repair_request {
Some(identity_keypair)
} else {
None
};
let (to, req) = serve_repair
.repair_request(
&repair_info.cluster_slots,
Expand All @@ -349,7 +336,7 @@ impl RepairService {
&mut repair_stats,
&repair_info.repair_validators,
&mut outstanding_requests,
maybe_keypair,
identity_keypair,
)
.ok()?;
Some((req, to))
Expand Down Expand Up @@ -617,6 +604,7 @@ impl RepairService {
repair_socket: &UdpSocket,
repair_validators: &Option<HashSet<Pubkey>>,
outstanding_requests: &RwLock<OutstandingShredRepairs>,
identity_keypair: &Keypair,
) {
duplicate_slot_repair_statuses.retain(|slot, status| {
Self::update_duplicate_slot_repair_addr(
Expand All @@ -641,6 +629,7 @@ impl RepairService {
serve_repair,
repair_stats,
nonce,
identity_keypair,
) {
info!(
"repair req send_to {} ({}) error {:?}",
Expand All @@ -667,13 +656,14 @@ impl RepairService {
serve_repair: &ServeRepair,
repair_stats: &mut RepairStats,
nonce: Nonce,
identity_keypair: &Keypair,
) -> Result<()> {
let req = serve_repair.map_repair_request(
repair_type,
repair_pubkey,
repair_stats,
nonce,
None,
identity_keypair,
)?;
repair_socket.send_to(&req, to)?;
Ok(())
Expand Down Expand Up @@ -1091,10 +1081,9 @@ mod test {
let blockstore_path = get_tmp_ledger_path!();
let blockstore = Blockstore::open(&blockstore_path).unwrap();
let cluster_slots = ClusterSlots::default();
let serve_repair = ServeRepair::new(
Arc::new(new_test_cluster_info(Node::new_localhost().info)),
bank_forks,
);
let cluster_info = Arc::new(new_test_cluster_info(Node::new_localhost().info));
let identity_keypair = cluster_info.keypair().clone();
let serve_repair = ServeRepair::new(cluster_info, bank_forks);
let mut duplicate_slot_repair_statuses = HashMap::new();
let dead_slot = 9;
let receive_socket = &UdpSocket::bind("0.0.0.0:0").unwrap();
Expand Down Expand Up @@ -1129,6 +1118,7 @@ mod test {
&UdpSocket::bind("0.0.0.0:0").unwrap(),
&None,
&RwLock::new(OutstandingRequests::default()),
&identity_keypair,
);
assert!(duplicate_slot_repair_statuses
.get(&dead_slot)
Expand All @@ -1154,6 +1144,7 @@ mod test {
&UdpSocket::bind("0.0.0.0:0").unwrap(),
&None,
&RwLock::new(OutstandingRequests::default()),
&identity_keypair,
);
assert_eq!(duplicate_slot_repair_statuses.len(), 1);
assert!(duplicate_slot_repair_statuses.get(&dead_slot).is_some());
Expand All @@ -1172,6 +1163,7 @@ mod test {
&UdpSocket::bind("0.0.0.0:0").unwrap(),
&None,
&RwLock::new(OutstandingRequests::default()),
&identity_keypair,
);
assert!(duplicate_slot_repair_statuses.is_empty());
}
Expand Down
Loading

0 comments on commit 15050b1

Please sign in to comment.