Skip to content

Commit

Permalink
feat(indexer-selection): penalize indexers with 0 allocation (#420)
Browse files Browse the repository at this point in the history
The expectation is that backstop indexers will not be selected over
other indexers at equivalent QoS. Allocation size is only accounted for
with sybil protection, so this makes our expected behavior much more
explicit.
  • Loading branch information
Theodus authored Nov 20, 2023
1 parent 2911de5 commit 1cf40cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions indexer-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ impl State {
let reliability = state.reliability.expected_value();
let perf_success = state.perf_success.expected_value();
let slashable_usd = slashable.0.into();
let zero_allocation = state.status.allocation == GRT(UDecimal18::from(0));

let expected_score = NotNan::new(expected_individual_score(
params,
Expand All @@ -303,6 +304,7 @@ impl State {
state.status.versions_behind,
block_status.blocks_behind,
slashable_usd,
zero_allocation,
&fee,
))
.unwrap_or(NotNan::zero());
Expand Down
4 changes: 4 additions & 0 deletions indexer-selection/src/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,22 +207,26 @@ impl MetaIndexer<'_> {
}
}

#[allow(clippy::too_many_arguments)]
pub fn expected_individual_score(
params: &UtilityParameters,
reliability: f64,
perf_success: f64,
versions_behind: u8,
blocks_behind: u64,
slashable_usd: f64,
zero_allocation: bool,
fee: &GRT,
) -> f64 {
let altruism_penalty = UtilityFactor::one(if zero_allocation { 0.8 } else { 1.0 });
weighted_product_model([
reliability_utility(reliability),
performance_utility(perf_success as u32),
economic_security_utility(slashable_usd),
versions_behind_utility(versions_behind),
data_freshness_utility(params.block_rate_hz, &params.requirements, blocks_behind),
fee_utility(fee, &params.budget),
altruism_penalty,
])
}

Expand Down

0 comments on commit 1cf40cc

Please sign in to comment.