Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose types from sc-service #5855

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 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
10 changes: 10 additions & 0 deletions prdoc/pr_5855.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Remove feature `test-helpers` from sc-service
doc:
- audience: Node Dev
description: |-
Removes feature `test-helpers` from sc-service.
crates:
- name: sc-service
bump: major
- name: sc-rpc-spec-v2
bump: major
2 changes: 1 addition & 1 deletion substrate/bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sc-client-api = { workspace = true, default-features = true }
sc-client-db = { features = ["rocksdb"], workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-service = { features = ["rocksdb", "test-helpers"], workspace = true, default-features = true }
sc-service = { features = ["rocksdb"], workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-block-builder = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sc-network-types = { workspace = true, default-features = true }
sc-utils = { workspace = true, default-features = true }
sc-network-light = { workspace = true, default-features = true }
sc-network-sync = { workspace = true, default-features = true }
sc-service = { features = ["test-helpers"], workspace = true }
sc-service = { workspace = true }
sp-blockchain = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/rpc-spec-v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sp-consensus = { workspace = true, default-features = true }
sp-externalities = { workspace = true, default-features = true }
sp-maybe-compressed-blob = { workspace = true, default-features = true }
sc-block-builder = { workspace = true, default-features = true }
sc-service = { features = ["test-helpers"], workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true, features = ["test-helpers"] }
assert_matches = { workspace = true }
pretty_assertions = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ mod tests {
use super::*;
use jsonrpsee::ConnectionId;
use sc_block_builder::BlockBuilderBuilder;
use sc_service::client::new_in_mem;
use sc_service::client::new_with_backend;
use sp_consensus::BlockOrigin;
use sp_core::{testing::TaskExecutor, H256};
use substrate_test_runtime_client::{
Expand All @@ -811,13 +811,13 @@ mod tests {
)
.unwrap();
let client = Arc::new(
new_in_mem::<_, Block, _, RuntimeApi>(
new_with_backend::<_, _, Block, _, RuntimeApi>(
backend.clone(),
executor,
genesis_block_builder,
Box::new(TaskExecutor::new()),
None,
None,
Box::new(TaskExecutor::new()),
client_config,
)
.unwrap(),
Expand Down
6 changes: 3 additions & 3 deletions substrate/client/rpc-spec-v2/src/chain_head/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use jsonrpsee::{
use sc_block_builder::BlockBuilderBuilder;
use sc_client_api::ChildInfo;
use sc_rpc::testing::TokioTestExecutor;
use sc_service::client::new_in_mem;
use sc_service::client::new_with_backend;
use sp_blockchain::HeaderBackend;
use sp_consensus::BlockOrigin;
use sp_core::{
Expand Down Expand Up @@ -2547,13 +2547,13 @@ async fn pin_block_references() {
.unwrap();

let client = Arc::new(
new_in_mem::<_, Block, _, RuntimeApi>(
new_with_backend::<_, _, Block, _, RuntimeApi>(
backend.clone(),
executor,
genesis_block_builder,
Box::new(TokioTestExecutor::default()),
None,
None,
Box::new(TokioTestExecutor::default()),
client_config,
)
.unwrap(),
Expand Down
2 changes: 0 additions & 2 deletions substrate/client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ default = ["rocksdb"]
# The RocksDB feature activates the RocksDB database backend. If it is not activated, and you pass
# a path to a database, an error will be produced at runtime.
rocksdb = ["sc-client-db/rocksdb"]
# exposes the client type
test-helpers = []
runtime-benchmarks = [
"sc-client-db/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
Expand Down
40 changes: 2 additions & 38 deletions substrate/client/service/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ use std::{
sync::Arc,
};

#[cfg(feature = "test-helpers")]
use {
super::call_executor::LocalCallExecutor, sc_client_api::in_mem, sp_core::traits::CodeExecutor,
};
use super::call_executor::LocalCallExecutor;
use sp_core::traits::CodeExecutor;

type NotificationSinks<T> = Mutex<Vec<TracingUnboundedSender<T>>>;

Expand Down Expand Up @@ -152,39 +150,6 @@ enum PrepareStorageChangesResult<Block: BlockT> {
Discard(ImportResult),
Import(Option<sc_consensus::StorageChanges<Block>>),
}

/// Create an instance of in-memory client.
#[cfg(feature = "test-helpers")]
pub fn new_in_mem<E, Block, G, RA>(
backend: Arc<in_mem::Backend<Block>>,
executor: E,
genesis_block_builder: G,
prometheus_registry: Option<Registry>,
telemetry: Option<TelemetryHandle>,
spawn_handle: Box<dyn SpawnNamed>,
config: ClientConfig<Block>,
) -> sp_blockchain::Result<
Client<in_mem::Backend<Block>, LocalCallExecutor<Block, in_mem::Backend<Block>, E>, Block, RA>,
>
where
E: CodeExecutor + sc_executor::RuntimeVersionOf,
Block: BlockT,
G: BuildGenesisBlock<
Block,
BlockImportOperation = <in_mem::Backend<Block> as backend::Backend<Block>>::BlockImportOperation,
>,
{
new_with_backend(
backend,
executor,
genesis_block_builder,
spawn_handle,
prometheus_registry,
telemetry,
config,
)
}

/// Client configuration items.
#[derive(Debug, Clone)]
pub struct ClientConfig<Block: BlockT> {
Expand Down Expand Up @@ -218,7 +183,6 @@ impl<Block: BlockT> Default for ClientConfig<Block> {

/// Create a client with the explicitly provided backend.
/// This is useful for testing backend implementations.
#[cfg(feature = "test-helpers")]
pub fn new_with_backend<B, E, Block, G, RA>(
backend: Arc<B>,
executor: E,
Expand Down
3 changes: 1 addition & 2 deletions substrate/client/service/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ pub use call_executor::LocalCallExecutor;
pub use client::{Client, ClientConfig};
pub(crate) use code_provider::CodeProvider;

#[cfg(feature = "test-helpers")]
pub use self::client::{new_in_mem, new_with_backend};
pub use self::client::new_with_backend;
5 changes: 1 addition & 4 deletions substrate/client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
#![recursion_limit = "1024"]

pub mod chain_ops;
pub mod client;
pub mod config;
pub mod error;

mod builder;
#[cfg(feature = "test-helpers")]
pub mod client;
#[cfg(not(feature = "test-helpers"))]
mod client;
mod metrics;
mod task_manager;

Expand Down
2 changes: 1 addition & 1 deletion substrate/client/service/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sc-consensus = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-network-sync = { workspace = true, default-features = true }
sc-service = { features = ["test-helpers"], workspace = true, default-features = true }
sc-service = {workspace = true, default-features = true }
sc-transaction-pool-api = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
Expand Down
6 changes: 3 additions & 3 deletions substrate/client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sc_consensus::{
BlockCheckParams, BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult,
};
use sc_executor::WasmExecutor;
use sc_service::client::{new_in_mem, Client, LocalCallExecutor};
use sc_service::client::{new_with_backend, Client, LocalCallExecutor};
use sp_api::ProvideRuntimeApi;
use sp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain};
use sp_core::{testing::TaskExecutor, traits::CallContext, H256};
Expand Down Expand Up @@ -2087,13 +2087,13 @@ fn cleans_up_closed_notification_sinks_on_block_import() {
// NOTE: we need to build the client here instead of using the client
// provided by test_runtime_client otherwise we can't access the private
// `import_notification_sinks` and `finality_notification_sinks` fields.
let mut client = new_in_mem::<_, Block, _, RuntimeApi>(
let mut client = new_with_backend::<_, _, Block, _, RuntimeApi>(
backend,
executor,
genesis_block_builder,
Box::new(TaskExecutor::new()),
None,
None,
Box::new(TaskExecutor::new()),
client_config,
)
.unwrap();
Expand Down
4 changes: 1 addition & 3 deletions substrate/test-utils/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ sc-client-db = { features = [
sc-consensus = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-offchain = { workspace = true, default-features = true }
sc-service = { features = [
"test-helpers",
], workspace = true }
sc-service = { workspace = true }
sp-blockchain = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion substrate/test-utils/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sp-consensus-grandpa = { features = ["serde"], workspace = true }
sp-trie = { workspace = true }
sp-transaction-pool = { workspace = true }
trie-db = { workspace = true }
sc-service = { features = ["test-helpers"], optional = true, workspace = true }
sc-service = { optional = true, workspace = true }
sp-state-machine = { workspace = true }
sp-externalities = { workspace = true }

Expand Down
Loading