Skip to content

Commit

Permalink
indexer-selection: remove versions_behind
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Jun 8, 2024
1 parent 1d6db83 commit a803471
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
10 changes: 0 additions & 10 deletions indexer-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub struct Candidate<I, D> {
/// seconds behind chain head
pub seconds_behind: u32,
pub slashable_grt: u64,
/// subgraph versions behind latest deployment
pub versions_behind: u8,
pub zero_allocation: bool,
}

Expand Down Expand Up @@ -58,7 +56,6 @@ where
score_latency(self.perf.latency_ms),
score_seconds_behind(self.seconds_behind),
score_slashable_grt(self.slashable_grt),
score_subgraph_versions_behind(self.versions_behind),
score_zero_allocation(self.zero_allocation),
]
.into_iter()
Expand Down Expand Up @@ -109,15 +106,13 @@ where
.recip() as u16;
let seconds_behind = candidates.iter().map(|c| c.seconds_behind).max().unwrap();
let slashable_grt = candidates.iter().map(|c| c.slashable_grt).min().unwrap();
let versions_behind = candidates.iter().map(|c| c.versions_behind).max().unwrap();
let zero_allocation = candidates.iter().all(|c| c.zero_allocation);

[
score_success_rate(success_rate),
score_latency(latency),
score_seconds_behind(seconds_behind),
score_slashable_grt(slashable_grt),
score_subgraph_versions_behind(versions_behind),
score_zero_allocation(zero_allocation),
]
.into_iter()
Expand All @@ -128,11 +123,6 @@ where
// When picking curves to use consider the following reference:
// https://en.wikipedia.org/wiki/Logistic_function

/// Avoid serving deployments behind latest version, unless newer versions have poor indexer support.
fn score_subgraph_versions_behind(versions_behind: u8) -> Normalized {
Normalized::new(0.25_f64.powi(versions_behind as i32)).unwrap()
}

/// https://www.desmos.com/calculator/gzmp7rbiai
fn score_seconds_behind(seconds_behind: u32) -> Normalized {
let b: f64 = 1e-6;
Expand Down
12 changes: 0 additions & 12 deletions indexer-selection/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ prop_compose! {
fee,
seconds_behind: seconds_behind as u32,
slashable_grt: slashable_grt as u64,
versions_behind,
zero_allocation,
}
}
Expand Down Expand Up @@ -97,7 +96,6 @@ fn sensitivity_seconds_behind() {
fee: Normalized::ZERO,
seconds_behind: 86400,
slashable_grt: 1_000_000,
versions_behind: 0,
zero_allocation: false,
},
Candidate {
Expand All @@ -110,7 +108,6 @@ fn sensitivity_seconds_behind() {
fee: Normalized::ONE,
seconds_behind: 120,
slashable_grt: 100_000,
versions_behind: 0,
zero_allocation: false,
},
];
Expand Down Expand Up @@ -141,7 +138,6 @@ fn sensitivity_seconds_behind_vs_latency() {
fee: Normalized::ZERO,
seconds_behind: 35_000_000,
slashable_grt: 1_600_000,
versions_behind: 0,
zero_allocation: false,
},
Candidate {
Expand All @@ -154,7 +150,6 @@ fn sensitivity_seconds_behind_vs_latency() {
fee: Normalized::ZERO,
seconds_behind: 120,
slashable_grt: 100_000,
versions_behind: 0,
zero_allocation: true,
},
];
Expand Down Expand Up @@ -185,7 +180,6 @@ fn multi_selection_preference() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 9445169,
versions_behind: 0,
zero_allocation: false,
},
Candidate {
Expand All @@ -198,7 +192,6 @@ fn multi_selection_preference() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 1330801,
versions_behind: 0,
zero_allocation: false,
},
Candidate {
Expand All @@ -211,7 +204,6 @@ fn multi_selection_preference() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 2675210,
versions_behind: 0,
zero_allocation: false,
},
];
Expand Down Expand Up @@ -244,7 +236,6 @@ fn low_volume_response() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 100000,
versions_behind: 0,
zero_allocation: false,
},
Candidate {
Expand All @@ -257,7 +248,6 @@ fn low_volume_response() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 100000,
versions_behind: 0,
zero_allocation: false,
},
Candidate {
Expand All @@ -270,7 +260,6 @@ fn low_volume_response() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 100000,
versions_behind: 0,
zero_allocation: true,
},
];
Expand Down Expand Up @@ -300,7 +289,6 @@ fn perf_decay() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 1_000_000,
versions_behind: 0,
zero_allocation: false,
};

Expand Down

0 comments on commit a803471

Please sign in to comment.