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

Remove unnecessary generics #979

Merged
merged 3 commits into from
Nov 15, 2024
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
12 changes: 6 additions & 6 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Should only be used for benchmarking as it may break in other contexts.

use crate::service::Client;
use crate::client::FullClient;

use node_subtensor_runtime as runtime;
use node_subtensor_runtime::check_nonce;
Expand All @@ -21,12 +21,12 @@ use std::{sync::Arc, time::Duration};
//
// Note: Should only be used for benchmarking.
pub struct RemarkBuilder {
client: Arc<Client>,
client: Arc<FullClient>,
}

impl RemarkBuilder {
// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<Client>) -> Self {
pub fn new(client: Arc<FullClient>) -> Self {
Self { client }
}
}
Expand Down Expand Up @@ -58,14 +58,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
//
// Note: Should only be used for benchmarking.
pub struct TransferKeepAliveBuilder {
client: Arc<Client>,
client: Arc<FullClient>,
dest: AccountId,
value: Balance,
}

impl TransferKeepAliveBuilder {
// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<Client>, dest: AccountId, value: Balance) -> Self {
pub fn new(client: Arc<FullClient>, dest: AccountId, value: Balance) -> Self {
Self {
client,
dest,
Expand Down Expand Up @@ -105,7 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
//
// Note: Should only be used for benchmarking.
pub fn create_benchmark_extrinsic(
client: &Client,
client: &FullClient,
sender: sp_core::sr25519::Pair,
call: runtime::RuntimeCall,
nonce: u32,
Expand Down
84 changes: 12 additions & 72 deletions node/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,76 +1,16 @@
use scale_codec::Codec;
// Substrate
use node_subtensor_runtime::{opaque::Block, RuntimeApi};
use sc_executor::WasmExecutor;
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};

use crate::ethereum::EthCompatRuntimeApiCollection;

/// Full backend.
pub type FullBackend<B> = sc_service::TFullBackend<B>;
pub type FullBackend = sc_service::TFullBackend<Block>;
/// Full client.
pub type FullClient<B, RA, HF> = sc_service::TFullClient<B, RA, WasmExecutor<HF>>;

/// A set of APIs that every runtime must implement.
pub trait BaseRuntimeApiCollection<Block: BlockT>:
sp_api::ApiExt<Block>
+ sp_api::Metadata<Block>
+ sp_block_builder::BlockBuilder<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
{
}

impl<Block, Api> BaseRuntimeApiCollection<Block> for Api
where
Block: BlockT,
Api: sp_api::ApiExt<Block>
+ sp_api::Metadata<Block>
+ sp_block_builder::BlockBuilder<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
{
}

/// A set of APIs that Subtensor runtime must implement.
pub trait RuntimeApiCollection<
Block: BlockT,
AuraId: Codec,
AccountId: Codec,
Nonce: Codec,
Balance: Codec + MaybeDisplay,
>:
BaseRuntimeApiCollection<Block>
+ EthCompatRuntimeApiCollection<Block>
+ sp_consensus_aura::AuraApi<Block, AuraId>
+ sp_consensus_grandpa::GrandpaApi<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>
{
}

impl<Block, AuraId, AccountId, Nonce, Balance, Api>
RuntimeApiCollection<Block, AuraId, AccountId, Nonce, Balance> for Api
where
Block: BlockT,
AuraId: Codec,
AccountId: Codec,
Nonce: Codec,
Balance: Codec + MaybeDisplay,
Api: BaseRuntimeApiCollection<Block>
+ EthCompatRuntimeApiCollection<Block>
+ sp_consensus_aura::AuraApi<Block, AuraId>
+ sp_consensus_grandpa::GrandpaApi<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
{
}
pub type FullClient = sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
/// Always enable runtime benchmark host functions, the genesis state
/// was built with them so we're stuck with them forever.
///
/// They're just a noop, never actually get used if the runtime was not compiled with
/// `runtime-benchmarks`.
type HostFunctions = (
sp_io::SubstrateHostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
);
Loading
Loading