Skip to content

Commit 2d70704

Browse files
authored
Merge pull request #1335 from opentensor/feat/root-set-sn-moving-alpha
add root set sn moving alpha
2 parents 07da454 + 3c280ce commit 2d70704

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub mod pallet {
2929
use frame_system::pallet_prelude::*;
3030
use pallet_evm_chain_id::{self, ChainId};
3131
use sp_runtime::BoundedVec;
32+
use substrate_fixed::types::I96F32;
3233

3334
/// The main data structure of the module.
3435
#[pallet::pallet]
@@ -1377,6 +1378,28 @@ pub mod pallet {
13771378
}
13781379
Ok(())
13791380
}
1381+
1382+
///
1383+
///
1384+
/// # Arguments
1385+
/// * `origin` - The origin of the call, which must be the root account.
1386+
/// * `precompile_id` - The identifier of the EVM precompile to toggle.
1387+
/// * `enabled` - The new enablement state of the precompile.
1388+
///
1389+
/// # Errors
1390+
/// * `BadOrigin` - If the caller is not the root account.
1391+
///
1392+
/// # Weight
1393+
/// Weight is handled by the `#[pallet::weight]` attribute.
1394+
#[pallet::call_index(63)]
1395+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1396+
pub fn sudo_set_subnet_moving_alpha(origin: OriginFor<T>, alpha: I96F32) -> DispatchResult {
1397+
ensure_root(origin)?;
1398+
pallet_subtensor::SubnetMovingAlpha::<T>::set(alpha);
1399+
1400+
log::debug!("SubnetMovingAlphaSet( alpha: {:?} )", alpha);
1401+
Ok(())
1402+
}
13801403
}
13811404
}
13821405

pallets/admin-utils/src/tests/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use pallet_subtensor::Error as SubtensorError;
1010
use pallet_subtensor::Event;
1111
use sp_consensus_grandpa::AuthorityId as GrandpaId;
1212
use sp_core::{Pair, U256, ed25519};
13+
use substrate_fixed::types::I96F32;
1314

1415
use crate::Error;
1516
use crate::pallet::PrecompileEnable;
@@ -1449,3 +1450,19 @@ fn test_sudo_toggle_evm_precompile() {
14491450
assert!(final_enabled);
14501451
});
14511452
}
1453+
1454+
#[test]
1455+
fn test_sudo_root_sets_subnet_moving_alpha() {
1456+
new_test_ext().execute_with(|| {
1457+
let alpha: I96F32 = I96F32::saturating_from_num(0.5);
1458+
let initial = pallet_subtensor::SubnetMovingAlpha::<Test>::get();
1459+
assert!(initial != alpha);
1460+
1461+
assert_ok!(AdminUtils::sudo_set_subnet_moving_alpha(
1462+
<<Test as Config>::RuntimeOrigin>::root(),
1463+
alpha
1464+
));
1465+
1466+
assert_eq!(pallet_subtensor::SubnetMovingAlpha::<Test>::get(), alpha);
1467+
});
1468+
}

0 commit comments

Comments
 (0)