* Add CrdsData::IncrementalSnapshotHashes (#20374)
(cherry picked from commit 4e3818e5c1
)
# Conflicts:
# gossip/src/cluster_info.rs
* removes backport merge conflicts
Co-authored-by: Brooks Prumo <brooks@solana.com>
Co-authored-by: behzad nouri <behzadnouri@gmail.com>
This commit is contained in:
@ -255,7 +255,7 @@ pub fn make_accounts_hashes_message(
|
|||||||
pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;
|
pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;
|
||||||
|
|
||||||
// TODO These messages should go through the gpu pipeline for spam filtering
|
// TODO These messages should go through the gpu pipeline for spam filtering
|
||||||
#[frozen_abi(digest = "3qq56sFGXGbNqr7qKq8x47t144ugdfv5adCkVJUMnMf3")]
|
#[frozen_abi(digest = "D2ebKKmm6EQ8JJjYc3xUpzpBTJguqgEzShhj9fiUcP6F")]
|
||||||
#[derive(Serialize, Deserialize, Debug, AbiEnumVisitor, AbiExample)]
|
#[derive(Serialize, Deserialize, Debug, AbiEnumVisitor, AbiExample)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub(crate) enum Protocol {
|
pub(crate) enum Protocol {
|
||||||
@ -372,7 +372,7 @@ fn retain_staked(values: &mut Vec<CrdsValue>, stakes: &HashMap<Pubkey, u64>) {
|
|||||||
// Unstaked nodes can still help repair.
|
// Unstaked nodes can still help repair.
|
||||||
CrdsData::EpochSlots(_, _) => true,
|
CrdsData::EpochSlots(_, _) => true,
|
||||||
// Unstaked nodes can still serve snapshots.
|
// Unstaked nodes can still serve snapshots.
|
||||||
CrdsData::SnapshotHashes(_) => true,
|
CrdsData::SnapshotHashes(_) | CrdsData::IncrementalSnapshotHashes(_) => true,
|
||||||
// Otherwise unstaked voting nodes will show up with no version in
|
// Otherwise unstaked voting nodes will show up with no version in
|
||||||
// the various dashboards.
|
// the various dashboards.
|
||||||
CrdsData::Version(_) => true,
|
CrdsData::Version(_) => true,
|
||||||
|
@ -91,6 +91,7 @@ pub enum CrdsData {
|
|||||||
Version(Version),
|
Version(Version),
|
||||||
NodeInstance(NodeInstance),
|
NodeInstance(NodeInstance),
|
||||||
DuplicateShred(DuplicateShredIndex, DuplicateShred),
|
DuplicateShred(DuplicateShredIndex, DuplicateShred),
|
||||||
|
IncrementalSnapshotHashes(IncrementalSnapshotHashes),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sanitize for CrdsData {
|
impl Sanitize for CrdsData {
|
||||||
@ -127,6 +128,7 @@ impl Sanitize for CrdsData {
|
|||||||
shred.sanitize()
|
shred.sanitize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CrdsData::IncrementalSnapshotHashes(val) => val.sanitize(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,6 +206,33 @@ impl SnapshotHash {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
|
||||||
|
pub struct IncrementalSnapshotHashes {
|
||||||
|
from: Pubkey,
|
||||||
|
base: (Slot, Hash),
|
||||||
|
hashes: Vec<(Slot, Hash)>,
|
||||||
|
wallclock: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Sanitize for IncrementalSnapshotHashes {
|
||||||
|
fn sanitize(&self) -> Result<(), SanitizeError> {
|
||||||
|
sanitize_wallclock(self.wallclock)?;
|
||||||
|
if self.base.0 >= MAX_SLOT {
|
||||||
|
return Err(SanitizeError::ValueOutOfBounds);
|
||||||
|
}
|
||||||
|
for (slot, _) in &self.hashes {
|
||||||
|
if *slot >= MAX_SLOT {
|
||||||
|
return Err(SanitizeError::ValueOutOfBounds);
|
||||||
|
}
|
||||||
|
if self.base.0 >= *slot {
|
||||||
|
return Err(SanitizeError::InvalidValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.from.sanitize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
|
||||||
pub struct LowestSlot {
|
pub struct LowestSlot {
|
||||||
pub from: Pubkey,
|
pub from: Pubkey,
|
||||||
@ -470,6 +499,7 @@ pub enum CrdsValueLabel {
|
|||||||
Version(Pubkey),
|
Version(Pubkey),
|
||||||
NodeInstance(Pubkey),
|
NodeInstance(Pubkey),
|
||||||
DuplicateShred(DuplicateShredIndex, Pubkey),
|
DuplicateShred(DuplicateShredIndex, Pubkey),
|
||||||
|
IncrementalSnapshotHashes(Pubkey),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for CrdsValueLabel {
|
impl fmt::Display for CrdsValueLabel {
|
||||||
@ -485,6 +515,9 @@ impl fmt::Display for CrdsValueLabel {
|
|||||||
CrdsValueLabel::Version(_) => write!(f, "Version({})", self.pubkey()),
|
CrdsValueLabel::Version(_) => write!(f, "Version({})", self.pubkey()),
|
||||||
CrdsValueLabel::NodeInstance(pk) => write!(f, "NodeInstance({})", pk),
|
CrdsValueLabel::NodeInstance(pk) => write!(f, "NodeInstance({})", pk),
|
||||||
CrdsValueLabel::DuplicateShred(ix, pk) => write!(f, "DuplicateShred({}, {})", ix, pk),
|
CrdsValueLabel::DuplicateShred(ix, pk) => write!(f, "DuplicateShred({}, {})", ix, pk),
|
||||||
|
CrdsValueLabel::IncrementalSnapshotHashes(_) => {
|
||||||
|
write!(f, "IncrementalSnapshotHashes({})", self.pubkey())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,6 +535,7 @@ impl CrdsValueLabel {
|
|||||||
CrdsValueLabel::Version(p) => *p,
|
CrdsValueLabel::Version(p) => *p,
|
||||||
CrdsValueLabel::NodeInstance(p) => *p,
|
CrdsValueLabel::NodeInstance(p) => *p,
|
||||||
CrdsValueLabel::DuplicateShred(_, p) => *p,
|
CrdsValueLabel::DuplicateShred(_, p) => *p,
|
||||||
|
CrdsValueLabel::IncrementalSnapshotHashes(p) => *p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,6 +584,7 @@ impl CrdsValue {
|
|||||||
CrdsData::Version(version) => version.wallclock,
|
CrdsData::Version(version) => version.wallclock,
|
||||||
CrdsData::NodeInstance(node) => node.wallclock,
|
CrdsData::NodeInstance(node) => node.wallclock,
|
||||||
CrdsData::DuplicateShred(_, shred) => shred.wallclock,
|
CrdsData::DuplicateShred(_, shred) => shred.wallclock,
|
||||||
|
CrdsData::IncrementalSnapshotHashes(hash) => hash.wallclock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn pubkey(&self) -> Pubkey {
|
pub fn pubkey(&self) -> Pubkey {
|
||||||
@ -564,6 +599,7 @@ impl CrdsValue {
|
|||||||
CrdsData::Version(version) => version.from,
|
CrdsData::Version(version) => version.from,
|
||||||
CrdsData::NodeInstance(node) => node.from,
|
CrdsData::NodeInstance(node) => node.from,
|
||||||
CrdsData::DuplicateShred(_, shred) => shred.from,
|
CrdsData::DuplicateShred(_, shred) => shred.from,
|
||||||
|
CrdsData::IncrementalSnapshotHashes(hash) => hash.from,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn label(&self) -> CrdsValueLabel {
|
pub fn label(&self) -> CrdsValueLabel {
|
||||||
@ -578,6 +614,9 @@ impl CrdsValue {
|
|||||||
CrdsData::Version(_) => CrdsValueLabel::Version(self.pubkey()),
|
CrdsData::Version(_) => CrdsValueLabel::Version(self.pubkey()),
|
||||||
CrdsData::NodeInstance(node) => CrdsValueLabel::NodeInstance(node.from),
|
CrdsData::NodeInstance(node) => CrdsValueLabel::NodeInstance(node.from),
|
||||||
CrdsData::DuplicateShred(ix, shred) => CrdsValueLabel::DuplicateShred(*ix, shred.from),
|
CrdsData::DuplicateShred(ix, shred) => CrdsValueLabel::DuplicateShred(*ix, shred.from),
|
||||||
|
CrdsData::IncrementalSnapshotHashes(_) => {
|
||||||
|
CrdsValueLabel::IncrementalSnapshotHashes(self.pubkey())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn contact_info(&self) -> Option<&ContactInfo> {
|
pub fn contact_info(&self) -> Option<&ContactInfo> {
|
||||||
|
Reference in New Issue
Block a user