Cherry pick fix for freeze (#4459)

* check freeze before updating slot_hashes (#4448)

* check freeze before updating slot_hashes

* fixup

* add more information to dropped vote warning (#4449)

* add more information to dropped vote warning

* fixup
This commit is contained in:
Rob Walker
2019-05-28 19:35:54 -07:00
committed by Dan Albert
parent b9b541441b
commit b4adb1c266
2 changed files with 23 additions and 7 deletions

View File

@ -145,10 +145,22 @@ impl VoteState {
.iter()
.any(|(slot, hash)| vote.slot == *slot && vote.hash == *hash)
{
if log_enabled!(log::Level::Warn) {
for (slot, hash) in slot_hashes {
if vote.slot == *slot {
warn!(
"dropping vote {:?}, no matching slot/hash combination",
vote
"dropped vote {:?} matched slot {}, but not hash {:?}",
vote, *slot, *hash
);
}
if vote.hash == *hash {
warn!(
"dropped vote {:?} matched hash {:?}, but not slot {}",
vote, *hash, *slot,
);
}
}
}
return;
}

View File

@ -215,19 +215,23 @@ impl Bank {
self.store(&slot_hashes::id(), &account);
}
fn set_hash(&self) {
fn set_hash(&self) -> bool {
let mut hash = self.hash.write().unwrap();
if *hash == Hash::default() {
// freeze is a one-way trip, idempotent
*hash = self.hash_internal_state();
true
} else {
false
}
}
pub fn freeze(&self) {
self.set_hash();
if self.set_hash() {
self.update_slot_hashes();
}
}
pub fn epoch_schedule(&self) -> &EpochSchedule {
&self.epoch_schedule