Skip to content
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
96 changes: 40 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ mod dispatches {
/// - On failure for each failed item in the batch.
///
#[pallet::call_index(100)]
#[pallet::weight((Weight::from_parts(82_010_000, 0)
#[pallet::weight((Weight::from_parts(100_500_000, 0)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))]
pub fn batch_commit_weights(
Expand Down Expand Up @@ -891,7 +891,7 @@ mod dispatches {
///
#[pallet::call_index(69)]
#[pallet::weight((
Weight::from_parts(5_912_000, 0)
Weight::from_parts(5_660_000, 0)
.saturating_add(T::DbWeight::get().reads(0))
.saturating_add(T::DbWeight::get().writes(1)),
DispatchClass::Operational,
Expand Down Expand Up @@ -1041,7 +1041,7 @@ mod dispatches {
#[pallet::call_index(59)]
#[pallet::weight((Weight::from_parts(235_400_000, 0)
.saturating_add(T::DbWeight::get().reads(36))
.saturating_add(T::DbWeight::get().writes(51_u64)), DispatchClass::Normal, Pays::No))]
.saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Normal, Pays::Yes))]
pub fn register_network(origin: OriginFor<T>, hotkey: T::AccountId) -> DispatchResult {
Self::do_register_network(origin, &hotkey, 1, None)
}
Expand Down Expand Up @@ -1328,7 +1328,7 @@ mod dispatches {
#[pallet::call_index(79)]
#[pallet::weight((Weight::from_parts(234_200_000, 0)
.saturating_add(T::DbWeight::get().reads(35))
.saturating_add(T::DbWeight::get().writes(50_u64)), DispatchClass::Normal, Pays::No))]
.saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Normal, Pays::Yes))]
pub fn register_network_with_identity(
origin: OriginFor<T>,
hotkey: T::AccountId,
Expand Down Expand Up @@ -2011,7 +2011,7 @@ mod dispatches {
/// Set the autostake destination hotkey for a coldkey.
///
/// The caller selects a hotkey where all future rewards
/// will be automatically staked.
/// will be automatically staked.
///
/// # Args:
/// * `origin` - (<T as frame_system::Config>::Origin):
Expand Down
3 changes: 1 addition & 2 deletions pallets/subtensor/src/subnets/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ impl<T: Config> Pallet<T> {

// --- 4. Rate limit for network registrations.
let current_block = Self::get_current_block_as_u64();
let last_lock_block = Self::get_network_last_lock_block();
ensure!(
current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::<T>::get(),
Self::passes_rate_limit(&TransactionType::RegisterNetwork, &coldkey),
Error::<T>::NetworkTxRateLimitExceeded
);

Expand Down
8 changes: 8 additions & 0 deletions pallets/subtensor/src/transaction_extension.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
BalancesCall, Call, ColdkeySwapScheduled, Config, CustomTransactionError, Error, Pallet,
TransactionType,
};
use codec::{Decode, DecodeWithMemTracking, Encode};
use frame_support::dispatch::{DispatchInfo, PostDispatchInfo};
Expand Down Expand Up @@ -277,6 +278,13 @@ where
)
.map(|validity| (validity, Some(who.clone()), origin.clone()))
}
Some(Call::register_network { .. }) => {
if !Pallet::<T>::passes_rate_limit(&TransactionType::RegisterNetwork, who) {
return Err(CustomTransactionError::RateLimitExceeded.into());
}

Ok((Default::default(), Some(who.clone()), origin))
}
_ => Ok((Default::default(), Some(who.clone()), origin)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 313,
spec_version: 314,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Loading