* skips retransmit for shreds with unknown slot leader (#19472)
Shreds' signatures should be verified before they reach retransmit
stage, and if the leader is unknown they should fail signature check.
Therefore retransmit-stage can as well expect to know who the slot
leader is and otherwise just skip the shred.
Blockstore checking signature of recovered shreds before sending them to
retransmit stage:
https://github.com/solana-labs/solana/blob/4305d4b7b/ledger/src/blockstore.rs#L884-L930
Shred signature verifier:
https://github.com/solana-labs/solana/blob/4305d4b7b/core/src/sigverify_shreds.rs#L41-L57
https://github.com/solana-labs/solana/blob/4305d4b7b/ledger/src/sigverify_shreds.rs#L105
(cherry picked from commit 6d9818b8e4
)
# Conflicts:
# core/src/broadcast_stage/broadcast_duplicates_run.rs
# ledger/src/shred.rs
* removes backport merge conflicts
Co-authored-by: behzad nouri <behzadnouri@gmail.com>
This commit is contained in:
@@ -49,34 +49,36 @@
|
||||
//! So, given a) - c), we must restrict data shred's payload length such that the entire coding
|
||||
//! payload can fit into one coding shred / packet.
|
||||
|
||||
use crate::{
|
||||
blockstore::MAX_DATA_SHREDS_PER_SLOT,
|
||||
entry::{create_ticks, Entry},
|
||||
erasure::Session,
|
||||
use {
|
||||
crate::{
|
||||
blockstore::MAX_DATA_SHREDS_PER_SLOT,
|
||||
entry::{create_ticks, Entry},
|
||||
erasure::Session,
|
||||
},
|
||||
bincode::config::Options,
|
||||
core::cell::RefCell,
|
||||
rayon::{
|
||||
iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator},
|
||||
slice::ParallelSlice,
|
||||
ThreadPool,
|
||||
},
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_measure::measure::Measure,
|
||||
solana_perf::packet::{limited_deserialize, Packet},
|
||||
solana_rayon_threadlimit::get_thread_count,
|
||||
solana_runtime::bank::Bank,
|
||||
solana_sdk::{
|
||||
clock::Slot,
|
||||
feature_set,
|
||||
hash::hashv,
|
||||
hash::Hash,
|
||||
packet::PACKET_DATA_SIZE,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signature, Signer},
|
||||
},
|
||||
std::{convert::TryInto, mem::size_of, ops::Deref, sync::Arc},
|
||||
thiserror::Error,
|
||||
};
|
||||
use bincode::config::Options;
|
||||
use core::cell::RefCell;
|
||||
use rayon::{
|
||||
iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator},
|
||||
slice::ParallelSlice,
|
||||
ThreadPool,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_perf::packet::{limited_deserialize, Packet};
|
||||
use solana_rayon_threadlimit::get_thread_count;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
feature_set,
|
||||
hash::hashv,
|
||||
hash::Hash,
|
||||
packet::PACKET_DATA_SIZE,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signature, Signer},
|
||||
};
|
||||
use std::{mem::size_of, ops::Deref, sync::Arc};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct ProcessShredsStats {
|
||||
@@ -469,23 +471,19 @@ impl Shred {
|
||||
self.common_header.signature
|
||||
}
|
||||
|
||||
pub fn seed(&self, leader_pubkey: Option<Pubkey>, root_bank: &Bank) -> [u8; 32] {
|
||||
if let Some(leader_pubkey) = leader_pubkey {
|
||||
if enable_deterministic_seed(self.slot(), root_bank) {
|
||||
let h = hashv(&[
|
||||
&self.slot().to_le_bytes(),
|
||||
&self.index().to_le_bytes(),
|
||||
&leader_pubkey.to_bytes(),
|
||||
]);
|
||||
return h.to_bytes();
|
||||
}
|
||||
pub fn seed(&self, leader_pubkey: Pubkey, root_bank: &Bank) -> [u8; 32] {
|
||||
if enable_deterministic_seed(self.slot(), root_bank) {
|
||||
hashv(&[
|
||||
&self.slot().to_le_bytes(),
|
||||
&self.index().to_le_bytes(),
|
||||
&leader_pubkey.to_bytes(),
|
||||
])
|
||||
.to_bytes()
|
||||
} else {
|
||||
let signature = self.common_header.signature.as_ref();
|
||||
let offset = signature.len().checked_sub(32).unwrap();
|
||||
signature[offset..].try_into().unwrap()
|
||||
}
|
||||
|
||||
let mut seed = [0; 32];
|
||||
let seed_len = seed.len();
|
||||
let sig = self.common_header.signature.as_ref();
|
||||
seed[0..seed_len].copy_from_slice(&sig[(sig.len() - seed_len)..]);
|
||||
seed
|
||||
}
|
||||
|
||||
pub fn is_data(&self) -> bool {
|
||||
|
Reference in New Issue
Block a user