From 51a8267cb0958d27dca3f494d39046bf00834bb1 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 11 Mar 2026 14:01:44 +0300 Subject: [PATCH 01/14] Modify mev-shield --- pallets/shield/src/lib.rs | 216 +++++++++++++- pallets/shield/src/mock.rs | 13 + pallets/shield/src/tests.rs | 426 +++++++++++++++++++++++++++- pallets/subtensor/src/tests/mock.rs | 2 + runtime/src/check_mortality.rs | 30 +- runtime/src/lib.rs | 2 + 6 files changed, 672 insertions(+), 17 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 6b742687f5..9b8c9261e9 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -3,11 +3,16 @@ extern crate alloc; +use alloc::vec; use chacha20poly1305::{ KeyInit, XChaCha20Poly1305, XNonce, aead::{Aead, Payload}, }; -use frame_support::{pallet_prelude::*, traits::IsSubType}; +use frame_support::{ + dispatch::{GetDispatchInfo, PostDispatchInfo}, + pallet_prelude::*, + traits::IsSubType, +}; use frame_system::{ensure_none, ensure_signed, pallet_prelude::*}; use ml_kem::{ Ciphertext, EncodedSizeUser, MlKem768, MlKem768Params, @@ -15,12 +20,12 @@ use ml_kem::{ }; use sp_io::hashing::twox_128; use sp_runtime::traits::{Applyable, Block as BlockT, Checkable, Hash}; +use sp_runtime::traits::{Dispatchable, Saturating}; use stp_shield::{ INHERENT_IDENTIFIER, InherentType, LOG_TARGET, MLKEM768_ENC_KEY_LEN, ShieldEncKey, ShieldedTransaction, }; - -use alloc::vec; +use subtensor_macros::freeze_struct; pub use pallet::*; @@ -45,6 +50,19 @@ type ApplyableCallOf = ::Call; const MAX_EXTRINSIC_DEPTH: u32 = 8; +/// Trait for decrypting stored extrinsics before dispatch. +pub trait ExtrinsicDecryptor { + /// Decrypt the stored bytes and return the decoded RuntimeCall. + fn decrypt(data: &[u8]) -> Result; +} + +/// Default implementation that always returns an error. +impl ExtrinsicDecryptor for () { + fn decrypt(_data: &[u8]) -> Result { + Err(DispatchError::Other("ExtrinsicDecryptor not implemented")) + } +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -56,6 +74,14 @@ pub mod pallet { /// A way to find the current and next block author. type FindAuthors: FindAuthors; + + /// The overarching call type for dispatching stored extrinsics. + type RuntimeCall: Parameter + + Dispatchable + + GetDispatchInfo; + + /// Decryptor for stored extrinsics. + type ExtrinsicDecryptor: ExtrinsicDecryptor<::RuntimeCall>; } #[pallet::pallet] @@ -93,11 +119,63 @@ pub mod pallet { pub type HasMigrationRun = StorageMap<_, Identity, BoundedVec, bool, ValueQuery>; + /// Maximum size of a single encoded call. + pub type MaxCallSize = ConstU32<8192>; + + /// Maximum number of pending extrinsics. + pub type MaxPendingExtrinsics = ConstU32<100>; + + /// Maximum block difference between submission and execution. + pub const MAX_EXTRINSIC_LIFETIME: u32 = 10; + + /// Maximum weight allowed for on_initialize processing. + /// Processing stops when this limit would be exceeded. + pub const MAX_ON_INITIALIZE_WEIGHT: Weight = Weight::from_parts(500_000_000_000, 0); + + /// A pending extrinsic stored for later execution. + #[freeze_struct("c5749ec89253be61")] + #[derive(Clone, Encode, Decode, TypeInfo, MaxEncodedLen, PartialEq, Debug)] + #[scale_info(skip_type_params(T))] + pub struct PendingExtrinsic { + /// The account that submitted the extrinsic. + pub who: T::AccountId, + /// The encoded call data. + pub call: BoundedVec, + /// The block number when the extrinsic was submitted. + pub submitted_at: BlockNumberFor, + } + + /// Storage map for encrypted extrinsics to be executed in on_initialize. + /// Uses u32 index for O(1) insertion and removal. + #[pallet::storage] + pub type PendingExtrinsics = + StorageMap<_, Identity, u32, PendingExtrinsic, OptionQuery>; + + /// Next index to use when inserting a pending extrinsic (unique auto-increment). + #[pallet::storage] + pub type NextPendingExtrinsicIndex = StorageValue<_, u32, ValueQuery>; + + /// Number of pending extrinsics currently stored (for limit checking). + #[pallet::storage] + pub type PendingExtrinsicCount = StorageValue<_, u32, ValueQuery>; + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Encrypted wrapper accepted. EncryptedSubmitted { id: T::Hash, who: T::AccountId }, + /// Encrypted extrinsic was stored for later execution. + ExtrinsicStored { index: u32, who: T::AccountId }, + /// Extrinsic decode failed during on_initialize. + ExtrinsicDecodeFailed { index: u32 }, + /// Extrinsic dispatch failed during on_initialize. + ExtrinsicDispatchFailed { index: u32, error: DispatchError }, + /// Extrinsic was successfully dispatched during on_initialize. + ExtrinsicDispatched { index: u32 }, + /// Extrinsic expired (exceeded max block lifetime). + ExtrinsicExpired { index: u32 }, + /// Extrinsic postponed due to weight limit. + ExtrinsicPostponed { index: u32 }, } #[pallet::error] @@ -106,10 +184,16 @@ pub mod pallet { BadEncKeyLen, /// Unreachable. Unreachable, + /// Too many pending extrinsics in storage. + TooManyPendingExtrinsics, } #[pallet::hooks] impl Hooks> for Pallet { + fn on_initialize(_block_number: BlockNumberFor) -> Weight { + Self::process_pending_extrinsics() + } + fn on_runtime_upgrade() -> frame_support::weights::Weight { let mut weight = frame_support::weights::Weight::from_parts(0, 0); @@ -229,6 +313,39 @@ pub mod pallet { Self::deposit_event(Event::EncryptedSubmitted { id, who }); Ok(()) } + + /// Store an encrypted extrinsic for later execution in on_initialize. + #[pallet::call_index(2)] + #[pallet::weight(Weight::from_parts(10_000_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)))] + pub fn store_encrypted( + origin: OriginFor, + call: BoundedVec, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + + let count = PendingExtrinsicCount::::get(); + + ensure!( + count < >::get(), + Error::::TooManyPendingExtrinsics + ); + + let index = NextPendingExtrinsicIndex::::get(); + let pending = PendingExtrinsic { + who: who.clone(), + call, + submitted_at: frame_system::Pallet::::block_number(), + }; + PendingExtrinsics::::insert(index, pending); + + NextPendingExtrinsicIndex::::put(index.saturating_add(1)); + PendingExtrinsicCount::::put(count.saturating_add(1)); + + Self::deposit_event(Event::ExtrinsicStored { index, who }); + Ok(()) + } } #[pallet::inherent] @@ -255,6 +372,99 @@ pub mod pallet { } impl Pallet { + /// Process pending encrypted extrinsics up to the weight limit. + /// Returns the total weight consumed. + pub fn process_pending_extrinsics() -> Weight { + let next_index = NextPendingExtrinsicIndex::::get(); + let count = PendingExtrinsicCount::::get(); + + let mut weight = T::DbWeight::get().reads(2); + + if count == 0 { + return weight; + } + + let start_index = next_index.saturating_sub(count); + let current_block = frame_system::Pallet::::block_number(); + + // Process extrinsics + for index in start_index..next_index { + let Some(pending) = PendingExtrinsics::::get(index) else { + weight = weight.saturating_add(T::DbWeight::get().reads(1)); + + continue; + }; + + // Check if the extrinsic has expired + let age = current_block.saturating_sub(pending.submitted_at); + if age > MAX_EXTRINSIC_LIFETIME.into() { + remove_pending_extrinsic::(index, &mut weight); + + Self::deposit_event(Event::ExtrinsicExpired { index }); + + continue; + } + + let call = match T::ExtrinsicDecryptor::decrypt(&pending.call) { + Ok(call) => call, + Err(_) => { + remove_pending_extrinsic::(index, &mut weight); + + Self::deposit_event(Event::ExtrinsicDecodeFailed { index }); + + continue; + } + }; + + // Check if dispatching would exceed weight limit + let info = call.get_dispatch_info(); + let dispatch_weight = T::DbWeight::get() + .writes(2) + .saturating_add(info.call_weight); + + if weight + .saturating_add(dispatch_weight) + .any_gt(MAX_ON_INITIALIZE_WEIGHT) + { + Self::deposit_event(Event::ExtrinsicPostponed { index }); + break; + } + + // We're going to execute it - remove the item from storage + remove_pending_extrinsic::(index, &mut weight); + + // Dispatch the extrinsic + let origin: T::RuntimeOrigin = frame_system::RawOrigin::Signed(pending.who).into(); + let result = call.dispatch(origin); + + match result { + Ok(post_info) => { + let actual_weight = post_info.actual_weight.unwrap_or(info.call_weight); + weight = weight.saturating_add(actual_weight); + + Self::deposit_event(Event::ExtrinsicDispatched { index }); + } + Err(e) => { + weight = weight.saturating_add(info.call_weight); + + Self::deposit_event(Event::ExtrinsicDispatchFailed { + index, + error: e.error, + }); + } + } + } + + /// Remove a pending extrinsic from storage and decrement count. + fn remove_pending_extrinsic(index: u32, weight: &mut Weight) { + PendingExtrinsics::::remove(index); + PendingExtrinsicCount::::mutate(|c| *c = c.saturating_sub(1)); + *weight = weight.saturating_add(T::DbWeight::get().writes(2)); + } + + weight + } + pub fn try_decode_shielded_tx( uxt: ExtrinsicOf, ) -> Option diff --git a/pallets/shield/src/mock.rs b/pallets/shield/src/mock.rs index 5a2aef7d80..530a0b913d 100644 --- a/pallets/shield/src/mock.rs +++ b/pallets/shield/src/mock.rs @@ -1,6 +1,8 @@ use crate as pallet_shield; use stp_shield::MLKEM768_ENC_KEY_LEN; +use codec::Decode; +use frame_support::pallet_prelude::DispatchError; use frame_support::traits::{ConstBool, ConstU64}; use frame_support::{BoundedVec, construct_runtime, derive_impl, parameter_types}; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -85,9 +87,20 @@ impl pallet_shield::FindAuthors for MockFindAuthors { } } +/// Mock decryptor that just decodes the bytes without decryption. +pub struct MockDecryptor; + +impl pallet_shield::ExtrinsicDecryptor for MockDecryptor { + fn decrypt(data: &[u8]) -> Result { + RuntimeCall::decode(&mut &data[..]).map_err(|_| DispatchError::Other("decode failed")) + } +} + impl pallet_shield::Config for Test { type AuthorityId = AuraId; type FindAuthors = MockFindAuthors; + type RuntimeCall = RuntimeCall; + type ExtrinsicDecryptor = MockDecryptor; } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index 04eb29126b..e331f91b92 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -1,8 +1,10 @@ use crate::mock::*; use crate::{ - AuthorKeys, CurrentKey, Error, HasMigrationRun, NextKey, NextKeyExpiresAt, PendingKey, - PendingKeyExpiresAt, + AuthorKeys, CurrentKey, Error, HasMigrationRun, MaxPendingExtrinsics, NextKey, + NextKeyExpiresAt, NextPendingExtrinsicIndex, PendingExtrinsic, PendingExtrinsicCount, + PendingExtrinsics, PendingKey, PendingKeyExpiresAt, }; +use frame_support::traits::Get; use codec::Encode; use frame_support::{BoundedVec, assert_noop, assert_ok}; @@ -460,3 +462,423 @@ mod migration_tests { count } } + +// --------------------------------------------------------------------------- +// Encrypted extrinsics storage tests +// --------------------------------------------------------------------------- + +mod encrypted_extrinsics_tests { + use super::*; + use frame_support::traits::Hooks; + + #[test] + fn store_encrypted_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + let call = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + let encoded_call = BoundedVec::truncate_from(call.encode()); + let who: u64 = 1; + + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(who), + encoded_call.clone(), + )); + + // Verify the extrinsic was stored at index 0 with account ID + let expected = PendingExtrinsic:: { + who, + call: encoded_call, + submitted_at: 1, + }; + assert_eq!(PendingExtrinsics::::get(0), Some(expected)); + assert_eq!(NextPendingExtrinsicIndex::::get(), 1); + assert_eq!(PendingExtrinsicCount::::get(), 1); + + // Verify event was emitted with index + System::assert_last_event( + crate::Event::::ExtrinsicStored { index: 0, who }.into(), + ); + }); + } + + #[test] + fn on_initialize_decodes_and_dispatches() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Store an encoded remark call + let call = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + let encoded_call = BoundedVec::truncate_from(call.encode()); + + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + encoded_call, + )); + + // Verify there's a pending extrinsic + assert_eq!(NextPendingExtrinsicIndex::::get(), 1); + assert_eq!(PendingExtrinsicCount::::get(), 1); + assert!(PendingExtrinsics::::get(0).is_some()); + + // Run on_initialize + MevShield::on_initialize(2); + + // Verify storage was cleared but NextPendingExtrinsicIndex stays (unique auto-increment) + assert!(PendingExtrinsics::::get(0).is_none()); + assert_eq!(NextPendingExtrinsicIndex::::get(), 1); + assert_eq!(PendingExtrinsicCount::::get(), 0); + + // Verify ExtrinsicDispatched event was emitted + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 0 }.into()); + }); + } + + #[test] + fn on_initialize_handles_decode_failure() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Store invalid bytes that can't be decoded as a call + let invalid_bytes = BoundedVec::truncate_from(vec![0xFF, 0xFF, 0xFF, 0xFF]); + + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + invalid_bytes, + )); + + // Run on_initialize + MevShield::on_initialize(2); + + // Verify storage was cleared + assert!(PendingExtrinsics::::get(0).is_none()); + + // Verify ExtrinsicDecodeFailed event was emitted + System::assert_has_event( + crate::Event::::ExtrinsicDecodeFailed { index: 0 }.into(), + ); + }); + } + + #[test] + fn on_initialize_handles_dispatch_failure() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Test with multiple calls to ensure the iteration works correctly. + + let call1 = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + let call2 = RuntimeCall::System(frame_system::Call::remark { + remark: vec![4, 5, 6], + }); + + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call1.encode()), + )); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call2.encode()), + )); + + // Verify there are 2 pending extrinsics + assert_eq!(NextPendingExtrinsicIndex::::get(), 2); + assert_eq!(PendingExtrinsicCount::::get(), 2); + assert!(PendingExtrinsics::::get(0).is_some()); + assert!(PendingExtrinsics::::get(1).is_some()); + + // Run on_initialize + MevShield::on_initialize(2); + + // Verify storage was cleared + assert!(PendingExtrinsics::::get(0).is_none()); + assert!(PendingExtrinsics::::get(1).is_none()); + + // Verify both calls were dispatched + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 0 }.into()); + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 1 }.into()); + }); + } + + #[test] + fn store_encrypted_rejects_when_full() { + new_test_ext().execute_with(|| { + let max = >::get(); + + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }); + let encoded_call = BoundedVec::truncate_from(call.encode()); + + // Fill up the pending extrinsics storage to max + for _ in 0..max { + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + encoded_call.clone(), + )); + } + + // The next one should fail + assert_noop!( + MevShield::store_encrypted(RuntimeOrigin::signed(1), encoded_call), + Error::::TooManyPendingExtrinsics + ); + }); + } + + #[test] + fn on_initialize_processes_mixed_success_and_failure() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Store a valid call + let valid_call = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(valid_call.encode()), + )); + + // Store invalid bytes + let invalid_bytes = BoundedVec::truncate_from(vec![0xFF, 0xFF]); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + invalid_bytes, + )); + + // Store another valid call + let valid_call2 = RuntimeCall::System(frame_system::Call::remark { + remark: vec![4, 5, 6], + }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(valid_call2.encode()), + )); + + // Run on_initialize + MevShield::on_initialize(2); + + // Verify storage was cleared + assert!(PendingExtrinsics::::get(0).is_none()); + assert!(PendingExtrinsics::::get(1).is_none()); + assert!(PendingExtrinsics::::get(2).is_none()); + + // Verify correct events were emitted + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 0 }.into()); + System::assert_has_event( + crate::Event::::ExtrinsicDecodeFailed { index: 1 }.into(), + ); + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 2 }.into()); + }); + } + + #[test] + fn on_initialize_expires_old_extrinsics() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Store an extrinsic at block 1 + let call = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call.encode()), + )); + + // Verify the extrinsic was stored with submitted_at = 1 + let pending = PendingExtrinsics::::get(0).unwrap(); + assert_eq!(pending.submitted_at, 1); + + // Run on_initialize at block 12 (1 + 10 + 1 = 12, which is > MAX_EXTRINSIC_LIFETIME) + // MAX_EXTRINSIC_LIFETIME is 10, so at block 12, age is 11 which exceeds the limit + System::set_block_number(12); + MevShield::on_initialize(12); + + // Verify storage was cleared + assert!(PendingExtrinsics::::get(0).is_none()); + assert_eq!(PendingExtrinsicCount::::get(), 0); + + // Verify ExtrinsicExpired event was emitted (not ExtrinsicDispatched) + System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); + }); + } + + #[test] + fn on_initialize_does_not_expire_recent_extrinsics() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Store an extrinsic at block 1 + let call = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call.encode()), + )); + + // Run on_initialize at block 11 (age is 10, which equals MAX_EXTRINSIC_LIFETIME) + // Should NOT expire since we check age > MAX, not age >= + System::set_block_number(11); + MevShield::on_initialize(11); + + // Verify storage was cleared (extrinsic was dispatched, not expired) + assert!(PendingExtrinsics::::get(0).is_none()); + + // Verify ExtrinsicDispatched event was emitted (not ExtrinsicExpired) + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 0 }.into()); + }); + } + + #[test] + fn on_initialize_emits_dispatch_failed_on_bad_origin() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // set_heap_pages requires Root origin, so dispatching with Signed will fail + let call = RuntimeCall::System(frame_system::Call::set_heap_pages { pages: 10 }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call.encode()), + )); + + // Run on_initialize + MevShield::on_initialize(2); + + // Verify storage was cleared + assert!(PendingExtrinsics::::get(0).is_none()); + assert_eq!(PendingExtrinsicCount::::get(), 0); + + // Verify ExtrinsicDispatchFailed event was emitted + System::assert_has_event( + crate::Event::::ExtrinsicDispatchFailed { + index: 0, + error: sp_runtime::DispatchError::BadOrigin, + } + .into(), + ); + }); + } + + #[test] + fn on_initialize_handles_missing_slots() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Manually create a gap in indices by directly manipulating storage + let call = RuntimeCall::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + }); + let pending = PendingExtrinsic:: { + who: 1, + call: BoundedVec::truncate_from(call.encode()), + submitted_at: 1, + }; + + // Insert at index 5, leaving 0-4 empty + PendingExtrinsics::::insert(5, pending); + NextPendingExtrinsicIndex::::put(6); + PendingExtrinsicCount::::put(1); + + // Run on_initialize - should handle the gap and process index 5 + MevShield::on_initialize(2); + + // Verify the extrinsic at index 5 was processed + assert!(PendingExtrinsics::::get(5).is_none()); + assert_eq!(PendingExtrinsicCount::::get(), 0); + + // Verify ExtrinsicDispatched event for index 5 + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 5 }.into()); + }); + } + + #[test] + fn multiple_accounts_dispatch_with_correct_origins() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + let user_a: u64 = 100; + let user_b: u64 = 200; + + // User A submits a remark_with_event + let call_a = + RuntimeCall::System(frame_system::Call::remark_with_event { remark: vec![0xAA] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(user_a), + BoundedVec::truncate_from(call_a.encode()), + )); + + // User B submits a remark_with_event + let call_b = + RuntimeCall::System(frame_system::Call::remark_with_event { remark: vec![0xBB] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(user_b), + BoundedVec::truncate_from(call_b.encode()), + )); + + // Run on_initialize + MevShield::on_initialize(2); + + // Verify both events have correct senders + let hash_a = ::Hashing::hash(&[0xAAu8]); + let hash_b = ::Hashing::hash(&[0xBBu8]); + + System::assert_has_event( + frame_system::Event::::Remarked { + sender: user_a, + hash: hash_a, + } + .into(), + ); + System::assert_has_event( + frame_system::Event::::Remarked { + sender: user_b, + hash: hash_b, + } + .into(), + ); + }); + } + + #[test] + fn expiration_mixed_with_valid_extrinsics() { + new_test_ext().execute_with(|| { + // Submit first extrinsic at block 1 + System::set_block_number(1); + let old_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![0x01] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(old_call.encode()), + )); + + // Submit second extrinsic at block 10 + System::set_block_number(10); + let new_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![0x02] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(2), + BoundedVec::truncate_from(new_call.encode()), + )); + + // Run on_initialize at block 12 + // First extrinsic: age = 12 - 1 = 11 > 10, should expire + // Second extrinsic: age = 12 - 10 = 2 <= 10, should dispatch + System::set_block_number(12); + MevShield::on_initialize(12); + + // Verify both were removed from storage + assert!(PendingExtrinsics::::get(0).is_none()); + assert!(PendingExtrinsics::::get(1).is_none()); + assert_eq!(PendingExtrinsicCount::::get(), 0); + + // Verify first expired, second dispatched + System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); + System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 1 }.into()); + }); + } +} diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 772909638b..38c2330b48 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -100,6 +100,8 @@ impl pallet_balances::Config for Test { impl pallet_shield::Config for Test { type AuthorityId = sp_core::sr25519::Public; type FindAuthors = (); + type RuntimeCall = RuntimeCall; + type ExtrinsicDecryptor = (); } pub struct NoNestingCallFilter; diff --git a/runtime/src/check_mortality.rs b/runtime/src/check_mortality.rs index 6d8316ba01..2ec5233ed1 100644 --- a/runtime/src/check_mortality.rs +++ b/runtime/src/check_mortality.rs @@ -52,36 +52,42 @@ impl core::fmt::Debug for CheckMortality< } } -impl TransactionExtension - for CheckMortality +impl + TransactionExtension<::RuntimeCall> for CheckMortality where - T::RuntimeCall: Dispatchable + IsSubType>, + ::RuntimeCall: Dispatchable + IsSubType>, T: pallet_shield::Config, { const IDENTIFIER: &'static str = "CheckMortality"; - type Implicit = as TransactionExtension>::Implicit; - type Val = as TransactionExtension>::Val; - type Pre = as TransactionExtension>::Pre; + type Implicit = as TransactionExtension< + ::RuntimeCall, + >>::Implicit; + type Val = as TransactionExtension< + ::RuntimeCall, + >>::Val; + type Pre = as TransactionExtension< + ::RuntimeCall, + >>::Pre; fn implicit(&self) -> Result { CheckMortalitySubstrate::::from(self.0).implicit() } - fn weight(&self, call: &T::RuntimeCall) -> sp_weights::Weight { + fn weight(&self, call: &::RuntimeCall) -> sp_weights::Weight { CheckMortalitySubstrate::::from(self.0).weight(call) } fn validate( &self, origin: T::RuntimeOrigin, - call: &T::RuntimeCall, - info: &DispatchInfoOf, + call: &::RuntimeCall, + info: &DispatchInfoOf<::RuntimeCall>, len: usize, self_implicit: Self::Implicit, inherited_implication: &impl Implication, source: TransactionSource, - ) -> ValidateResult { + ) -> ValidateResult::RuntimeCall> { if let Some(ShieldCall::submit_encrypted { .. }) = IsSubType::>::is_sub_type(call) { @@ -109,8 +115,8 @@ where self, val: Self::Val, origin: &T::RuntimeOrigin, - call: &T::RuntimeCall, - info: &DispatchInfoOf, + call: &::RuntimeCall, + info: &DispatchInfoOf<::RuntimeCall>, len: usize, ) -> Result { CheckMortalitySubstrate::::from(self.0).prepare(val, origin, call, info, len) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5fd4e5b401..6c8da6f98d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -149,6 +149,8 @@ impl pallet_shield::FindAuthors for FindAuraAuthors { impl pallet_shield::Config for Runtime { type AuthorityId = AuraId; type FindAuthors = FindAuraAuthors; + type RuntimeCall = RuntimeCall; + type ExtrinsicDecryptor = (); } parameter_types! { From 7404d76b12fbe8707d65b03a187ec64b7035a3c4 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 20 Mar 2026 16:26:28 +0300 Subject: [PATCH 02/14] Add set_max_pending_extrinsics_number extrinsic --- pallets/shield/src/lib.rs | 31 ++++++++++++++--- pallets/shield/src/tests.rs | 67 ++++++++++++++++++++++++++++++++++--- 2 files changed, 90 insertions(+), 8 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 9b8c9261e9..c36987f4db 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -13,7 +13,7 @@ use frame_support::{ pallet_prelude::*, traits::IsSubType, }; -use frame_system::{ensure_none, ensure_signed, pallet_prelude::*}; +use frame_system::{ensure_none, ensure_root, ensure_signed, pallet_prelude::*}; use ml_kem::{ Ciphertext, EncodedSizeUser, MlKem768, MlKem768Params, kem::{Decapsulate, DecapsulationKey}, @@ -122,8 +122,14 @@ pub mod pallet { /// Maximum size of a single encoded call. pub type MaxCallSize = ConstU32<8192>; - /// Maximum number of pending extrinsics. - pub type MaxPendingExtrinsics = ConstU32<100>; + /// Default maximum number of pending extrinsics. + pub type DefaultMaxPendingExtrinsics = ConstU32<100>; + + /// Configurable maximum number of pending extrinsics. + /// Defaults to 100 if not explicitly set via `set_max_pending_extrinsics`. + #[pallet::storage] + pub type MaxPendingExtrinsicsLimit = + StorageValue<_, u32, ValueQuery, DefaultMaxPendingExtrinsics>; /// Maximum block difference between submission and execution. pub const MAX_EXTRINSIC_LIFETIME: u32 = 10; @@ -176,6 +182,8 @@ pub mod pallet { ExtrinsicExpired { index: u32 }, /// Extrinsic postponed due to weight limit. ExtrinsicPostponed { index: u32 }, + /// Maximum pending extrinsics limit was updated. + MaxPendingExtrinsicsNumberSet { value: u32 }, } #[pallet::error] @@ -328,7 +336,7 @@ pub mod pallet { let count = PendingExtrinsicCount::::get(); ensure!( - count < >::get(), + count < MaxPendingExtrinsicsLimit::::get(), Error::::TooManyPendingExtrinsics ); @@ -346,6 +354,21 @@ pub mod pallet { Self::deposit_event(Event::ExtrinsicStored { index, who }); Ok(()) } + + /// Set the maximum number of pending extrinsics allowed in the queue. + #[pallet::call_index(3)] + #[pallet::weight(T::DbWeight::get().writes(1_u64))] + pub fn set_max_pending_extrinsics_number( + origin: OriginFor, + value: u32, + ) -> DispatchResult { + ensure_root(origin)?; + + MaxPendingExtrinsicsLimit::::put(value); + + Self::deposit_event(Event::MaxPendingExtrinsicsNumberSet { value }); + Ok(()) + } } #[pallet::inherent] diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index e331f91b92..52542a791d 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -1,11 +1,9 @@ use crate::mock::*; use crate::{ - AuthorKeys, CurrentKey, Error, HasMigrationRun, MaxPendingExtrinsics, NextKey, + AuthorKeys, CurrentKey, Error, HasMigrationRun, MaxPendingExtrinsicsLimit, NextKey, NextKeyExpiresAt, NextPendingExtrinsicIndex, PendingExtrinsic, PendingExtrinsicCount, PendingExtrinsics, PendingKey, PendingKeyExpiresAt, }; -use frame_support::traits::Get; - use codec::Encode; use frame_support::{BoundedVec, assert_noop, assert_ok}; use sp_runtime::testing::TestSignature; @@ -609,7 +607,7 @@ mod encrypted_extrinsics_tests { #[test] fn store_encrypted_rejects_when_full() { new_test_ext().execute_with(|| { - let max = >::get(); + let max = MaxPendingExtrinsicsLimit::::get(); let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }); let encoded_call = BoundedVec::truncate_from(call.encode()); @@ -881,4 +879,65 @@ mod encrypted_extrinsics_tests { System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 1 }.into()); }); } + + #[test] + fn set_max_pending_extrinsics_number_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Default is 100 + assert_eq!(MaxPendingExtrinsicsLimit::::get(), 100); + + assert_ok!(MevShield::set_max_pending_extrinsics_number( + RuntimeOrigin::root(), + 50, + )); + + assert_eq!(MaxPendingExtrinsicsLimit::::get(), 50); + + System::assert_last_event( + crate::Event::::MaxPendingExtrinsicsNumberSet { value: 50 }.into(), + ); + }); + } + + #[test] + fn set_max_pending_extrinsics_number_rejects_signed_origin() { + new_test_ext().execute_with(|| { + assert_noop!( + MevShield::set_max_pending_extrinsics_number(RuntimeOrigin::signed(1), 50), + sp_runtime::DispatchError::BadOrigin + ); + }); + } + + #[test] + fn set_max_pending_extrinsics_number_enforced_on_store() { + new_test_ext().execute_with(|| { + // Set limit to 2 + assert_ok!(MevShield::set_max_pending_extrinsics_number( + RuntimeOrigin::root(), + 2, + )); + + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }); + let encoded_call = BoundedVec::truncate_from(call.encode()); + + // First two should succeed + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + encoded_call.clone(), + )); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + encoded_call.clone(), + )); + + // Third should fail + assert_noop!( + MevShield::store_encrypted(RuntimeOrigin::signed(1), encoded_call), + Error::::TooManyPendingExtrinsics + ); + }); + } } From aafd8396c2999b0457a47cd771ff83a9e1bcb0a8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 23 Mar 2026 15:17:06 +0300 Subject: [PATCH 03/14] Add set_on_initialize_weight extrinsic --- pallets/shield/src/lib.rs | 45 +++++++++++++++---- pallets/shield/src/tests.rs | 86 ++++++++++++++++++++++++++++++++++++- 2 files changed, 121 insertions(+), 10 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index c36987f4db..c503f5d39b 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -11,7 +11,7 @@ use chacha20poly1305::{ use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, pallet_prelude::*, - traits::IsSubType, + traits::{ConstU64, IsSubType}, }; use frame_system::{ensure_none, ensure_root, ensure_signed, pallet_prelude::*}; use ml_kem::{ @@ -134,9 +134,17 @@ pub mod pallet { /// Maximum block difference between submission and execution. pub const MAX_EXTRINSIC_LIFETIME: u32 = 10; - /// Maximum weight allowed for on_initialize processing. - /// Processing stops when this limit would be exceeded. - pub const MAX_ON_INITIALIZE_WEIGHT: Weight = Weight::from_parts(500_000_000_000, 0); + /// Default maximum weight allowed for on_initialize processing. + pub const DEFAULT_ON_INITIALIZE_WEIGHT: u64 = 500_000_000_000; + + /// Absolute maximum weight for on_initialize: half the total block weight (2s of 4s). + pub const MAX_ON_INITIALIZE_WEIGHT: u64 = 2_000_000_000_000; + + /// Configurable maximum weight for on_initialize processing. + /// Defaults to 500_000_000_000 ref_time if not explicitly set. + #[pallet::storage] + pub type OnInitializeWeight = + StorageValue<_, u64, ValueQuery, ConstU64>; /// A pending extrinsic stored for later execution. #[freeze_struct("c5749ec89253be61")] @@ -184,6 +192,8 @@ pub mod pallet { ExtrinsicPostponed { index: u32 }, /// Maximum pending extrinsics limit was updated. MaxPendingExtrinsicsNumberSet { value: u32 }, + /// Maximum on_initialize weight was updated. + OnInitializeWeightSet { value: u64 }, } #[pallet::error] @@ -194,6 +204,8 @@ pub mod pallet { Unreachable, /// Too many pending extrinsics in storage. TooManyPendingExtrinsics, + /// Weight exceeds the absolute maximum (half of total block weight). + WeightExceedsAbsoluteMax, } #[pallet::hooks] @@ -369,6 +381,24 @@ pub mod pallet { Self::deposit_event(Event::MaxPendingExtrinsicsNumberSet { value }); Ok(()) } + + /// Set the maximum weight allowed for on_initialize processing. + /// Rejects values exceeding the absolute limit (half of total block weight). + #[pallet::call_index(4)] + #[pallet::weight(T::DbWeight::get().writes(1_u64))] + pub fn set_on_initialize_weight(origin: OriginFor, value: u64) -> DispatchResult { + ensure_root(origin)?; + + ensure!( + value <= MAX_ON_INITIALIZE_WEIGHT, + Error::::WeightExceedsAbsoluteMax + ); + + OnInitializeWeight::::put(value); + + Self::deposit_event(Event::OnInitializeWeightSet { value }); + Ok(()) + } } #[pallet::inherent] @@ -445,10 +475,9 @@ impl Pallet { .writes(2) .saturating_add(info.call_weight); - if weight - .saturating_add(dispatch_weight) - .any_gt(MAX_ON_INITIALIZE_WEIGHT) - { + let max_weight = Weight::from_parts(OnInitializeWeight::::get(), 0); + + if weight.saturating_add(dispatch_weight).any_gt(max_weight) { Self::deposit_event(Event::ExtrinsicPostponed { index }); break; } diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index 52542a791d..24c32fa518 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -1,8 +1,8 @@ use crate::mock::*; use crate::{ AuthorKeys, CurrentKey, Error, HasMigrationRun, MaxPendingExtrinsicsLimit, NextKey, - NextKeyExpiresAt, NextPendingExtrinsicIndex, PendingExtrinsic, PendingExtrinsicCount, - PendingExtrinsics, PendingKey, PendingKeyExpiresAt, + NextKeyExpiresAt, NextPendingExtrinsicIndex, OnInitializeWeight, PendingExtrinsic, + PendingExtrinsicCount, PendingExtrinsics, PendingKey, PendingKeyExpiresAt, }; use codec::Encode; use frame_support::{BoundedVec, assert_noop, assert_ok}; @@ -940,4 +940,86 @@ mod encrypted_extrinsics_tests { ); }); } + + #[test] + fn set_on_initialize_weight_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + assert_eq!( + OnInitializeWeight::::get(), + crate::DEFAULT_ON_INITIALIZE_WEIGHT + ); + + assert_ok!(MevShield::set_on_initialize_weight( + RuntimeOrigin::root(), + 1_000_000, + )); + + assert_eq!(OnInitializeWeight::::get(), 1_000_000); + + System::assert_last_event( + crate::Event::::OnInitializeWeightSet { value: 1_000_000 }.into(), + ); + }); + } + + #[test] + fn set_on_initialize_weight_rejects_signed_origin() { + new_test_ext().execute_with(|| { + assert_noop!( + MevShield::set_on_initialize_weight(RuntimeOrigin::signed(1), 1_000_000), + sp_runtime::DispatchError::BadOrigin + ); + }); + } + + #[test] + fn set_on_initialize_weight_rejects_above_absolute_max() { + new_test_ext().execute_with(|| { + // Exactly at absolute max should succeed + assert_ok!(MevShield::set_on_initialize_weight( + RuntimeOrigin::root(), + crate::MAX_ON_INITIALIZE_WEIGHT, + )); + + // Above absolute max should fail + assert_noop!( + MevShield::set_on_initialize_weight( + RuntimeOrigin::root(), + crate::MAX_ON_INITIALIZE_WEIGHT + 1, + ), + Error::::WeightExceedsAbsoluteMax + ); + }); + } + + #[test] + fn set_on_initialize_weight_enforced_on_processing() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Set weight to 0 so nothing can be processed + assert_ok!(MevShield::set_on_initialize_weight( + RuntimeOrigin::root(), + 0, + )); + + // Store an extrinsic + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call.encode()), + )); + + assert_eq!(PendingExtrinsicCount::::get(), 1); + + // Run on_initialize — should postpone due to weight limit + MevShield::on_initialize(2); + + // Extrinsic should still be pending (postponed) + assert_eq!(PendingExtrinsicCount::::get(), 1); + System::assert_has_event(crate::Event::::ExtrinsicPostponed { index: 0 }.into()); + }); + } } From b85df946cb27b5db369a0359dc8db5502ff61b01 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 23 Mar 2026 21:20:35 +0300 Subject: [PATCH 04/14] Add set_stored_extrinsic_lifetime extrinsic. --- pallets/shield/src/lib.rs | 26 +++++++++++++-- pallets/shield/src/tests.rs | 65 +++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index c503f5d39b..44e35e9597 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -131,8 +131,14 @@ pub mod pallet { pub type MaxPendingExtrinsicsLimit = StorageValue<_, u32, ValueQuery, DefaultMaxPendingExtrinsics>; - /// Maximum block difference between submission and execution. - pub const MAX_EXTRINSIC_LIFETIME: u32 = 10; + /// Default extrinsic lifetime in blocks. + pub const DEFAULT_EXTRINSIC_LIFETIME: u32 = 10; + + /// Configurable extrinsic lifetime (max block difference between submission and execution). + /// Defaults to 10 blocks if not explicitly set. + #[pallet::storage] + pub type ExtrinsicLifetime = + StorageValue<_, u32, ValueQuery, ConstU32>; /// Default maximum weight allowed for on_initialize processing. pub const DEFAULT_ON_INITIALIZE_WEIGHT: u64 = 500_000_000_000; @@ -194,6 +200,8 @@ pub mod pallet { MaxPendingExtrinsicsNumberSet { value: u32 }, /// Maximum on_initialize weight was updated. OnInitializeWeightSet { value: u64 }, + /// Extrinsic lifetime was updated. + ExtrinsicLifetimeSet { value: u32 }, } #[pallet::error] @@ -399,6 +407,18 @@ pub mod pallet { Self::deposit_event(Event::OnInitializeWeightSet { value }); Ok(()) } + + /// Set the extrinsic lifetime (max blocks between submission and execution). + #[pallet::call_index(5)] + #[pallet::weight(T::DbWeight::get().writes(1_u64))] + pub fn set_stored_extrinsic_lifetime(origin: OriginFor, value: u32) -> DispatchResult { + ensure_root(origin)?; + + ExtrinsicLifetime::::put(value); + + Self::deposit_event(Event::ExtrinsicLifetimeSet { value }); + Ok(()) + } } #[pallet::inherent] @@ -450,7 +470,7 @@ impl Pallet { // Check if the extrinsic has expired let age = current_block.saturating_sub(pending.submitted_at); - if age > MAX_EXTRINSIC_LIFETIME.into() { + if age > ExtrinsicLifetime::::get().into() { remove_pending_extrinsic::(index, &mut weight); Self::deposit_event(Event::ExtrinsicExpired { index }); diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index 24c32fa518..14e906ac2f 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -1,7 +1,7 @@ use crate::mock::*; use crate::{ - AuthorKeys, CurrentKey, Error, HasMigrationRun, MaxPendingExtrinsicsLimit, NextKey, - NextKeyExpiresAt, NextPendingExtrinsicIndex, OnInitializeWeight, PendingExtrinsic, + AuthorKeys, CurrentKey, Error, ExtrinsicLifetime, HasMigrationRun, MaxPendingExtrinsicsLimit, + NextKey, NextKeyExpiresAt, NextPendingExtrinsicIndex, OnInitializeWeight, PendingExtrinsic, PendingExtrinsicCount, PendingExtrinsics, PendingKey, PendingKeyExpiresAt, }; use codec::Encode; @@ -1022,4 +1022,65 @@ mod encrypted_extrinsics_tests { System::assert_has_event(crate::Event::::ExtrinsicPostponed { index: 0 }.into()); }); } + + #[test] + fn set_stored_extrinsic_lifetime_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + assert_eq!( + ExtrinsicLifetime::::get(), + crate::DEFAULT_EXTRINSIC_LIFETIME + ); + + assert_ok!(MevShield::set_stored_extrinsic_lifetime( + RuntimeOrigin::root(), + 20 + )); + + assert_eq!(ExtrinsicLifetime::::get(), 20); + + System::assert_last_event( + crate::Event::::ExtrinsicLifetimeSet { value: 20 }.into(), + ); + }); + } + + #[test] + fn set_stored_extrinsic_lifetime_rejects_signed_origin() { + new_test_ext().execute_with(|| { + assert_noop!( + MevShield::set_stored_extrinsic_lifetime(RuntimeOrigin::signed(1), 20), + sp_runtime::DispatchError::BadOrigin + ); + }); + } + + #[test] + fn set_stored_extrinsic_lifetime_enforced_on_expiration() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Set lifetime to 2 blocks + assert_ok!(MevShield::set_stored_extrinsic_lifetime( + RuntimeOrigin::root(), + 2 + )); + + // Store an extrinsic at block 1 + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call.encode()), + )); + + // At block 4: age = 4 - 1 = 3 > 2, should expire + System::set_block_number(4); + MevShield::on_initialize(4); + + assert!(PendingExtrinsics::::get(0).is_none()); + assert_eq!(PendingExtrinsicCount::::get(), 0); + System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); + }); + } } From 5966204a091132f0eb7147db9f63f14f307b2ba6 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 27 Mar 2026 16:53:54 +0300 Subject: [PATCH 05/14] Apply review suggestions --- pallets/shield/src/lib.rs | 23 ++++++++++----------- pallets/shield/src/tests.rs | 40 ++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 44e35e9597..55a700a9d8 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -120,7 +120,7 @@ pub mod pallet { StorageMap<_, Identity, BoundedVec, bool, ValueQuery>; /// Maximum size of a single encoded call. - pub type MaxCallSize = ConstU32<8192>; + pub type MaxEncryptedCallSize = ConstU32<8192>; /// Default maximum number of pending extrinsics. pub type DefaultMaxPendingExtrinsics = ConstU32<100>; @@ -153,14 +153,14 @@ pub mod pallet { StorageValue<_, u64, ValueQuery, ConstU64>; /// A pending extrinsic stored for later execution. - #[freeze_struct("c5749ec89253be61")] + #[freeze_struct("f13d2a9d7bd4767d")] #[derive(Clone, Encode, Decode, TypeInfo, MaxEncodedLen, PartialEq, Debug)] #[scale_info(skip_type_params(T))] pub struct PendingExtrinsic { /// The account that submitted the extrinsic. pub who: T::AccountId, /// The encoded call data. - pub call: BoundedVec, + pub encrypted_call: BoundedVec, /// The block number when the extrinsic was submitted. pub submitted_at: BlockNumberFor, } @@ -349,7 +349,7 @@ pub mod pallet { .saturating_add(T::DbWeight::get().writes(3_u64)))] pub fn store_encrypted( origin: OriginFor, - call: BoundedVec, + encrypted_call: BoundedVec, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -363,7 +363,7 @@ pub mod pallet { let index = NextPendingExtrinsicIndex::::get(); let pending = PendingExtrinsic { who: who.clone(), - call, + encrypted_call, submitted_at: frame_system::Pallet::::block_number(), }; PendingExtrinsics::::insert(index, pending); @@ -478,15 +478,12 @@ impl Pallet { continue; } - let call = match T::ExtrinsicDecryptor::decrypt(&pending.call) { - Ok(call) => call, - Err(_) => { - remove_pending_extrinsic::(index, &mut weight); + let Ok(call) = T::ExtrinsicDecryptor::decrypt(&pending.encrypted_call) else { + remove_pending_extrinsic::(index, &mut weight); - Self::deposit_event(Event::ExtrinsicDecodeFailed { index }); + Self::deposit_event(Event::ExtrinsicDecodeFailed { index }); - continue; - } + continue; }; // Check if dispatching would exceed weight limit @@ -531,7 +528,7 @@ impl Pallet { fn remove_pending_extrinsic(index: u32, weight: &mut Weight) { PendingExtrinsics::::remove(index); PendingExtrinsicCount::::mutate(|c| *c = c.saturating_sub(1)); - *weight = weight.saturating_add(T::DbWeight::get().writes(2)); + *weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 2)); } weight diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index 14e906ac2f..1c223b81f0 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -488,7 +488,7 @@ mod encrypted_extrinsics_tests { // Verify the extrinsic was stored at index 0 with account ID let expected = PendingExtrinsic:: { who, - call: encoded_call, + encrypted_call: encoded_call, submitted_at: 1, }; assert_eq!(PendingExtrinsics::::get(0), Some(expected)); @@ -567,40 +567,34 @@ mod encrypted_extrinsics_tests { new_test_ext().execute_with(|| { System::set_block_number(1); - // Test with multiple calls to ensure the iteration works correctly. - - let call1 = RuntimeCall::System(frame_system::Call::remark { - remark: vec![1, 2, 3], - }); - let call2 = RuntimeCall::System(frame_system::Call::remark { - remark: vec![4, 5, 6], - }); + // A root-only call dispatched from a signed origin will fail. + let failing_call = + RuntimeCall::System(frame_system::Call::set_heap_pages { pages: 64 }); assert_ok!(MevShield::store_encrypted( RuntimeOrigin::signed(1), - BoundedVec::truncate_from(call1.encode()), - )); - assert_ok!(MevShield::store_encrypted( - RuntimeOrigin::signed(1), - BoundedVec::truncate_from(call2.encode()), + BoundedVec::truncate_from(failing_call.encode()), )); - // Verify there are 2 pending extrinsics - assert_eq!(NextPendingExtrinsicIndex::::get(), 2); - assert_eq!(PendingExtrinsicCount::::get(), 2); + // Verify there is 1 pending extrinsic + assert_eq!(NextPendingExtrinsicIndex::::get(), 1); + assert_eq!(PendingExtrinsicCount::::get(), 1); assert!(PendingExtrinsics::::get(0).is_some()); - assert!(PendingExtrinsics::::get(1).is_some()); // Run on_initialize MevShield::on_initialize(2); // Verify storage was cleared assert!(PendingExtrinsics::::get(0).is_none()); - assert!(PendingExtrinsics::::get(1).is_none()); - // Verify both calls were dispatched - System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 0 }.into()); - System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 1 }.into()); + // Verify the call failed + System::assert_has_event( + crate::Event::::ExtrinsicDispatchFailed { + index: 0, + error: sp_runtime::DispatchError::BadOrigin, + } + .into(), + ); }); } @@ -775,7 +769,7 @@ mod encrypted_extrinsics_tests { }); let pending = PendingExtrinsic:: { who: 1, - call: BoundedVec::truncate_from(call.encode()), + encrypted_call: BoundedVec::truncate_from(call.encode()), submitted_at: 1, }; From 79f950182ed6ef985029d84b8677c0cbb290b46f Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 30 Mar 2026 15:51:22 +0300 Subject: [PATCH 06/14] Add benchmarks --- pallets/shield/src/benchmarking.rs | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/pallets/shield/src/benchmarking.rs b/pallets/shield/src/benchmarking.rs index 3fbf564f85..366c4ce111 100644 --- a/pallets/shield/src/benchmarking.rs +++ b/pallets/shield/src/benchmarking.rs @@ -188,5 +188,59 @@ mod benches { } } + /// Worst-case `store_encrypted`: queue is nearly full (count = limit - 1), + /// max-size encrypted call data (8192 bytes). + #[benchmark] + fn store_encrypted() { + let who: T::AccountId = whitelisted_caller(); + + // Fill queue to just under the limit for worst-case read path. + let limit = MaxPendingExtrinsicsLimit::::get(); + PendingExtrinsicCount::::put(limit.saturating_sub(1)); + NextPendingExtrinsicIndex::::put(limit.saturating_sub(1)); + + let encrypted_call: BoundedVec = + BoundedVec::truncate_from(vec![0xAB; 8192]); + + #[extrinsic_call] + store_encrypted(RawOrigin::Signed(who.clone()), encrypted_call); + + assert_eq!(PendingExtrinsicCount::::get(), limit); + } + + /// Benchmark `set_max_pending_extrinsics_number`: root origin, single storage write. + #[benchmark] + fn set_max_pending_extrinsics_number() { + let value: u32 = 500; + + #[extrinsic_call] + set_max_pending_extrinsics_number(RawOrigin::Root, value); + + assert_eq!(MaxPendingExtrinsicsLimit::::get(), value); + } + + /// Benchmark `set_on_initialize_weight`: root origin, single storage write. + /// Uses the maximum allowed value for worst-case. + #[benchmark] + fn set_on_initialize_weight() { + let value: u64 = MAX_ON_INITIALIZE_WEIGHT; + + #[extrinsic_call] + set_on_initialize_weight(RawOrigin::Root, value); + + assert_eq!(OnInitializeWeight::::get(), value); + } + + /// Benchmark `set_stored_extrinsic_lifetime`: root origin, single storage write. + #[benchmark] + fn set_stored_extrinsic_lifetime() { + let value: u32 = 100; + + #[extrinsic_call] + set_stored_extrinsic_lifetime(RawOrigin::Root, value); + + assert_eq!(ExtrinsicLifetime::::get(), value); + } + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); } From 61fd6f417518e51a5a60a2d3875d1e200d21330c Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 30 Mar 2026 15:52:20 +0300 Subject: [PATCH 07/14] Add weights --- pallets/shield/src/weights.rs | 208 ++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 pallets/shield/src/weights.rs diff --git a/pallets/shield/src/weights.rs b/pallets/shield/src/weights.rs new file mode 100644 index 0000000000..d7264c15fd --- /dev/null +++ b/pallets/shield/src/weights.rs @@ -0,0 +1,208 @@ + +//! Autogenerated weights for `pallet_shield` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 +//! DATE: 2026-03-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `shamix2.local`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: `1024` + +// Executed Command: +// ./target/release/node-subtensor +// benchmark +// pallet +// --chain +// local +// --pallet +// pallet_shield +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --template=./.maintain/frame-weight-template.hbs +// --allow-missing-host-functions +// --output +// pallets/shield/src/weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weight functions needed for `pallet_shield`. +pub trait WeightInfo { + fn announce_next_key() -> Weight; + fn submit_encrypted() -> Weight; + fn store_encrypted() -> Weight; + fn set_max_pending_extrinsics_number() -> Weight; + fn set_on_initialize_weight() -> Weight; + fn set_stored_extrinsic_lifetime() -> Weight; +} + +/// Weights for `pallet_shield` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `Aura::Authorities` (r:1 w:0) + /// Proof: `Aura::Authorities` (`max_values`: Some(1), `max_size`: Some(1025), added: 1520, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKey` (r:1 w:1) + /// Proof: `MevShield::PendingKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKey` (r:1 w:1) + /// Proof: `MevShield::NextKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::AuthorKeys` (r:1 w:1) + /// Proof: `MevShield::AuthorKeys` (`max_values`: None, `max_size`: Some(2090), added: 4565, mode: `MaxEncodedLen`) + /// Storage: `MevShield::CurrentKey` (r:0 w:1) + /// Proof: `MevShield::CurrentKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::NextKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::PendingKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn announce_next_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `3877` + // Estimated: `5555` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 5555) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + fn submit_encrypted() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 117_000_000 picoseconds. + Weight::from_parts(118_000_000, 0) + } + /// Storage: `MevShield::PendingExtrinsicCount` (r:1 w:1) + /// Proof: `MevShield::PendingExtrinsicCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:1 w:0) + /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextPendingExtrinsicIndex` (r:1 w:1) + /// Proof: `MevShield::NextPendingExtrinsicIndex` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingExtrinsics` (r:0 w:1) + /// Proof: `MevShield::PendingExtrinsics` (`max_values`: None, `max_size`: Some(8234), added: 10709, mode: `MaxEncodedLen`) + fn store_encrypted() -> Weight { + // Proof Size summary in bytes: + // Measured: `56` + // Estimated: `1489` + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(14_000_000, 1489) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) + /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_max_pending_extrinsics_number() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::OnInitializeWeight` (r:0 w:1) + /// Proof: `MevShield::OnInitializeWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_on_initialize_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::ExtrinsicLifetime` (r:0 w:1) + /// Proof: `MevShield::ExtrinsicLifetime` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_stored_extrinsic_lifetime() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `Aura::Authorities` (r:1 w:0) + /// Proof: `Aura::Authorities` (`max_values`: Some(1), `max_size`: Some(1025), added: 1520, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKey` (r:1 w:1) + /// Proof: `MevShield::PendingKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKey` (r:1 w:1) + /// Proof: `MevShield::NextKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::AuthorKeys` (r:1 w:1) + /// Proof: `MevShield::AuthorKeys` (`max_values`: None, `max_size`: Some(2090), added: 4565, mode: `MaxEncodedLen`) + /// Storage: `MevShield::CurrentKey` (r:0 w:1) + /// Proof: `MevShield::CurrentKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::NextKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::PendingKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn announce_next_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `3877` + // Estimated: `5555` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_000_000, 5555) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + fn submit_encrypted() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 117_000_000 picoseconds. + Weight::from_parts(118_000_000, 0) + } + /// Storage: `MevShield::PendingExtrinsicCount` (r:1 w:1) + /// Proof: `MevShield::PendingExtrinsicCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:1 w:0) + /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextPendingExtrinsicIndex` (r:1 w:1) + /// Proof: `MevShield::NextPendingExtrinsicIndex` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingExtrinsics` (r:0 w:1) + /// Proof: `MevShield::PendingExtrinsics` (`max_values`: None, `max_size`: Some(8234), added: 10709, mode: `MaxEncodedLen`) + fn store_encrypted() -> Weight { + // Proof Size summary in bytes: + // Measured: `56` + // Estimated: `1489` + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(14_000_000, 1489) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) + /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_max_pending_extrinsics_number() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::OnInitializeWeight` (r:0 w:1) + /// Proof: `MevShield::OnInitializeWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_on_initialize_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::ExtrinsicLifetime` (r:0 w:1) + /// Proof: `MevShield::ExtrinsicLifetime` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_stored_extrinsic_lifetime() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} \ No newline at end of file From ff3fef3b6ae08359f6b5fa1254a32cb8baee72a8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 30 Mar 2026 16:05:31 +0300 Subject: [PATCH 08/14] Integrate weights. --- pallets/shield/src/lib.rs | 24 ++++++++++++------------ pallets/shield/src/mock.rs | 1 + pallets/subtensor/src/tests/mock.rs | 1 + runtime/src/lib.rs | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 55a700a9d8..9468a67da2 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -32,6 +32,9 @@ pub use pallet::*; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod weights; +pub use weights::WeightInfo; + #[cfg(test)] pub mod mock; @@ -82,6 +85,9 @@ pub mod pallet { /// Decryptor for stored extrinsics. type ExtrinsicDecryptor: ExtrinsicDecryptor<::RuntimeCall>; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; } #[pallet::pallet] @@ -246,9 +252,7 @@ pub mod pallet { /// 3. NextKey ← next-next author's key (user-facing) /// 4. AuthorKeys[current] ← announced key #[pallet::call_index(0)] - #[pallet::weight(Weight::from_parts(33_230_000, 0) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)))] + #[pallet::weight(T::WeightInfo::announce_next_key())] pub fn announce_next_key( origin: OriginFor, enc_key: Option, @@ -328,9 +332,7 @@ pub mod pallet { /// ciphertext = key_hash || kem_len || kem_ct || nonce || aead_ct /// #[pallet::call_index(1)] - #[pallet::weight(Weight::from_parts(207_500_000, 0) - .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)))] + #[pallet::weight(T::WeightInfo::submit_encrypted())] pub fn submit_encrypted( origin: OriginFor, ciphertext: BoundedVec>, @@ -344,9 +346,7 @@ pub mod pallet { /// Store an encrypted extrinsic for later execution in on_initialize. #[pallet::call_index(2)] - #[pallet::weight(Weight::from_parts(10_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)))] + #[pallet::weight(T::WeightInfo::store_encrypted())] pub fn store_encrypted( origin: OriginFor, encrypted_call: BoundedVec, @@ -377,7 +377,7 @@ pub mod pallet { /// Set the maximum number of pending extrinsics allowed in the queue. #[pallet::call_index(3)] - #[pallet::weight(T::DbWeight::get().writes(1_u64))] + #[pallet::weight(T::WeightInfo::set_max_pending_extrinsics_number())] pub fn set_max_pending_extrinsics_number( origin: OriginFor, value: u32, @@ -393,7 +393,7 @@ pub mod pallet { /// Set the maximum weight allowed for on_initialize processing. /// Rejects values exceeding the absolute limit (half of total block weight). #[pallet::call_index(4)] - #[pallet::weight(T::DbWeight::get().writes(1_u64))] + #[pallet::weight(T::WeightInfo::set_on_initialize_weight())] pub fn set_on_initialize_weight(origin: OriginFor, value: u64) -> DispatchResult { ensure_root(origin)?; @@ -410,7 +410,7 @@ pub mod pallet { /// Set the extrinsic lifetime (max blocks between submission and execution). #[pallet::call_index(5)] - #[pallet::weight(T::DbWeight::get().writes(1_u64))] + #[pallet::weight(T::WeightInfo::set_stored_extrinsic_lifetime())] pub fn set_stored_extrinsic_lifetime(origin: OriginFor, value: u32) -> DispatchResult { ensure_root(origin)?; diff --git a/pallets/shield/src/mock.rs b/pallets/shield/src/mock.rs index 530a0b913d..1bb6fa018a 100644 --- a/pallets/shield/src/mock.rs +++ b/pallets/shield/src/mock.rs @@ -101,6 +101,7 @@ impl pallet_shield::Config for Test { type FindAuthors = MockFindAuthors; type RuntimeCall = RuntimeCall; type ExtrinsicDecryptor = MockDecryptor; + type WeightInfo = (); } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 38c2330b48..fa9e6f034e 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -102,6 +102,7 @@ impl pallet_shield::Config for Test { type FindAuthors = (); type RuntimeCall = RuntimeCall; type ExtrinsicDecryptor = (); + type WeightInfo = (); } pub struct NoNestingCallFilter; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 6c8da6f98d..1059795551 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -151,6 +151,7 @@ impl pallet_shield::Config for Runtime { type FindAuthors = FindAuraAuthors; type RuntimeCall = RuntimeCall; type ExtrinsicDecryptor = (); + type WeightInfo = pallet_shield::weights::SubstrateWeight; } parameter_types! { From a17b8c29fa1073ac8e2dc256a4064dd6d486d44a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 31 Mar 2026 13:11:05 +0300 Subject: [PATCH 09/14] Add max extrinsic weight limit for processing. --- pallets/shield/src/benchmarking.rs | 12 ++++ pallets/shield/src/lib.rs | 42 ++++++++++++++ pallets/shield/src/tests.rs | 92 +++++++++++++++++++++++++++++- pallets/shield/src/weights.rs | 21 +++++++ 4 files changed, 164 insertions(+), 3 deletions(-) diff --git a/pallets/shield/src/benchmarking.rs b/pallets/shield/src/benchmarking.rs index 366c4ce111..0d884765a4 100644 --- a/pallets/shield/src/benchmarking.rs +++ b/pallets/shield/src/benchmarking.rs @@ -242,5 +242,17 @@ mod benches { assert_eq!(ExtrinsicLifetime::::get(), value); } + /// Benchmark `set_max_extrinsic_weight`: root origin, single storage write. + /// Uses the maximum allowed value for worst-case. + #[benchmark] + fn set_max_extrinsic_weight() { + let value: u64 = MAX_ON_INITIALIZE_WEIGHT; + + #[extrinsic_call] + set_max_extrinsic_weight(RawOrigin::Root, value); + + assert_eq!(MaxExtrinsicWeight::::get(), value); + } + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); } diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 9468a67da2..a7f8f7f6e5 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -158,6 +158,15 @@ pub mod pallet { pub type OnInitializeWeight = StorageValue<_, u64, ValueQuery, ConstU64>; + /// Default maximum weight for a single extrinsic (3x set_weights base weight). + pub const DEFAULT_MAX_EXTRINSIC_WEIGHT: u64 = 50_000_000_000; + + /// Configurable maximum weight for a single extrinsic dispatched during on_initialize. + /// Extrinsics exceeding this limit are removed from the queue. + #[pallet::storage] + pub type MaxExtrinsicWeight = + StorageValue<_, u64, ValueQuery, ConstU64>; + /// A pending extrinsic stored for later execution. #[freeze_struct("f13d2a9d7bd4767d")] #[derive(Clone, Encode, Decode, TypeInfo, MaxEncodedLen, PartialEq, Debug)] @@ -208,6 +217,10 @@ pub mod pallet { OnInitializeWeightSet { value: u64 }, /// Extrinsic lifetime was updated. ExtrinsicLifetimeSet { value: u32 }, + /// Maximum per-extrinsic weight was updated. + MaxExtrinsicWeightSet { value: u64 }, + /// Extrinsic exceeded the per-extrinsic weight limit and was removed. + ExtrinsicWeightExceeded { index: u32 }, } #[pallet::error] @@ -419,6 +432,25 @@ pub mod pallet { Self::deposit_event(Event::ExtrinsicLifetimeSet { value }); Ok(()) } + + /// Set the maximum weight allowed for a single extrinsic during on_initialize processing. + /// Extrinsics exceeding this limit are removed from the queue. + /// Rejects values exceeding the absolute limit. + #[pallet::call_index(6)] + #[pallet::weight(T::WeightInfo::set_max_extrinsic_weight())] + pub fn set_max_extrinsic_weight(origin: OriginFor, value: u64) -> DispatchResult { + ensure_root(origin)?; + + ensure!( + value <= MAX_ON_INITIALIZE_WEIGHT, + Error::::WeightExceedsAbsoluteMax + ); + + MaxExtrinsicWeight::::put(value); + + Self::deposit_event(Event::MaxExtrinsicWeightSet { value }); + Ok(()) + } } #[pallet::inherent] @@ -492,6 +524,16 @@ impl Pallet { .writes(2) .saturating_add(info.call_weight); + // Check per-extrinsic weight limit + let max_extrinsic_weight = Weight::from_parts(MaxExtrinsicWeight::::get(), 0); + if info.call_weight.any_gt(max_extrinsic_weight) { + remove_pending_extrinsic::(index, &mut weight); + + Self::deposit_event(Event::ExtrinsicWeightExceeded { index }); + + continue; + } + let max_weight = Weight::from_parts(OnInitializeWeight::::get(), 0); if weight.saturating_add(dispatch_weight).any_gt(max_weight) { diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index 1c223b81f0..0f858d8f9f 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -1,8 +1,9 @@ use crate::mock::*; use crate::{ - AuthorKeys, CurrentKey, Error, ExtrinsicLifetime, HasMigrationRun, MaxPendingExtrinsicsLimit, - NextKey, NextKeyExpiresAt, NextPendingExtrinsicIndex, OnInitializeWeight, PendingExtrinsic, - PendingExtrinsicCount, PendingExtrinsics, PendingKey, PendingKeyExpiresAt, + AuthorKeys, CurrentKey, Error, ExtrinsicLifetime, HasMigrationRun, MaxExtrinsicWeight, + MaxPendingExtrinsicsLimit, NextKey, NextKeyExpiresAt, NextPendingExtrinsicIndex, + OnInitializeWeight, PendingExtrinsic, PendingExtrinsicCount, PendingExtrinsics, PendingKey, + PendingKeyExpiresAt, }; use codec::Encode; use frame_support::{BoundedVec, assert_noop, assert_ok}; @@ -1077,4 +1078,89 @@ mod encrypted_extrinsics_tests { System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); }); } + + #[test] + fn set_max_extrinsic_weight_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + assert_eq!( + MaxExtrinsicWeight::::get(), + crate::DEFAULT_MAX_EXTRINSIC_WEIGHT + ); + + assert_ok!(MevShield::set_max_extrinsic_weight( + RuntimeOrigin::root(), + 1_000_000, + )); + + assert_eq!(MaxExtrinsicWeight::::get(), 1_000_000); + + System::assert_last_event( + crate::Event::::MaxExtrinsicWeightSet { value: 1_000_000 }.into(), + ); + }); + } + + #[test] + fn set_max_extrinsic_weight_rejects_signed_origin() { + new_test_ext().execute_with(|| { + assert_noop!( + MevShield::set_max_extrinsic_weight(RuntimeOrigin::signed(1), 1_000_000), + sp_runtime::DispatchError::BadOrigin + ); + }); + } + + #[test] + fn set_max_extrinsic_weight_rejects_above_absolute_max() { + new_test_ext().execute_with(|| { + // Exactly at absolute max should succeed + assert_ok!(MevShield::set_max_extrinsic_weight( + RuntimeOrigin::root(), + crate::MAX_ON_INITIALIZE_WEIGHT, + )); + + // Above absolute max should fail + assert_noop!( + MevShield::set_max_extrinsic_weight( + RuntimeOrigin::root(), + crate::MAX_ON_INITIALIZE_WEIGHT + 1, + ), + Error::::WeightExceedsAbsoluteMax + ); + }); + } + + #[test] + fn max_extrinsic_weight_is_enforced() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + + // Set per-extrinsic weight to 0 so all extrinsics exceed the limit + assert_ok!(MevShield::set_max_extrinsic_weight( + RuntimeOrigin::root(), + 0, + )); + + // Store an extrinsic + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }); + assert_ok!(MevShield::store_encrypted( + RuntimeOrigin::signed(1), + BoundedVec::truncate_from(call.encode()), + )); + + assert_eq!(PendingExtrinsicCount::::get(), 1); + + // Run on_initialize — should remove the extrinsic (weight exceeded) + MevShield::on_initialize(2); + + // Extrinsic should be removed (not postponed) + assert_eq!(PendingExtrinsicCount::::get(), 0); + assert!(PendingExtrinsics::::get(0).is_none()); + System::assert_has_event( + crate::Event::::ExtrinsicWeightExceeded { index: 0 }.into(), + ); + }); + } } diff --git a/pallets/shield/src/weights.rs b/pallets/shield/src/weights.rs index d7264c15fd..db444219b9 100644 --- a/pallets/shield/src/weights.rs +++ b/pallets/shield/src/weights.rs @@ -42,6 +42,7 @@ pub trait WeightInfo { fn set_max_pending_extrinsics_number() -> Weight; fn set_on_initialize_weight() -> Weight; fn set_stored_extrinsic_lifetime() -> Weight; + fn set_max_extrinsic_weight() -> Weight; } /// Weights for `pallet_shield` using the Substrate node and recommended hardware. @@ -124,6 +125,16 @@ impl WeightInfo for SubstrateWeight { Weight::from_parts(5_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `MevShield::MaxExtrinsicWeight` (r:0 w:1) + /// Proof: `MevShield::MaxExtrinsicWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_max_extrinsic_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } // For backwards compatibility and tests. @@ -205,4 +216,14 @@ impl WeightInfo for () { Weight::from_parts(5_000_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: `MevShield::MaxExtrinsicWeight` (r:0 w:1) + /// Proof: `MevShield::MaxExtrinsicWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_max_extrinsic_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } } \ No newline at end of file From cbec3e23f5adf28f7fe5725edf241491db7702d7 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 31 Mar 2026 14:20:10 +0300 Subject: [PATCH 10/14] Update store_encrypted weights. --- pallets/shield/src/benchmarking.rs | 2 +- pallets/shield/src/lib.rs | 12 +++++-- pallets/shield/src/weights.rs | 53 +++++------------------------- 3 files changed, 20 insertions(+), 47 deletions(-) diff --git a/pallets/shield/src/benchmarking.rs b/pallets/shield/src/benchmarking.rs index 0d884765a4..0e76d2f024 100644 --- a/pallets/shield/src/benchmarking.rs +++ b/pallets/shield/src/benchmarking.rs @@ -190,7 +190,7 @@ mod benches { /// Worst-case `store_encrypted`: queue is nearly full (count = limit - 1), /// max-size encrypted call data (8192 bytes). - #[benchmark] + #[benchmark(extra)] fn store_encrypted() { let who: T::AccountId = whitelisted_caller(); diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index a7f8f7f6e5..afd8fb49f1 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -53,6 +53,14 @@ type ApplyableCallOf = ::Call; const MAX_EXTRINSIC_DEPTH: u32 = 8; +/// Weight for `store_encrypted`, intentionally set higher than the benchmark +/// to discourage abuse of the encrypted extrinsic queue. +const STORE_ENCRYPTED_WEIGHT: u64 = 20_000_000_000; + +pub fn store_encrypted_weight() -> Weight { + Weight::from_parts(STORE_ENCRYPTED_WEIGHT, 0) +} + /// Trait for decrypting stored extrinsics before dispatch. pub trait ExtrinsicDecryptor { /// Decrypt the stored bytes and return the decoded RuntimeCall. @@ -158,7 +166,7 @@ pub mod pallet { pub type OnInitializeWeight = StorageValue<_, u64, ValueQuery, ConstU64>; - /// Default maximum weight for a single extrinsic (3x set_weights base weight). + /// Default maximum weight for a single extrinsic. pub const DEFAULT_MAX_EXTRINSIC_WEIGHT: u64 = 50_000_000_000; /// Configurable maximum weight for a single extrinsic dispatched during on_initialize. @@ -359,7 +367,7 @@ pub mod pallet { /// Store an encrypted extrinsic for later execution in on_initialize. #[pallet::call_index(2)] - #[pallet::weight(T::WeightInfo::store_encrypted())] + #[pallet::weight(store_encrypted_weight())] pub fn store_encrypted( origin: OriginFor, encrypted_call: BoundedVec, diff --git a/pallets/shield/src/weights.rs b/pallets/shield/src/weights.rs index db444219b9..a2be12560c 100644 --- a/pallets/shield/src/weights.rs +++ b/pallets/shield/src/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_shield` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 -//! DATE: 2026-03-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-03-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `shamix2.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: `1024` @@ -38,7 +38,6 @@ use core::marker::PhantomData; pub trait WeightInfo { fn announce_next_key() -> Weight; fn submit_encrypted() -> Weight; - fn store_encrypted() -> Weight; fn set_max_pending_extrinsics_number() -> Weight; fn set_on_initialize_weight() -> Weight; fn set_stored_extrinsic_lifetime() -> Weight; @@ -66,8 +65,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3877` // Estimated: `5555` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(26_000_000, 5555) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 5555) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -75,25 +74,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 117_000_000 picoseconds. - Weight::from_parts(118_000_000, 0) - } - /// Storage: `MevShield::PendingExtrinsicCount` (r:1 w:1) - /// Proof: `MevShield::PendingExtrinsicCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:1 w:0) - /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `MevShield::NextPendingExtrinsicIndex` (r:1 w:1) - /// Proof: `MevShield::NextPendingExtrinsicIndex` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `MevShield::PendingExtrinsics` (r:0 w:1) - /// Proof: `MevShield::PendingExtrinsics` (`max_values`: None, `max_size`: Some(8234), added: 10709, mode: `MaxEncodedLen`) - fn store_encrypted() -> Weight { - // Proof Size summary in bytes: - // Measured: `56` - // Estimated: `1489` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(14_000_000, 1489) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Minimum execution time: 119_000_000 picoseconds. + Weight::from_parts(120_000_000, 0) } /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -157,8 +139,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3877` // Estimated: `5555` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(26_000_000, 5555) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 5555) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -166,25 +148,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 117_000_000 picoseconds. - Weight::from_parts(118_000_000, 0) - } - /// Storage: `MevShield::PendingExtrinsicCount` (r:1 w:1) - /// Proof: `MevShield::PendingExtrinsicCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:1 w:0) - /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `MevShield::NextPendingExtrinsicIndex` (r:1 w:1) - /// Proof: `MevShield::NextPendingExtrinsicIndex` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `MevShield::PendingExtrinsics` (r:0 w:1) - /// Proof: `MevShield::PendingExtrinsics` (`max_values`: None, `max_size`: Some(8234), added: 10709, mode: `MaxEncodedLen`) - fn store_encrypted() -> Weight { - // Proof Size summary in bytes: - // Measured: `56` - // Estimated: `1489` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(14_000_000, 1489) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Minimum execution time: 119_000_000 picoseconds. + Weight::from_parts(120_000_000, 0) } /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) From a40bdf81511a70614433754118dee5de33289906 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 31 Mar 2026 17:28:44 +0300 Subject: [PATCH 11/14] Change storage map type. --- pallets/shield/src/benchmarking.rs | 11 +++++++-- pallets/shield/src/lib.rs | 36 ++++++++++++------------------ pallets/shield/src/tests.rs | 30 ++++++++++++------------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/pallets/shield/src/benchmarking.rs b/pallets/shield/src/benchmarking.rs index 0e76d2f024..74e156ec5c 100644 --- a/pallets/shield/src/benchmarking.rs +++ b/pallets/shield/src/benchmarking.rs @@ -196,7 +196,14 @@ mod benches { // Fill queue to just under the limit for worst-case read path. let limit = MaxPendingExtrinsicsLimit::::get(); - PendingExtrinsicCount::::put(limit.saturating_sub(1)); + let dummy = PendingExtrinsic:: { + who: who.clone(), + encrypted_call: BoundedVec::truncate_from(vec![0x00; 1]), + submitted_at: 0u32.into(), + }; + for i in 0..limit.saturating_sub(1) { + PendingExtrinsics::::insert(i, dummy.clone()); + } NextPendingExtrinsicIndex::::put(limit.saturating_sub(1)); let encrypted_call: BoundedVec = @@ -205,7 +212,7 @@ mod benches { #[extrinsic_call] store_encrypted(RawOrigin::Signed(who.clone()), encrypted_call); - assert_eq!(PendingExtrinsicCount::::get(), limit); + assert_eq!(PendingExtrinsics::::count(), limit); } /// Benchmark `set_max_pending_extrinsics_number`: root origin, single storage write. diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index afd8fb49f1..753609272f 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -189,19 +189,15 @@ pub mod pallet { } /// Storage map for encrypted extrinsics to be executed in on_initialize. - /// Uses u32 index for O(1) insertion and removal. + /// Uses u32 index for O(1) insertion and removal. Count is maintained automatically. #[pallet::storage] pub type PendingExtrinsics = - StorageMap<_, Identity, u32, PendingExtrinsic, OptionQuery>; + CountedStorageMap<_, Identity, u32, PendingExtrinsic, OptionQuery>; /// Next index to use when inserting a pending extrinsic (unique auto-increment). #[pallet::storage] pub type NextPendingExtrinsicIndex = StorageValue<_, u32, ValueQuery>; - /// Number of pending extrinsics currently stored (for limit checking). - #[pallet::storage] - pub type PendingExtrinsicCount = StorageValue<_, u32, ValueQuery>; - #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -374,10 +370,8 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - let count = PendingExtrinsicCount::::get(); - ensure!( - count < MaxPendingExtrinsicsLimit::::get(), + PendingExtrinsics::::count() < MaxPendingExtrinsicsLimit::::get(), Error::::TooManyPendingExtrinsics ); @@ -390,7 +384,6 @@ pub mod pallet { PendingExtrinsics::::insert(index, pending); NextPendingExtrinsicIndex::::put(index.saturating_add(1)); - PendingExtrinsicCount::::put(count.saturating_add(1)); Self::deposit_event(Event::ExtrinsicStored { index, who }); Ok(()) @@ -489,7 +482,7 @@ impl Pallet { /// Returns the total weight consumed. pub fn process_pending_extrinsics() -> Weight { let next_index = NextPendingExtrinsicIndex::::get(); - let count = PendingExtrinsicCount::::get(); + let count = PendingExtrinsics::::count(); let mut weight = T::DbWeight::get().reads(2); @@ -508,10 +501,13 @@ impl Pallet { continue; }; + let remove_weight = T::DbWeight::get().reads_writes(1, 2); + // Check if the extrinsic has expired let age = current_block.saturating_sub(pending.submitted_at); if age > ExtrinsicLifetime::::get().into() { - remove_pending_extrinsic::(index, &mut weight); + PendingExtrinsics::::remove(index); + weight = weight.saturating_add(remove_weight); Self::deposit_event(Event::ExtrinsicExpired { index }); @@ -519,7 +515,8 @@ impl Pallet { } let Ok(call) = T::ExtrinsicDecryptor::decrypt(&pending.encrypted_call) else { - remove_pending_extrinsic::(index, &mut weight); + PendingExtrinsics::::remove(index); + weight = weight.saturating_add(remove_weight); Self::deposit_event(Event::ExtrinsicDecodeFailed { index }); @@ -535,7 +532,8 @@ impl Pallet { // Check per-extrinsic weight limit let max_extrinsic_weight = Weight::from_parts(MaxExtrinsicWeight::::get(), 0); if info.call_weight.any_gt(max_extrinsic_weight) { - remove_pending_extrinsic::(index, &mut weight); + PendingExtrinsics::::remove(index); + weight = weight.saturating_add(remove_weight); Self::deposit_event(Event::ExtrinsicWeightExceeded { index }); @@ -550,7 +548,8 @@ impl Pallet { } // We're going to execute it - remove the item from storage - remove_pending_extrinsic::(index, &mut weight); + PendingExtrinsics::::remove(index); + weight = weight.saturating_add(remove_weight); // Dispatch the extrinsic let origin: T::RuntimeOrigin = frame_system::RawOrigin::Signed(pending.who).into(); @@ -574,13 +573,6 @@ impl Pallet { } } - /// Remove a pending extrinsic from storage and decrement count. - fn remove_pending_extrinsic(index: u32, weight: &mut Weight) { - PendingExtrinsics::::remove(index); - PendingExtrinsicCount::::mutate(|c| *c = c.saturating_sub(1)); - *weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 2)); - } - weight } diff --git a/pallets/shield/src/tests.rs b/pallets/shield/src/tests.rs index 0f858d8f9f..622b5be74a 100644 --- a/pallets/shield/src/tests.rs +++ b/pallets/shield/src/tests.rs @@ -2,8 +2,7 @@ use crate::mock::*; use crate::{ AuthorKeys, CurrentKey, Error, ExtrinsicLifetime, HasMigrationRun, MaxExtrinsicWeight, MaxPendingExtrinsicsLimit, NextKey, NextKeyExpiresAt, NextPendingExtrinsicIndex, - OnInitializeWeight, PendingExtrinsic, PendingExtrinsicCount, PendingExtrinsics, PendingKey, - PendingKeyExpiresAt, + OnInitializeWeight, PendingExtrinsic, PendingExtrinsics, PendingKey, PendingKeyExpiresAt, }; use codec::Encode; use frame_support::{BoundedVec, assert_noop, assert_ok}; @@ -494,7 +493,7 @@ mod encrypted_extrinsics_tests { }; assert_eq!(PendingExtrinsics::::get(0), Some(expected)); assert_eq!(NextPendingExtrinsicIndex::::get(), 1); - assert_eq!(PendingExtrinsicCount::::get(), 1); + assert_eq!(PendingExtrinsics::::count(), 1); // Verify event was emitted with index System::assert_last_event( @@ -521,7 +520,7 @@ mod encrypted_extrinsics_tests { // Verify there's a pending extrinsic assert_eq!(NextPendingExtrinsicIndex::::get(), 1); - assert_eq!(PendingExtrinsicCount::::get(), 1); + assert_eq!(PendingExtrinsics::::count(), 1); assert!(PendingExtrinsics::::get(0).is_some()); // Run on_initialize @@ -530,7 +529,7 @@ mod encrypted_extrinsics_tests { // Verify storage was cleared but NextPendingExtrinsicIndex stays (unique auto-increment) assert!(PendingExtrinsics::::get(0).is_none()); assert_eq!(NextPendingExtrinsicIndex::::get(), 1); - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); // Verify ExtrinsicDispatched event was emitted System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 0 }.into()); @@ -579,7 +578,7 @@ mod encrypted_extrinsics_tests { // Verify there is 1 pending extrinsic assert_eq!(NextPendingExtrinsicIndex::::get(), 1); - assert_eq!(PendingExtrinsicCount::::get(), 1); + assert_eq!(PendingExtrinsics::::count(), 1); assert!(PendingExtrinsics::::get(0).is_some()); // Run on_initialize @@ -695,7 +694,7 @@ mod encrypted_extrinsics_tests { // Verify storage was cleared assert!(PendingExtrinsics::::get(0).is_none()); - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); // Verify ExtrinsicExpired event was emitted (not ExtrinsicDispatched) System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); @@ -746,7 +745,7 @@ mod encrypted_extrinsics_tests { // Verify storage was cleared assert!(PendingExtrinsics::::get(0).is_none()); - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); // Verify ExtrinsicDispatchFailed event was emitted System::assert_has_event( @@ -777,14 +776,13 @@ mod encrypted_extrinsics_tests { // Insert at index 5, leaving 0-4 empty PendingExtrinsics::::insert(5, pending); NextPendingExtrinsicIndex::::put(6); - PendingExtrinsicCount::::put(1); // Run on_initialize - should handle the gap and process index 5 MevShield::on_initialize(2); // Verify the extrinsic at index 5 was processed assert!(PendingExtrinsics::::get(5).is_none()); - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); // Verify ExtrinsicDispatched event for index 5 System::assert_has_event(crate::Event::::ExtrinsicDispatched { index: 5 }.into()); @@ -867,7 +865,7 @@ mod encrypted_extrinsics_tests { // Verify both were removed from storage assert!(PendingExtrinsics::::get(0).is_none()); assert!(PendingExtrinsics::::get(1).is_none()); - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); // Verify first expired, second dispatched System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); @@ -1007,13 +1005,13 @@ mod encrypted_extrinsics_tests { BoundedVec::truncate_from(call.encode()), )); - assert_eq!(PendingExtrinsicCount::::get(), 1); + assert_eq!(PendingExtrinsics::::count(), 1); // Run on_initialize — should postpone due to weight limit MevShield::on_initialize(2); // Extrinsic should still be pending (postponed) - assert_eq!(PendingExtrinsicCount::::get(), 1); + assert_eq!(PendingExtrinsics::::count(), 1); System::assert_has_event(crate::Event::::ExtrinsicPostponed { index: 0 }.into()); }); } @@ -1074,7 +1072,7 @@ mod encrypted_extrinsics_tests { MevShield::on_initialize(4); assert!(PendingExtrinsics::::get(0).is_none()); - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); System::assert_has_event(crate::Event::::ExtrinsicExpired { index: 0 }.into()); }); } @@ -1150,13 +1148,13 @@ mod encrypted_extrinsics_tests { BoundedVec::truncate_from(call.encode()), )); - assert_eq!(PendingExtrinsicCount::::get(), 1); + assert_eq!(PendingExtrinsics::::count(), 1); // Run on_initialize — should remove the extrinsic (weight exceeded) MevShield::on_initialize(2); // Extrinsic should be removed (not postponed) - assert_eq!(PendingExtrinsicCount::::get(), 0); + assert_eq!(PendingExtrinsics::::count(), 0); assert!(PendingExtrinsics::::get(0).is_none()); System::assert_has_event( crate::Event::::ExtrinsicWeightExceeded { index: 0 }.into(), From 930a45005409df3854e8e6a9f7965616956e4ee8 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 8 Apr 2026 12:40:45 +0300 Subject: [PATCH 12/14] Fix merge conflicts --- pallets/shield/src/lib.rs | 2 - pallets/shield/src/weights.rs | 167 ++++++++++++++++++++++++++++++++-- precompiles/src/staking.rs | 17 +--- 3 files changed, 162 insertions(+), 24 deletions(-) diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 69e8592c8d..f96374590e 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -29,8 +29,6 @@ use subtensor_macros::freeze_struct; pub use pallet::*; -pub mod weights; - #[cfg(feature = "runtime-benchmarks")] mod benchmarking; diff --git a/pallets/shield/src/weights.rs b/pallets/shield/src/weights.rs index 2481a20437..a2be12560c 100644 --- a/pallets/shield/src/weights.rs +++ b/pallets/shield/src/weights.rs @@ -1,9 +1,30 @@ -//! Placeholder weights for `pallet_shield`. +//! Autogenerated weights for `pallet_shield` //! -//! These weights are NOT based on benchmarking output. They are copied from -//! the hardcoded values that were previously inlined in `#[pallet::weight(…)]` -//! annotations and will be replaced once proper benchmarks are run. +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 +//! DATE: 2026-03-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `shamix2.local`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: `1024` + +// Executed Command: +// ./target/release/node-subtensor +// benchmark +// pallet +// --chain +// local +// --pallet +// pallet_shield +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --template=./.maintain/frame-weight-template.hbs +// --allow-missing-host-functions +// --output +// pallets/shield/src/weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -17,29 +38,157 @@ use core::marker::PhantomData; pub trait WeightInfo { fn announce_next_key() -> Weight; fn submit_encrypted() -> Weight; + fn set_max_pending_extrinsics_number() -> Weight; + fn set_on_initialize_weight() -> Weight; + fn set_stored_extrinsic_lifetime() -> Weight; + fn set_max_extrinsic_weight() -> Weight; } /// Weights for `pallet_shield` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + /// Storage: `Aura::Authorities` (r:1 w:0) + /// Proof: `Aura::Authorities` (`max_values`: Some(1), `max_size`: Some(1025), added: 1520, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKey` (r:1 w:1) + /// Proof: `MevShield::PendingKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKey` (r:1 w:1) + /// Proof: `MevShield::NextKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::AuthorKeys` (r:1 w:1) + /// Proof: `MevShield::AuthorKeys` (`max_values`: None, `max_size`: Some(2090), added: 4565, mode: `MaxEncodedLen`) + /// Storage: `MevShield::CurrentKey` (r:0 w:1) + /// Proof: `MevShield::CurrentKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::NextKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::PendingKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn announce_next_key() -> Weight { - Weight::from_parts(33_230_000, 0) + // Proof Size summary in bytes: + // Measured: `3877` + // Estimated: `5555` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 5555) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } fn submit_encrypted() -> Weight { - Weight::from_parts(207_500_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 119_000_000 picoseconds. + Weight::from_parts(120_000_000, 0) + } + /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) + /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_max_pending_extrinsics_number() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::OnInitializeWeight` (r:0 w:1) + /// Proof: `MevShield::OnInitializeWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_on_initialize_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::ExtrinsicLifetime` (r:0 w:1) + /// Proof: `MevShield::ExtrinsicLifetime` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_stored_extrinsic_lifetime() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::MaxExtrinsicWeight` (r:0 w:1) + /// Proof: `MevShield::MaxExtrinsicWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_max_extrinsic_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests. impl WeightInfo for () { + /// Storage: `Aura::Authorities` (r:1 w:0) + /// Proof: `Aura::Authorities` (`max_values`: Some(1), `max_size`: Some(1025), added: 1520, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKey` (r:1 w:1) + /// Proof: `MevShield::PendingKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKey` (r:1 w:1) + /// Proof: `MevShield::NextKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::AuthorKeys` (r:1 w:1) + /// Proof: `MevShield::AuthorKeys` (`max_values`: None, `max_size`: Some(2090), added: 4565, mode: `MaxEncodedLen`) + /// Storage: `MevShield::CurrentKey` (r:0 w:1) + /// Proof: `MevShield::CurrentKey` (`max_values`: Some(1), `max_size`: Some(2050), added: 2545, mode: `MaxEncodedLen`) + /// Storage: `MevShield::NextKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::NextKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `MevShield::PendingKeyExpiresAt` (r:0 w:1) + /// Proof: `MevShield::PendingKeyExpiresAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn announce_next_key() -> Weight { - Weight::from_parts(33_230_000, 0) + // Proof Size summary in bytes: + // Measured: `3877` + // Estimated: `5555` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 5555) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } fn submit_encrypted() -> Weight { - Weight::from_parts(207_500_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 119_000_000 picoseconds. + Weight::from_parts(120_000_000, 0) } -} + /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) + /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_max_pending_extrinsics_number() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::OnInitializeWeight` (r:0 w:1) + /// Proof: `MevShield::OnInitializeWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_on_initialize_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::ExtrinsicLifetime` (r:0 w:1) + /// Proof: `MevShield::ExtrinsicLifetime` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn set_stored_extrinsic_lifetime() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `MevShield::MaxExtrinsicWeight` (r:0 w:1) + /// Proof: `MevShield::MaxExtrinsicWeight` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn set_max_extrinsic_weight() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} \ No newline at end of file diff --git a/precompiles/src/staking.rs b/precompiles/src/staking.rs index 04877d40e5..30d28aaa13 100644 --- a/precompiles/src/staking.rs +++ b/precompiles/src/staking.rs @@ -43,7 +43,7 @@ use pallet_evm::{ }; use pallet_subtensor_proxy as pallet_proxy; use precompile_utils::EvmResult; -use precompile_utils::prelude::{RuntimeHelper, revert, Address}; +use precompile_utils::prelude::{Address, RuntimeHelper, revert}; use sp_core::{H160, H256, U256}; use sp_runtime::traits::{AsSystemOriginSigner, Dispatchable, StaticLookup, UniqueSaturatedInto}; use sp_std::vec; @@ -63,15 +63,12 @@ impl StorageInstance for AllowancesPrefix { pub type AllowancesStorage = StorageDoubleMap< AllowancesPrefix, - // For each approver (EVM address as only EVM-natives need the precompile) Blake2_128Concat, H160, - // For each pair of (spender, netuid) (EVM address as only EVM-natives need the precompile) Blake2_128Concat, (H160, u16), - // Allowed amount U256, ValueQuery, @@ -627,20 +624,14 @@ where amount_alpha: U256, ) -> EvmResult<()> { let spender = handle.context().caller; - let source_address = source_address.0; + let source_address = source_address.0; let destination_coldkey = R::AccountId::from(destination_coldkey.0); let hotkey = R::AccountId::from(hotkey.0); let origin_netuid = try_u16_from_u256(origin_netuid)?; let destination_netuid = try_u16_from_u256(destination_netuid)?; let alpha_amount: u64 = amount_alpha.unique_saturated_into(); - Self::try_consume_allowance( - handle, - source_address, - spender, - origin_netuid, - amount_alpha, - )?; + Self::try_consume_allowance(handle, source_address, spender, origin_netuid, amount_alpha)?; let call = pallet_subtensor::Call::::transfer_stake { destination_coldkey, @@ -649,7 +640,7 @@ where destination_netuid: destination_netuid.into(), alpha_amount: alpha_amount.into(), }; - let source_id = ::AddressMapping::into_account_id(source_address); + let source_id = ::AddressMapping::into_account_id(source_address); handle.try_dispatch_runtime_call::(call, RawOrigin::Signed(source_id)) } From db44146b042fbe1fce99ddefbfa83ceec8476c97 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 8 Apr 2026 15:52:54 +0300 Subject: [PATCH 13/14] Fix eco-tests. --- eco-tests/src/mock.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eco-tests/src/mock.rs b/eco-tests/src/mock.rs index a24af9a39d..65cb6eac03 100644 --- a/eco-tests/src/mock.rs +++ b/eco-tests/src/mock.rs @@ -88,6 +88,8 @@ impl pallet_balances::Config for Test { impl pallet_shield::Config for Test { type AuthorityId = sp_core::sr25519::Public; type FindAuthors = (); + type RuntimeCall = RuntimeCall; + type ExtrinsicDecryptor = (); type WeightInfo = (); } From d269bbe6151841a6adedf957d1c94cd0fe8b5a64 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 8 Apr 2026 13:37:15 +0000 Subject: [PATCH 14/14] auto-update benchmark weights --- pallets/proxy/src/weights.rs | 222 ++++----- pallets/shield/src/weights.rs | 86 ++-- pallets/subtensor/src/weights.rs | 750 +++++++++++++++---------------- pallets/utility/src/weights.rs | 101 ++--- 4 files changed, 577 insertions(+), 582 deletions(-) diff --git a/pallets/proxy/src/weights.rs b/pallets/proxy/src/weights.rs index 9dd82ba383..d84f4260e4 100644 --- a/pallets/proxy/src/weights.rs +++ b/pallets/proxy/src/weights.rs @@ -2,9 +2,9 @@ //! Autogenerated weights for `pallet_subtensor_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 -//! DATE: 2026-04-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-04-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runnervmrg6be`, CPU: `AMD EPYC 7763 64-Core Processor` +//! HOSTNAME: `runnervm727z3`, CPU: `AMD EPYC 9V74 80-Core Processor` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: @@ -22,7 +22,7 @@ // --no-storage-info // --no-min-squares // --no-median-slopes -// --output=/tmp/tmp.YtfzJ0r25T +// --output=/tmp/tmp.UdS7wrYng3 // --template=/home/runner/work/subtensor/subtensor/.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -66,10 +66,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `637 + p * (37 ±0)` // Estimated: `4254 + p * (37 ±0)` - // Minimum execution time: 25_808_000 picoseconds. - Weight::from_parts(27_091_845, 4254) - // Standard Error: 3_977 - .saturating_add(Weight::from_parts(70_379, 0).saturating_mul(p.into())) + // Minimum execution time: 23_005_000 picoseconds. + Weight::from_parts(24_052_533, 4254) + // Standard Error: 2_666 + .saturating_add(Weight::from_parts(58_523, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 37).saturating_mul(p.into())) @@ -92,12 +92,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `894 + a * (68 ±0) + p * (37 ±0)` // Estimated: `8615 + a * (68 ±0) + p * (37 ±0)` - // Minimum execution time: 51_596_000 picoseconds. - Weight::from_parts(52_284_638, 8615) - // Standard Error: 1_812 - .saturating_add(Weight::from_parts(199_279, 0).saturating_mul(a.into())) - // Standard Error: 7_260 - .saturating_add(Weight::from_parts(67_811, 0).saturating_mul(p.into())) + // Minimum execution time: 46_310_000 picoseconds. + Weight::from_parts(48_074_790, 8615) + // Standard Error: 1_422 + .saturating_add(Weight::from_parts(221_154, 0).saturating_mul(a.into())) + // Standard Error: 5_697 + .saturating_add(Weight::from_parts(36_689, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 68).saturating_mul(a.into())) @@ -113,12 +113,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `299 + a * (68 ±0)` // Estimated: `8615` - // Minimum execution time: 25_147_000 picoseconds. - Weight::from_parts(25_023_332, 8615) - // Standard Error: 1_514 - .saturating_add(Weight::from_parts(186_109, 0).saturating_mul(a.into())) - // Standard Error: 6_067 - .saturating_add(Weight::from_parts(61_564, 0).saturating_mul(p.into())) + // Minimum execution time: 22_745_000 picoseconds. + Weight::from_parts(23_094_031, 8615) + // Standard Error: 729 + .saturating_add(Weight::from_parts(193_569, 0).saturating_mul(a.into())) + // Standard Error: 2_919 + .saturating_add(Weight::from_parts(42_742, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -132,12 +132,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `299 + a * (68 ±0)` // Estimated: `8615` - // Minimum execution time: 25_227_000 picoseconds. - Weight::from_parts(25_898_845, 8615) - // Standard Error: 1_248 - .saturating_add(Weight::from_parts(186_052, 0).saturating_mul(a.into())) - // Standard Error: 5_001 - .saturating_add(Weight::from_parts(21_247, 0).saturating_mul(p.into())) + // Minimum execution time: 23_035_000 picoseconds. + Weight::from_parts(23_770_698, 8615) + // Standard Error: 919 + .saturating_add(Weight::from_parts(192_686, 0).saturating_mul(a.into())) + // Standard Error: 3_684 + .saturating_add(Weight::from_parts(17_239, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -153,12 +153,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `308 + a * (68 ±0) + p * (37 ±0)` // Estimated: `8615` - // Minimum execution time: 33_132_000 picoseconds. - Weight::from_parts(33_395_676, 8615) - // Standard Error: 1_213 - .saturating_add(Weight::from_parts(182_232, 0).saturating_mul(a.into())) - // Standard Error: 4_860 - .saturating_add(Weight::from_parts(49_853, 0).saturating_mul(p.into())) + // Minimum execution time: 30_125_000 picoseconds. + Weight::from_parts(30_973_053, 8615) + // Standard Error: 1_111 + .saturating_add(Weight::from_parts(193_333, 0).saturating_mul(a.into())) + // Standard Error: 4_450 + .saturating_add(Weight::from_parts(37_421, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -169,10 +169,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 24_176_000 picoseconds. - Weight::from_parts(25_168_383, 4254) - // Standard Error: 2_342 - .saturating_add(Weight::from_parts(77_557, 0).saturating_mul(p.into())) + // Minimum execution time: 22_114_000 picoseconds. + Weight::from_parts(23_387_688, 4254) + // Standard Error: 7_703 + .saturating_add(Weight::from_parts(42_739, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -185,10 +185,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 25_869_000 picoseconds. - Weight::from_parts(27_179_936, 4254) - // Standard Error: 3_426 - .saturating_add(Weight::from_parts(75_069, 0).saturating_mul(p.into())) + // Minimum execution time: 23_516_000 picoseconds. + Weight::from_parts(24_544_894, 4254) + // Standard Error: 2_101 + .saturating_add(Weight::from_parts(60_100, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -199,10 +199,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 26_119_000 picoseconds. - Weight::from_parts(27_131_627, 4254) - // Standard Error: 2_766 - .saturating_add(Weight::from_parts(39_345, 0).saturating_mul(p.into())) + // Minimum execution time: 23_395_000 picoseconds. + Weight::from_parts(24_322_168, 4254) + // Standard Error: 2_432 + .saturating_add(Weight::from_parts(40_847, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -213,10 +213,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `139` // Estimated: `4254` - // Minimum execution time: 26_149_000 picoseconds. - Weight::from_parts(27_322_859, 4254) - // Standard Error: 2_918 - .saturating_add(Weight::from_parts(25_565, 0).saturating_mul(p.into())) + // Minimum execution time: 23_216_000 picoseconds. + Weight::from_parts(24_452_575, 4254) + // Standard Error: 2_103 + .saturating_add(Weight::from_parts(15_858, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -227,10 +227,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `156 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 25_167_000 picoseconds. - Weight::from_parts(26_239_815, 4254) - // Standard Error: 2_467 - .saturating_add(Weight::from_parts(41_178, 0).saturating_mul(p.into())) + // Minimum execution time: 22_294_000 picoseconds. + Weight::from_parts(23_403_931, 4254) + // Standard Error: 3_071 + .saturating_add(Weight::from_parts(56_461, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -244,8 +244,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `412` // Estimated: `8615` - // Minimum execution time: 44_423_000 picoseconds. - Weight::from_parts(45_565_000, 8615) + // Minimum execution time: 41_673_000 picoseconds. + Weight::from_parts(43_175_000, 8615) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -258,10 +258,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 13_505_000 picoseconds. - Weight::from_parts(14_375_067, 4254) - // Standard Error: 2_360 - .saturating_add(Weight::from_parts(28_886, 0).saturating_mul(p.into())) + // Minimum execution time: 11_437_000 picoseconds. + Weight::from_parts(12_276_272, 4254) + // Standard Error: 1_478 + .saturating_add(Weight::from_parts(36_038, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -282,10 +282,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `637 + p * (37 ±0)` // Estimated: `4254 + p * (37 ±0)` - // Minimum execution time: 25_808_000 picoseconds. - Weight::from_parts(27_091_845, 4254) - // Standard Error: 3_977 - .saturating_add(Weight::from_parts(70_379, 0).saturating_mul(p.into())) + // Minimum execution time: 23_005_000 picoseconds. + Weight::from_parts(24_052_533, 4254) + // Standard Error: 2_666 + .saturating_add(Weight::from_parts(58_523, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 37).saturating_mul(p.into())) @@ -308,12 +308,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `894 + a * (68 ±0) + p * (37 ±0)` // Estimated: `8615 + a * (68 ±0) + p * (37 ±0)` - // Minimum execution time: 51_596_000 picoseconds. - Weight::from_parts(52_284_638, 8615) - // Standard Error: 1_812 - .saturating_add(Weight::from_parts(199_279, 0).saturating_mul(a.into())) - // Standard Error: 7_260 - .saturating_add(Weight::from_parts(67_811, 0).saturating_mul(p.into())) + // Minimum execution time: 46_310_000 picoseconds. + Weight::from_parts(48_074_790, 8615) + // Standard Error: 1_422 + .saturating_add(Weight::from_parts(221_154, 0).saturating_mul(a.into())) + // Standard Error: 5_697 + .saturating_add(Weight::from_parts(36_689, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 68).saturating_mul(a.into())) @@ -329,12 +329,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `299 + a * (68 ±0)` // Estimated: `8615` - // Minimum execution time: 25_147_000 picoseconds. - Weight::from_parts(25_023_332, 8615) - // Standard Error: 1_514 - .saturating_add(Weight::from_parts(186_109, 0).saturating_mul(a.into())) - // Standard Error: 6_067 - .saturating_add(Weight::from_parts(61_564, 0).saturating_mul(p.into())) + // Minimum execution time: 22_745_000 picoseconds. + Weight::from_parts(23_094_031, 8615) + // Standard Error: 729 + .saturating_add(Weight::from_parts(193_569, 0).saturating_mul(a.into())) + // Standard Error: 2_919 + .saturating_add(Weight::from_parts(42_742, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -348,12 +348,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `299 + a * (68 ±0)` // Estimated: `8615` - // Minimum execution time: 25_227_000 picoseconds. - Weight::from_parts(25_898_845, 8615) - // Standard Error: 1_248 - .saturating_add(Weight::from_parts(186_052, 0).saturating_mul(a.into())) - // Standard Error: 5_001 - .saturating_add(Weight::from_parts(21_247, 0).saturating_mul(p.into())) + // Minimum execution time: 23_035_000 picoseconds. + Weight::from_parts(23_770_698, 8615) + // Standard Error: 919 + .saturating_add(Weight::from_parts(192_686, 0).saturating_mul(a.into())) + // Standard Error: 3_684 + .saturating_add(Weight::from_parts(17_239, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -369,12 +369,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `308 + a * (68 ±0) + p * (37 ±0)` // Estimated: `8615` - // Minimum execution time: 33_132_000 picoseconds. - Weight::from_parts(33_395_676, 8615) - // Standard Error: 1_213 - .saturating_add(Weight::from_parts(182_232, 0).saturating_mul(a.into())) - // Standard Error: 4_860 - .saturating_add(Weight::from_parts(49_853, 0).saturating_mul(p.into())) + // Minimum execution time: 30_125_000 picoseconds. + Weight::from_parts(30_973_053, 8615) + // Standard Error: 1_111 + .saturating_add(Weight::from_parts(193_333, 0).saturating_mul(a.into())) + // Standard Error: 4_450 + .saturating_add(Weight::from_parts(37_421, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -385,10 +385,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 24_176_000 picoseconds. - Weight::from_parts(25_168_383, 4254) - // Standard Error: 2_342 - .saturating_add(Weight::from_parts(77_557, 0).saturating_mul(p.into())) + // Minimum execution time: 22_114_000 picoseconds. + Weight::from_parts(23_387_688, 4254) + // Standard Error: 7_703 + .saturating_add(Weight::from_parts(42_739, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -401,10 +401,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 25_869_000 picoseconds. - Weight::from_parts(27_179_936, 4254) - // Standard Error: 3_426 - .saturating_add(Weight::from_parts(75_069, 0).saturating_mul(p.into())) + // Minimum execution time: 23_516_000 picoseconds. + Weight::from_parts(24_544_894, 4254) + // Standard Error: 2_101 + .saturating_add(Weight::from_parts(60_100, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -415,10 +415,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 26_119_000 picoseconds. - Weight::from_parts(27_131_627, 4254) - // Standard Error: 2_766 - .saturating_add(Weight::from_parts(39_345, 0).saturating_mul(p.into())) + // Minimum execution time: 23_395_000 picoseconds. + Weight::from_parts(24_322_168, 4254) + // Standard Error: 2_432 + .saturating_add(Weight::from_parts(40_847, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -429,10 +429,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `139` // Estimated: `4254` - // Minimum execution time: 26_149_000 picoseconds. - Weight::from_parts(27_322_859, 4254) - // Standard Error: 2_918 - .saturating_add(Weight::from_parts(25_565, 0).saturating_mul(p.into())) + // Minimum execution time: 23_216_000 picoseconds. + Weight::from_parts(24_452_575, 4254) + // Standard Error: 2_103 + .saturating_add(Weight::from_parts(15_858, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -443,10 +443,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `156 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 25_167_000 picoseconds. - Weight::from_parts(26_239_815, 4254) - // Standard Error: 2_467 - .saturating_add(Weight::from_parts(41_178, 0).saturating_mul(p.into())) + // Minimum execution time: 22_294_000 picoseconds. + Weight::from_parts(23_403_931, 4254) + // Standard Error: 3_071 + .saturating_add(Weight::from_parts(56_461, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -460,8 +460,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `412` // Estimated: `8615` - // Minimum execution time: 44_423_000 picoseconds. - Weight::from_parts(45_565_000, 8615) + // Minimum execution time: 41_673_000 picoseconds. + Weight::from_parts(43_175_000, 8615) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -474,10 +474,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `119 + p * (37 ±0)` // Estimated: `4254` - // Minimum execution time: 13_505_000 picoseconds. - Weight::from_parts(14_375_067, 4254) - // Standard Error: 2_360 - .saturating_add(Weight::from_parts(28_886, 0).saturating_mul(p.into())) + // Minimum execution time: 11_437_000 picoseconds. + Weight::from_parts(12_276_272, 4254) + // Standard Error: 1_478 + .saturating_add(Weight::from_parts(36_038, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/pallets/shield/src/weights.rs b/pallets/shield/src/weights.rs index a2be12560c..85b2add031 100644 --- a/pallets/shield/src/weights.rs +++ b/pallets/shield/src/weights.rs @@ -2,34 +2,34 @@ //! Autogenerated weights for `pallet_shield` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 -//! DATE: 2026-03-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-04-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `shamix2.local`, CPU: `` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: `1024` +//! HOSTNAME: `runnervm727z3`, CPU: `AMD EPYC 9V74 80-Core Processor` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// ./target/release/node-subtensor +// /home/runner/work/subtensor/subtensor/target/production/node-subtensor // benchmark // pallet -// --chain -// local -// --pallet -// pallet_shield -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 -// --template=./.maintain/frame-weight-template.hbs -// --allow-missing-host-functions -// --output -// pallets/shield/src/weights.rs +// --runtime=/home/runner/work/subtensor/subtensor/target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm +// --genesis-builder=runtime +// --genesis-builder-preset=benchmark +// --wasm-execution=compiled +// --pallet=pallet_shield +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --no-storage-info +// --no-min-squares +// --no-median-slopes +// --output=/tmp/tmp.eBEZWxdqPW +// --template=/home/runner/work/subtensor/subtensor/.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] #![allow(missing_docs)] +#![allow(dead_code)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; @@ -65,8 +65,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3877` // Estimated: `5555` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(27_000_000, 5555) + // Minimum execution time: 32_118_000 picoseconds. + Weight::from_parts(33_661_000, 5555) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -74,8 +74,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 119_000_000 picoseconds. - Weight::from_parts(120_000_000, 0) + // Minimum execution time: 204_519_000 picoseconds. + Weight::from_parts(207_223_000, 0) } /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -83,8 +83,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 3_865_000 picoseconds. + Weight::from_parts(4_206_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `MevShield::OnInitializeWeight` (r:0 w:1) @@ -93,8 +93,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 4_066_000 picoseconds. + Weight::from_parts(4_327_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `MevShield::ExtrinsicLifetime` (r:0 w:1) @@ -103,8 +103,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 3_906_000 picoseconds. + Weight::from_parts(4_116_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `MevShield::MaxExtrinsicWeight` (r:0 w:1) @@ -113,8 +113,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 4_037_000 picoseconds. + Weight::from_parts(4_227_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -139,8 +139,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3877` // Estimated: `5555` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(27_000_000, 5555) + // Minimum execution time: 32_118_000 picoseconds. + Weight::from_parts(33_661_000, 5555) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -148,8 +148,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 119_000_000 picoseconds. - Weight::from_parts(120_000_000, 0) + // Minimum execution time: 204_519_000 picoseconds. + Weight::from_parts(207_223_000, 0) } /// Storage: `MevShield::MaxPendingExtrinsicsLimit` (r:0 w:1) /// Proof: `MevShield::MaxPendingExtrinsicsLimit` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -157,8 +157,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 3_865_000 picoseconds. + Weight::from_parts(4_206_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `MevShield::OnInitializeWeight` (r:0 w:1) @@ -167,8 +167,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 4_066_000 picoseconds. + Weight::from_parts(4_327_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `MevShield::ExtrinsicLifetime` (r:0 w:1) @@ -177,8 +177,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 3_906_000 picoseconds. + Weight::from_parts(4_116_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `MevShield::MaxExtrinsicWeight` (r:0 w:1) @@ -187,8 +187,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 4_037_000 picoseconds. + Weight::from_parts(4_227_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } -} \ No newline at end of file +} diff --git a/pallets/subtensor/src/weights.rs b/pallets/subtensor/src/weights.rs index fe529fea00..a30e09d1ac 100644 --- a/pallets/subtensor/src/weights.rs +++ b/pallets/subtensor/src/weights.rs @@ -2,9 +2,9 @@ //! Autogenerated weights for `pallet_subtensor` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 -//! DATE: 2026-04-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-04-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runnervmrg6be`, CPU: `AMD EPYC 7763 64-Core Processor` +//! HOSTNAME: `runnervm727z3`, CPU: `AMD EPYC 9V74 80-Core Processor` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: @@ -22,7 +22,7 @@ // --no-storage-info // --no-min-squares // --no-median-slopes -// --output=/tmp/tmp.wjGbvrvFdo +// --output=/tmp/tmp.caw6C0JGm3 // --template=/home/runner/work/subtensor/subtensor/.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -187,10 +187,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Swap::CurrentTick` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: - // Measured: `1687` + // Measured: `1629` // Estimated: `13600` - // Minimum execution time: 351_469_000 picoseconds. - Weight::from_parts(370_384_000, 13600) + // Minimum execution time: 348_026_000 picoseconds. + Weight::from_parts(354_034_000, 13600) .saturating_add(T::DbWeight::get().reads(46_u64)) .saturating_add(T::DbWeight::get().writes(38_u64)) } @@ -230,10 +230,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `188840` - // Estimated: `10327430` - // Minimum execution time: 15_014_320_000 picoseconds. - Weight::from_parts(15_501_163_000, 10327430) + // Measured: `188782` + // Estimated: `10327372` + // Minimum execution time: 16_089_221_000 picoseconds. + Weight::from_parts(16_473_771_000, 10327372) .saturating_add(T::DbWeight::get().reads(4112_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -293,10 +293,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `2358` + // Measured: `2307` // Estimated: `8556` - // Minimum execution time: 337_482_000 picoseconds. - Weight::from_parts(347_320_000, 8556) + // Minimum execution time: 338_691_000 picoseconds. + Weight::from_parts(346_814_000, 8556) .saturating_add(T::DbWeight::get().reads(27_u64)) .saturating_add(T::DbWeight::get().writes(15_u64)) } @@ -308,10 +308,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::ServingRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn serve_axon() -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `6743` - // Minimum execution time: 33_903_000 picoseconds. - Weight::from_parts(34_945_000, 6743) + // Measured: `791` + // Estimated: `6731` + // Minimum execution time: 32_479_000 picoseconds. + Weight::from_parts(33_721_000, 6731) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -323,10 +323,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::ServingRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn serve_prometheus() -> Weight { // Proof Size summary in bytes: - // Measured: `776` - // Estimated: `6716` - // Minimum execution time: 30_076_000 picoseconds. - Weight::from_parts(31_088_000, 6716) + // Measured: `764` + // Estimated: `6704` + // Minimum execution time: 29_264_000 picoseconds. + Weight::from_parts(30_095_000, 6704) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -424,10 +424,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Swap::CurrentTick` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) fn burned_register() -> Weight { // Proof Size summary in bytes: - // Measured: `1697` + // Measured: `1639` // Estimated: `13600` - // Minimum execution time: 344_215_000 picoseconds. - Weight::from_parts(364_713_000, 13600) + // Minimum execution time: 341_145_000 picoseconds. + Weight::from_parts(345_863_000, 13600) .saturating_add(T::DbWeight::get().reads(46_u64)) .saturating_add(T::DbWeight::get().writes(38_u64)) } @@ -477,10 +477,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::IsNetworkMember` (`max_values`: None, `max_size`: None, mode: `Measured`) fn root_register() -> Weight { // Proof Size summary in bytes: - // Measured: `1465` - // Estimated: `4930` - // Minimum execution time: 103_233_000 picoseconds. - Weight::from_parts(104_135_000, 4930) + // Measured: `1415` + // Estimated: `4880` + // Minimum execution time: 100_752_000 picoseconds. + Weight::from_parts(102_565_000, 4880) .saturating_add(T::DbWeight::get().reads(19_u64)) .saturating_add(T::DbWeight::get().writes(16_u64)) } @@ -606,10 +606,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::MaxAllowedUids` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_network() -> Weight { // Proof Size summary in bytes: - // Measured: `1745` - // Estimated: `10160` - // Minimum execution time: 298_670_000 picoseconds. - Weight::from_parts(319_769_000, 10160) + // Measured: `1676` + // Estimated: `10091` + // Minimum execution time: 289_917_000 picoseconds. + Weight::from_parts(293_954_000, 10091) .saturating_add(T::DbWeight::get().reads(45_u64)) .saturating_add(T::DbWeight::get().writes(49_u64)) } @@ -635,10 +635,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::SubnetworkN` (`max_values`: None, `max_size`: None, mode: `Measured`) fn commit_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1084` - // Estimated: `4549` - // Minimum execution time: 62_226_000 picoseconds. - Weight::from_parts(63_640_000, 4549) + // Measured: `1061` + // Estimated: `4526` + // Minimum execution time: 59_199_000 picoseconds. + Weight::from_parts(60_772_000, 4526) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -680,10 +680,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn reveal_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1637` - // Estimated: `7577` - // Minimum execution time: 110_287_000 picoseconds. - Weight::from_parts(112_200_000, 7577) + // Measured: `1579` + // Estimated: `7519` + // Minimum execution time: 107_763_000 picoseconds. + Weight::from_parts(109_746_000, 7519) .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -693,8 +693,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_550_000 picoseconds. - Weight::from_parts(5_801_000, 0) + // Minimum execution time: 4_126_000 picoseconds. + Weight::from_parts(4_407_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `SubtensorModule::Owner` (r:1 w:0) @@ -709,10 +709,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::TransactionKeyLastBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_childkey_take() -> Weight { // Proof Size summary in bytes: - // Measured: `950` - // Estimated: `4415` - // Minimum execution time: 46_437_000 picoseconds. - Weight::from_parts(47_268_000, 4415) + // Measured: `938` + // Estimated: `4403` + // Minimum execution time: 45_358_000 picoseconds. + Weight::from_parts(46_140_000, 4403) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -726,10 +726,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::ColdkeySwapAnnouncementDelay` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn announce_coldkey_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `717` - // Estimated: `4182` - // Minimum execution time: 44_364_000 picoseconds. - Weight::from_parts(45_315_000, 4182) + // Measured: `694` + // Estimated: `4159` + // Minimum execution time: 39_469_000 picoseconds. + Weight::from_parts(40_962_000, 4159) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -765,10 +765,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastRateLimitedBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_coldkey_announced() -> Weight { // Proof Size summary in bytes: - // Measured: `1852` - // Estimated: `12742` - // Minimum execution time: 260_729_000 picoseconds. - Weight::from_parts(263_113_000, 12742) + // Measured: `1815` + // Estimated: `12705` + // Minimum execution time: 260_764_000 picoseconds. + Weight::from_parts(265_261_000, 12705) .saturating_add(T::DbWeight::get().reads(31_u64)) .saturating_add(T::DbWeight::get().writes(15_u64)) } @@ -808,10 +808,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastRateLimitedBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_coldkey() -> Weight { // Proof Size summary in bytes: - // Measured: `1968` - // Estimated: `12858` - // Minimum execution time: 281_277_000 picoseconds. - Weight::from_parts(287_689_000, 12858) + // Measured: `1908` + // Estimated: `12798` + // Minimum execution time: 281_736_000 picoseconds. + Weight::from_parts(286_753_000, 12798) .saturating_add(T::DbWeight::get().reads(31_u64)) .saturating_add(T::DbWeight::get().writes(19_u64)) } @@ -823,8 +823,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `665` // Estimated: `4130` - // Minimum execution time: 22_472_000 picoseconds. - Weight::from_parts(23_103_000, 4130) + // Minimum execution time: 19_950_000 picoseconds. + Weight::from_parts(20_701_000, 4130) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -836,8 +836,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `613` // Estimated: `4078` - // Minimum execution time: 18_865_000 picoseconds. - Weight::from_parts(19_767_000, 4078) + // Minimum execution time: 16_415_000 picoseconds. + Weight::from_parts(17_096_000, 4078) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -849,8 +849,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_756_000 picoseconds. - Weight::from_parts(9_117_000, 0) + // Minimum execution time: 6_790_000 picoseconds. + Weight::from_parts(7_151_000, 0) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: `SubtensorModule::CommitRevealWeightsEnabled` (r:1 w:0) @@ -891,10 +891,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn batch_reveal_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `2142` - // Estimated: `8082` - // Minimum execution time: 413_094_000 picoseconds. - Weight::from_parts(422_682_000, 8082) + // Measured: `2084` + // Estimated: `8024` + // Minimum execution time: 426_724_000 picoseconds. + Weight::from_parts(431_712_000, 8024) .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -918,10 +918,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::SubnetAlphaOut` (`max_values`: None, `max_size`: None, mode: `Measured`) fn recycle_alpha() -> Weight { // Proof Size summary in bytes: - // Measured: `1452` - // Estimated: `4917` - // Minimum execution time: 127_739_000 picoseconds. - Weight::from_parts(129_623_000, 4917) + // Measured: `1424` + // Estimated: `4889` + // Minimum execution time: 128_484_000 picoseconds. + Weight::from_parts(130_548_000, 4889) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -945,10 +945,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::SubnetAlphaOut` (`max_values`: None, `max_size`: None, mode: `Measured`) fn burn_alpha() -> Weight { // Proof Size summary in bytes: - // Measured: `1452` - // Estimated: `4917` - // Minimum execution time: 126_257_000 picoseconds. - Weight::from_parts(128_621_000, 4917) + // Measured: `1424` + // Estimated: `4889` + // Minimum execution time: 126_171_000 picoseconds. + Weight::from_parts(128_965_000, 4889) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -966,10 +966,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::SubtokenEnabled` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_call() -> Weight { // Proof Size summary in bytes: - // Measured: `1091` - // Estimated: `4556` - // Minimum execution time: 38_201_000 picoseconds. - Weight::from_parts(38_683_000, 4556) + // Measured: `1079` + // Estimated: `4544` + // Minimum execution time: 37_957_000 picoseconds. + Weight::from_parts(38_939_000, 4544) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1029,10 +1029,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_stake_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2358` + // Measured: `2307` // Estimated: `8556` - // Minimum execution time: 372_377_000 picoseconds. - Weight::from_parts(378_619_000, 8556) + // Minimum execution time: 376_539_000 picoseconds. + Weight::from_parts(383_750_000, 8556) .saturating_add(T::DbWeight::get().reads(27_u64)) .saturating_add(T::DbWeight::get().writes(15_u64)) } @@ -1066,10 +1066,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn move_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `2030` - // Estimated: `7970` - // Minimum execution time: 213_279_000 picoseconds. - Weight::from_parts(214_963_000, 7970) + // Measured: `2002` + // Estimated: `7942` + // Minimum execution time: 222_486_000 picoseconds. + Weight::from_parts(223_918_000, 7942) .saturating_add(T::DbWeight::get().reads(19_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -1125,10 +1125,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_stake_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2224` - // Estimated: `10639` - // Minimum execution time: 384_961_000 picoseconds. - Weight::from_parts(395_060_000, 10639) + // Measured: `2211` + // Estimated: `10626` + // Minimum execution time: 387_646_000 picoseconds. + Weight::from_parts(403_169_000, 10626) .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } @@ -1186,10 +1186,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_stake_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2543` + // Measured: `2494` // Estimated: `8556` - // Minimum execution time: 453_049_000 picoseconds. - Weight::from_parts(464_480_000, 8556) + // Minimum execution time: 461_377_000 picoseconds. + Weight::from_parts(477_951_000, 8556) .saturating_add(T::DbWeight::get().reads(40_u64)) .saturating_add(T::DbWeight::get().writes(22_u64)) } @@ -1225,10 +1225,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn transfer_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `1857` - // Estimated: `7797` - // Minimum execution time: 209_523_000 picoseconds. - Weight::from_parts(212_028_000, 7797) + // Measured: `1829` + // Estimated: `7769` + // Minimum execution time: 215_726_000 picoseconds. + Weight::from_parts(219_552_000, 7769) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -1286,10 +1286,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `2470` + // Measured: `2421` // Estimated: `8556` - // Minimum execution time: 396_283_000 picoseconds. - Weight::from_parts(403_145_000, 8556) + // Minimum execution time: 402_808_000 picoseconds. + Weight::from_parts(420_035_000, 8556) .saturating_add(T::DbWeight::get().reads(40_u64)) .saturating_add(T::DbWeight::get().writes(22_u64)) } @@ -1317,10 +1317,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::WeightsSetRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn batch_commit_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1107` - // Estimated: `4572` - // Minimum execution time: 127_449_000 picoseconds. - Weight::from_parts(128_801_000, 4572) + // Measured: `1084` + // Estimated: `4549` + // Minimum execution time: 125_589_000 picoseconds. + Weight::from_parts(141_484_000, 4549) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1358,10 +1358,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn batch_set_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1474` - // Estimated: `7414` - // Minimum execution time: 102_092_000 picoseconds. - Weight::from_parts(103_243_000, 7414) + // Measured: `1416` + // Estimated: `7356` + // Minimum execution time: 99_310_000 picoseconds. + Weight::from_parts(101_193_000, 7356) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1375,10 +1375,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastRateLimitedBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn decrease_take() -> Weight { // Proof Size summary in bytes: - // Measured: `816` - // Estimated: `4281` - // Minimum execution time: 28_713_000 picoseconds. - Weight::from_parts(29_786_000, 4281) + // Measured: `793` + // Estimated: `4258` + // Minimum execution time: 25_499_000 picoseconds. + Weight::from_parts(26_330_000, 4258) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1394,10 +1394,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::TxDelegateTakeRateLimit` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn increase_take() -> Weight { // Proof Size summary in bytes: - // Measured: `909` - // Estimated: `4374` - // Minimum execution time: 35_506_000 picoseconds. - Weight::from_parts(36_489_000, 4374) + // Measured: `886` + // Estimated: `4351` + // Minimum execution time: 32_540_000 picoseconds. + Weight::from_parts(33_501_000, 4351) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -1521,10 +1521,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::MaxAllowedUids` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_network_with_identity() -> Weight { // Proof Size summary in bytes: - // Measured: `1629` - // Estimated: `10044` - // Minimum execution time: 290_685_000 picoseconds. - Weight::from_parts(294_402_000, 10044) + // Measured: `1560` + // Estimated: `9975` + // Minimum execution time: 279_983_000 picoseconds. + Weight::from_parts(284_690_000, 9975) .saturating_add(T::DbWeight::get().reads(44_u64)) .saturating_add(T::DbWeight::get().writes(48_u64)) } @@ -1536,10 +1536,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::ServingRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn serve_axon_tls() -> Weight { // Proof Size summary in bytes: - // Measured: `774` - // Estimated: `6714` - // Minimum execution time: 33_724_000 picoseconds. - Weight::from_parts(34_194_000, 6714) + // Measured: `762` + // Estimated: `6702` + // Minimum execution time: 31_257_000 picoseconds. + Weight::from_parts(32_769_000, 6702) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -1551,10 +1551,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::IdentitiesV2` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_identity() -> Weight { // Proof Size summary in bytes: - // Measured: `878` - // Estimated: `6818` - // Minimum execution time: 31_560_000 picoseconds. - Weight::from_parts(32_581_000, 6818) + // Measured: `842` + // Estimated: `6782` + // Minimum execution time: 28_703_000 picoseconds. + Weight::from_parts(30_106_000, 6782) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -1566,8 +1566,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `595` // Estimated: `4060` - // Minimum execution time: 17_743_000 picoseconds. - Weight::from_parts(18_505_000, 4060) + // Minimum execution time: 15_634_000 picoseconds. + Weight::from_parts(16_254_000, 4060) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -1635,10 +1635,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::Keys` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_hotkey() -> Weight { // Proof Size summary in bytes: - // Measured: `3072` - // Estimated: `28812` - // Minimum execution time: 1_125_248_000 picoseconds. - Weight::from_parts(1_136_920_000, 28812) + // Measured: `3026` + // Estimated: `28766` + // Minimum execution time: 1_148_985_000 picoseconds. + Weight::from_parts(1_154_584_000, 28766) .saturating_add(T::DbWeight::get().reads(159_u64)) .saturating_add(T::DbWeight::get().writes(95_u64)) } @@ -1650,10 +1650,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::StakingHotkeys` (`max_values`: None, `max_size`: None, mode: `Measured`) fn try_associate_hotkey() -> Weight { // Proof Size summary in bytes: - // Measured: `792` - // Estimated: `4257` - // Minimum execution time: 25_438_000 picoseconds. - Weight::from_parts(26_159_000, 4257) + // Measured: `745` + // Estimated: `4210` + // Minimum execution time: 21_963_000 picoseconds. + Weight::from_parts(22_504_000, 4210) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1665,10 +1665,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::SubtokenEnabled` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unstake_all() -> Weight { // Proof Size summary in bytes: - // Measured: `763` - // Estimated: `9178` - // Minimum execution time: 27_111_000 picoseconds. - Weight::from_parts(28_363_000, 9178) + // Measured: `740` + // Estimated: `9155` + // Minimum execution time: 24_397_000 picoseconds. + Weight::from_parts(25_138_000, 9155) .saturating_add(T::DbWeight::get().reads(6_u64)) } /// Storage: `SubtensorModule::Owner` (r:1 w:0) @@ -1733,10 +1733,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unstake_all_alpha() -> Weight { // Proof Size summary in bytes: - // Measured: `2423` - // Estimated: `10838` - // Minimum execution time: 409_037_000 picoseconds. - Weight::from_parts(431_929_000, 10838) + // Measured: `2372` + // Estimated: `10787` + // Minimum execution time: 414_015_000 picoseconds. + Weight::from_parts(427_445_000, 10787) .saturating_add(T::DbWeight::get().reads(44_u64)) .saturating_add(T::DbWeight::get().writes(24_u64)) } @@ -1792,10 +1792,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_stake_full_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2224` - // Estimated: `10639` - // Minimum execution time: 408_485_000 picoseconds. - Weight::from_parts(430_457_000, 10639) + // Measured: `2211` + // Estimated: `10626` + // Minimum execution time: 412_223_000 picoseconds. + Weight::from_parts(430_190_000, 10626) .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } @@ -1940,12 +1940,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[2, 500]`. fn register_leased_network(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2048 + k * (44 ±0)` - // Estimated: `10469 + k * (2579 ±0)` - // Minimum execution time: 511_318_000 picoseconds. - Weight::from_parts(314_210_493, 10469) - // Standard Error: 33_355 - .saturating_add(Weight::from_parts(48_540_258, 0).saturating_mul(k.into())) + // Measured: `1979 + k * (44 ±0)` + // Estimated: `10400 + k * (2579 ±0)` + // Minimum execution time: 488_338_000 picoseconds. + Weight::from_parts(286_320_370, 10400) + // Standard Error: 33_372 + .saturating_add(Weight::from_parts(47_145_967, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(54_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(54_u64)) @@ -1973,17 +1973,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[2, 500]`. fn terminate_lease(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1493 + k * (53 ±0)` - // Estimated: `6148 + k * (2529 ±0)` - // Minimum execution time: 93_285_000 picoseconds. - Weight::from_parts(85_691_633, 6148) - // Standard Error: 8_977 - .saturating_add(Weight::from_parts(1_625_938, 0).saturating_mul(k.into())) + // Measured: `1447 + k * (53 ±0)` + // Estimated: `6148 + k * (2514 ±0)` + // Minimum execution time: 112_219_000 picoseconds. + Weight::from_parts(130_541_041, 6148) + // Standard Error: 7_186 + .saturating_add(Weight::from_parts(1_496_294, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(7_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) - .saturating_add(Weight::from_parts(0, 2529).saturating_mul(k.into())) + .saturating_add(Weight::from_parts(0, 2514).saturating_mul(k.into())) } /// Storage: `SubtensorModule::SubnetOwner` (r:1 w:0) /// Proof: `SubtensorModule::SubnetOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -1993,8 +1993,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `649` // Estimated: `9064` - // Minimum execution time: 27_983_000 picoseconds. - Weight::from_parts(28_704_000, 9064) + // Minimum execution time: 24_617_000 picoseconds. + Weight::from_parts(25_379_000, 9064) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -2020,10 +2020,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::SubnetworkN` (`max_values`: None, `max_size`: None, mode: `Measured`) fn commit_timelocked_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1083` - // Estimated: `4548` - // Minimum execution time: 74_399_000 picoseconds. - Weight::from_parts(75_311_000, 4548) + // Measured: `1060` + // Estimated: `4525` + // Minimum execution time: 72_058_000 picoseconds. + Weight::from_parts(73_902_000, 4525) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -2037,10 +2037,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::AutoStakeDestinationColdkeys` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_coldkey_auto_stake_hotkey() -> Weight { // Proof Size summary in bytes: - // Measured: `822` - // Estimated: `4287` - // Minimum execution time: 34_555_000 picoseconds. - Weight::from_parts(35_276_000, 4287) + // Measured: `799` + // Estimated: `4264` + // Minimum execution time: 31_788_000 picoseconds. + Weight::from_parts(32_469_000, 4264) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -2056,8 +2056,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `476` // Estimated: `3941` - // Minimum execution time: 17_823_000 picoseconds. - Weight::from_parts(18_364_000, 3941) + // Minimum execution time: 15_574_000 picoseconds. + Weight::from_parts(15_894_000, 3941) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -2085,10 +2085,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::RootClaimableThreshold` (`max_values`: None, `max_size`: None, mode: `Measured`) fn claim_root() -> Weight { // Proof Size summary in bytes: - // Measured: `1920` - // Estimated: `7860` - // Minimum execution time: 132_699_000 picoseconds. - Weight::from_parts(135_744_000, 7860) + // Measured: `1908` + // Estimated: `7848` + // Minimum execution time: 137_608_000 picoseconds. + Weight::from_parts(140_011_000, 7848) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -2098,8 +2098,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_815_000 picoseconds. - Weight::from_parts(3_085_000, 0) + // Minimum execution time: 1_983_000 picoseconds. + Weight::from_parts(2_173_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `SubtensorModule::RootClaimableThreshold` (r:0 w:1) @@ -2108,8 +2108,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_490_000 picoseconds. - Weight::from_parts(5_911_000, 0) + // Minimum execution time: 4_336_000 picoseconds. + Weight::from_parts(4_737_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `SubtensorModule::SubnetOwner` (r:1 w:0) @@ -2174,10 +2174,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_stake_burn() -> Weight { // Proof Size summary in bytes: - // Measured: `2416` + // Measured: `2365` // Estimated: `8556` - // Minimum execution time: 465_923_000 picoseconds. - Weight::from_parts(484_888_000, 8556) + // Minimum execution time: 471_702_000 picoseconds. + Weight::from_parts(484_481_000, 8556) .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(16_u64)) } @@ -2187,8 +2187,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_775_000 picoseconds. - Weight::from_parts(2_986_000, 0) + // Minimum execution time: 2_013_000 picoseconds. + Weight::from_parts(2_243_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -2289,10 +2289,10 @@ impl WeightInfo for () { /// Proof: `Swap::CurrentTick` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: - // Measured: `1687` + // Measured: `1629` // Estimated: `13600` - // Minimum execution time: 351_469_000 picoseconds. - Weight::from_parts(370_384_000, 13600) + // Minimum execution time: 348_026_000 picoseconds. + Weight::from_parts(354_034_000, 13600) .saturating_add(RocksDbWeight::get().reads(46_u64)) .saturating_add(RocksDbWeight::get().writes(38_u64)) } @@ -2332,10 +2332,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `188840` - // Estimated: `10327430` - // Minimum execution time: 15_014_320_000 picoseconds. - Weight::from_parts(15_501_163_000, 10327430) + // Measured: `188782` + // Estimated: `10327372` + // Minimum execution time: 16_089_221_000 picoseconds. + Weight::from_parts(16_473_771_000, 10327372) .saturating_add(RocksDbWeight::get().reads(4112_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2395,10 +2395,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `2358` + // Measured: `2307` // Estimated: `8556` - // Minimum execution time: 337_482_000 picoseconds. - Weight::from_parts(347_320_000, 8556) + // Minimum execution time: 338_691_000 picoseconds. + Weight::from_parts(346_814_000, 8556) .saturating_add(RocksDbWeight::get().reads(27_u64)) .saturating_add(RocksDbWeight::get().writes(15_u64)) } @@ -2410,10 +2410,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::ServingRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn serve_axon() -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `6743` - // Minimum execution time: 33_903_000 picoseconds. - Weight::from_parts(34_945_000, 6743) + // Measured: `791` + // Estimated: `6731` + // Minimum execution time: 32_479_000 picoseconds. + Weight::from_parts(33_721_000, 6731) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2425,10 +2425,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::ServingRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn serve_prometheus() -> Weight { // Proof Size summary in bytes: - // Measured: `776` - // Estimated: `6716` - // Minimum execution time: 30_076_000 picoseconds. - Weight::from_parts(31_088_000, 6716) + // Measured: `764` + // Estimated: `6704` + // Minimum execution time: 29_264_000 picoseconds. + Weight::from_parts(30_095_000, 6704) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2526,10 +2526,10 @@ impl WeightInfo for () { /// Proof: `Swap::CurrentTick` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) fn burned_register() -> Weight { // Proof Size summary in bytes: - // Measured: `1697` + // Measured: `1639` // Estimated: `13600` - // Minimum execution time: 344_215_000 picoseconds. - Weight::from_parts(364_713_000, 13600) + // Minimum execution time: 341_145_000 picoseconds. + Weight::from_parts(345_863_000, 13600) .saturating_add(RocksDbWeight::get().reads(46_u64)) .saturating_add(RocksDbWeight::get().writes(38_u64)) } @@ -2579,10 +2579,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::IsNetworkMember` (`max_values`: None, `max_size`: None, mode: `Measured`) fn root_register() -> Weight { // Proof Size summary in bytes: - // Measured: `1465` - // Estimated: `4930` - // Minimum execution time: 103_233_000 picoseconds. - Weight::from_parts(104_135_000, 4930) + // Measured: `1415` + // Estimated: `4880` + // Minimum execution time: 100_752_000 picoseconds. + Weight::from_parts(102_565_000, 4880) .saturating_add(RocksDbWeight::get().reads(19_u64)) .saturating_add(RocksDbWeight::get().writes(16_u64)) } @@ -2708,10 +2708,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::MaxAllowedUids` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_network() -> Weight { // Proof Size summary in bytes: - // Measured: `1745` - // Estimated: `10160` - // Minimum execution time: 298_670_000 picoseconds. - Weight::from_parts(319_769_000, 10160) + // Measured: `1676` + // Estimated: `10091` + // Minimum execution time: 289_917_000 picoseconds. + Weight::from_parts(293_954_000, 10091) .saturating_add(RocksDbWeight::get().reads(45_u64)) .saturating_add(RocksDbWeight::get().writes(49_u64)) } @@ -2737,10 +2737,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::SubnetworkN` (`max_values`: None, `max_size`: None, mode: `Measured`) fn commit_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1084` - // Estimated: `4549` - // Minimum execution time: 62_226_000 picoseconds. - Weight::from_parts(63_640_000, 4549) + // Measured: `1061` + // Estimated: `4526` + // Minimum execution time: 59_199_000 picoseconds. + Weight::from_parts(60_772_000, 4526) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2782,10 +2782,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn reveal_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1637` - // Estimated: `7577` - // Minimum execution time: 110_287_000 picoseconds. - Weight::from_parts(112_200_000, 7577) + // Measured: `1579` + // Estimated: `7519` + // Minimum execution time: 107_763_000 picoseconds. + Weight::from_parts(109_746_000, 7519) .saturating_add(RocksDbWeight::get().reads(18_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2795,8 +2795,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_550_000 picoseconds. - Weight::from_parts(5_801_000, 0) + // Minimum execution time: 4_126_000 picoseconds. + Weight::from_parts(4_407_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `SubtensorModule::Owner` (r:1 w:0) @@ -2811,10 +2811,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::TransactionKeyLastBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_childkey_take() -> Weight { // Proof Size summary in bytes: - // Measured: `950` - // Estimated: `4415` - // Minimum execution time: 46_437_000 picoseconds. - Weight::from_parts(47_268_000, 4415) + // Measured: `938` + // Estimated: `4403` + // Minimum execution time: 45_358_000 picoseconds. + Weight::from_parts(46_140_000, 4403) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -2828,10 +2828,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::ColdkeySwapAnnouncementDelay` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn announce_coldkey_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `717` - // Estimated: `4182` - // Minimum execution time: 44_364_000 picoseconds. - Weight::from_parts(45_315_000, 4182) + // Measured: `694` + // Estimated: `4159` + // Minimum execution time: 39_469_000 picoseconds. + Weight::from_parts(40_962_000, 4159) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2867,10 +2867,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastRateLimitedBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_coldkey_announced() -> Weight { // Proof Size summary in bytes: - // Measured: `1852` - // Estimated: `12742` - // Minimum execution time: 260_729_000 picoseconds. - Weight::from_parts(263_113_000, 12742) + // Measured: `1815` + // Estimated: `12705` + // Minimum execution time: 260_764_000 picoseconds. + Weight::from_parts(265_261_000, 12705) .saturating_add(RocksDbWeight::get().reads(31_u64)) .saturating_add(RocksDbWeight::get().writes(15_u64)) } @@ -2910,10 +2910,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastRateLimitedBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_coldkey() -> Weight { // Proof Size summary in bytes: - // Measured: `1968` - // Estimated: `12858` - // Minimum execution time: 281_277_000 picoseconds. - Weight::from_parts(287_689_000, 12858) + // Measured: `1908` + // Estimated: `12798` + // Minimum execution time: 281_736_000 picoseconds. + Weight::from_parts(286_753_000, 12798) .saturating_add(RocksDbWeight::get().reads(31_u64)) .saturating_add(RocksDbWeight::get().writes(19_u64)) } @@ -2925,8 +2925,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `665` // Estimated: `4130` - // Minimum execution time: 22_472_000 picoseconds. - Weight::from_parts(23_103_000, 4130) + // Minimum execution time: 19_950_000 picoseconds. + Weight::from_parts(20_701_000, 4130) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2938,8 +2938,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `613` // Estimated: `4078` - // Minimum execution time: 18_865_000 picoseconds. - Weight::from_parts(19_767_000, 4078) + // Minimum execution time: 16_415_000 picoseconds. + Weight::from_parts(17_096_000, 4078) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -2951,8 +2951,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_756_000 picoseconds. - Weight::from_parts(9_117_000, 0) + // Minimum execution time: 6_790_000 picoseconds. + Weight::from_parts(7_151_000, 0) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `SubtensorModule::CommitRevealWeightsEnabled` (r:1 w:0) @@ -2993,10 +2993,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn batch_reveal_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `2142` - // Estimated: `8082` - // Minimum execution time: 413_094_000 picoseconds. - Weight::from_parts(422_682_000, 8082) + // Measured: `2084` + // Estimated: `8024` + // Minimum execution time: 426_724_000 picoseconds. + Weight::from_parts(431_712_000, 8024) .saturating_add(RocksDbWeight::get().reads(18_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -3020,10 +3020,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::SubnetAlphaOut` (`max_values`: None, `max_size`: None, mode: `Measured`) fn recycle_alpha() -> Weight { // Proof Size summary in bytes: - // Measured: `1452` - // Estimated: `4917` - // Minimum execution time: 127_739_000 picoseconds. - Weight::from_parts(129_623_000, 4917) + // Measured: `1424` + // Estimated: `4889` + // Minimum execution time: 128_484_000 picoseconds. + Weight::from_parts(130_548_000, 4889) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -3047,10 +3047,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::SubnetAlphaOut` (`max_values`: None, `max_size`: None, mode: `Measured`) fn burn_alpha() -> Weight { // Proof Size summary in bytes: - // Measured: `1452` - // Estimated: `4917` - // Minimum execution time: 126_257_000 picoseconds. - Weight::from_parts(128_621_000, 4917) + // Measured: `1424` + // Estimated: `4889` + // Minimum execution time: 126_171_000 picoseconds. + Weight::from_parts(128_965_000, 4889) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3068,10 +3068,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::SubtokenEnabled` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_call() -> Weight { // Proof Size summary in bytes: - // Measured: `1091` - // Estimated: `4556` - // Minimum execution time: 38_201_000 picoseconds. - Weight::from_parts(38_683_000, 4556) + // Measured: `1079` + // Estimated: `4544` + // Minimum execution time: 37_957_000 picoseconds. + Weight::from_parts(38_939_000, 4544) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -3131,10 +3131,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_stake_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2358` + // Measured: `2307` // Estimated: `8556` - // Minimum execution time: 372_377_000 picoseconds. - Weight::from_parts(378_619_000, 8556) + // Minimum execution time: 376_539_000 picoseconds. + Weight::from_parts(383_750_000, 8556) .saturating_add(RocksDbWeight::get().reads(27_u64)) .saturating_add(RocksDbWeight::get().writes(15_u64)) } @@ -3168,10 +3168,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn move_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `2030` - // Estimated: `7970` - // Minimum execution time: 213_279_000 picoseconds. - Weight::from_parts(214_963_000, 7970) + // Measured: `2002` + // Estimated: `7942` + // Minimum execution time: 222_486_000 picoseconds. + Weight::from_parts(223_918_000, 7942) .saturating_add(RocksDbWeight::get().reads(19_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -3227,10 +3227,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_stake_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2224` - // Estimated: `10639` - // Minimum execution time: 384_961_000 picoseconds. - Weight::from_parts(395_060_000, 10639) + // Measured: `2211` + // Estimated: `10626` + // Minimum execution time: 387_646_000 picoseconds. + Weight::from_parts(403_169_000, 10626) .saturating_add(RocksDbWeight::get().reads(30_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } @@ -3288,10 +3288,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_stake_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2543` + // Measured: `2494` // Estimated: `8556` - // Minimum execution time: 453_049_000 picoseconds. - Weight::from_parts(464_480_000, 8556) + // Minimum execution time: 461_377_000 picoseconds. + Weight::from_parts(477_951_000, 8556) .saturating_add(RocksDbWeight::get().reads(40_u64)) .saturating_add(RocksDbWeight::get().writes(22_u64)) } @@ -3327,10 +3327,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn transfer_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `1857` - // Estimated: `7797` - // Minimum execution time: 209_523_000 picoseconds. - Weight::from_parts(212_028_000, 7797) + // Measured: `1829` + // Estimated: `7769` + // Minimum execution time: 215_726_000 picoseconds. + Weight::from_parts(219_552_000, 7769) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -3388,10 +3388,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_stake() -> Weight { // Proof Size summary in bytes: - // Measured: `2470` + // Measured: `2421` // Estimated: `8556` - // Minimum execution time: 396_283_000 picoseconds. - Weight::from_parts(403_145_000, 8556) + // Minimum execution time: 402_808_000 picoseconds. + Weight::from_parts(420_035_000, 8556) .saturating_add(RocksDbWeight::get().reads(40_u64)) .saturating_add(RocksDbWeight::get().writes(22_u64)) } @@ -3419,10 +3419,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::WeightsSetRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn batch_commit_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1107` - // Estimated: `4572` - // Minimum execution time: 127_449_000 picoseconds. - Weight::from_parts(128_801_000, 4572) + // Measured: `1084` + // Estimated: `4549` + // Minimum execution time: 125_589_000 picoseconds. + Weight::from_parts(141_484_000, 4549) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -3460,10 +3460,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::Weights` (`max_values`: None, `max_size`: None, mode: `Measured`) fn batch_set_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1474` - // Estimated: `7414` - // Minimum execution time: 102_092_000 picoseconds. - Weight::from_parts(103_243_000, 7414) + // Measured: `1416` + // Estimated: `7356` + // Minimum execution time: 99_310_000 picoseconds. + Weight::from_parts(101_193_000, 7356) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -3477,10 +3477,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastRateLimitedBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn decrease_take() -> Weight { // Proof Size summary in bytes: - // Measured: `816` - // Estimated: `4281` - // Minimum execution time: 28_713_000 picoseconds. - Weight::from_parts(29_786_000, 4281) + // Measured: `793` + // Estimated: `4258` + // Minimum execution time: 25_499_000 picoseconds. + Weight::from_parts(26_330_000, 4258) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -3496,10 +3496,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::TxDelegateTakeRateLimit` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn increase_take() -> Weight { // Proof Size summary in bytes: - // Measured: `909` - // Estimated: `4374` - // Minimum execution time: 35_506_000 picoseconds. - Weight::from_parts(36_489_000, 4374) + // Measured: `886` + // Estimated: `4351` + // Minimum execution time: 32_540_000 picoseconds. + Weight::from_parts(33_501_000, 4351) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -3623,10 +3623,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::MaxAllowedUids` (`max_values`: None, `max_size`: None, mode: `Measured`) fn register_network_with_identity() -> Weight { // Proof Size summary in bytes: - // Measured: `1629` - // Estimated: `10044` - // Minimum execution time: 290_685_000 picoseconds. - Weight::from_parts(294_402_000, 10044) + // Measured: `1560` + // Estimated: `9975` + // Minimum execution time: 279_983_000 picoseconds. + Weight::from_parts(284_690_000, 9975) .saturating_add(RocksDbWeight::get().reads(44_u64)) .saturating_add(RocksDbWeight::get().writes(48_u64)) } @@ -3638,10 +3638,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::ServingRateLimit` (`max_values`: None, `max_size`: None, mode: `Measured`) fn serve_axon_tls() -> Weight { // Proof Size summary in bytes: - // Measured: `774` - // Estimated: `6714` - // Minimum execution time: 33_724_000 picoseconds. - Weight::from_parts(34_194_000, 6714) + // Measured: `762` + // Estimated: `6702` + // Minimum execution time: 31_257_000 picoseconds. + Weight::from_parts(32_769_000, 6702) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -3653,10 +3653,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::IdentitiesV2` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_identity() -> Weight { // Proof Size summary in bytes: - // Measured: `878` - // Estimated: `6818` - // Minimum execution time: 31_560_000 picoseconds. - Weight::from_parts(32_581_000, 6818) + // Measured: `842` + // Estimated: `6782` + // Minimum execution time: 28_703_000 picoseconds. + Weight::from_parts(30_106_000, 6782) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -3668,8 +3668,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `595` // Estimated: `4060` - // Minimum execution time: 17_743_000 picoseconds. - Weight::from_parts(18_505_000, 4060) + // Minimum execution time: 15_634_000 picoseconds. + Weight::from_parts(16_254_000, 4060) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -3737,10 +3737,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::Keys` (`max_values`: None, `max_size`: None, mode: `Measured`) fn swap_hotkey() -> Weight { // Proof Size summary in bytes: - // Measured: `3072` - // Estimated: `28812` - // Minimum execution time: 1_125_248_000 picoseconds. - Weight::from_parts(1_136_920_000, 28812) + // Measured: `3026` + // Estimated: `28766` + // Minimum execution time: 1_148_985_000 picoseconds. + Weight::from_parts(1_154_584_000, 28766) .saturating_add(RocksDbWeight::get().reads(159_u64)) .saturating_add(RocksDbWeight::get().writes(95_u64)) } @@ -3752,10 +3752,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::StakingHotkeys` (`max_values`: None, `max_size`: None, mode: `Measured`) fn try_associate_hotkey() -> Weight { // Proof Size summary in bytes: - // Measured: `792` - // Estimated: `4257` - // Minimum execution time: 25_438_000 picoseconds. - Weight::from_parts(26_159_000, 4257) + // Measured: `745` + // Estimated: `4210` + // Minimum execution time: 21_963_000 picoseconds. + Weight::from_parts(22_504_000, 4210) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3767,10 +3767,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::SubtokenEnabled` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unstake_all() -> Weight { // Proof Size summary in bytes: - // Measured: `763` - // Estimated: `9178` - // Minimum execution time: 27_111_000 picoseconds. - Weight::from_parts(28_363_000, 9178) + // Measured: `740` + // Estimated: `9155` + // Minimum execution time: 24_397_000 picoseconds. + Weight::from_parts(25_138_000, 9155) .saturating_add(RocksDbWeight::get().reads(6_u64)) } /// Storage: `SubtensorModule::Owner` (r:1 w:0) @@ -3835,10 +3835,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unstake_all_alpha() -> Weight { // Proof Size summary in bytes: - // Measured: `2423` - // Estimated: `10838` - // Minimum execution time: 409_037_000 picoseconds. - Weight::from_parts(431_929_000, 10838) + // Measured: `2372` + // Estimated: `10787` + // Minimum execution time: 414_015_000 picoseconds. + Weight::from_parts(427_445_000, 10787) .saturating_add(RocksDbWeight::get().reads(44_u64)) .saturating_add(RocksDbWeight::get().writes(24_u64)) } @@ -3894,10 +3894,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_stake_full_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `2224` - // Estimated: `10639` - // Minimum execution time: 408_485_000 picoseconds. - Weight::from_parts(430_457_000, 10639) + // Measured: `2211` + // Estimated: `10626` + // Minimum execution time: 412_223_000 picoseconds. + Weight::from_parts(430_190_000, 10626) .saturating_add(RocksDbWeight::get().reads(30_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } @@ -4042,12 +4042,12 @@ impl WeightInfo for () { /// The range of component `k` is `[2, 500]`. fn register_leased_network(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2048 + k * (44 ±0)` - // Estimated: `10469 + k * (2579 ±0)` - // Minimum execution time: 511_318_000 picoseconds. - Weight::from_parts(314_210_493, 10469) - // Standard Error: 33_355 - .saturating_add(Weight::from_parts(48_540_258, 0).saturating_mul(k.into())) + // Measured: `1979 + k * (44 ±0)` + // Estimated: `10400 + k * (2579 ±0)` + // Minimum execution time: 488_338_000 picoseconds. + Weight::from_parts(286_320_370, 10400) + // Standard Error: 33_372 + .saturating_add(Weight::from_parts(47_145_967, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(54_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(54_u64)) @@ -4075,17 +4075,17 @@ impl WeightInfo for () { /// The range of component `k` is `[2, 500]`. fn terminate_lease(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1493 + k * (53 ±0)` - // Estimated: `6148 + k * (2529 ±0)` - // Minimum execution time: 93_285_000 picoseconds. - Weight::from_parts(85_691_633, 6148) - // Standard Error: 8_977 - .saturating_add(Weight::from_parts(1_625_938, 0).saturating_mul(k.into())) + // Measured: `1447 + k * (53 ±0)` + // Estimated: `6148 + k * (2514 ±0)` + // Minimum execution time: 112_219_000 picoseconds. + Weight::from_parts(130_541_041, 6148) + // Standard Error: 7_186 + .saturating_add(Weight::from_parts(1_496_294, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(7_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) - .saturating_add(Weight::from_parts(0, 2529).saturating_mul(k.into())) + .saturating_add(Weight::from_parts(0, 2514).saturating_mul(k.into())) } /// Storage: `SubtensorModule::SubnetOwner` (r:1 w:0) /// Proof: `SubtensorModule::SubnetOwner` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -4095,8 +4095,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `649` // Estimated: `9064` - // Minimum execution time: 27_983_000 picoseconds. - Weight::from_parts(28_704_000, 9064) + // Minimum execution time: 24_617_000 picoseconds. + Weight::from_parts(25_379_000, 9064) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -4122,10 +4122,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::SubnetworkN` (`max_values`: None, `max_size`: None, mode: `Measured`) fn commit_timelocked_weights() -> Weight { // Proof Size summary in bytes: - // Measured: `1083` - // Estimated: `4548` - // Minimum execution time: 74_399_000 picoseconds. - Weight::from_parts(75_311_000, 4548) + // Measured: `1060` + // Estimated: `4525` + // Minimum execution time: 72_058_000 picoseconds. + Weight::from_parts(73_902_000, 4525) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -4139,10 +4139,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::AutoStakeDestinationColdkeys` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_coldkey_auto_stake_hotkey() -> Weight { // Proof Size summary in bytes: - // Measured: `822` - // Estimated: `4287` - // Minimum execution time: 34_555_000 picoseconds. - Weight::from_parts(35_276_000, 4287) + // Measured: `799` + // Estimated: `4264` + // Minimum execution time: 31_788_000 picoseconds. + Weight::from_parts(32_469_000, 4264) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -4158,8 +4158,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `476` // Estimated: `3941` - // Minimum execution time: 17_823_000 picoseconds. - Weight::from_parts(18_364_000, 3941) + // Minimum execution time: 15_574_000 picoseconds. + Weight::from_parts(15_894_000, 3941) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -4187,10 +4187,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::RootClaimableThreshold` (`max_values`: None, `max_size`: None, mode: `Measured`) fn claim_root() -> Weight { // Proof Size summary in bytes: - // Measured: `1920` - // Estimated: `7860` - // Minimum execution time: 132_699_000 picoseconds. - Weight::from_parts(135_744_000, 7860) + // Measured: `1908` + // Estimated: `7848` + // Minimum execution time: 137_608_000 picoseconds. + Weight::from_parts(140_011_000, 7848) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -4200,8 +4200,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_815_000 picoseconds. - Weight::from_parts(3_085_000, 0) + // Minimum execution time: 1_983_000 picoseconds. + Weight::from_parts(2_173_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `SubtensorModule::RootClaimableThreshold` (r:0 w:1) @@ -4210,8 +4210,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_490_000 picoseconds. - Weight::from_parts(5_911_000, 0) + // Minimum execution time: 4_336_000 picoseconds. + Weight::from_parts(4_737_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `SubtensorModule::SubnetOwner` (r:1 w:0) @@ -4276,10 +4276,10 @@ impl WeightInfo for () { /// Proof: `SubtensorModule::LastColdkeyHotkeyStakeBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_stake_burn() -> Weight { // Proof Size summary in bytes: - // Measured: `2416` + // Measured: `2365` // Estimated: `8556` - // Minimum execution time: 465_923_000 picoseconds. - Weight::from_parts(484_888_000, 8556) + // Minimum execution time: 471_702_000 picoseconds. + Weight::from_parts(484_481_000, 8556) .saturating_add(RocksDbWeight::get().reads(30_u64)) .saturating_add(RocksDbWeight::get().writes(16_u64)) } @@ -4289,8 +4289,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_775_000 picoseconds. - Weight::from_parts(2_986_000, 0) + // Minimum execution time: 2_013_000 picoseconds. + Weight::from_parts(2_243_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/utility/src/weights.rs b/pallets/utility/src/weights.rs index 9507a7909e..b4b30f1b17 100644 --- a/pallets/utility/src/weights.rs +++ b/pallets/utility/src/weights.rs @@ -2,32 +2,27 @@ //! Autogenerated weights for `pallet_subtensor_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 -//! DATE: 2026-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-04-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runnervm46oaq`, CPU: `AMD EPYC 7763 64-Core Processor` +//! HOSTNAME: `runnervm727z3`, CPU: `AMD EPYC 9V74 80-Core Processor` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: // /home/runner/work/subtensor/subtensor/target/production/node-subtensor // benchmark // pallet -// --runtime -// /home/runner/work/subtensor/subtensor/target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm +// --runtime=/home/runner/work/subtensor/subtensor/target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm // --genesis-builder=runtime // --genesis-builder-preset=benchmark // --wasm-execution=compiled -// --pallet -// pallet_subtensor_utility -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 +// --pallet=pallet_subtensor_utility +// --extrinsic=* +// --steps=50 +// --repeat=20 // --no-storage-info // --no-min-squares // --no-median-slopes -// --output=/tmp/tmp.Rfo4jDh0U9 +// --output=/tmp/tmp.bdmILpT1Dx // --template=/home/runner/work/subtensor/subtensor/.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -62,10 +57,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 5_100_000 picoseconds. - Weight::from_parts(13_936_720, 3983) - // Standard Error: 2_373 - .saturating_add(Weight::from_parts(5_509_150, 0).saturating_mul(c.into())) + // Minimum execution time: 3_726_000 picoseconds. + Weight::from_parts(4_951_606, 3983) + // Standard Error: 2_953 + .saturating_add(Weight::from_parts(5_288_894, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) @@ -76,8 +71,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 15_209_000 picoseconds. - Weight::from_parts(15_699_000, 3983) + // Minimum execution time: 13_431_000 picoseconds. + Weight::from_parts(14_051_000, 3983) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) @@ -89,18 +84,18 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 4_999_000 picoseconds. - Weight::from_parts(13_673_497, 3983) - // Standard Error: 2_579 - .saturating_add(Weight::from_parts(5_720_464, 0).saturating_mul(c.into())) + // Minimum execution time: 3_856_000 picoseconds. + Weight::from_parts(18_145_044, 3983) + // Standard Error: 2_082 + .saturating_add(Weight::from_parts(5_480_670, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_893_000 picoseconds. - Weight::from_parts(7_203_000, 0) + // Minimum execution time: 5_518_000 picoseconds. + Weight::from_parts(5_749_000, 0) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) /// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -111,18 +106,18 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 5_099_000 picoseconds. - Weight::from_parts(14_137_292, 3983) - // Standard Error: 1_934 - .saturating_add(Weight::from_parts(5_498_784, 0).saturating_mul(c.into())) + // Minimum execution time: 3_826_000 picoseconds. + Weight::from_parts(9_890_933, 3983) + // Standard Error: 3_427 + .saturating_add(Weight::from_parts(5_245_970, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) } fn dispatch_as_fallible() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_893_000 picoseconds. - Weight::from_parts(7_384_000, 0) + // Minimum execution time: 5_588_000 picoseconds. + Weight::from_parts(5_709_000, 0) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) /// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -132,8 +127,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 21_440_000 picoseconds. - Weight::from_parts(22_021_000, 3983) + // Minimum execution time: 18_888_000 picoseconds. + Weight::from_parts(19_269_000, 3983) .saturating_add(T::DbWeight::get().reads(2_u64)) } } @@ -149,10 +144,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 5_100_000 picoseconds. - Weight::from_parts(13_936_720, 3983) - // Standard Error: 2_373 - .saturating_add(Weight::from_parts(5_509_150, 0).saturating_mul(c.into())) + // Minimum execution time: 3_726_000 picoseconds. + Weight::from_parts(4_951_606, 3983) + // Standard Error: 2_953 + .saturating_add(Weight::from_parts(5_288_894, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) @@ -163,8 +158,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 15_209_000 picoseconds. - Weight::from_parts(15_699_000, 3983) + // Minimum execution time: 13_431_000 picoseconds. + Weight::from_parts(14_051_000, 3983) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) @@ -176,18 +171,18 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 4_999_000 picoseconds. - Weight::from_parts(13_673_497, 3983) - // Standard Error: 2_579 - .saturating_add(Weight::from_parts(5_720_464, 0).saturating_mul(c.into())) + // Minimum execution time: 3_856_000 picoseconds. + Weight::from_parts(18_145_044, 3983) + // Standard Error: 2_082 + .saturating_add(Weight::from_parts(5_480_670, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_893_000 picoseconds. - Weight::from_parts(7_203_000, 0) + // Minimum execution time: 5_518_000 picoseconds. + Weight::from_parts(5_749_000, 0) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) /// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -198,18 +193,18 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 5_099_000 picoseconds. - Weight::from_parts(14_137_292, 3983) - // Standard Error: 1_934 - .saturating_add(Weight::from_parts(5_498_784, 0).saturating_mul(c.into())) + // Minimum execution time: 3_826_000 picoseconds. + Weight::from_parts(9_890_933, 3983) + // Standard Error: 3_427 + .saturating_add(Weight::from_parts(5_245_970, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) } fn dispatch_as_fallible() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_893_000 picoseconds. - Weight::from_parts(7_384_000, 0) + // Minimum execution time: 5_588_000 picoseconds. + Weight::from_parts(5_709_000, 0) } /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) /// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -219,8 +214,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `518` // Estimated: `3983` - // Minimum execution time: 21_440_000 picoseconds. - Weight::from_parts(22_021_000, 3983) + // Minimum execution time: 18_888_000 picoseconds. + Weight::from_parts(19_269_000, 3983) .saturating_add(RocksDbWeight::get().reads(2_u64)) } }