Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix reveal_round calculation edge cases #8

Merged
merged 10 commits into from
Dec 12, 2024
Prev Previous commit
Next Next commit
fix the reveal round at the exact epoch
  • Loading branch information
JohnReedV committed Dec 12, 2024
commit efaa176a786a06ecf860f5d3ca360025c6909443
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -58,7 +58,15 @@ async fn generate_commit(
let tempo_plus_one = tempo + 1;
let netuid_plus_one = (netuid as u64) + 1;
let block_with_offset = current_block + netuid_plus_one;
let current_epoch = block_with_offset / tempo_plus_one;

// If at an exact epoch boundary, treat this as the new epoch start.
let is_epoch_boundary = (block_with_offset % tempo_plus_one) == 0;
let base_epoch = block_with_offset / tempo_plus_one;
let current_epoch = if is_epoch_boundary {
base_epoch + 1
} else {
base_epoch
};

// Compute the reveal epoch
let reveal_epoch = current_epoch + subnet_reveal_period_epochs;
Loading