Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ff cleanup: vote_state_update_credit_per_deque #32966

Merged
merged 1 commit into from
Aug 30, 2023
Merged
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
20 changes: 5 additions & 15 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intentionally leaving this here because the upcoming timely vote credits change will need it

) -> Result<(), VoteError> {
assert!(!new_state.is_empty());
if new_state.len() > MAX_LOCKOUT_HISTORY {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1670,8 +1661,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
Expand Down