ff cleanup: vote_state_update_credit_per_deque (#32966)

This commit is contained in:
Ashwin Sekar 2023-08-30 15:42:18 -07:00 committed by GitHub
parent b13589b588
commit e88d6c6130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 15 deletions

View File

@ -549,7 +549,7 @@ pub fn process_new_vote_state(
new_root: Option<Slot>,
timestamp: Option<i64>,
epoch: Epoch,
feature_set: Option<&FeatureSet>,
_feature_set: Option<&FeatureSet>,
) -> Result<(), VoteError> {
assert!(!new_state.is_empty());
if new_state.len() > MAX_LOCKOUT_HISTORY {
@ -683,18 +683,9 @@ pub fn process_new_vote_state(
// our state.
if vote_state.root_slot != new_root {
// Award vote credits based on the number of slots that were voted on and have reached finality
if feature_set
.map(|feature_set| {
feature_set.is_active(&feature_set::vote_state_update_credit_per_dequeue::id())
})
.unwrap_or(false)
{
// For each finalized slot, there was one voted-on slot in the new vote state that was responsible for
// finalizing it. Each of those votes is awarded 1 credit.
vote_state.increment_credits(epoch, finalized_slot_count);
} else {
vote_state.increment_credits(epoch, 1);
}
// For each finalized slot, there was one voted-on slot in the new vote state that was responsible for
// finalizing it. Each of those votes is awarded 1 credit.
vote_state.increment_credits(epoch, finalized_slot_count);
}
if let Some(timestamp) = timestamp {
let last_slot = new_state.back().unwrap().slot();
@ -1671,8 +1662,7 @@ mod tests {
vec![227, 228, 229, 230, 231, 232, 233, 234, 235, 236],
];
let mut feature_set = FeatureSet::default();
feature_set.activate(&feature_set::vote_state_update_credit_per_dequeue::id(), 1);
let feature_set = FeatureSet::default();
for vote_group in test_vote_groups {
// Duplicate vote_state so that the new vote can be applied