Skip to content

Commit 5bcb978

Browse files
authored
Merge pull request #979 from opentensor/feat/clean-up-node-crate
Remove unnecessary generics
2 parents 2b80315 + 90927da commit 5bcb978

File tree

5 files changed

+152
-364
lines changed

5 files changed

+152
-364
lines changed

node/src/benchmarking.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Should only be used for benchmarking as it may break in other contexts.
44
5-
use crate::service::Client;
5+
use crate::client::FullClient;
66

77
use node_subtensor_runtime as runtime;
88
use node_subtensor_runtime::check_nonce;
@@ -21,12 +21,12 @@ use std::{sync::Arc, time::Duration};
2121
//
2222
// Note: Should only be used for benchmarking.
2323
pub struct RemarkBuilder {
24-
client: Arc<Client>,
24+
client: Arc<FullClient>,
2525
}
2626

2727
impl RemarkBuilder {
2828
// Creates a new [`Self`] from the given client.
29-
pub fn new(client: Arc<Client>) -> Self {
29+
pub fn new(client: Arc<FullClient>) -> Self {
3030
Self { client }
3131
}
3232
}
@@ -58,14 +58,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
5858
//
5959
// Note: Should only be used for benchmarking.
6060
pub struct TransferKeepAliveBuilder {
61-
client: Arc<Client>,
61+
client: Arc<FullClient>,
6262
dest: AccountId,
6363
value: Balance,
6464
}
6565

6666
impl TransferKeepAliveBuilder {
6767
// Creates a new [`Self`] from the given client.
68-
pub fn new(client: Arc<Client>, dest: AccountId, value: Balance) -> Self {
68+
pub fn new(client: Arc<FullClient>, dest: AccountId, value: Balance) -> Self {
6969
Self {
7070
client,
7171
dest,
@@ -105,7 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
105105
//
106106
// Note: Should only be used for benchmarking.
107107
pub fn create_benchmark_extrinsic(
108-
client: &Client,
108+
client: &FullClient,
109109
sender: sp_core::sr25519::Pair,
110110
call: runtime::RuntimeCall,
111111
nonce: u32,

node/src/client.rs

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,16 @@
1-
use scale_codec::Codec;
2-
// Substrate
1+
use node_subtensor_runtime::{opaque::Block, RuntimeApi};
32
use sc_executor::WasmExecutor;
4-
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};
5-
6-
use crate::ethereum::EthCompatRuntimeApiCollection;
73

84
/// Full backend.
9-
pub type FullBackend<B> = sc_service::TFullBackend<B>;
5+
pub type FullBackend = sc_service::TFullBackend<Block>;
106
/// Full client.
11-
pub type FullClient<B, RA, HF> = sc_service::TFullClient<B, RA, WasmExecutor<HF>>;
12-
13-
/// A set of APIs that every runtime must implement.
14-
pub trait BaseRuntimeApiCollection<Block: BlockT>:
15-
sp_api::ApiExt<Block>
16-
+ sp_api::Metadata<Block>
17-
+ sp_block_builder::BlockBuilder<Block>
18-
+ sp_offchain::OffchainWorkerApi<Block>
19-
+ sp_session::SessionKeys<Block>
20-
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
21-
{
22-
}
23-
24-
impl<Block, Api> BaseRuntimeApiCollection<Block> for Api
25-
where
26-
Block: BlockT,
27-
Api: sp_api::ApiExt<Block>
28-
+ sp_api::Metadata<Block>
29-
+ sp_block_builder::BlockBuilder<Block>
30-
+ sp_offchain::OffchainWorkerApi<Block>
31-
+ sp_session::SessionKeys<Block>
32-
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
33-
{
34-
}
35-
36-
/// A set of APIs that Subtensor runtime must implement.
37-
pub trait RuntimeApiCollection<
38-
Block: BlockT,
39-
AuraId: Codec,
40-
AccountId: Codec,
41-
Nonce: Codec,
42-
Balance: Codec + MaybeDisplay,
43-
>:
44-
BaseRuntimeApiCollection<Block>
45-
+ EthCompatRuntimeApiCollection<Block>
46-
+ sp_consensus_aura::AuraApi<Block, AuraId>
47-
+ sp_consensus_grandpa::GrandpaApi<Block>
48-
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
49-
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
50-
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
51-
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
52-
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
53-
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>
54-
{
55-
}
56-
57-
impl<Block, AuraId, AccountId, Nonce, Balance, Api>
58-
RuntimeApiCollection<Block, AuraId, AccountId, Nonce, Balance> for Api
59-
where
60-
Block: BlockT,
61-
AuraId: Codec,
62-
AccountId: Codec,
63-
Nonce: Codec,
64-
Balance: Codec + MaybeDisplay,
65-
Api: BaseRuntimeApiCollection<Block>
66-
+ EthCompatRuntimeApiCollection<Block>
67-
+ sp_consensus_aura::AuraApi<Block, AuraId>
68-
+ sp_consensus_grandpa::GrandpaApi<Block>
69-
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
70-
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
71-
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
72-
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
73-
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
74-
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
75-
{
76-
}
7+
pub type FullClient = sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
8+
/// Always enable runtime benchmark host functions, the genesis state
9+
/// was built with them so we're stuck with them forever.
10+
///
11+
/// They're just a noop, never actually get used if the runtime was not compiled with
12+
/// `runtime-benchmarks`.
13+
type HostFunctions = (
14+
sp_io::SubstrateHostFunctions,
15+
frame_benchmarking::benchmarking::HostFunctions,
16+
);

0 commit comments

Comments
 (0)