Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions indexer-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub struct Candidate<I, D> {
/// seconds behind chain head
pub seconds_behind: u32,
pub slashable_grt: u64,
pub zero_allocation: bool,
}

pub fn select<I, D, const LIMIT: usize>(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 0 additions & 13 deletions indexer-selection/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64, ()> {
Expand All @@ -47,7 +46,6 @@ prop_compose! {
fee,
seconds_behind: seconds_behind as u32,
slashable_grt: slashable_grt as u64,
zero_allocation,
}
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -108,7 +105,6 @@ fn sensitivity_seconds_behind() {
fee: Normalized::ONE,
seconds_behind: 120,
slashable_grt: 100_000,
zero_allocation: false,
},
];

Expand Down Expand Up @@ -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,
Expand All @@ -150,7 +145,6 @@ fn sensitivity_seconds_behind_vs_latency() {
fee: Normalized::ZERO,
seconds_behind: 120,
slashable_grt: 100_000,
zero_allocation: true,
},
];

Expand Down Expand Up @@ -180,7 +174,6 @@ fn multi_selection_preference() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 9445169,
zero_allocation: false,
},
Candidate {
id: 1,
Expand All @@ -192,7 +185,6 @@ fn multi_selection_preference() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 1330801,
zero_allocation: false,
},
Candidate {
id: 2,
Expand All @@ -204,7 +196,6 @@ fn multi_selection_preference() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 2675210,
zero_allocation: false,
},
];

Expand Down Expand Up @@ -236,7 +227,6 @@ fn low_volume_response() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 100000,
zero_allocation: false,
},
Candidate {
id: 1,
Expand All @@ -248,7 +238,6 @@ fn low_volume_response() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 100000,
zero_allocation: false,
},
Candidate {
id: 2,
Expand All @@ -260,7 +249,6 @@ fn low_volume_response() {
fee: Normalized::ZERO,
seconds_behind: 0,
slashable_grt: 100000,
zero_allocation: true,
},
];

Expand Down Expand Up @@ -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| {
Expand Down
Loading