mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 11:51:12 +00:00
Fetch Babe configuration from runtime state (#11760)
* Fetch babe config data from runtime state * Some renaming * More renaming * Final nits * Fix tests and benches * Rename to in BabeConfiguration * Remove duplicate babe parameter description Already specified over the 'PRIMARY_PROBABILITY' constant value * trigger pipeline * trigger pipeline
This commit is contained in:
@@ -199,7 +199,7 @@ pub fn new_partial(
|
||||
let justification_import = grandpa_block_import.clone();
|
||||
|
||||
let (block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get(&*client)?,
|
||||
sc_consensus_babe::configuration(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
)?;
|
||||
@@ -682,10 +682,7 @@ mod tests {
|
||||
.epoch_changes()
|
||||
.shared_data()
|
||||
.epoch_data(&epoch_descriptor, |slot| {
|
||||
sc_consensus_babe::Epoch::genesis(
|
||||
babe_link.config().genesis_config(),
|
||||
slot,
|
||||
)
|
||||
sc_consensus_babe::Epoch::genesis(babe_link.config(), slot)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ use std::sync::Arc;
|
||||
use jsonrpsee::RpcModule;
|
||||
use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index};
|
||||
use sc_client_api::AuxStore;
|
||||
use sc_consensus_babe::{Config, Epoch};
|
||||
use sc_consensus_babe::{BabeConfiguration, Epoch};
|
||||
use sc_consensus_epochs::SharedEpochChanges;
|
||||
use sc_finality_grandpa::{
|
||||
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
|
||||
@@ -54,7 +54,7 @@ use sp_keystore::SyncCryptoStorePtr;
|
||||
/// Extra dependencies for BABE.
|
||||
pub struct BabeDeps {
|
||||
/// BABE protocol config.
|
||||
pub babe_config: Config,
|
||||
pub babe_config: BabeConfiguration,
|
||||
/// BABE pending epoch changes.
|
||||
pub shared_epoch_changes: SharedEpochChanges<Block, Epoch>,
|
||||
/// The keystore that manages the keys of the node.
|
||||
|
||||
@@ -1859,19 +1859,15 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl sp_consensus_babe::BabeApi<Block> for Runtime {
|
||||
fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration {
|
||||
// The choice of `c` parameter (where `1 - c` represents the
|
||||
// probability of a slot being empty), is done in accordance to the
|
||||
// slot duration and expected target block time, for safely
|
||||
// resisting network delays of maximum two seconds.
|
||||
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
||||
sp_consensus_babe::BabeGenesisConfiguration {
|
||||
fn configuration() -> sp_consensus_babe::BabeConfiguration {
|
||||
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
|
||||
sp_consensus_babe::BabeConfiguration {
|
||||
slot_duration: Babe::slot_duration(),
|
||||
epoch_length: EpochDuration::get(),
|
||||
c: BABE_GENESIS_EPOCH_CONFIG.c,
|
||||
genesis_authorities: Babe::authorities().to_vec(),
|
||||
c: epoch_config.c,
|
||||
authorities: Babe::authorities().to_vec(),
|
||||
randomness: Babe::randomness(),
|
||||
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
|
||||
allowed_slots: epoch_config.allowed_slots,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user