@@ -1687,6 +1687,38 @@ async def get_neuron_for_pubkey_and_subnet(
1687
1687
reuse_block = reuse_block ,
1688
1688
)
1689
1689
1690
+ async def get_next_epoch_start_block (
1691
+ self ,
1692
+ netuid : int ,
1693
+ block : Optional [int ] = None ,
1694
+ block_hash : Optional [str ] = None ,
1695
+ reuse_block : bool = False ,
1696
+ ) -> Optional [int ]:
1697
+ """
1698
+ Calculates the first block number of the next epoch for the given subnet.
1699
+
1700
+ If `block` is not provided, the current chain block will be used. Epochs are
1701
+ determined based on the subnet's tempo (i.e., blocks per epoch). The result
1702
+ is the block number at which the next epoch will begin.
1703
+
1704
+ Args:
1705
+ netuid (int): The unique identifier of the subnet.
1706
+ block (Optional[int], optional): The reference block to calculate from.
1707
+ If None, uses the current chain block height.
1708
+ block_hash (Optional[int]): The blockchain block number at which to perform the query.
1709
+ reuse_block (bool): Whether to reuse the last-used blockchain block hash.
1710
+
1711
+
1712
+ Returns:
1713
+ int: The block number at which the next epoch will start.
1714
+ """
1715
+ block_hash = await self .determine_block_hash (block , block_hash , reuse_block )
1716
+ if not block_hash and reuse_block :
1717
+ block_hash = self .substrate .last_block_hash
1718
+ block = await self .substrate .get_block_number (block_hash = block_hash )
1719
+ tempo = await self .tempo (netuid = netuid , block_hash = block_hash )
1720
+ return (((block // tempo ) + 1 ) * tempo ) + 1 if tempo else None
1721
+
1690
1722
async def get_owned_hotkeys (
1691
1723
self ,
1692
1724
coldkey_ss58 : str ,
@@ -3813,6 +3845,7 @@ async def set_weights(
3813
3845
wait_for_finalization : bool = False ,
3814
3846
max_retries : int = 5 ,
3815
3847
block_time : float = 12.0 ,
3848
+ period : int = 5 ,
3816
3849
):
3817
3850
"""
3818
3851
Sets the inter-neuronal weights for the specified neuron. This process involves specifying the influence or
@@ -3833,6 +3866,7 @@ async def set_weights(
3833
3866
``False``.
3834
3867
max_retries (int): The number of maximum attempts to set weights. Default is ``5``.
3835
3868
block_time (float): The amount of seconds for block duration. Default is 12.0 seconds.
3869
+ period (int, optional): The period in seconds to wait for extrinsic inclusion or finalization. Defaults to 5.
3836
3870
3837
3871
Returns:
3838
3872
tuple[bool, str]: ``True`` if the setting of weights is successful, False otherwise. And `msg`, a string
@@ -3907,6 +3941,7 @@ async def _blocks_weight_limit() -> bool:
3907
3941
version_key = version_key ,
3908
3942
wait_for_inclusion = wait_for_inclusion ,
3909
3943
wait_for_finalization = wait_for_finalization ,
3944
+ period = period ,
3910
3945
)
3911
3946
except Exception as e :
3912
3947
logging .error (f"Error setting weights: { e } " )
0 commit comments