Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions bittensor_cli/src/commands/stake/children_hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@ async def get_childkey_completion_block(
"""
Calculates the block at which the childkey set request will complete
"""
bh = await subtensor.substrate.get_chain_head()
blocks_since_last_step_query = subtensor.query(
"SubtensorModule",
"BlocksSinceLastStep",
params=[netuid],
"SubtensorModule", "BlocksSinceLastStep", params=[netuid], block_hash=bh
)
tempo_query = subtensor.get_hyperparameter(
param_name="Tempo",
netuid=netuid,
param_name="Tempo", netuid=netuid, block_hash=bh
)
block_number, blocks_since_last_step, tempo = await asyncio.gather(
subtensor.substrate.get_block_number(),
subtensor.substrate.get_block_number(block_hash=bh),
blocks_since_last_step_query,
tempo_query,
)
cooldown = block_number + 1
cooldown = block_number + 7200
blocks_left_in_tempo = tempo - blocks_since_last_step
next_tempo = block_number + blocks_left_in_tempo
next_epoch_after_cooldown = (cooldown - next_tempo) % tempo + cooldown
next_epoch_after_cooldown = (cooldown - next_tempo) % (tempo + 1) + cooldown
return block_number, next_epoch_after_cooldown


Expand Down
15 changes: 15 additions & 0 deletions tests/e2e_tests/test_children_hotkeys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest

from bittensor_cli.src.bittensor.subtensor_interface import SubtensorInterface
from bittensor_cli.src.commands.stake.children_hotkeys import (
get_childkey_completion_block,
)


@pytest.mark.asyncio
async def test_get_childkey_completion_block(local_chain):
async with SubtensorInterface("ws://127.0.0.1:9945") as subtensor:
current_block, completion_block = await get_childkey_completion_block(
subtensor, 1
)
assert (completion_block - current_block) >= 7200
Loading