Skip to content
21 changes: 0 additions & 21 deletions evm-tests/test/subnet.precompile.hyperparameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,27 +269,6 @@ describe("Test the Subnet precompile contract", () => {
assert.equal(valueFromContract, onchainValue);
})

it("Can set kappa parameter", async () => {

const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;

const newValue = 109;
const tx = await contract.setKappa(netuid, newValue);
await tx.wait();

let onchainValue = await api.query.SubtensorModule.Kappa.getValue(netuid)


let valueFromContract = Number(
await contract.getKappa(netuid)
);

assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
})

it("Can set rho parameter", async () => {

const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
Expand Down
2 changes: 1 addition & 1 deletion pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ pub mod pallet {
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(1_u64))
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
pub fn sudo_set_kappa(origin: OriginFor<T>, netuid: NetUid, kappa: u16) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
ensure_root(origin)?;

ensure!(
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
Expand Down
14 changes: 7 additions & 7 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ mod dispatches {
/// - Attempting to set prometheus information withing the rate limit min.
///
#[pallet::call_index(4)]
#[pallet::weight((Weight::from_parts(36_090_000, 0)
#[pallet::weight((Weight::from_parts(25_840_000, 0)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))]
pub fn serve_axon(
Expand Down Expand Up @@ -1609,8 +1609,8 @@ mod dispatches {
/// - Thrown if key has hit transaction rate limit
#[pallet::call_index(84)]
#[pallet::weight((Weight::from_parts(294_800_000, 0)
.saturating_add(T::DbWeight::get().reads(33))
.saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::Yes))]
.saturating_add(T::DbWeight::get().reads(38_u64))
.saturating_add(T::DbWeight::get().writes(21_u64)), DispatchClass::Operational, Pays::Yes))]
pub fn unstake_all_alpha(origin: OriginFor<T>, hotkey: T::AccountId) -> DispatchResult {
Self::do_unstake_all_alpha(origin, hotkey)
}
Expand Down Expand Up @@ -1723,8 +1723,8 @@ mod dispatches {
#[pallet::call_index(87)]
#[pallet::weight((
Weight::from_parts(274_400_000, 0)
.saturating_add(T::DbWeight::get().reads(32))
.saturating_add(T::DbWeight::get().writes(17)),
.saturating_add(T::DbWeight::get().reads(37_u64))
.saturating_add(T::DbWeight::get().writes(22_u64)),
DispatchClass::Operational,
Pays::Yes
))]
Expand Down Expand Up @@ -1896,8 +1896,8 @@ mod dispatches {
#[pallet::call_index(90)]
#[pallet::weight((
Weight::from_parts(330_400_000, 0)
.saturating_add(T::DbWeight::get().reads(32))
.saturating_add(T::DbWeight::get().writes(17)),
.saturating_add(T::DbWeight::get().reads(37_u64))
.saturating_add(T::DbWeight::get().writes(22_u64)),
DispatchClass::Operational,
Pays::Yes
))]
Expand Down
16 changes: 5 additions & 11 deletions precompiles/src/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::marker::PhantomData;
use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo};
use frame_support::traits::ConstU32;
use frame_system::RawOrigin;
use pallet_evm::{AddressMapping, PrecompileHandle};
use pallet_evm::{AddressMapping, ExitError, PrecompileFailure, PrecompileHandle};
use precompile_utils::{EvmResult, prelude::BoundedString};
use sp_core::H256;
use sp_runtime::traits::Dispatchable;
Expand Down Expand Up @@ -373,16 +373,10 @@ where

#[precompile::public("setKappa(uint16,uint16)")]
#[precompile::payable]
fn set_kappa(handle: &mut impl PrecompileHandle, netuid: u16, kappa: u16) -> EvmResult<()> {
let call = pallet_admin_utils::Call::<R>::sudo_set_kappa {
netuid: netuid.into(),
kappa,
};

handle.try_dispatch_runtime_call::<R, _>(
call,
RawOrigin::Signed(handle.caller_account_id::<R>()),
)
fn set_kappa(_handle: &mut impl PrecompileHandle, _netuid: u16, _kappa: u16) -> EvmResult<()> {
Err(PrecompileFailure::Error {
exit_status: ExitError::Other("Bad origin".into()),
})
}

#[precompile::public("getRho(uint16)")]
Expand Down