From 08410eee2818b7092e302f17a5cbcfd1895dafec Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Wed, 19 Feb 2025 10:16:16 -0500 Subject: [PATCH] fix: remove zero_allocation factor --- indexer-selection/src/lib.rs | 11 ----------- indexer-selection/src/test.rs | 13 ------------- 2 files changed, 24 deletions(-) diff --git a/indexer-selection/src/lib.rs b/indexer-selection/src/lib.rs index 0d16997..58c458d 100644 --- a/indexer-selection/src/lib.rs +++ b/indexer-selection/src/lib.rs @@ -22,7 +22,6 @@ pub struct Candidate { /// seconds behind chain head pub seconds_behind: u32, pub slashable_grt: u64, - pub zero_allocation: bool, } pub fn select( @@ -56,7 +55,6 @@ where score_latency(self.perf.latency_ms), score_seconds_behind(self.seconds_behind), score_slashable_grt(self.slashable_grt), - score_zero_allocation(self.zero_allocation), ] .into_iter() .product() @@ -106,14 +104,12 @@ 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 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_zero_allocation(zero_allocation), ] .into_iter() .product() @@ -141,13 +137,6 @@ fn score_slashable_grt(slashable_grt: u64) -> Normalized { Normalized::new(1.0 - E.powf(-a * x)).unwrap() } -/// Allocations of zero indicate that an indexer wants lower selection priority. -fn score_zero_allocation(zero_allocation: bool) -> Normalized { - zero_allocation - .then(|| Normalized::new(0.9).unwrap()) - .unwrap_or(Normalized::ONE) -} - /// https://www.desmos.com/calculator/v2vrfktlpl pub fn score_latency(latency_ms: u16) -> Normalized { let s = |x: u16| 1.0 + E.powf(((x as f64) - 400.0) / 300.0); diff --git a/indexer-selection/src/test.rs b/indexer-selection/src/test.rs index 9a80fc0..4b2f1ad 100644 --- a/indexer-selection/src/test.rs +++ b/indexer-selection/src/test.rs @@ -25,7 +25,6 @@ prop_compose! { versions_behind in 0..=3_u8, seconds_behind in 0..=7500_u16, slashable_grt: u32, - zero_allocation: bool, avg_latency_ms: u16, avg_success_rate_percent in 0..=100_u8, ) -> Candidate { @@ -47,7 +46,6 @@ prop_compose! { fee, seconds_behind: seconds_behind as u32, slashable_grt: slashable_grt as u64, - zero_allocation, } } } @@ -96,7 +94,6 @@ fn sensitivity_seconds_behind() { fee: Normalized::ZERO, seconds_behind: 86400, slashable_grt: 1_000_000, - zero_allocation: false, }, Candidate { id: 1, @@ -108,7 +105,6 @@ fn sensitivity_seconds_behind() { fee: Normalized::ONE, seconds_behind: 120, slashable_grt: 100_000, - zero_allocation: false, }, ]; @@ -138,7 +134,6 @@ fn sensitivity_seconds_behind_vs_latency() { fee: Normalized::ZERO, seconds_behind: 35_000_000, slashable_grt: 1_600_000, - zero_allocation: false, }, Candidate { id: 1, @@ -150,7 +145,6 @@ fn sensitivity_seconds_behind_vs_latency() { fee: Normalized::ZERO, seconds_behind: 120, slashable_grt: 100_000, - zero_allocation: true, }, ]; @@ -180,7 +174,6 @@ fn multi_selection_preference() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 9445169, - zero_allocation: false, }, Candidate { id: 1, @@ -192,7 +185,6 @@ fn multi_selection_preference() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 1330801, - zero_allocation: false, }, Candidate { id: 2, @@ -204,7 +196,6 @@ fn multi_selection_preference() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 2675210, - zero_allocation: false, }, ]; @@ -236,7 +227,6 @@ fn low_volume_response() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 100000, - zero_allocation: false, }, Candidate { id: 1, @@ -248,7 +238,6 @@ fn low_volume_response() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 100000, - zero_allocation: false, }, Candidate { id: 2, @@ -260,7 +249,6 @@ fn low_volume_response() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 100000, - zero_allocation: true, }, ]; @@ -289,7 +277,6 @@ fn perf_decay() { fee: Normalized::ZERO, seconds_behind: 0, slashable_grt: 1_000_000, - zero_allocation: false, }; let mut simulate = |seconds, success, latency_ms| {