removes id from push_lowest_slot args (#18645)

push_lowest_slot cannot sign the new crds-value unless the id (pubkey)
argument passed-in is the same pubkey as in ClusterInfo::keypair(), in
which case the id argument is redundant:
https://github.com/solana-labs/solana/blob/bb41cf346/gossip/src/cluster_info.rs#L824-L845

Additionally, the lookup is done with self.id(), but insert is done with
the id argument, which is logically a bug.
This commit is contained in:
behzad nouri
2021-07-13 22:32:59 +00:00
committed by GitHub
parent 350baece21
commit c90af3cd63
3 changed files with 26 additions and 25 deletions

View File

@ -821,20 +821,20 @@ impl ClusterInfo {
)
}
pub fn push_lowest_slot(&self, id: Pubkey, min: Slot) {
let now = timestamp();
let last = self
.gossip
.read()
.unwrap()
.crds
.get(&CrdsValueLabel::LowestSlot(self.id()))
.and_then(|x| x.value.lowest_slot())
.map(|x| x.lowest)
.unwrap_or(0);
pub fn push_lowest_slot(&self, min: Slot) {
let self_pubkey = self.id();
let last = {
let gossip = self.gossip.read().unwrap();
gossip
.crds
.get_lowest_slot(self_pubkey)
.map(|x| x.lowest)
.unwrap_or_default()
};
if min > last {
let now = timestamp();
let entry = CrdsValue::new_signed(
CrdsData::LowestSlot(0, LowestSlot::new(id, min, now)),
CrdsData::LowestSlot(0, LowestSlot::new(self_pubkey, min, now)),
&self.keypair(),
);
self.local_message_pending_push_queue

View File

@ -83,7 +83,7 @@ impl Signable for CrdsValue {
pub enum CrdsData {
ContactInfo(ContactInfo),
Vote(VoteIndex, Vote),
LowestSlot(u8, LowestSlot),
LowestSlot(/*DEPRECATED:*/ u8, LowestSlot),
SnapshotHashes(SnapshotHash),
AccountsHashes(SnapshotHash),
EpochSlots(EpochSlotsIndex, EpochSlots),