Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
Expand All @@ -58,13 +59,15 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.gi
sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
Expand Down Expand Up @@ -136,4 +139,4 @@ panic = "unwind"
[profile.production]
inherits = "release"
lto = true
codegen-units = 1
codegen-units = 1
3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-babe = { workspace = true }
sc-consensus-babe-rpc = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-consensus-grandpa-rpc = { workspace = true }
sc-executor = { workspace = true }
Expand All @@ -35,11 +36,13 @@ sc-service = { workspace = true }
sc-telemetry = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sp-consensus = { workspace = true }
sp-consensus-babe = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-io = { workspace = true }
sp-keyring = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
sp-timestamp = { workspace = true }
sp-transaction-storage-proof = { workspace = true }
Expand Down
31 changes: 26 additions & 5 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::Arc;

use jsonrpsee::RpcModule;
use polkadot_bulletin_chain_runtime::{opaque::Block, AccountId, BlockNumber, Hash, Nonce};
use sc_consensus_babe::{BabeApi, BabeWorkerHandle};
use sc_consensus_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
};
Expand All @@ -18,17 +19,31 @@ use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus::SelectChain;
use sp_keystore::KeystorePtr;

/// Full client dependencies.
pub struct FullDeps<C, P, B> {
pub struct FullDeps<C, P, SC, B> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// The chain selection strategy.
pub select_chain: SC,
/// BABE RPC dependencies.
pub babe: BabeDeps,
/// GRANDPA RPC dependencies.
pub grandpa: GrandpaDeps<B>,
}

/// BABE RPC dependencies.
pub struct BabeDeps {
/// A handle to the BABE worker for issuing requests.
pub babe_worker_handle: BabeWorkerHandle<Block>,
/// The keystore that manages the keys of the node.
pub keystore: KeystorePtr,
}

/// GRANDPA RPC dependncies.
pub struct GrandpaDeps<B> {
/// Subscription task executor.
Expand All @@ -44,24 +59,30 @@ pub struct GrandpaDeps<B> {
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P, B>(
deps: FullDeps<C, P, B>,
pub fn create_full<C, P, SC, B>(
deps: FullDeps<C, P, SC, B>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
C: Send + Sync + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: BlockBuilder<Block>,
C::Api: BabeApi<Block>,
P: TransactionPool + 'static,
SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
{
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcModule::new(());
let FullDeps { client, pool, grandpa } = deps;
let FullDeps { client, pool, select_chain, babe, grandpa } = deps;
let BabeDeps { babe_worker_handle, keystore } = babe;

module.merge(System::new(client, pool).into_rpc())?;
module.merge(System::new(client.clone(), pool).into_rpc())?;
module
.merge(Babe::new(client, babe_worker_handle.clone(), keystore, select_chain).into_rpc())?;
module.merge(
Grandpa::new(
grandpa.subscription_executor,
Expand Down
15 changes: 10 additions & 5 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub fn new_partial(
>,
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
sc_consensus_babe::BabeLink<Block>,
sc_consensus_babe::BabeWorkerHandle<Block>,
Option<Telemetry>,
),
>,
Expand Down Expand Up @@ -128,9 +129,6 @@ pub fn new_partial(
telemetry: telemetry.as_ref().map(|x| x.handle()),
})?;

// TODO Wire up to RPC
std::mem::forget(babe_worker_handle);

Ok(sc_service::PartialComponents {
client,
backend,
Expand All @@ -139,7 +137,7 @@ pub fn new_partial(
keystore_container,
select_chain,
transaction_pool,
other: (block_import, grandpa_link, babe_link, telemetry),
other: (block_import, grandpa_link, babe_link, babe_worker_handle, telemetry),
})
}

Expand All @@ -157,7 +155,7 @@ pub fn new_full<
keystore_container,
select_chain,
transaction_pool,
other: (block_import, grandpa_link, babe_link, mut telemetry),
other: (block_import, grandpa_link, babe_link, babe_worker_handle, mut telemetry),
} = new_partial(&config)?;

let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, N>::new(
Expand Down Expand Up @@ -226,6 +224,8 @@ pub fn new_full<
let rpc_extensions_builder = {
let client = client.clone();
let pool = transaction_pool.clone();
let keystore = keystore_container.keystore();
let select_chain = select_chain.clone();

let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
Expand All @@ -240,6 +240,11 @@ pub fn new_full<
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
select_chain: select_chain.clone(),
babe: crate::rpc::BabeDeps {
babe_worker_handle: babe_worker_handle.clone(),
keystore: keystore.clone(),
},
grandpa: crate::rpc::GrandpaDeps {
subscription_executor,
shared_authority_set: shared_authority_set.clone(),
Expand Down