opentensor / subtensor

Bittensor Blockchain Layer
The Unlicense
123 stars 131 forks source link

Refactor epoch function #435

Closed gztensor closed 2 months ago

gztensor commented 2 months ago

Description

We need this refactoring to prepare for a safe DTAO upgrade: Separate epoch and epoch_sparse functions into different parts:

  1. Initialization
  2. Running
  3. Saving to storage

Also, split running into following functions to make it more testable and extendable:

  1. fn calc_active_inactive(&mut self);
  2. fn calc_validator_forbids(&mut self);
  3. fn calc_active_stake(&mut self);
  4. fn adjust_weights(&mut self);
  5. fn calc_consensus(&mut self);
  6. fn calc_ranks(&mut self);
  7. fn calc_trust(&mut self);
  8. fn calc_incentive(&mut self);
  9. fn calc_bonds_and_dividends(&mut self);
  10. fn calc_emission_and_pruning_scores(&mut self, rao_emission: u64);
  11. fn calc_validator_trust(&mut self);
  12. fn calc_new_validator_permits(&mut self);
  13. fn adjust_ema_bonds(&mut self);
  14. fn log_epoch(&self);

Related Issue(s)

n/a

Type of Change

Breaking Change

none (hopefully :))

Checklist

Screenshots (if applicable)

n/a

Additional Notes

n/a