Skip to content

Commit cd5647b

Browse files
authored
Merge branch 'main' into bko-cleanup
2 parents 4e8d6fe + c28412b commit cd5647b

File tree

5 files changed

+70
-13
lines changed

5 files changed

+70
-13
lines changed

Cargo.lock

Lines changed: 27 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1
4444
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4545
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4646
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
47+
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4748
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4849
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4950
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
@@ -58,13 +59,15 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.gi
5859
sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
5960
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6061
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
62+
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6163
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6264
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6365
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6466
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6567
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6668
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6769
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
70+
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6871
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6972
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
7073
sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
@@ -136,4 +139,4 @@ panic = "unwind"
136139
[profile.production]
137140
inherits = "release"
138141
lto = true
139-
codegen-units = 1
142+
codegen-units = 1

node/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sc-cli = { workspace = true }
2525
sc-client-api = { workspace = true }
2626
sc-consensus = { workspace = true }
2727
sc-consensus-babe = { workspace = true }
28+
sc-consensus-babe-rpc = { workspace = true }
2829
sc-consensus-grandpa = { workspace = true }
2930
sc-consensus-grandpa-rpc = { workspace = true }
3031
sc-executor = { workspace = true }
@@ -35,11 +36,13 @@ sc-service = { workspace = true }
3536
sc-telemetry = { workspace = true }
3637
sc-transaction-pool = { workspace = true }
3738
sc-transaction-pool-api = { workspace = true }
39+
sp-consensus = { workspace = true }
3840
sp-consensus-babe = { workspace = true }
3941
sp-core = { workspace = true }
4042
sp-inherents = { workspace = true }
4143
sp-io = { workspace = true }
4244
sp-keyring = { workspace = true }
45+
sp-keystore = { workspace = true }
4346
sp-runtime = { workspace = true }
4447
sp-timestamp = { workspace = true }
4548
sp-transaction-storage-proof = { workspace = true }

node/src/rpc.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::sync::Arc;
99

1010
use jsonrpsee::RpcModule;
1111
use polkadot_bulletin_chain_runtime::{opaque::Block, AccountId, BlockNumber, Hash, Nonce};
12+
use sc_consensus_babe::{BabeApi, BabeWorkerHandle};
1213
use sc_consensus_grandpa::{
1314
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
1415
};
@@ -18,17 +19,31 @@ use sc_transaction_pool_api::TransactionPool;
1819
use sp_api::ProvideRuntimeApi;
1920
use sp_block_builder::BlockBuilder;
2021
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
22+
use sp_consensus::SelectChain;
23+
use sp_keystore::KeystorePtr;
2124

2225
/// Full client dependencies.
23-
pub struct FullDeps<C, P, B> {
26+
pub struct FullDeps<C, P, SC, B> {
2427
/// The client instance to use.
2528
pub client: Arc<C>,
2629
/// Transaction pool instance.
2730
pub pool: Arc<P>,
31+
/// The chain selection strategy.
32+
pub select_chain: SC,
33+
/// BABE RPC dependencies.
34+
pub babe: BabeDeps,
2835
/// GRANDPA RPC dependencies.
2936
pub grandpa: GrandpaDeps<B>,
3037
}
3138

39+
/// BABE RPC dependencies.
40+
pub struct BabeDeps {
41+
/// A handle to the BABE worker for issuing requests.
42+
pub babe_worker_handle: BabeWorkerHandle<Block>,
43+
/// The keystore that manages the keys of the node.
44+
pub keystore: KeystorePtr,
45+
}
46+
3247
/// GRANDPA RPC dependncies.
3348
pub struct GrandpaDeps<B> {
3449
/// Subscription task executor.
@@ -44,24 +59,30 @@ pub struct GrandpaDeps<B> {
4459
}
4560

4661
/// Instantiate all full RPC extensions.
47-
pub fn create_full<C, P, B>(
48-
deps: FullDeps<C, P, B>,
62+
pub fn create_full<C, P, SC, B>(
63+
deps: FullDeps<C, P, SC, B>,
4964
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
5065
where
5166
C: ProvideRuntimeApi<Block>,
5267
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
5368
C: Send + Sync + 'static,
5469
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
5570
C::Api: BlockBuilder<Block>,
71+
C::Api: BabeApi<Block>,
5672
P: TransactionPool + 'static,
73+
SC: SelectChain<Block> + 'static,
5774
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
5875
{
76+
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
5977
use substrate_frame_rpc_system::{System, SystemApiServer};
6078

6179
let mut module = RpcModule::new(());
62-
let FullDeps { client, pool, grandpa } = deps;
80+
let FullDeps { client, pool, select_chain, babe, grandpa } = deps;
81+
let BabeDeps { babe_worker_handle, keystore } = babe;
6382

64-
module.merge(System::new(client, pool).into_rpc())?;
83+
module.merge(System::new(client.clone(), pool).into_rpc())?;
84+
module
85+
.merge(Babe::new(client, babe_worker_handle.clone(), keystore, select_chain).into_rpc())?;
6586
module.merge(
6687
Grandpa::new(
6788
grandpa.subscription_executor,

node/src/service.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub fn new_partial(
4545
>,
4646
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
4747
sc_consensus_babe::BabeLink<Block>,
48+
sc_consensus_babe::BabeWorkerHandle<Block>,
4849
Option<Telemetry>,
4950
),
5051
>,
@@ -128,9 +129,6 @@ pub fn new_partial(
128129
telemetry: telemetry.as_ref().map(|x| x.handle()),
129130
})?;
130131

131-
// TODO Wire up to RPC
132-
std::mem::forget(babe_worker_handle);
133-
134132
Ok(sc_service::PartialComponents {
135133
client,
136134
backend,
@@ -139,7 +137,7 @@ pub fn new_partial(
139137
keystore_container,
140138
select_chain,
141139
transaction_pool,
142-
other: (block_import, grandpa_link, babe_link, telemetry),
140+
other: (block_import, grandpa_link, babe_link, babe_worker_handle, telemetry),
143141
})
144142
}
145143

@@ -157,7 +155,7 @@ pub fn new_full<
157155
keystore_container,
158156
select_chain,
159157
transaction_pool,
160-
other: (block_import, grandpa_link, babe_link, mut telemetry),
158+
other: (block_import, grandpa_link, babe_link, babe_worker_handle, mut telemetry),
161159
} = new_partial(&config)?;
162160

163161
let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, N>::new(
@@ -226,6 +224,8 @@ pub fn new_full<
226224
let rpc_extensions_builder = {
227225
let client = client.clone();
228226
let pool = transaction_pool.clone();
227+
let keystore = keystore_container.keystore();
228+
let select_chain = select_chain.clone();
229229

230230
let justification_stream = grandpa_link.justification_stream();
231231
let shared_authority_set = grandpa_link.shared_authority_set().clone();
@@ -240,6 +240,11 @@ pub fn new_full<
240240
let deps = crate::rpc::FullDeps {
241241
client: client.clone(),
242242
pool: pool.clone(),
243+
select_chain: select_chain.clone(),
244+
babe: crate::rpc::BabeDeps {
245+
babe_worker_handle: babe_worker_handle.clone(),
246+
keystore: keystore.clone(),
247+
},
243248
grandpa: crate::rpc::GrandpaDeps {
244249
subscription_executor,
245250
shared_authority_set: shared_authority_set.clone(),

0 commit comments

Comments
 (0)