Skip to content

Commit

Permalink
Merge pull request #627 from opentensor/fix/remove_childkey_rpcs
Browse files Browse the repository at this point in the history
chore: remove coldkey swap rpc
  • Loading branch information
distributedstatemachine authored Jul 12, 2024
2 parents 0efeaf3 + 0abfb9b commit 3e8afeb
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 268 deletions.
1 change: 0 additions & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ where
C::Api: subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>,
C::Api: subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>,
C::Api: subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
C::Api: subtensor_custom_rpc_runtime_api::ColdkeySwapRuntimeApi<Block>,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
P: TransactionPool + 'static,
{
Expand Down
68 changes: 1 addition & 67 deletions pallets/subtensor/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::sync::Arc;
use sp_api::ProvideRuntimeApi;

pub use subtensor_custom_rpc_runtime_api::{
ColdkeySwapRuntimeApi, DelegateInfoRuntimeApi, NeuronInfoRuntimeApi, SubnetInfoRuntimeApi,
DelegateInfoRuntimeApi, NeuronInfoRuntimeApi, SubnetInfoRuntimeApi,
SubnetRegistrationRuntimeApi,
};

Expand Down Expand Up @@ -51,24 +51,6 @@ pub trait SubtensorCustomApi<BlockHash> {

#[method(name = "subnetInfo_getLockCost")]
fn get_network_lock_cost(&self, at: Option<BlockHash>) -> RpcResult<u64>;
#[method(name = "coldkeySwap_getScheduledColdkeySwap")]
fn get_scheduled_coldkey_swap(
&self,
coldkey_account_vec: Vec<u8>,
at: Option<BlockHash>,
) -> RpcResult<Vec<u8>>;
#[method(name = "coldkeySwap_getRemainingArbitrationPeriod")]
fn get_remaining_arbitration_period(
&self,
coldkey_account_vec: Vec<u8>,
at: Option<BlockHash>,
) -> RpcResult<Vec<u8>>;
#[method(name = "coldkeySwap_getColdkeySwapDestinations")]
fn get_coldkey_swap_destinations(
&self,
coldkey_account_vec: Vec<u8>,
at: Option<BlockHash>,
) -> RpcResult<Vec<u8>>;
}

pub struct SubtensorCustom<C, P> {
Expand Down Expand Up @@ -117,7 +99,6 @@ where
C::Api: NeuronInfoRuntimeApi<Block>,
C::Api: SubnetInfoRuntimeApi<Block>,
C::Api: SubnetRegistrationRuntimeApi<Block>,
C::Api: ColdkeySwapRuntimeApi<Block>,
{
fn get_delegates(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
Expand Down Expand Up @@ -242,51 +223,4 @@ where
Error::RuntimeError(format!("Unable to get subnet lock cost: {:?}", e)).into()
})
}

fn get_scheduled_coldkey_swap(
&self,
coldkey_account_vec: Vec<u8>,
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_scheduled_coldkey_swap(at, coldkey_account_vec)
.map_err(|e| {
Error::RuntimeError(format!("Unable to get scheduled coldkey swap: {:?}", e)).into()
})
}

fn get_remaining_arbitration_period(
&self,
coldkey_account_vec: Vec<u8>,
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_remaining_arbitration_period(at, coldkey_account_vec)
.map_err(|e| {
Error::RuntimeError(format!(
"Unable to get remaining arbitration period: {:?}",
e
))
.into()
})
}

fn get_coldkey_swap_destinations(
&self,
coldkey_account_vec: Vec<u8>,
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_coldkey_swap_destinations(at, coldkey_account_vec)
.map_err(|e| {
Error::RuntimeError(format!("Unable to get coldkey swap destinations: {:?}", e))
.into()
})
}
}
6 changes: 0 additions & 6 deletions pallets/subtensor/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,4 @@ sp_api::decl_runtime_apis! {
pub trait SubnetRegistrationRuntimeApi {
fn get_network_registration_cost() -> u64;
}

pub trait ColdkeySwapRuntimeApi {
fn get_scheduled_coldkey_swap( coldkey_account_vec: Vec<u8> ) -> Vec<u8>;
fn get_remaining_arbitration_period( coldkey_account_vec: Vec<u8> ) -> Vec<u8>;
fn get_coldkey_swap_destinations( coldkey_account_vec: Vec<u8> ) -> Vec<u8>;
}
}
1 change: 0 additions & 1 deletion pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ mod weights;

pub mod delegate_info;
pub mod neuron_info;
pub mod schedule_coldkey_swap_info;
pub mod stake_info;
pub mod subnet_info;

Expand Down
176 changes: 0 additions & 176 deletions pallets/subtensor/src/schedule_coldkey_swap_info.rs

This file was deleted.

17 changes: 0 additions & 17 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,23 +1664,6 @@ impl_runtime_apis! {
SubtensorModule::get_network_lock_cost()
}
}

impl subtensor_custom_rpc_runtime_api::ColdkeySwapRuntimeApi<Block> for Runtime {
fn get_scheduled_coldkey_swap( coldkey_account_vec: Vec<u8> ) -> Vec<u8> {
let result = SubtensorModule::get_scheduled_coldkey_swap( coldkey_account_vec );
result.encode()
}

fn get_remaining_arbitration_period( coldkey_account_vec: Vec<u8> ) -> Vec<u8> {
let result = SubtensorModule::get_remaining_arbitration_period( coldkey_account_vec );
result.encode()
}

fn get_coldkey_swap_destinations( coldkey_account_vec: Vec<u8> ) -> Vec<u8> {
let result = SubtensorModule::get_coldkey_swap_destinations( coldkey_account_vec );
result.encode()
}
}
}

// #[cfg(test)]
Expand Down

0 comments on commit 3e8afeb

Please sign in to comment.