subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

Epoch is every 361 blocks, while it seems it should be 360

Open gztensor opened this issue 9 months ago • 3 comments

The actual length of an epoch is Tempo + 1 because of how blocks_until_next_epoch is implemented:

    pub fn blocks_until_next_epoch(netuid: u16, tempo: u16, block_number: u64) -> u64 {
        if tempo == 0 {
            return u64::MAX;
        }
        let netuid_plus_one = (netuid as u64).saturating_add(1);
        let tempo_plus_one = (tempo as u64).saturating_add(1);
        let adjusted_block = block_number.wrapping_add(netuid_plus_one);
        let remainder = adjusted_block.checked_rem(tempo_plus_one).unwrap_or(0);
        (tempo as u64).saturating_sub(remainder)
    }

The fix is easy, but the real task is to investigate whether this fix will have any impactful side-effects and mitigate if needed.

gztensor avatar Apr 25 '25 20:04 gztensor

Initial thought is to leave it as it is. Changing the calculation would require refactors all over the place. Is this causing any problems now?

JohnReedV avatar Apr 28 '25 03:04 JohnReedV

This was discussed a while ago and the conclusion was that we should leave it as it is until dynamic tempo duration is implemented. The gain of changing it by one block is none, but it'll will upset a number of things in the entire community. Slow us down... and for what?

Dynamic tempo will upset everything anyway and people will need to adjust everything for it. That's when we'll fix it.

ppolewicz avatar May 04 '25 17:05 ppolewicz

@gztensor please close it if you agree - I doubt we'll forget about this one ha ha

ppolewicz avatar May 04 '25 17:05 ppolewicz

Please don't change this, we already work around it. I think I discussed it with somebody at OTF ages ago.

bdmason avatar Jun 05 '25 09:06 bdmason