Decouples light-sync state from chain spec (#9491)

* Decouples light-sync state from chain spec

This decouples the light-sync state from chain spec. First, the
light-sync state currently only works with BABE+Grandpa, so not
all *Substrate* based chains can use this feature. The next problem was
also that this pulled the `sc-consensus-babe` and `sc-finality-grandpa`
crate into `sc-chain-spec`.

If a chain now wants to support the light-sync state, it needs to add
the `LightSyncStateExtension` to the chain spec as an extension. This is
documented in the crate level docs of `sc-sync-state-rpc`. If this
extension is not available, `SyncStateRpc` fails at initialization.

* Fix compilation for browser

* Fmt
This commit is contained in:
Bastian Köcher
2021-08-04 15:38:14 +02:00
committed by GitHub
parent 2f4db88b41
commit 6e4d30e8ad
17 changed files with 211 additions and 149 deletions
+2
View File
@@ -57,6 +57,8 @@ pub struct Extensions {
pub fork_blocks: sc_client_api::ForkBlocks<Block>,
/// Known bad block hashes.
pub bad_blocks: sc_client_api::BadBlocks<Block>,
/// The light sync state extension used by the sync-state rpc.
pub light_sync_state: sc_sync_state_rpc::LightSyncStateExtension,
}
/// Specialized `ChainSpec`.
+5 -2
View File
@@ -49,7 +49,10 @@ pub fn new_partial(
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
impl Fn(node_rpc::DenyUnsafe, sc_rpc::SubscriptionTaskExecutor) -> node_rpc::IoHandler,
impl Fn(
node_rpc::DenyUnsafe,
sc_rpc::SubscriptionTaskExecutor,
) -> Result<node_rpc::IoHandler, sc_service::Error>,
(
sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
@@ -180,7 +183,7 @@ pub fn new_partial(
},
};
node_rpc::create_full(deps)
node_rpc::create_full(deps).map_err(Into::into)
};
(rpc_extensions_builder, rpc_setup)