mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
sc-consensus-beefy: improve gossip logic (#1852)
- Remove cached messages used for deduplication in `GossipValidator` since they're already deduplicated in upper layer `NetworkGossip`. - Add cache for "justified rounds" to quickly discard any further (even if potentially different) justifications at the gossip level, once a valid one (for a respective round) is submitted to the worker. - Add short-circuit in worker `finalize()` method to not attempt to finalize same block multiple times (for example when we get justifications for same block from multiple components like block-import, gossip or on-demand). - Change a test which had A LOT of latency in syncing blocks for some weird reason and would only run after ~150seconds. It now runs instantly. Fixes https://github.com/paritytech/polkadot-sdk/issues/1728
This commit is contained in:
@@ -604,6 +604,11 @@ where
|
||||
VersionedFinalityProof::V1(ref sc) => sc.commitment.block_number,
|
||||
};
|
||||
|
||||
if block_num <= self.persisted_state.voting_oracle.best_beefy_block {
|
||||
// we've already finalized this round before, short-circuit.
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
// Finalize inner round and update voting_oracle state.
|
||||
self.persisted_state.voting_oracle.finalize(block_num)?;
|
||||
|
||||
@@ -629,7 +634,7 @@ where
|
||||
self.backend
|
||||
.append_justification(hash, (BEEFY_ENGINE_ID, finality_proof.encode()))
|
||||
}) {
|
||||
error!(
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"🥩 Error {:?} on appending justification: {:?}", e, finality_proof
|
||||
);
|
||||
@@ -648,7 +653,7 @@ where
|
||||
}
|
||||
|
||||
/// Handle previously buffered justifications, that now land in the voting interval.
|
||||
fn try_pending_justififactions(&mut self) -> Result<(), Error> {
|
||||
fn try_pending_justifications(&mut self) -> Result<(), Error> {
|
||||
// Interval of blocks for which we can process justifications and votes right now.
|
||||
let (start, end) = self.voting_oracle().accepted_interval()?;
|
||||
// Process pending justifications.
|
||||
@@ -782,7 +787,7 @@ where
|
||||
|
||||
fn process_new_state(&mut self) {
|
||||
// Handle pending justifications and/or votes for now GRANDPA finalized blocks.
|
||||
if let Err(err) = self.try_pending_justififactions() {
|
||||
if let Err(err) = self.try_pending_justifications() {
|
||||
debug!(target: LOG_TARGET, "🥩 {}", err);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user