Skip to content

Commit

Permalink
Expose GRANDPA RPC API from Millau node (paritytech#408)
Browse files Browse the repository at this point in the history
* expose GRANDPA RPC API from Millau node

* fmt
  • Loading branch information
svyatonik authored and serban300 committed Apr 10, 2024
1 parent 7460e1f commit a6dfe5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions bridges/bin/millau/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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"
Expand Down
17 changes: 16 additions & 1 deletion bridges/bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ 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_inherents::InherentDataProviders;
Expand Down Expand Up @@ -160,19 +161,33 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();

let rpc_extensions_builder = {
use sc_finality_grandpa_rpc::GrandpaApi;
use sc_rpc::DenyUnsafe;
use substrate_frame_rpc_system::{FullSystem, SystemApi};

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
})
Expand Down

0 comments on commit a6dfe5b

Please sign in to comment.