Transactions
trim-null-subnet-batch
Execute one bounded Null subnet pruning batch toward `target`.
Cancels pending weight commits before moving UIDs, then removes at most
the runtime's batch size (currently 64). A large legacy commit backlog
can produce a cleanup-only batch. Read NullPruningTarget and
SubnetworkN after inclusion: a successful transaction does not imply
the final target has been reached. Continue with the same target until
the pending target is absent. Each batch is owner-authorized and respects
the admin freeze window. Only the first batch starts the trimming cooldown;
changing the target is a new operation. Survivor UID values can change.
| Signer | Origin | Pallet | Wraps |
|---|---|---|---|
coldkey | subnet owner | AdminUtils | AdminUtils.sudo_trim_null_uids_batch |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
netuid | integer | yes | Null subnet owned by the signer. |
target | integer | yes | Final UID count, shared by every continuation. |
Address parameters (--hotkey, --coldkey, --dest, ...) accept a raw ss58
address, an address-book or proxy-book name, or a local wallet/hotkey name.
CLI
Preview with --dry-run (shows fee, effects, and policy result without
submitting), then submit:
btcli tx trim-null-subnet-batch \
--netuid <int> \
--target <int> --dry-run
btcli tx trim-null-subnet-batch \
--netuid <int> \
--target <int> -w my_coldkeyPython
import bittensor as bt
from bittensor.wallet import Wallet
wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.TrimNullSubnetBatch(netuid=1, target=64)
sub = bt.Subtensor()
plan = sub.plan(intent, wallet) # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
print(result.error.code, result.error.remediation)(bt.Subtensor is also the async client — async with bt.Subtensor() as client:
— see The client.) Or build the intent by op name, as
an agent would:
result = sub.execute_tool("trim_null_subnet_batch", {...}, wallet)On-chain implementation
AdminUtils.sudo_trim_null_uids_batch — pallets/admin-utils/src/lib.rs#L2138:
#[pallet::call_index(112)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::sudo_trim_null_uids_batch().max(<T as pallet::Config>::WeightInfo::sudo_trim_null_uids_batch_many_mechanisms()))]
pub fn sudo_trim_null_uids_batch(
origin: OriginFor<T>,
netuid: NetUid,
target: u16,
) -> DispatchResult {
let continuing = pallet_subtensor::NullPruningTarget::<T>::get(netuid) == Some(target);
let limits: &[TransactionType] = if continuing {
&[]
} else {
&[TransactionType::MaxUidsTrimming]
};
let maybe_owner = pallet_subtensor::Pallet::<T>::ensure_sn_owner_or_root_with_limits(
origin, netuid, limits,
)?;
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
pallet_subtensor::Pallet::<T>::trim_null_uids_batch(netuid, target)?;
if !continuing {
pallet_subtensor::Pallet::<T>::record_owner_rl(
maybe_owner,
netuid,
&[TransactionType::MaxUidsTrimming],
);
}
Ok(())
}Every file is browsable under /code exactly as built into the runtime, or as plain text under /code/raw/<path> (index: /code/index.json).