Skip to content

Commit

Permalink
indexer-selection: lower minimum score for success rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed May 1, 2024
1 parent f1c11fe commit e1deddc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion indexer-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@ pub fn score_latency(latency_ms: u32) -> Normalized {

/// https://www.desmos.com/calculator/df2keku3ad
fn score_success_rate(success_rate: Normalized) -> Normalized {
Normalized::new(success_rate.as_f64().powi(7).max(0.01)).unwrap()
let min_score = 1e-8;
Normalized::new(success_rate.as_f64().powi(7).max(min_score)).unwrap()
}
42 changes: 21 additions & 21 deletions indexer-selection/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ use proptest::{prop_assert, prop_compose, proptest};
use std::ops::RangeInclusive;
use thegraph_core::types::alloy_primitives::{hex, FixedBytes};

#[test]
fn candidate_should_use_url_display_for_debug() {
let expected_url = "https://example.com/candidate/test/url";
let candidate = Candidate {
indexer: Default::default(),
deployment: FixedBytes::default().into(),
url: expected_url.parse().expect("valid url"),
perf: ExpectedPerformance {
success_rate: Normalized::ZERO,
latency_success_ms: 0,
latency_failure_ms: 0,
},
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 0,
subgraph_versions_behind: 0,
zero_allocation: false,
};
assert!(format!("{candidate:?}").contains(expected_url));
}

mod limits {
use super::*;

Expand Down Expand Up @@ -143,24 +164,3 @@ fn sensitivity_seconds_behind() {
"select candidate closer to chain head",
);
}

#[test]
fn candidate_should_use_url_display_for_debug() {
let expected_url = "https://example.com/candidate/test/url";
let candidate = Candidate {
indexer: Default::default(),
deployment: FixedBytes::default().into(),
url: expected_url.parse().expect("valid url"),
perf: ExpectedPerformance {
success_rate: Normalized::ZERO,
latency_success_ms: 0,
latency_failure_ms: 0,
},
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 0,
subgraph_versions_behind: 0,
zero_allocation: false,
};
assert!(format!("{candidate:?}").contains(expected_url));
}

0 comments on commit e1deddc

Please sign in to comment.