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:
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user