grandpa: avoid importing unnecessary justifications (#14423)

* grandpa: avoid importing unnecessary justifications

* grandpa: make justification_import_period configurable

* grandpa: keep the first justification

* grandpa: add test for justification import period

* grandpa: fix test
This commit is contained in:
André Silva
2023-07-17 18:38:34 +01:00
committed by GitHub
parent 58bbe568cb
commit c761d4c39e
8 changed files with 178 additions and 90 deletions
+6 -1
View File
@@ -54,6 +54,10 @@ type FullGrandpaBlockImport =
/// The transaction pool type defintion.
pub type TransactionPool = sc_transaction_pool::FullPool<Block, FullClient>;
/// The minimum period of blocks on which justifications will be
/// imported and generated.
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
/// Fetch the nonce of the given `account` from the chain state.
///
/// Note: Should only be used for tests.
@@ -193,6 +197,7 @@ pub fn new_partial(
let (grandpa_block_import, grandpa_link) = grandpa::block_import(
client.clone(),
GRANDPA_JUSTIFICATION_PERIOD,
&(client.clone() as Arc<_>),
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
@@ -524,7 +529,7 @@ pub fn new_full_base(
let grandpa_config = grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: std::time::Duration::from_millis(333),
justification_period: 512,
justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD,
name: Some(name),
observer_enabled: false,
keystore,