From 03f4b32a5e80e87a4e3088533d16223213eb07a4 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Fri, 6 Nov 2020 12:19:31 +0300 Subject: [PATCH] enable GrandpaRpcApi for Rialto (#486) --- bridges/bin/millau/node/src/service.rs | 3 +-- bridges/bin/rialto/node/Cargo.toml | 1 + bridges/bin/rialto/node/src/service.rs | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index 0a6b5d8b849e6..086ef7609cc1e 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -35,7 +35,6 @@ use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_executor::native_executor_instance; pub use sc_executor::NativeExecutor; use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState}; -use sc_finality_grandpa_rpc::GrandpaRpcHandler; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_core::storage::StorageKey; @@ -193,7 +192,7 @@ pub fn new_full(config: Configuration) -> Result { } use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler}; - use sc_finality_grandpa_rpc::GrandpaApi; + use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler}; use sc_rpc::DenyUnsafe; use substrate_frame_rpc_system::{FullSystem, SystemApi}; diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml index a0394f34af06b..dd905a53a9c27 100644 --- a/bridges/bin/rialto/node/Cargo.toml +++ b/bridges/bin/rialto/node/Cargo.toml @@ -31,6 +31,7 @@ sc-consensus = "0.8" sc-consensus-aura = "0.8" sc-executor = "0.8" sc-finality-grandpa = "0.8" +sc-finality-grandpa-rpc = "0.8" sc-service = "0.8" sc-rpc = "2.0" sc-transaction-pool = "2.0" diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index 07a49a26858ac..1d7dfdffefbd3 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -192,19 +192,33 @@ pub fn new_full(config: Configuration) -> Result { } use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler}; + use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler}; use sc_rpc::DenyUnsafe; use substrate_frame_rpc_system::{FullSystem, SystemApi}; let backend = backend.clone(); let client = client.clone(); let pool = transaction_pool.clone(); - Box::new(move |_, _| { + let justification_stream = grandpa_link.justification_stream(); + let shared_authority_set = grandpa_link.shared_authority_set().clone(); + let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone()); + + Box::new(move |_, subscription_executor| { + let shared_voter_state = SharedVoterState::empty(); + let mut io = jsonrpc_core::IoHandler::default(); io.extend_with(SystemApi::to_delegate(FullSystem::new( client.clone(), pool.clone(), DenyUnsafe::No, ))); + io.extend_with(GrandpaApi::to_delegate(GrandpaRpcHandler::new( + shared_authority_set.clone(), + shared_voter_state, + justification_stream.clone(), + subscription_executor, + finality_proof_provider.clone(), + ))); io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new( client.clone(), backend.clone(),