Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Add to Repair enum to support both nonce and non-nonced repairs
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin committed May 13, 2020
1 parent 50f7149 commit 86cd4c5
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 117 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion archiver-lib/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ impl Archiver {
.into_iter()
.filter_map(|repair_request| {
serve_repair
.map_repair_request(&repair_request, &mut repair_stats, 0)
.map_repair_request(&repair_request, &mut repair_stats, Some(0))
.map(|result| ((archiver_info.gossip, result), repair_request))
.ok()
})
Expand Down
4 changes: 2 additions & 2 deletions core/benches/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rand::{thread_rng, Rng};
use solana_core::broadcast_stage::{broadcast_shreds, get_broadcast_peers};
use solana_core::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo;
use solana_ledger::shred::{Shred, SHRED_PAYLOAD_SIZE};
use solana_ledger::shred::{Shred, NONCE_SHRED_PAYLOAD_SIZE};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::timestamp;
use std::{
Expand All @@ -25,7 +25,7 @@ fn broadcast_shreds_bench(bencher: &mut Bencher) {
let socket = UdpSocket::bind("0.0.0.0:0").unwrap();

const NUM_SHREDS: usize = 32;
let shreds = vec![Shred::new_empty_data_shred(SHRED_PAYLOAD_SIZE); NUM_SHREDS];
let shreds = vec![Shred::new_empty_data_shred(NONCE_SHRED_PAYLOAD_SIZE); NUM_SHREDS];
let mut stakes = HashMap::new();
const NUM_PEERS: usize = 200;
for _ in 0..NUM_PEERS {
Expand Down
4 changes: 2 additions & 2 deletions core/src/outstanding_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
pub(crate) mod tests {
use super::*;
use crate::serve_repair::RepairType;
use solana_ledger::shred::{Shred, SHRED_PAYLOAD_SIZE};
use solana_ledger::shred::{Shred, NONCE_SHRED_PAYLOAD_SIZE};

#[test]
fn test_add_request() {
Expand All @@ -198,7 +198,7 @@ pub(crate) mod tests {
let mut nonce = node_outstanding_requests.nonce;
node_outstanding_requests.add_request(repair_type);

let shred = Shred::new_empty_data_shred(SHRED_PAYLOAD_SIZE);
let shred = Shred::new_empty_data_shred(NONCE_SHRED_PAYLOAD_SIZE);
let mut expire_timestamp = node_outstanding_requests
.requests
.get(&nonce)
Expand Down
11 changes: 8 additions & 3 deletions core/src/repair_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,13 @@ impl RepairService {

if let Some(repairs) = repairs {
for repair_type in repairs {
let nonce =
outstanding_requests.add_request(&repair_addr, repair_type.clone());
let nonce = if Shred::is_nonce_unlocked(*slot) {
Some(
outstanding_requests.add_request(&repair_addr, repair_type.clone()),
)
} else {
None
};
if let Err(e) = Self::serialize_and_send_request(
&repair_type,
repair_socket,
Expand Down Expand Up @@ -381,7 +386,7 @@ impl RepairService {
to: &SocketAddr,
serve_repair: &ServeRepair,
repair_stats: &mut RepairStats,
nonce: Nonce,
nonce: Option<Nonce>,
) -> Result<()> {
let req = serve_repair.map_repair_request(&repair_type, repair_stats, nonce)?;
repair_socket.send_to(&req, to)?;
Expand Down
8 changes: 4 additions & 4 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,7 @@ pub(crate) mod tests {
get_tmp_ledger_path,
shred::{
CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED,
SHRED_PAYLOAD_SIZE, SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER,
SIZE_OF_DATA_SHRED_PAYLOAD,
SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD,
},
};
use solana_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs};
Expand All @@ -1812,6 +1811,7 @@ pub(crate) mod tests {
genesis_config,
hash::{hash, Hash},
instruction::InstructionError,
packet::PACKET_DATA_SIZE,
rent::Rent,
signature::{Keypair, Signature, Signer},
system_transaction,
Expand Down Expand Up @@ -2520,14 +2520,14 @@ pub(crate) mod tests {
// Insert entry that causes deserialization failure
let res = check_dead_fork(|_, _| {
let payload_len = SIZE_OF_DATA_SHRED_PAYLOAD;
let gibberish = [0xa5u8; SHRED_PAYLOAD_SIZE];
let gibberish = [0xa5u8; PACKET_DATA_SIZE];
let mut data_header = DataShredHeader::default();
data_header.flags |= DATA_COMPLETE_SHRED;
let mut shred = Shred::new_empty_from_header(
ShredCommonHeader::default(),
data_header,
CodingShredHeader::default(),
SHRED_PAYLOAD_SIZE,
PACKET_DATA_SIZE,
);
bincode::serialize_into(
&mut shred.payload[SIZE_OF_COMMON_SHRED_HEADER + SIZE_OF_DATA_SHRED_HEADER..],
Expand Down
Loading

0 comments on commit 86cd4c5

Please sign in to comment.