|
|
@@ -20,6 +20,7 @@ pub(crate) struct LastVotedForkSlotsAggregate {
|
|
|
slots_stake_map: HashMap<Slot, u64>,
|
|
|
active_peers: HashSet<Pubkey>,
|
|
|
slots_to_repair: HashSet<Slot>,
|
|
|
+ my_pubkey: Pubkey,
|
|
|
}
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
@@ -53,6 +54,7 @@ impl LastVotedForkSlotsAggregate {
|
|
|
slots_stake_map,
|
|
|
active_peers,
|
|
|
slots_to_repair: HashSet::new(),
|
|
|
+ my_pubkey: *my_pubkey,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -70,6 +72,9 @@ impl LastVotedForkSlotsAggregate {
|
|
|
record: &LastVotedForkSlotsRecord,
|
|
|
) -> Result<Option<LastVotedForkSlotsRecord>> {
|
|
|
let from = Pubkey::from_str(key_string)?;
|
|
|
+ if from == self.my_pubkey {
|
|
|
+ return Ok(None);
|
|
|
+ }
|
|
|
let last_voted_hash = Hash::from_str(&record.last_vote_bankhash)?;
|
|
|
let converted_record = RestartLastVotedForkSlots::new(
|
|
|
from,
|
|
|
@@ -88,6 +93,9 @@ impl LastVotedForkSlotsAggregate {
|
|
|
let total_stake = self.epoch_stakes.total_stake();
|
|
|
let threshold_stake = (total_stake as f64 * self.repair_threshold) as u64;
|
|
|
let from = &new_slots.from;
|
|
|
+ if from == &self.my_pubkey {
|
|
|
+ return None;
|
|
|
+ }
|
|
|
let sender_stake = Self::validator_stake(&self.epoch_stakes, from);
|
|
|
if sender_stake == 0 {
|
|
|
warn!(
|
|
|
@@ -354,6 +362,23 @@ mod tests {
|
|
|
Vec::from_iter(test_state.slots_aggregate.slots_to_repair_iter().cloned());
|
|
|
actual_slots.sort();
|
|
|
assert_eq!(actual_slots, vec![root_slot + 1]);
|
|
|
+
|
|
|
+ // test that message from my pubkey is ignored.
|
|
|
+ assert_eq!(
|
|
|
+ test_state.slots_aggregate.aggregate(
|
|
|
+ RestartLastVotedForkSlots::new(
|
|
|
+ test_state.validator_voting_keypairs[MY_INDEX]
|
|
|
+ .node_keypair
|
|
|
+ .pubkey(),
|
|
|
+ timestamp(),
|
|
|
+ &[root_slot + 1, root_slot + 4, root_slot + 5],
|
|
|
+ Hash::default(),
|
|
|
+ SHRED_VERSION,
|
|
|
+ )
|
|
|
+ .unwrap(),
|
|
|
+ ),
|
|
|
+ None,
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
@@ -446,6 +471,26 @@ mod tests {
|
|
|
);
|
|
|
// percentage doesn't change since the previous aggregate is ignored.
|
|
|
assert_eq!(test_state.slots_aggregate.active_percent(), 20.0);
|
|
|
+
|
|
|
+ // Record from my pubkey should be ignored.
|
|
|
+ assert_eq!(
|
|
|
+ test_state
|
|
|
+ .slots_aggregate
|
|
|
+ .aggregate_from_record(
|
|
|
+ &test_state.validator_voting_keypairs[MY_INDEX]
|
|
|
+ .node_keypair
|
|
|
+ .pubkey()
|
|
|
+ .to_string(),
|
|
|
+ &LastVotedForkSlotsRecord {
|
|
|
+ wallclock: timestamp(),
|
|
|
+ last_voted_fork_slots: vec![root_slot + 10, root_slot + 300],
|
|
|
+ last_vote_bankhash: Hash::new_unique().to_string(),
|
|
|
+ shred_version: SHRED_VERSION as u32,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .unwrap(),
|
|
|
+ None,
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
#[test]
|