Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix noting rounds for non-authorities (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoerr authored Jul 14, 2021
1 parent 3f5de10 commit 40f23ab
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions client/beefy/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use codec::{Decode, Encode};
use log::{debug, trace};
use parking_lot::RwLock;
use std::collections::BTreeMap;

use sc_network::PeerId;
use sc_network_gossip::{MessageIntent, ValidationResult, Validator, ValidatorContext};

use sp_core::hashing::twox_64;
use sp_runtime::traits::{Block, Hash, Header, NumberFor};

use codec::{Decode, Encode};
use log::{debug, trace};
use parking_lot::RwLock;

use beefy_primitives::{
crypto::{Public, Signature},
MmrRootHash, VoteMessage,
Expand Down Expand Up @@ -103,8 +103,21 @@ where
known_votes.get_mut(round).map(|known| known.insert(hash));
}

// Note that we will always keep the most recent unseen round alive.
//
// This is a preliminary fix and the detailed description why we are
// doing this can be found as part of the issue below
//
// https://github.com/paritytech/grandpa-bridge-gadget/issues/237
//
fn is_live(known_votes: &KnownVotes<B>, round: &NumberFor<B>) -> bool {
known_votes.contains_key(round)
let unseen_round = if let Some(max_known_round) = known_votes.keys().last() {
round > max_known_round
} else {
known_votes.is_empty()
};

known_votes.contains_key(round) || unseen_round
}

fn is_known(known_votes: &KnownVotes<B>, round: &NumberFor<B>, hash: &MessageHash) -> bool {
Expand Down

0 comments on commit 40f23ab

Please sign in to comment.