Skip to content

Commit

Permalink
Merge pull request #264 from autonomys/cleanup-todo
Browse files Browse the repository at this point in the history
Replace `MAX_AUDITING_TIME` constant with slot duration
  • Loading branch information
nazar-pc authored Aug 5, 2024
2 parents f5937cb + b8b5353 commit 6b4b600
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/frontend/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ impl RunningView {
total_sectors: initial_farm_state.total_sectors_count,
plotted_total_sectors: initial_farm_state.plotted_sectors_count,
plotting_paused: self.plotting_paused,
slot_duration: chain_constants.slot_duration().as_duration(),
block_authoring_delay: chain_constants.slot_duration().as_duration()
* u64::from(chain_constants.block_authoring_delay()) as u32,
},
Expand Down
12 changes: 6 additions & 6 deletions src/frontend/running/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const INVALID_SCORE_VALUE: f64 = -1.0;
const SECTORS_PER_ROW: usize = 108;
/// Number of samples over which to track auditing time, 1 minute in slots
const AUDITING_TIME_TRACKING_WINDOW: usize = 60;
// TODO: Replace constant with slot duration
/// One second to audit
const MAX_AUDITING_TIME: Duration = Duration::from_secs(1);
/// 500ms auditing time is excellent, anything larger will result in auditing performance indicator decrease
const EXCELLENT_AUDITING_TIME: Duration = Duration::from_millis(500);
/// Number of samples over which to track proving time
Expand Down Expand Up @@ -77,6 +74,7 @@ pub(super) struct FarmWidgetInit {
pub(super) total_sectors: SectorIndex,
pub(super) plotted_total_sectors: SectorIndex,
pub(super) plotting_paused: bool,
pub(super) slot_duration: Duration,
pub(super) block_authoring_delay: Duration,
}

Expand Down Expand Up @@ -125,6 +123,7 @@ pub(super) struct FarmWidget {
farm_details: bool,
encoding_sectors: usize,
plotting_paused: bool,
slot_duration: Duration,
block_authoring_delay: Duration,
#[no_eq]
error: Option<Arc<anyhow::Error>>,
Expand Down Expand Up @@ -222,7 +221,7 @@ impl FactoryComponent for FarmWidget {
set_tooltip: T
.running_farmer_farm_auditing_performance_tooltip(
self.auditing_time_average.as_secs_f32(),
MAX_AUDITING_TIME.as_secs_f32()
self.slot_duration.as_secs_f32()
)
.as_str(),
#[track = "self.changed_farm_details() || self.changed_auditing_time_score()"]
Expand Down Expand Up @@ -426,6 +425,7 @@ impl FactoryComponent for FarmWidget {
farm_details: false,
encoding_sectors: 0,
plotting_paused: init.plotting_paused,
slot_duration: init.slot_duration,
block_authoring_delay: init.block_authoring_delay,
error: None,
tracker: u32::MAX,
Expand Down Expand Up @@ -521,9 +521,9 @@ impl FarmWidget {

let average_time = self.auditing_time.get_average();
let slot_time_fraction_remaining =
1.0 - average_time.as_secs_f64() / MAX_AUDITING_TIME.as_secs_f64();
1.0 - average_time.as_secs_f64() / self.slot_duration.as_secs_f64();
let excellent_time_fraction_remaining = 1.0
- EXCELLENT_AUDITING_TIME.as_secs_f64() / MAX_AUDITING_TIME.as_secs_f64();
- EXCELLENT_AUDITING_TIME.as_secs_f64() / self.slot_duration.as_secs_f64();
let score = (slot_time_fraction_remaining / excellent_time_fraction_remaining)
.clamp(0.0, 1.0);
// Round to 5% precision
Expand Down

0 comments on commit 6b4b600

Please sign in to comment.