use signed repair request variants (#28283)

This commit is contained in:
Jeff Biseda 2022-10-10 14:09:45 -07:00 committed by GitHub
parent 2929c8f7a2
commit 15050b14b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 245 deletions

View File

@ -643,7 +643,6 @@ impl AncestorHashesService {
repair_stats, repair_stats,
outstanding_requests, outstanding_requests,
identity_keypair, identity_keypair,
&root_bank,
) { ) {
request_throttle.push(timestamp()); request_throttle.push(timestamp());
repairable_dead_slot_pool.take(&slot).unwrap(); repairable_dead_slot_pool.take(&slot).unwrap();
@ -719,7 +718,6 @@ impl AncestorHashesService {
repair_stats: &mut AncestorRepairRequestsStats, repair_stats: &mut AncestorRepairRequestsStats,
outstanding_requests: &RwLock<OutstandingAncestorHashesRepairs>, outstanding_requests: &RwLock<OutstandingAncestorHashesRepairs>,
identity_keypair: &Keypair, identity_keypair: &Keypair,
root_bank: &Bank,
) -> bool { ) -> bool {
let sampled_validators = serve_repair.repair_request_ancestor_hashes_sample_peers( let sampled_validators = serve_repair.repair_request_ancestor_hashes_sample_peers(
duplicate_slot, duplicate_slot,
@ -738,7 +736,6 @@ impl AncestorHashesService {
.add_request(AncestorHashesRepairType(duplicate_slot), timestamp()); .add_request(AncestorHashesRepairType(duplicate_slot), timestamp());
let request_bytes = serve_repair.ancestor_repair_request_bytes( let request_bytes = serve_repair.ancestor_repair_request_bytes(
identity_keypair, identity_keypair,
root_bank,
pubkey, pubkey,
duplicate_slot, duplicate_slot,
nonce, nonce,
@ -1164,7 +1161,6 @@ mod test {
} = ManageAncestorHashesState::new(vote_simulator.bank_forks); } = ManageAncestorHashesState::new(vote_simulator.bank_forks);
let RepairInfo { let RepairInfo {
bank_forks,
cluster_info: requester_cluster_info, cluster_info: requester_cluster_info,
cluster_slots, cluster_slots,
repair_validators, repair_validators,
@ -1181,7 +1177,6 @@ mod test {
&mut repair_stats, &mut repair_stats,
&outstanding_requests, &outstanding_requests,
&requester_cluster_info.keypair(), &requester_cluster_info.keypair(),
&bank_forks.read().unwrap().root_bank(),
); );
assert!(ancestor_hashes_request_statuses.is_empty()); assert!(ancestor_hashes_request_statuses.is_empty());
@ -1200,7 +1195,6 @@ mod test {
&mut repair_stats, &mut repair_stats,
&outstanding_requests, &outstanding_requests,
&requester_cluster_info.keypair(), &requester_cluster_info.keypair(),
&bank_forks.read().unwrap().root_bank(),
); );
assert_eq!(ancestor_hashes_request_statuses.len(), 1); assert_eq!(ancestor_hashes_request_statuses.len(), 1);

View File

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

View File

@ -29,16 +29,14 @@ use {
data_budget::DataBudget, data_budget::DataBudget,
packet::{Packet, PacketBatch, PacketBatchRecycler}, packet::{Packet, PacketBatch, PacketBatchRecycler},
}, },
solana_runtime::{bank::Bank, bank_forks::BankForks}, solana_runtime::bank_forks::BankForks,
solana_sdk::{ solana_sdk::{
clock::Slot, clock::Slot,
feature_set::sign_repair_requests,
hash::{Hash, HASH_BYTES}, hash::{Hash, HASH_BYTES},
packet::PACKET_DATA_SIZE, packet::PACKET_DATA_SIZE,
pubkey::{Pubkey, PUBKEY_BYTES}, pubkey::{Pubkey, PUBKEY_BYTES},
signature::{Signable, Signature, Signer, SIGNATURE_BYTES}, signature::{Signable, Signature, Signer, SIGNATURE_BYTES},
signer::keypair::Keypair, signer::keypair::Keypair,
stake_history::Epoch,
timing::{duration_as_ms, timestamp}, timing::{duration_as_ms, timestamp},
}, },
solana_streamer::{ solana_streamer::{
@ -317,10 +315,6 @@ impl ServeRepair {
} }
} }
fn my_info(&self) -> ContactInfo {
self.cluster_info.my_contact_info()
}
pub(crate) fn my_id(&self) -> Pubkey { pub(crate) fn my_id(&self) -> Pubkey {
self.cluster_info.id() self.cluster_info.id()
} }
@ -429,24 +423,6 @@ impl ServeRepair {
} }
} }
pub(crate) fn sign_repair_requests_activated_epoch(root_bank: &Bank) -> Option<Epoch> {
root_bank
.feature_set
.activated_slot(&sign_repair_requests::id())
.map(|slot| root_bank.epoch_schedule().get_epoch(slot))
}
pub(crate) fn should_sign_repair_request(
slot: Slot,
root_bank: &Bank,
sign_repairs_epoch: Option<Epoch>,
) -> bool {
match sign_repairs_epoch {
None => false,
Some(feature_epoch) => feature_epoch < root_bank.epoch_schedule().get_epoch(slot),
}
}
/// Process messages from the network /// Process messages from the network
fn run_listen( fn run_listen(
&self, &self,
@ -755,38 +731,22 @@ impl ServeRepair {
pub fn ancestor_repair_request_bytes( pub fn ancestor_repair_request_bytes(
&self, &self,
keypair: &Keypair, keypair: &Keypair,
root_bank: &Bank,
repair_peer_id: &Pubkey, repair_peer_id: &Pubkey,
request_slot: Slot, request_slot: Slot,
nonce: Nonce, nonce: Nonce,
) -> Result<Vec<u8>> { ) -> Result<Vec<u8>> {
let sign_repairs_epoch = Self::sign_repair_requests_activated_epoch(root_bank); let header = RepairRequestHeader {
let require_sig = signature: Signature::default(),
Self::should_sign_repair_request(request_slot, root_bank, sign_repairs_epoch); sender: self.my_id(),
recipient: *repair_peer_id,
let (request_proto, maybe_keypair) = if require_sig { timestamp: timestamp(),
let header = RepairRequestHeader { nonce,
signature: Signature::default(),
sender: self.my_id(),
recipient: *repair_peer_id,
timestamp: timestamp(),
nonce,
};
(
RepairProtocol::AncestorHashes {
header,
slot: request_slot,
},
Some(keypair),
)
} else {
(
RepairProtocol::LegacyAncestorHashes(self.my_info(), request_slot, nonce),
None,
)
}; };
let request = RepairProtocol::AncestorHashes {
Self::repair_proto_to_bytes(&request_proto, maybe_keypair) header,
slot: request_slot,
};
Self::repair_proto_to_bytes(&request, keypair)
} }
pub(crate) fn repair_request( pub(crate) fn repair_request(
@ -797,7 +757,7 @@ impl ServeRepair {
repair_stats: &mut RepairStats, repair_stats: &mut RepairStats,
repair_validators: &Option<HashSet<Pubkey>>, repair_validators: &Option<HashSet<Pubkey>>,
outstanding_requests: &mut OutstandingShredRepairs, outstanding_requests: &mut OutstandingShredRepairs,
identity_keypair: Option<&Keypair>, identity_keypair: &Keypair,
) -> Result<(SocketAddr, Vec<u8>)> { ) -> Result<(SocketAddr, Vec<u8>)> {
// find a peer that appears to be accepting replication and has the desired slot, as indicated // find a peer that appears to be accepting replication and has the desired slot, as indicated
// by a valid tvu port location // by a valid tvu port location
@ -873,67 +833,41 @@ impl ServeRepair {
repair_peer_id: &Pubkey, repair_peer_id: &Pubkey,
repair_stats: &mut RepairStats, repair_stats: &mut RepairStats,
nonce: Nonce, nonce: Nonce,
identity_keypair: Option<&Keypair>, identity_keypair: &Keypair,
) -> Result<Vec<u8>> { ) -> Result<Vec<u8>> {
let header = if identity_keypair.is_some() { let header = RepairRequestHeader {
Some(RepairRequestHeader { signature: Signature::default(),
signature: Signature::default(), sender: self.my_id(),
sender: self.my_id(), recipient: *repair_peer_id,
recipient: *repair_peer_id, timestamp: timestamp(),
timestamp: timestamp(), nonce,
nonce,
})
} else {
None
}; };
let request_proto = match repair_request { let request_proto = match repair_request {
ShredRepairType::Shred(slot, shred_index) => { ShredRepairType::Shred(slot, shred_index) => {
repair_stats repair_stats
.shred .shred
.update(repair_peer_id, *slot, *shred_index); .update(repair_peer_id, *slot, *shred_index);
if let Some(header) = header { RepairProtocol::WindowIndex {
RepairProtocol::WindowIndex { header,
header, slot: *slot,
slot: *slot, shred_index: *shred_index,
shred_index: *shred_index,
}
} else {
RepairProtocol::LegacyWindowIndexWithNonce(
self.my_info(),
*slot,
*shred_index,
nonce,
)
} }
} }
ShredRepairType::HighestShred(slot, shred_index) => { ShredRepairType::HighestShred(slot, shred_index) => {
repair_stats repair_stats
.highest_shred .highest_shred
.update(repair_peer_id, *slot, *shred_index); .update(repair_peer_id, *slot, *shred_index);
if let Some(header) = header { RepairProtocol::HighestWindowIndex {
RepairProtocol::HighestWindowIndex { header,
header, slot: *slot,
slot: *slot, shred_index: *shred_index,
shred_index: *shred_index,
}
} else {
RepairProtocol::LegacyHighestWindowIndexWithNonce(
self.my_info(),
*slot,
*shred_index,
nonce,
)
} }
} }
ShredRepairType::Orphan(slot) => { ShredRepairType::Orphan(slot) => {
repair_stats.orphan.update(repair_peer_id, *slot, 0); repair_stats.orphan.update(repair_peer_id, *slot, 0);
if let Some(header) = header { RepairProtocol::Orphan {
RepairProtocol::Orphan { header,
header, slot: *slot,
slot: *slot,
}
} else {
RepairProtocol::LegacyOrphanWithNonce(self.my_info(), *slot, nonce)
} }
} }
}; };
@ -994,17 +928,12 @@ impl ServeRepair {
} }
} }
pub fn repair_proto_to_bytes( pub fn repair_proto_to_bytes(request: &RepairProtocol, keypair: &Keypair) -> Result<Vec<u8>> {
request: &RepairProtocol, debug_assert!(request.supports_signature());
keypair: Option<&Keypair>,
) -> Result<Vec<u8>> {
let mut payload = serialize(&request)?; let mut payload = serialize(&request)?;
if let Some(keypair) = keypair { let signable_data = [&payload[..4], &payload[4 + SIGNATURE_BYTES..]].concat();
debug_assert!(request.supports_signature()); let signature = keypair.sign_message(&signable_data[..]);
let signable_data = [&payload[..4], &payload[4 + SIGNATURE_BYTES..]].concat(); payload[4..4 + SIGNATURE_BYTES].copy_from_slice(signature.as_ref());
let signature = keypair.sign_message(&signable_data[..]);
payload[4..4 + SIGNATURE_BYTES].copy_from_slice(signature.as_ref());
}
Ok(payload) Ok(payload)
} }
@ -1233,7 +1162,7 @@ mod tests {
&repair_peer_id, &repair_peer_id,
&mut RepairStats::default(), &mut RepairStats::default(),
456, 456,
Some(&keypair), &keypair,
) )
.unwrap(); .unwrap();
@ -1257,7 +1186,7 @@ mod tests {
#[test] #[test]
fn test_serialize_deserialize_ancestor_hashes_request() { fn test_serialize_deserialize_ancestor_hashes_request() {
let slot = 50; let slot: Slot = 50;
let nonce = 70; let nonce = 70;
let me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
let cluster_info = Arc::new(new_test_cluster_info(me)); let cluster_info = Arc::new(new_test_cluster_info(me));
@ -1268,11 +1197,10 @@ mod tests {
let mut bank = Bank::new_for_tests(&genesis_config); let mut bank = Bank::new_for_tests(&genesis_config);
bank.feature_set = Arc::new(FeatureSet::all_enabled()); bank.feature_set = Arc::new(FeatureSet::all_enabled());
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank))); let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let serve_repair = ServeRepair::new(cluster_info.clone(), bank_forks.clone()); let serve_repair = ServeRepair::new(cluster_info, bank_forks);
let root_bank = bank_forks.read().unwrap().root_bank();
let request_bytes = serve_repair let request_bytes = serve_repair
.ancestor_repair_request_bytes(&keypair, &root_bank, &repair_peer_id, slot, nonce) .ancestor_repair_request_bytes(&keypair, &repair_peer_id, slot, nonce)
.unwrap(); .unwrap();
let mut cursor = Cursor::new(&request_bytes[..]); let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol = let deserialized_request: RepairProtocol =
@ -1294,35 +1222,10 @@ mod tests {
} else { } else {
panic!("unexpected request type {:?}", &deserialized_request); panic!("unexpected request type {:?}", &deserialized_request);
} }
let mut bank = Bank::new_for_tests(&genesis_config);
let mut feature_set = FeatureSet::all_enabled();
feature_set.deactivate(&sign_repair_requests::id());
bank.feature_set = Arc::new(feature_set);
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let serve_repair = ServeRepair::new(cluster_info, bank_forks.clone());
let root_bank = bank_forks.read().unwrap().root_bank();
let request_bytes = serve_repair
.ancestor_repair_request_bytes(&keypair, &root_bank, &repair_peer_id, slot, nonce)
.unwrap();
let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
assert_eq!(cursor.position(), request_bytes.len() as u64);
if let RepairProtocol::LegacyAncestorHashes(ci, deserialized_slot, deserialized_nonce) =
deserialized_request
{
assert_eq!(slot, deserialized_slot);
assert_eq!(nonce, deserialized_nonce);
assert_eq!(&serve_repair.my_id(), &ci.id);
} else {
panic!("unexpected request type {:?}", &deserialized_request);
}
} }
#[test] #[test]
fn test_map_requests_signed_unsigned() { fn test_map_requests_signed() {
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000);
let bank = Bank::new_for_tests(&genesis_config); let bank = Bank::new_for_tests(&genesis_config);
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank))); let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
@ -1337,20 +1240,20 @@ mod tests {
let nonce = 70; let nonce = 70;
let request = ShredRepairType::Shred(slot, shred_index); let request = ShredRepairType::Shred(slot, shred_index);
let rsp = serve_repair let request_bytes = serve_repair
.map_repair_request( .map_repair_request(
&request, &request,
&repair_peer_id, &repair_peer_id,
&mut RepairStats::default(), &mut RepairStats::default(),
nonce, nonce,
Some(&keypair), &keypair,
) )
.unwrap(); .unwrap();
let mut cursor = Cursor::new(&rsp[..]); let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol = let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap(); deserialize_from_with_limit(&mut cursor).unwrap();
assert_eq!(cursor.position(), rsp.len() as u64); assert_eq!(cursor.position(), request_bytes.len() as u64);
if let RepairProtocol::WindowIndex { if let RepairProtocol::WindowIndex {
header, header,
slot: deserialized_slot, slot: deserialized_slot,
@ -1362,7 +1265,7 @@ mod tests {
assert_eq!(header.nonce, nonce); assert_eq!(header.nonce, nonce);
assert_eq!(&header.sender, &serve_repair.my_id()); assert_eq!(&header.sender, &serve_repair.my_id());
assert_eq!(&header.recipient, &repair_peer_id); assert_eq!(&header.recipient, &repair_peer_id);
let signed_data = [&rsp[..4], &rsp[4 + SIGNATURE_BYTES..]].concat(); let signed_data = [&request_bytes[..4], &request_bytes[4 + SIGNATURE_BYTES..]].concat();
assert!(header assert!(header
.signature .signature
.verify(keypair.pubkey().as_ref(), &signed_data)); .verify(keypair.pubkey().as_ref(), &signed_data));
@ -1370,50 +1273,21 @@ mod tests {
panic!("unexpected request type {:?}", &deserialized_request); panic!("unexpected request type {:?}", &deserialized_request);
} }
let rsp = serve_repair
.map_repair_request(
&request,
&repair_peer_id,
&mut RepairStats::default(),
nonce,
None,
)
.unwrap();
let mut cursor = Cursor::new(&rsp[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
assert_eq!(cursor.position(), rsp.len() as u64);
if let RepairProtocol::LegacyWindowIndexWithNonce(
ci,
deserialized_slot,
deserialized_shred_index,
deserialized_nonce,
) = deserialized_request
{
assert_eq!(slot, deserialized_slot);
assert_eq!(shred_index, deserialized_shred_index);
assert_eq!(nonce, deserialized_nonce);
assert_eq!(&serve_repair.my_id(), &ci.id);
} else {
panic!("unexpected request type {:?}", &deserialized_request);
}
let request = ShredRepairType::HighestShred(slot, shred_index); let request = ShredRepairType::HighestShred(slot, shred_index);
let rsp = serve_repair let request_bytes = serve_repair
.map_repair_request( .map_repair_request(
&request, &request,
&repair_peer_id, &repair_peer_id,
&mut RepairStats::default(), &mut RepairStats::default(),
nonce, nonce,
Some(&keypair), &keypair,
) )
.unwrap(); .unwrap();
let mut cursor = Cursor::new(&rsp[..]); let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol = let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap(); deserialize_from_with_limit(&mut cursor).unwrap();
assert_eq!(cursor.position(), rsp.len() as u64); assert_eq!(cursor.position(), request_bytes.len() as u64);
if let RepairProtocol::HighestWindowIndex { if let RepairProtocol::HighestWindowIndex {
header, header,
slot: deserialized_slot, slot: deserialized_slot,
@ -1425,42 +1299,13 @@ mod tests {
assert_eq!(header.nonce, nonce); assert_eq!(header.nonce, nonce);
assert_eq!(&header.sender, &serve_repair.my_id()); assert_eq!(&header.sender, &serve_repair.my_id());
assert_eq!(&header.recipient, &repair_peer_id); assert_eq!(&header.recipient, &repair_peer_id);
let signed_data = [&rsp[..4], &rsp[4 + SIGNATURE_BYTES..]].concat(); let signed_data = [&request_bytes[..4], &request_bytes[4 + SIGNATURE_BYTES..]].concat();
assert!(header assert!(header
.signature .signature
.verify(keypair.pubkey().as_ref(), &signed_data)); .verify(keypair.pubkey().as_ref(), &signed_data));
} else { } else {
panic!("unexpected request type {:?}", &deserialized_request); panic!("unexpected request type {:?}", &deserialized_request);
} }
let rsp = serve_repair
.map_repair_request(
&request,
&repair_peer_id,
&mut RepairStats::default(),
nonce,
None,
)
.unwrap();
let mut cursor = Cursor::new(&rsp[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
assert_eq!(cursor.position(), rsp.len() as u64);
if let RepairProtocol::LegacyHighestWindowIndexWithNonce(
ci,
deserialized_slot,
deserialized_shred_index,
deserialized_nonce,
) = deserialized_request
{
assert_eq!(slot, deserialized_slot);
assert_eq!(shred_index, deserialized_shred_index);
assert_eq!(nonce, deserialized_nonce);
assert_eq!(&serve_repair.my_id(), &ci.id);
} else {
panic!("unexpected request type {:?}", &deserialized_request);
}
} }
#[test] #[test]
@ -1687,6 +1532,7 @@ mod tests {
let me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); let me = ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
let cluster_info = Arc::new(new_test_cluster_info(me)); let cluster_info = Arc::new(new_test_cluster_info(me));
let serve_repair = ServeRepair::new(cluster_info.clone(), bank_forks); let serve_repair = ServeRepair::new(cluster_info.clone(), bank_forks);
let identity_keypair = cluster_info.keypair().clone();
let mut outstanding_requests = OutstandingShredRepairs::default(); let mut outstanding_requests = OutstandingShredRepairs::default();
let rv = serve_repair.repair_request( let rv = serve_repair.repair_request(
&cluster_slots, &cluster_slots,
@ -1695,7 +1541,7 @@ mod tests {
&mut RepairStats::default(), &mut RepairStats::default(),
&None, &None,
&mut outstanding_requests, &mut outstanding_requests,
None, &identity_keypair,
); );
assert_matches!(rv, Err(Error::ClusterInfo(ClusterInfoError::NoPeers))); assert_matches!(rv, Err(Error::ClusterInfo(ClusterInfoError::NoPeers)));
@ -1724,7 +1570,7 @@ mod tests {
&mut RepairStats::default(), &mut RepairStats::default(),
&None, &None,
&mut outstanding_requests, &mut outstanding_requests,
None, &identity_keypair,
) )
.unwrap(); .unwrap();
assert_eq!(nxt.serve_repair, serve_repair_addr); assert_eq!(nxt.serve_repair, serve_repair_addr);
@ -1759,7 +1605,7 @@ mod tests {
&mut RepairStats::default(), &mut RepairStats::default(),
&None, &None,
&mut outstanding_requests, &mut outstanding_requests,
None, &identity_keypair,
) )
.unwrap(); .unwrap();
if rv.0 == serve_repair_addr { if rv.0 == serve_repair_addr {
@ -2015,6 +1861,7 @@ mod tests {
ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp()); ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
cluster_info.insert_info(contact_info2.clone()); cluster_info.insert_info(contact_info2.clone());
cluster_info.insert_info(contact_info3.clone()); cluster_info.insert_info(contact_info3.clone());
let identity_keypair = cluster_info.keypair().clone();
let serve_repair = ServeRepair::new(cluster_info, bank_forks); let serve_repair = ServeRepair::new(cluster_info, bank_forks);
// If: // If:
@ -2032,7 +1879,7 @@ mod tests {
&mut RepairStats::default(), &mut RepairStats::default(),
&known_validators, &known_validators,
&mut OutstandingShredRepairs::default(), &mut OutstandingShredRepairs::default(),
None, &identity_keypair,
) )
.is_err()); .is_err());
} }
@ -2050,7 +1897,7 @@ mod tests {
&mut RepairStats::default(), &mut RepairStats::default(),
&known_validators, &known_validators,
&mut OutstandingShredRepairs::default(), &mut OutstandingShredRepairs::default(),
None, &identity_keypair,
) )
.is_ok()); .is_ok());
@ -2072,7 +1919,7 @@ mod tests {
&mut RepairStats::default(), &mut RepairStats::default(),
&None, &None,
&mut OutstandingShredRepairs::default(), &mut OutstandingShredRepairs::default(),
None, &identity_keypair,
) )
.is_ok()); .is_ok());
} }

View File

@ -646,7 +646,7 @@ fn run_dos<T: 'static + BenchTpsClient + Send + Sync>(
slot, slot,
shred_index: 0, shred_index: 0,
}; };
ServeRepair::repair_proto_to_bytes(&req, Some(&keypair)).unwrap() ServeRepair::repair_proto_to_bytes(&req, &keypair).unwrap()
} }
DataType::RepairShred => { DataType::RepairShred => {
let slot = 100; let slot = 100;
@ -657,14 +657,14 @@ fn run_dos<T: 'static + BenchTpsClient + Send + Sync>(
slot, slot,
shred_index: 0, shred_index: 0,
}; };
ServeRepair::repair_proto_to_bytes(&req, Some(&keypair)).unwrap() ServeRepair::repair_proto_to_bytes(&req, &keypair).unwrap()
} }
DataType::RepairOrphan => { DataType::RepairOrphan => {
let slot = 100; let slot = 100;
let keypair = Keypair::new(); let keypair = Keypair::new();
let header = RepairRequestHeader::new(keypair.pubkey(), target_id, timestamp(), 0); let header = RepairRequestHeader::new(keypair.pubkey(), target_id, timestamp(), 0);
let req = RepairProtocol::Orphan { header, slot }; let req = RepairProtocol::Orphan { header, slot };
ServeRepair::repair_proto_to_bytes(&req, Some(&keypair)).unwrap() ServeRepair::repair_proto_to_bytes(&req, &keypair).unwrap()
} }
DataType::Random => { DataType::Random => {
vec![0; params.data_size] vec![0; params.data_size]

View File

@ -482,10 +482,6 @@ pub mod compact_vote_state_updates {
solana_sdk::declare_id!("86HpNqzutEZwLcPxS6EHDcMNYWk6ikhteg9un7Y2PBKE"); solana_sdk::declare_id!("86HpNqzutEZwLcPxS6EHDcMNYWk6ikhteg9un7Y2PBKE");
} }
pub mod sign_repair_requests {
solana_sdk::declare_id!("sigrs6u1EWeHuoKFkY8RR7qcSsPmrAeBBPESyf5pnYe");
}
pub mod incremental_snapshot_only_incremental_hash_calculation { pub mod incremental_snapshot_only_incremental_hash_calculation {
solana_sdk::declare_id!("25vqsfjk7Nv1prsQJmA4Xu1bN61s8LXCBGUPp8Rfy1UF"); solana_sdk::declare_id!("25vqsfjk7Nv1prsQJmA4Xu1bN61s8LXCBGUPp8Rfy1UF");
} }
@ -641,7 +637,6 @@ lazy_static! {
(loosen_cpi_size_restriction::id(), "loosen cpi size restrictions #26641"), (loosen_cpi_size_restriction::id(), "loosen cpi size restrictions #26641"),
(use_default_units_in_fee_calculation::id(), "use default units per instruction in fee calculation #26785"), (use_default_units_in_fee_calculation::id(), "use default units per instruction in fee calculation #26785"),
(compact_vote_state_updates::id(), "Compact vote state updates to lower block size"), (compact_vote_state_updates::id(), "Compact vote state updates to lower block size"),
(sign_repair_requests::id(), "sign repair requests #26834"),
(incremental_snapshot_only_incremental_hash_calculation::id(), "only hash accounts in incremental snapshot during incremental snapshot creation #26799"), (incremental_snapshot_only_incremental_hash_calculation::id(), "only hash accounts in incremental snapshot during incremental snapshot creation #26799"),
(disable_cpi_setting_executable_and_rent_epoch::id(), "disable setting is_executable and_rent_epoch in CPI #26987"), (disable_cpi_setting_executable_and_rent_epoch::id(), "disable setting is_executable and_rent_epoch in CPI #26987"),
(relax_authority_signer_check_for_lookup_table_creation::id(), "relax authority signer check for lookup table creation #27205"), (relax_authority_signer_check_for_lookup_table_creation::id(), "relax authority signer check for lookup table creation #27205"),