Skip to content
Open
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
7 changes: 6 additions & 1 deletion crates/autopilot-svm/src/domain/arbitrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ impl WinnerSelection<SolanaCycle> for SolanaArbitrator {
for winner in inner.winners() {
tracing::info!(solver = %winner.solver(), solution = winner.id(), "winner");
}
Ranking { inner, drivers }
let reference_scores = self.inner.compute_reference_scores(&inner);
Ranking {
inner,
drivers,
reference_scores,
}
}
}
22 changes: 21 additions & 1 deletion crates/autopilot-svm/src/domain/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
},
chain_types::solana::{IntentHash, Pubkey, Solana},
std::collections::{HashMap, HashSet},
winner_selection::{Unscored, solution},
winner_selection::{Unscored, solution, state::Ranked},
};

/// Marker type binding the generic loop to the Solana vocabulary.
Expand Down Expand Up @@ -45,6 +45,26 @@ pub struct Ranking {
pub inner: winner_selection::Ranking<Solana>,
/// Driver index per solution, keyed by `(solver, solution id)`.
pub drivers: HashMap<SolutionKey, usize>,
/// Per winning solver, the winners' total score with that solver's
/// solutions removed: the rewards baseline.
pub reference_scores: HashMap<Pubkey, u64>,
}

impl Ranking {
/// Every solution with its persisted uid: the position in `ranked`
/// followed by `filtered_out`, so winners come first. Everything
/// persisted references this uid, it disambiguates solver-assigned ids
/// across drivers.
pub fn enumerated(
&self,
) -> impl Iterator<Item = (i64, &solution::Solution<Ranked<u64>, Solana>)> {
self.inner
.ranked
.iter()
.chain(self.inner.filtered_out.iter())
.enumerate()
.map(|(uid, solution)| (i64::try_from(uid).unwrap_or(i64::MAX), solution))
}
}

impl RankingInfo<SolanaCycle> for Ranking {
Expand Down
Loading
Loading