Skip to content

Commit ce83530

Browse files
Merge pull request #2753 from opentensor/fix/zyzniewski/wait_epoch
Fix E2E: fix wait_epoch and next_tempo
2 parents fee2eaf + 403dbf5 commit ce83530

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/e2e_tests/utils/chain_interactions.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def sudo_set_hyperparameter_values(
7474
return response.is_success
7575

7676

77-
async def wait_epoch(subtensor: "Subtensor", netuid: int = 1, times: int = 1):
77+
async def wait_epoch(subtensor: "Subtensor", netuid: int = 1, **kwargs):
7878
"""
7979
Waits for the next epoch to start on a specific subnet.
8080
@@ -90,7 +90,7 @@ async def wait_epoch(subtensor: "Subtensor", netuid: int = 1, times: int = 1):
9090
raise Exception("could not determine tempo")
9191
tempo = q_tempo[0].value
9292
logging.info(f"tempo = {tempo}")
93-
await wait_interval(tempo * times, subtensor, netuid)
93+
await wait_interval(tempo, subtensor, netuid, **kwargs)
9494

9595

9696
def next_tempo(current_block: int, tempo: int, netuid: int) -> int:
@@ -105,6 +105,7 @@ def next_tempo(current_block: int, tempo: int, netuid: int) -> int:
105105
Returns:
106106
int: The next tempo block number.
107107
"""
108+
current_block += 1
108109
interval = tempo + 1
109110
last_epoch = current_block - 1 - (current_block + netuid + 1) % interval
110111
next_tempo_ = last_epoch + interval
@@ -117,6 +118,7 @@ async def wait_interval(
117118
netuid: int = 1,
118119
reporting_interval: int = 1,
119120
sleep: float = 0.25,
121+
times: int = 1,
120122
):
121123
"""
122124
Waits until the next tempo interval starts for a specific subnet.
@@ -126,7 +128,11 @@ async def wait_interval(
126128
the current block number until the next tempo interval starts.
127129
"""
128130
current_block = subtensor.get_current_block()
129-
next_tempo_block_start = next_tempo(current_block, tempo, netuid)
131+
next_tempo_block_start = current_block
132+
133+
for _ in range(times):
134+
next_tempo_block_start = next_tempo(next_tempo_block_start, tempo, netuid)
135+
130136
last_reported = None
131137

132138
while current_block < next_tempo_block_start:

0 commit comments

Comments
 (0)