mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
grandpa-rpc: use FinalityProofProvider to check finality for rpc (#6215)
* grandpa-rpc: use FinalityProofProvider to check finality for rpc * grandpa-rpc: minor tidy * grandpa-rpc: remove dyn FinalityProofProvider * grandpa-rpc: remove unused dependencies * node: move finality_proof_provider setup * grandpa-rpc: print error reported by finality_proof_provider * grandpa-rpc: add note about unnecessary encode/decode * grandpa-rpc: dont encode/decode and use correct hash * grandpa-rpc: set_id is optional * grandpa-rpc: create test for prove_finality * grandpa-rpc: set visibility back to how it was * grandpa-rpc: remove unused dependency * grandpa-rpc: minor tidy * grandpa: doc strings * grandpa-rpc: rename to prove_finality * grandpa-rpc: use current set id if none is provided * grandpa-rpc: remove unnecessary check in test * node: group finality_proof_provider in rpc_setup * grandpa: make prove_finality concrete in FinalityProofProvider * grandpa-rpc: wrap finality output in struct and store as Bytes * grandpa-rpc: exhaustive error codes and wrap * grandpa-rpc: let prove_finality take a range instead of a starting point * grandpa-rpc: fix test for changed API * grandpa-rpc: fix line length * grandpa: fix reviewer nits * node/rpc: fix reviewer comments
This commit is contained in:
@@ -58,7 +58,10 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
||||
grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
sc_consensus_babe::BabeLink<Block>,
|
||||
),
|
||||
grandpa::SharedVoterState,
|
||||
(
|
||||
grandpa::SharedVoterState,
|
||||
Arc<GrandpaFinalityProofProvider<FullBackend, Block>>,
|
||||
),
|
||||
)
|
||||
>, ServiceError> {
|
||||
let (client, backend, keystore, task_manager) =
|
||||
@@ -108,8 +111,10 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
||||
let justification_stream = grandpa_link.justification_stream();
|
||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
||||
let shared_voter_state = grandpa::SharedVoterState::empty();
|
||||
let finality_proof_provider =
|
||||
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
|
||||
|
||||
let rpc_setup = shared_voter_state.clone();
|
||||
let rpc_setup = (shared_voter_state.clone(), finality_proof_provider.clone());
|
||||
|
||||
let babe_config = babe_link.config().clone();
|
||||
let shared_epoch_changes = babe_link.epoch_changes().clone();
|
||||
@@ -135,6 +140,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
||||
shared_authority_set: shared_authority_set.clone(),
|
||||
justification_stream: justification_stream.clone(),
|
||||
subscription_executor,
|
||||
finality_provider: finality_proof_provider.clone(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -174,8 +180,7 @@ pub fn new_full_base(
|
||||
other: (rpc_extensions_builder, import_setup, rpc_setup),
|
||||
} = new_partial(&config)?;
|
||||
|
||||
let finality_proof_provider =
|
||||
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
|
||||
let (shared_voter_state, finality_proof_provider) = rpc_setup;
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
@@ -220,7 +225,6 @@ pub fn new_full_base(
|
||||
})?;
|
||||
|
||||
let (block_import, grandpa_link, babe_link) = import_setup;
|
||||
let shared_voter_state = rpc_setup;
|
||||
|
||||
(with_startup_data)(&block_import, &babe_link);
|
||||
|
||||
|
||||
@@ -30,5 +30,6 @@ sp-block-builder = { version = "2.0.0-rc6", path = "../../../primitives/block-bu
|
||||
sp-blockchain = { version = "2.0.0-rc6", path = "../../../primitives/blockchain" }
|
||||
sp-consensus = { version = "0.8.0-rc6", path = "../../../primitives/consensus/common" }
|
||||
sp-consensus-babe = { version = "0.8.0-rc6", path = "../../../primitives/consensus/babe" }
|
||||
sp-runtime = { version = "2.0.0-rc6", path = "../../../primitives/runtime" }
|
||||
sp-transaction-pool = { version = "2.0.0-rc6", path = "../../../primitives/transaction-pool" }
|
||||
substrate-frame-rpc-system = { version = "2.0.0-rc6", path = "../../../utils/frame/rpc/system" }
|
||||
|
||||
@@ -36,7 +36,9 @@ use node_primitives::{Block, BlockNumber, AccountId, Index, Balance, Hash};
|
||||
use sc_consensus_babe::{Config, Epoch};
|
||||
use sc_consensus_babe_rpc::BabeRpcHandler;
|
||||
use sc_consensus_epochs::SharedEpochChanges;
|
||||
use sc_finality_grandpa::{SharedVoterState, SharedAuthoritySet, GrandpaJustificationStream};
|
||||
use sc_finality_grandpa::{
|
||||
SharedVoterState, SharedAuthoritySet, FinalityProofProvider, GrandpaJustificationStream
|
||||
};
|
||||
use sc_finality_grandpa_rpc::GrandpaRpcHandler;
|
||||
use sc_keystore::KeyStorePtr;
|
||||
pub use sc_rpc_api::DenyUnsafe;
|
||||
@@ -71,7 +73,7 @@ pub struct BabeDeps {
|
||||
}
|
||||
|
||||
/// Extra dependencies for GRANDPA
|
||||
pub struct GrandpaDeps {
|
||||
pub struct GrandpaDeps<B> {
|
||||
/// Voting round info.
|
||||
pub shared_voter_state: SharedVoterState,
|
||||
/// Authority set info.
|
||||
@@ -80,10 +82,12 @@ pub struct GrandpaDeps {
|
||||
pub justification_stream: GrandpaJustificationStream<Block>,
|
||||
/// Executor to drive the subscription manager in the Grandpa RPC handler.
|
||||
pub subscription_executor: SubscriptionTaskExecutor,
|
||||
/// Finality proof provider.
|
||||
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
|
||||
}
|
||||
|
||||
/// Full client dependencies.
|
||||
pub struct FullDeps<C, P, SC> {
|
||||
pub struct FullDeps<C, P, SC, B> {
|
||||
/// The client instance to use.
|
||||
pub client: Arc<C>,
|
||||
/// Transaction pool instance.
|
||||
@@ -95,15 +99,15 @@ pub struct FullDeps<C, P, SC> {
|
||||
/// BABE specific dependencies.
|
||||
pub babe: BabeDeps,
|
||||
/// GRANDPA specific dependencies.
|
||||
pub grandpa: GrandpaDeps,
|
||||
pub grandpa: GrandpaDeps<B>,
|
||||
}
|
||||
|
||||
/// A IO handler that uses all Full RPC extensions.
|
||||
pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
|
||||
|
||||
/// Instantiate all Full RPC extensions.
|
||||
pub fn create_full<C, P, SC>(
|
||||
deps: FullDeps<C, P, SC>,
|
||||
pub fn create_full<C, P, SC, B>(
|
||||
deps: FullDeps<C, P, SC, B>,
|
||||
) -> jsonrpc_core::IoHandler<sc_rpc_api::Metadata> where
|
||||
C: ProvideRuntimeApi<Block>,
|
||||
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError> + 'static,
|
||||
@@ -115,6 +119,8 @@ pub fn create_full<C, P, SC>(
|
||||
C::Api: BlockBuilder<Block>,
|
||||
P: TransactionPool + 'static,
|
||||
SC: SelectChain<Block> +'static,
|
||||
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
|
||||
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
|
||||
{
|
||||
use substrate_frame_rpc_system::{FullSystem, SystemApi};
|
||||
use pallet_contracts_rpc::{Contracts, ContractsApi};
|
||||
@@ -140,6 +146,7 @@ pub fn create_full<C, P, SC>(
|
||||
shared_authority_set,
|
||||
justification_stream,
|
||||
subscription_executor,
|
||||
finality_provider,
|
||||
} = grandpa;
|
||||
|
||||
io.extend_with(
|
||||
@@ -173,6 +180,7 @@ pub fn create_full<C, P, SC>(
|
||||
shared_voter_state,
|
||||
justification_stream,
|
||||
subscription_executor,
|
||||
finality_provider,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user