Skip to content

Commit f08ef46

Browse files
Enable zero as sudo_set_num_root_claims param value.
1 parent efbe782 commit f08ef46

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ mod dispatches {
23672367
Ok(())
23682368
}
23692369

2370-
/// --- Sets root claim number (sudo extrinsic).
2370+
/// --- Sets root claim number (sudo extrinsic). Zero disables auto-claim.
23712371
#[pallet::call_index(123)]
23722372
#[pallet::weight((
23732373
Weight::from_parts(4_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)),
@@ -2378,7 +2378,7 @@ mod dispatches {
23782378
ensure_root(origin)?;
23792379

23802380
ensure!(
2381-
new_value > 0 && new_value <= MAX_NUM_ROOT_CLAIMS,
2381+
new_value <= MAX_NUM_ROOT_CLAIMS,
23822382
Error::<T>::InvalidNumRootClaim
23832383
);
23842384

pallets/subtensor/src/tests/claim_root.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,11 @@ fn test_claim_root_block_hash_indices() {
792792
let k = 15u64;
793793
let n = 15000u64;
794794

795+
// 0
796+
let indices =
797+
SubtensorModule::block_hash_to_indices(H256(sp_core::keccak_256(b"zero")), 0, n);
798+
assert!(indices.is_empty());
799+
795800
// 1
796801
let hash = sp_core::keccak_256(b"some");
797802
let mut indices = SubtensorModule::block_hash_to_indices(H256(hash), k, n);
@@ -1008,11 +1013,6 @@ fn test_sudo_set_num_root_claims() {
10081013
DispatchError::BadOrigin
10091014
);
10101015

1011-
assert_noop!(
1012-
SubtensorModule::sudo_set_num_root_claims(RuntimeOrigin::root(), 0u64),
1013-
Error::<Test>::InvalidNumRootClaim
1014-
);
1015-
10161016
assert_noop!(
10171017
SubtensorModule::sudo_set_num_root_claims(
10181018
RuntimeOrigin::root(),

0 commit comments

Comments
 (0)