Skip to content
37 changes: 32 additions & 5 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,35 @@ async def get_stake_weight(
)
return [u16_normalized_float(w) for w in result]

async def get_start_call_delay(
self,
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> int:
"""
Retrieves the start call delay in blocks.

Parameters:
block: The blockchain block number for the query.
block_hash: The blockchain block_hash of the block id.
reuse_block: Whether to reuse the last-used block hash.

Return:
Amount of blocks after the start call can be executed.
"""
return cast(
int,
(
await self.query_subtensor(
name="StartCallDelay",
block=block,
block_hash=block_hash,
reuse_block=reuse_block,
)
),
)

async def get_subnet_burn_cost(
self,
block: Optional[int] = None,
Expand Down Expand Up @@ -4985,19 +5014,17 @@ async def is_in_admin_freeze_window(
async def is_fast_blocks(self) -> bool:
"""Checks if the node is running with fast blocks enabled.

Fast blocks have a block time of 10 seconds, compared to the standard 12-second block time. This affects
Fast blocks have a block time of 0.25 seconds, compared to the standard 12-second block time. This affects
transaction timing and network synchronization.

Returns:
`True` if fast blocks are enabled (10-second block time), `False` otherwise (12-second block time).
`True` if fast blocks are enabled, `False` otherwise.

Notes:
- <https://docs.learnbittensor.org/resources/glossary#fast-blocks>

"""
return (
await self.query_constant("SubtensorModule", "DurationOfStartCall")
) == 10
return await self.get_start_call_delay() == 10

async def is_hotkey_delegate(
self,
Expand Down
24 changes: 21 additions & 3 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3540,6 +3540,24 @@ def get_stake_weight(self, netuid: int, block: Optional[int] = None) -> list[flo
)
return [u16_normalized_float(w) for w in result]

def get_start_call_delay(self, block: Optional[int] = None) -> int:
"""
Retrieves the start call delay in blocks.

Parameters:
block: The blockchain block number for the query.

Return:
Amount of blocks after the start call can be executed.
"""
return cast(
int,
self.query_subtensor(
name="StartCallDelay",
block=block,
),
)

def get_subnet_burn_cost(self, block: Optional[int] = None) -> Optional[Balance]:
"""
Retrieves the burn cost for registering a new subnet within the Bittensor network. This cost represents the
Expand Down Expand Up @@ -4075,17 +4093,17 @@ def is_in_admin_freeze_window(
def is_fast_blocks(self) -> bool:
"""Checks if the node is running with fast blocks enabled.

Fast blocks have a block time of 10 seconds, compared to the standard 12-second block time. This affects
Fast blocks have a block time of 0.25 seconds, compared to the standard 12-second block time. This affects
transaction timing and network synchronization.

Returns:
`True` if fast blocks are enabled (10-second block time), `False` otherwise (12-second block time).
`True` if fast blocks are enabled, `False` otherwise.

Notes:
- <https://docs.learnbittensor.org/resources/glossary#fast-blocks>

"""
return self.query_constant("SubtensorModule", "DurationOfStartCall") == 10
return self.get_start_call_delay() == 10

def is_hotkey_delegate(self, hotkey_ss58: str, block: Optional[int] = None) -> bool:
"""
Expand Down
98 changes: 91 additions & 7 deletions bittensor/extras/dev_framework/calls/non_sudo_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Note:
Any manual changes will be overwritten the next time the generator is run.
Subtensor spec version: 331
Subtensor spec version: 365
"""

from collections import namedtuple
Expand Down Expand Up @@ -42,6 +42,9 @@
ANNOUNCE = namedtuple(
"ANNOUNCE", ["wallet", "pallet", "real", "call_hash"]
) # args: [real: AccountIdLookupOf<T>, call_hash: CallHashOf<T>] | Pallet: Proxy
ANNOUNCE_NEXT_KEY = namedtuple(
"ANNOUNCE_NEXT_KEY", ["wallet", "pallet", "public_key"]
) # args: [public_key: BoundedVec<u8, ConstU32<2048>>] | Pallet: MevShield
APPLY_AUTHORIZED_UPGRADE = namedtuple(
"APPLY_AUTHORIZED_UPGRADE", ["wallet", "pallet", "code"]
) # args: [code: Vec<u8>] | Pallet: System
Expand Down Expand Up @@ -118,6 +121,10 @@
BURN_ALPHA = namedtuple(
"BURN_ALPHA", ["wallet", "pallet", "hotkey", "amount", "netuid"]
) # args: [hotkey: T::AccountId, amount: AlphaCurrency, netuid: NetUid] | Pallet: SubtensorModule
CALL = namedtuple(
"CALL",
["wallet", "pallet", "dest", "value", "gas_limit", "storage_deposit_limit", "data"],
) # args: [dest: AccountIdLookupOf<T>, value: BalanceOf<T>, gas_limit: Weight, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, data: Vec<u8>] | Pallet: Contracts
CALL = namedtuple(
"CALL",
[
Expand All @@ -135,6 +142,10 @@
"authorization_list",
],
) # args: [source: H160, target: H160, input: Vec<u8>, value: U256, gas_limit: u64, max_fee_per_gas: U256, max_priority_fee_per_gas: Option<U256>, nonce: Option<U256>, access_list: Vec<(H160, Vec<H256>)>, authorization_list: AuthorizationList] | Pallet: EVM
CALL_OLD_WEIGHT = namedtuple(
"CALL_OLD_WEIGHT",
["wallet", "pallet", "dest", "value", "gas_limit", "storage_deposit_limit", "data"],
) # args: [dest: AccountIdLookupOf<T>, value: BalanceOf<T>, gas_limit: OldWeight, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, data: Vec<u8>] | Pallet: Contracts
CANCEL = namedtuple(
"CANCEL", ["wallet", "pallet", "when", "index"]
) # args: [when: BlockNumberFor<T>, index: u32] | Pallet: Scheduler
Expand All @@ -152,12 +163,8 @@
"CANCEL_RETRY_NAMED", ["wallet", "pallet", "id"]
) # args: [id: TaskName] | Pallet: Scheduler
CLAIM_ROOT = namedtuple(
"CLAIM_ROOT",
[
"wallet",
"pallet",
],
) # args: [] | Pallet: SubtensorModule
"CLAIM_ROOT", ["wallet", "pallet", "subnets"]
) # args: [subnets: BTreeSet<NetUid>] | Pallet: SubtensorModule
CLEAR_IDENTITY = namedtuple(
"CLEAR_IDENTITY", ["wallet", "pallet", "identified"]
) # args: [identified: T::AccountId] | Pallet: Registry
Expand Down Expand Up @@ -242,6 +249,13 @@
DECREASE_TAKE = namedtuple(
"DECREASE_TAKE", ["wallet", "pallet", "hotkey", "take"]
) # args: [hotkey: T::AccountId, take: u16] | Pallet: SubtensorModule
DISABLE_LP = namedtuple(
"DISABLE_LP",
[
"wallet",
"pallet",
],
) # args: [] | Pallet: Swap
DISABLE_WHITELIST = namedtuple(
"DISABLE_WHITELIST", ["wallet", "pallet", "disabled"]
) # args: [disabled: bool] | Pallet: EVM
Expand Down Expand Up @@ -328,6 +342,58 @@
INCREASE_TAKE = namedtuple(
"INCREASE_TAKE", ["wallet", "pallet", "hotkey", "take"]
) # args: [hotkey: T::AccountId, take: u16] | Pallet: SubtensorModule
INSTANTIATE = namedtuple(
"INSTANTIATE",
[
"wallet",
"pallet",
"value",
"gas_limit",
"storage_deposit_limit",
"code_hash",
"data",
"salt",
],
) # args: [value: BalanceOf<T>, gas_limit: Weight, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, code_hash: CodeHash<T>, data: Vec<u8>, salt: Vec<u8>] | Pallet: Contracts
INSTANTIATE_OLD_WEIGHT = namedtuple(
"INSTANTIATE_OLD_WEIGHT",
[
"wallet",
"pallet",
"value",
"gas_limit",
"storage_deposit_limit",
"code_hash",
"data",
"salt",
],
) # args: [value: BalanceOf<T>, gas_limit: OldWeight, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, code_hash: CodeHash<T>, data: Vec<u8>, salt: Vec<u8>] | Pallet: Contracts
INSTANTIATE_WITH_CODE = namedtuple(
"INSTANTIATE_WITH_CODE",
[
"wallet",
"pallet",
"value",
"gas_limit",
"storage_deposit_limit",
"code",
"data",
"salt",
],
) # args: [value: BalanceOf<T>, gas_limit: Weight, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, code: Vec<u8>, data: Vec<u8>, salt: Vec<u8>] | Pallet: Contracts
INSTANTIATE_WITH_CODE_OLD_WEIGHT = namedtuple(
"INSTANTIATE_WITH_CODE_OLD_WEIGHT",
[
"wallet",
"pallet",
"value",
"gas_limit",
"storage_deposit_limit",
"code",
"data",
"salt",
],
) # args: [value: BalanceOf<T>, gas_limit: OldWeight, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, code: Vec<u8>, data: Vec<u8>, salt: Vec<u8>] | Pallet: Contracts
KILL_PREFIX = namedtuple(
"KILL_PREFIX", ["wallet", "pallet", "prefix", "subkeys"]
) # args: [prefix: Key, subkeys: u32] | Pallet: System
Expand All @@ -338,6 +404,12 @@
KILL_STORAGE = namedtuple(
"KILL_STORAGE", ["wallet", "pallet", "keys"]
) # args: [keys: Vec<Key>] | Pallet: System
MARK_DECRYPTION_FAILED = namedtuple(
"MARK_DECRYPTION_FAILED", ["wallet", "pallet", "id", "reason"]
) # args: [id: T::Hash, reason: BoundedVec<u8, ConstU32<256>>] | Pallet: MevShield
MIGRATE = namedtuple(
"MIGRATE", ["wallet", "pallet", "weight_limit"]
) # args: [weight_limit: Weight] | Pallet: Contracts
MODIFY_POSITION = namedtuple(
"MODIFY_POSITION",
["wallet", "pallet", "hotkey", "netuid", "position_id", "liquidity_delta"],
Expand Down Expand Up @@ -420,6 +492,9 @@
REMOVE_ANNOUNCEMENT = namedtuple(
"REMOVE_ANNOUNCEMENT", ["wallet", "pallet", "real", "call_hash"]
) # args: [real: AccountIdLookupOf<T>, call_hash: CallHashOf<T>] | Pallet: Proxy
REMOVE_CODE = namedtuple(
"REMOVE_CODE", ["wallet", "pallet", "code_hash"]
) # args: [code_hash: CodeHash<T>] | Pallet: Contracts
REMOVE_KEY = namedtuple(
"REMOVE_KEY",
[
Expand Down Expand Up @@ -557,6 +632,9 @@
SET_CODE = namedtuple(
"SET_CODE", ["wallet", "pallet", "code"]
) # args: [code: Vec<u8>] | Pallet: System
SET_CODE = namedtuple(
"SET_CODE", ["wallet", "pallet", "dest", "code_hash"]
) # args: [dest: AccountIdLookupOf<T>, code_hash: CodeHash<T>] | Pallet: Contracts
SET_CODE_WITHOUT_CHECKS = namedtuple(
"SET_CODE_WITHOUT_CHECKS", ["wallet", "pallet", "code"]
) # args: [code: Vec<u8>] | Pallet: System
Expand Down Expand Up @@ -645,6 +723,9 @@
START_CALL = namedtuple(
"START_CALL", ["wallet", "pallet", "netuid"]
) # args: [netuid: NetUid] | Pallet: SubtensorModule
SUBMIT_ENCRYPTED = namedtuple(
"SUBMIT_ENCRYPTED", ["wallet", "pallet", "commitment", "ciphertext"]
) # args: [commitment: T::Hash, ciphertext: BoundedVec<u8, ConstU32<8192>>] | Pallet: MevShield
SUDO = namedtuple(
"SUDO", ["wallet", "pallet", "call"]
) # args: [call: Box<<T as Config>::RuntimeCall>] | Pallet: Sudo
Expand Down Expand Up @@ -742,6 +823,9 @@
UPGRADE_ACCOUNTS = namedtuple(
"UPGRADE_ACCOUNTS", ["wallet", "pallet", "who"]
) # args: [who: Vec<T::AccountId>] | Pallet: Balances
UPLOAD_CODE = namedtuple(
"UPLOAD_CODE", ["wallet", "pallet", "code", "storage_deposit_limit", "determinism"]
) # args: [code: Vec<u8>, storage_deposit_limit: Option<<BalanceOf<T> as codec::HasCompact>::Type>, determinism: Determinism] | Pallet: Contracts
WITHDRAW = namedtuple(
"WITHDRAW", ["wallet", "pallet", "address", "value"]
) # args: [address: H160, value: BalanceOf<T>] | Pallet: EVM
Expand Down
4 changes: 3 additions & 1 deletion bittensor/extras/dev_framework/calls/pallets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" "
Subtensor spec version: 331
Subtensor spec version: 365
"""

System = "System"
Expand All @@ -23,3 +23,5 @@
Drand = "Drand"
Crowdloan = "Crowdloan"
Swap = "Swap"
Contracts = "Contracts"
MevShield = "MevShield"
18 changes: 17 additions & 1 deletion bittensor/extras/dev_framework/calls/sudo_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Note:
Any manual changes will be overwritten the next time the generator is run.
Subtensor spec version: 331
Subtensor spec version: 365
"""

from collections import namedtuple
Expand Down Expand Up @@ -149,6 +149,9 @@
SUDO_SET_MIN_DIFFICULTY = namedtuple(
"SUDO_SET_MIN_DIFFICULTY", ["wallet", "pallet", "sudo", "netuid", "min_difficulty"]
) # args: [netuid: NetUid, min_difficulty: u64] | Pallet: AdminUtils
SUDO_SET_MIN_NON_IMMUNE_UIDS = namedtuple(
"SUDO_SET_MIN_NON_IMMUNE_UIDS", ["wallet", "pallet", "sudo", "netuid", "min"]
) # args: [netuid: NetUid, min: u16] | Pallet: AdminUtils
SUDO_SET_NETWORK_IMMUNITY_PERIOD = namedtuple(
"SUDO_SET_NETWORK_IMMUNITY_PERIOD", ["wallet", "pallet", "sudo", "immunity_period"]
) # args: [immunity_period: u64] | Pallet: AdminUtils
Expand Down Expand Up @@ -202,6 +205,9 @@
SUDO_SET_STAKE_THRESHOLD = namedtuple(
"SUDO_SET_STAKE_THRESHOLD", ["wallet", "pallet", "sudo", "min_stake"]
) # args: [min_stake: u64] | Pallet: AdminUtils
SUDO_SET_START_CALL_DELAY = namedtuple(
"SUDO_SET_START_CALL_DELAY", ["wallet", "pallet", "sudo", "delay"]
) # args: [delay: u64] | Pallet: AdminUtils
SUDO_SET_SUBNET_LIMIT = namedtuple(
"SUDO_SET_SUBNET_LIMIT", ["wallet", "pallet", "sudo", "max_subnets"]
) # args: [max_subnets: u16] | Pallet: AdminUtils
Expand All @@ -218,6 +224,16 @@
"SUDO_SET_SUBTOKEN_ENABLED",
["wallet", "pallet", "sudo", "netuid", "subtoken_enabled"],
) # args: [netuid: NetUid, subtoken_enabled: bool] | Pallet: AdminUtils
SUDO_SET_TAO_FLOW_CUTOFF = namedtuple(
"SUDO_SET_TAO_FLOW_CUTOFF", ["wallet", "pallet", "sudo", "flow_cutoff"]
) # args: [flow_cutoff: I64F64] | Pallet: AdminUtils
SUDO_SET_TAO_FLOW_NORMALIZATION_EXPONENT = namedtuple(
"SUDO_SET_TAO_FLOW_NORMALIZATION_EXPONENT", ["wallet", "pallet", "sudo", "exponent"]
) # args: [exponent: U64F64] | Pallet: AdminUtils
SUDO_SET_TAO_FLOW_SMOOTHING_FACTOR = namedtuple(
"SUDO_SET_TAO_FLOW_SMOOTHING_FACTOR",
["wallet", "pallet", "sudo", "smoothing_factor"],
) # args: [smoothing_factor: u64] | Pallet: AdminUtils
SUDO_SET_TARGET_REGISTRATIONS_PER_INTERVAL = namedtuple(
"SUDO_SET_TARGET_REGISTRATIONS_PER_INTERVAL",
["wallet", "pallet", "sudo", "netuid", "target_registrations_per_interval"],
Expand Down
10 changes: 2 additions & 8 deletions bittensor/extras/dev_framework/subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ def _activate_subnet(
"""Activate subnet."""
self._check_netuid()
current_block = self.s.block
activation_block = self.s.queries.query_constant(
"SubtensorModule", "DurationOfStartCall"
).value
activation_block = self.s.chain.get_start_call_delay()
# added 10 blocks bc 2.5 seconds is not always enough for the chain to update.
self.s.wait_for_block(current_block + activation_block + 1)
response = self.s.subnets.start_call(
Expand Down Expand Up @@ -292,11 +290,7 @@ async def _async_activate_subnet(
"""Activate subnet."""
self._check_netuid()
current_block = await self.s.block
activation_block = (
await self.s.queries.query_constant(
"SubtensorModule", "DurationOfStartCall"
)
).value
activation_block = await self.s.chain.get_start_call_delay()
# added 10 blocks bc 2.5 seconds is not always enough for the chain to update.
await self.s.wait_for_block(current_block + activation_block + 1)

Expand Down
1 change: 1 addition & 0 deletions bittensor/extras/subtensor_api/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, subtensor: Union["_Subtensor", "_AsyncSubtensor"]):
self.get_delegate_identities = subtensor.get_delegate_identities
self.get_existential_deposit = subtensor.get_existential_deposit
self.get_minimum_required_stake = subtensor.get_minimum_required_stake
self.get_start_call_delay = subtensor.get_start_call_delay
self.get_timestamp = subtensor.get_timestamp
self.get_vote_data = subtensor.get_vote_data
self.is_fast_blocks = subtensor.is_fast_blocks
Expand Down
Loading