Unverified Commit 9190eb64 authored by Ashley's avatar Ashley Committed by GitHub
Browse files

Companion PR for 'Add missing fields to the light sync state #7225' (#1801)

* Add sync_state_items

* Add SyncStateRpc

* "Update Substrate"

Co-authored-by: parity-processbot <>
parent d5996479
Pipeline #110667 passed with stages
in 25 minutes and 6 seconds
This diff is collapsed.
......@@ -24,9 +24,6 @@ pub enum Subcommand {
/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),
/// Build a chain specification with a light client sync state.
BuildSyncSpec(sc_cli::BuildSyncSpecCmd),
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
......
......@@ -18,7 +18,6 @@ use log::info;
use service::{IdentifyVariant, self};
use sc_cli::{SubstrateCli, Result, RuntimeVersion, Role};
use crate::cli::{Cli, Subcommand};
use std::sync::Arc;
fn get_exec_name() -> Option<String> {
std::env::current_exe()
......@@ -158,43 +157,6 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
},
Some(Subcommand::BuildSyncSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);
let authority_discovery_disabled = cli.run.authority_discovery_disabled;
let grandpa_pause = if cli.run.grandpa_pause.is_empty() {
None
} else {
Some((cli.run.grandpa_pause[0], cli.run.grandpa_pause[1]))
};
if chain_spec.is_kusama() {
info!("----------------------------");
info!("This chain is not in any way");
info!(" endorsed by the ");
info!(" KUSAMA FOUNDATION ");
info!("----------------------------");
}
runner.async_run(|config| {
let chain_spec = config.chain_spec.cloned_box();
let network_config = config.network.clone();
let service::NewFull {
task_manager,
client,
network_status_sinks,
..
} = service::build_full(
config, authority_discovery_disabled, grandpa_pause,
)?;
let client = Arc::new(client);
Ok((cmd.run(chain_spec, network_config, client, network_status_sinks), task_manager))
})
},
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
......
......@@ -234,12 +234,14 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
let keystore = keystore_container.sync_keystore();
let transaction_pool = transaction_pool.clone();
let select_chain = select_chain.clone();
let chain_spec = config.chain_spec.cloned_box();
move |deny_unsafe, subscription_executor| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
select_chain: select_chain.clone(),
chain_spec: chain_spec.cloned_box(),
deny_unsafe,
babe: polkadot_rpc::BabeDeps {
babe_config: babe_config.clone(),
......
......@@ -14,6 +14,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master"}
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/substrate", branch = "master"}
......@@ -21,6 +22,7 @@ sc-consensus-epochs = { git = "https://github.com/paritytech/substrate", branch
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master"}
sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "master"}
txpool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master" }
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
......
......@@ -28,9 +28,11 @@ use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
use sp_consensus::SelectChain;
use sp_consensus_babe::BabeApi;
use sp_keystore::SyncCryptoStorePtr;
use sc_client_api::AuxStore;
use sc_client_api::light::{Fetcher, RemoteBlockchain};
use sc_consensus_babe::Epoch;
use sc_finality_grandpa::FinalityProofProvider;
use sc_sync_state_rpc::{SyncStateRpcApi, SyncStateRpcHandler};
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
/// A type representing all RPC extensions.
......@@ -80,6 +82,8 @@ pub struct FullDeps<C, P, SC, B> {
pub pool: Arc<P>,
/// The SelectChain Strategy
pub select_chain: SC,
/// A copy of the chain spec.
pub chain_spec: Box<dyn sc_chain_spec::ChainSpec>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// BABE specific dependencies.
......@@ -90,9 +94,8 @@ pub struct FullDeps<C, P, SC, B> {
/// Instantiate all RPC extensions.
pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError>,
C: Send + Sync + 'static,
C: ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore +
HeaderMetadata<Block, Error=BlockChainError> + Send + Sync + 'static,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>,
......@@ -112,6 +115,7 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
client,
pool,
select_chain,
chain_spec,
deny_unsafe,
babe,
grandpa,
......@@ -138,8 +142,8 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
io.extend_with(
sc_consensus_babe_rpc::BabeApi::to_delegate(
BabeRpcHandler::new(
client,
shared_epoch_changes,
client.clone(),
shared_epoch_changes.clone(),
keystore,
babe_config,
select_chain,
......@@ -149,13 +153,22 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
);
io.extend_with(
GrandpaApi::to_delegate(GrandpaRpcHandler::new(
shared_authority_set,
shared_authority_set.clone(),
shared_voter_state,
justification_stream,
subscription_executor,
finality_provider,
))
);
io.extend_with(
SyncStateRpcApi::to_delegate(SyncStateRpcHandler::new(
chain_spec,
client,
shared_authority_set,
shared_epoch_changes,
deny_unsafe,
))
);
io
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment