Skip to content

Commit

Permalink
Save persisted state only when adding new session
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 committed Nov 17, 2023
1 parent 3ed2566 commit 51bac2f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions substrate/client/consensus/beefy/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ where
.filter(|genesis| *genesis == self.persisted_state.pallet_genesis)
.ok_or(Error::ConsensusReset)?;

let mut new_session_added = false;
if *header.number() > self.best_grandpa_block() {
// update best GRANDPA finalized block we have seen
self.persisted_state.set_best_grandpa(header.clone());
Expand All @@ -475,11 +476,14 @@ where
{
if let Some(new_validator_set) = find_authorities_change::<B>(&header) {
self.init_session_at(new_validator_set, *header.number());
new_session_added = true;
}
}

crate::aux_schema::write_voter_state(&*self.backend, &self.persisted_state)
.map_err(|e| Error::Backend(e.to_string()))?;
if new_session_added {
crate::aux_schema::write_voter_state(&*self.backend, &self.persisted_state)
.map_err(|e| Error::Backend(e.to_string()))?;
}

// Update gossip validator votes filter.
if let Err(e) = self
Expand Down

0 comments on commit 51bac2f

Please sign in to comment.