Skip to content

Commit

Permalink
fixed not firing and doing all vote accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed May 28, 2024
1 parent d85e607 commit 480b95b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 24 deletions.
4 changes: 2 additions & 2 deletions keepers/validator-keeper/src/operations/cluster_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ fn _get_operation() -> KeeperOperations {

fn _should_run(epoch_info: &EpochInfo, runs_for_epoch: u64) -> bool {
// Run at 0.1%, 50% and 90% completion of epoch
(epoch_info.slot_index > epoch_info.slots_in_epoch / 1000 && runs_for_epoch < 1)
|| (epoch_info.slot_index > epoch_info.slots_in_epoch / 2 && runs_for_epoch < 2)
(epoch_info.slot_index > epoch_info.slots_in_epoch * 1 / 1000 && runs_for_epoch < 1)

Check failure on line 30 in keepers/validator-keeper/src/operations/cluster_history.rs

View workflow job for this annotation

GitHub Actions / lint

this operation has no effect
|| (epoch_info.slot_index > epoch_info.slots_in_epoch * 5 / 10 && runs_for_epoch < 2)
|| (epoch_info.slot_index > epoch_info.slots_in_epoch * 9 / 10 && runs_for_epoch < 3)
}

Expand Down
4 changes: 2 additions & 2 deletions keepers/validator-keeper/src/operations/stake_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ fn _get_operation() -> KeeperOperations {

fn _should_run(epoch_info: &EpochInfo, runs_for_epoch: u64) -> bool {
// Run at 0.1%, 50% and 90% completion of epoch
(epoch_info.slot_index > epoch_info.slots_in_epoch / 1000 && runs_for_epoch < 1)
|| (epoch_info.slot_index > epoch_info.slots_in_epoch / 2 && runs_for_epoch < 2)
(epoch_info.slot_index > epoch_info.slots_in_epoch * 1 / 1000 && runs_for_epoch < 1)

Check failure on line 30 in keepers/validator-keeper/src/operations/stake_upload.rs

View workflow job for this annotation

GitHub Actions / lint

this operation has no effect
|| (epoch_info.slot_index > epoch_info.slots_in_epoch * 5 / 10 && runs_for_epoch < 2)
|| (epoch_info.slot_index > epoch_info.slots_in_epoch * 9 / 10 && runs_for_epoch < 3)
}

Expand Down
26 changes: 12 additions & 14 deletions keepers/validator-keeper/src/operations/vote_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ fn _get_operation() -> KeeperOperations {

fn _should_run(epoch_info: &EpochInfo, runs_for_epoch: u64) -> bool {
// Run at 10%, 50% and 90% completion of epoch
(epoch_info.slot_index > epoch_info.slots_in_epoch / 1000 && runs_for_epoch < 1)
|| (epoch_info.slot_index > epoch_info.slots_in_epoch / 2 && runs_for_epoch < 2)
(epoch_info.slot_index > epoch_info.slots_in_epoch * 1 / 10 && runs_for_epoch < 1)

Check failure on line 30 in keepers/validator-keeper/src/operations/vote_account.rs

View workflow job for this annotation

GitHub Actions / lint

this operation has no effect
|| (epoch_info.slot_index > epoch_info.slots_in_epoch * 5 / 10 && runs_for_epoch < 2)
|| (epoch_info.slot_index > epoch_info.slots_in_epoch * 9 / 10 && runs_for_epoch < 3)
}

Expand Down Expand Up @@ -84,21 +84,19 @@ pub async fn update_vote_accounts(
keeper_state: &KeeperState,
) -> Result<SubmitStats, KeeperError> {
let validator_history_map = &keeper_state.validator_history_map;
let closed_vote_accounts = &keeper_state.get_closed_vote_accounts();
let epoch_info = &keeper_state.epoch_info;

// Remove closed vote accounts from all vote accounts
// Remove vote accounts for which this instruction has been called within 50,000 slots
let mut vote_accounts_to_update = keeper_state.vote_account_map.keys().collect::<Vec<_>>();

// Update all vote accounts, less they are closed
let mut vote_accounts_to_update = keeper_state.get_all_open_vote_accounts();
vote_accounts_to_update.retain(|vote_account| {
!closed_vote_accounts.contains(vote_account)
&& !vote_account_uploaded_recently(
validator_history_map,
vote_account,
epoch_info.epoch,
epoch_info.absolute_slot,
)
let should_update = !vote_account_uploaded_recently(
validator_history_map,
vote_account,
epoch_info.epoch,
epoch_info.absolute_slot,
);

should_update

Check failure on line 99 in keepers/validator-keeper/src/operations/vote_account.rs

View workflow job for this annotation

GitHub Actions / lint

returning the result of a `let` binding from a block
});

let entries = vote_accounts_to_update
Expand Down
33 changes: 27 additions & 6 deletions keepers/validator-keeper/src/state/keeper_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,35 @@ impl KeeperState {
pub fn get_closed_vote_accounts(&self) -> HashSet<&Pubkey> {
self.all_history_vote_account_map
.iter()
.filter(|(_, vote_account)| {
if let Some(account) = vote_account {
account.owner != get_vote_program_id()
} else {
true
.filter_map(|(vote_address, vote_account)| match vote_account {
Some(account) => {
if account.owner != get_vote_program_id() {
Some(vote_address)
} else {
None
}
}
_ => {
// If the account is not found, it is considered closed
Some(vote_address)
}
})
.map(|(pubkey, _)| pubkey)
.collect()
}

pub fn get_all_open_vote_accounts(&self) -> HashSet<&Pubkey> {
self.all_history_vote_account_map
.iter()
.filter_map(|(vote_address, vote_account)| match vote_account {
Some(account) => {
if account.owner == get_vote_program_id() {
Some(vote_address)
} else {
None
}
}
_ => None,
})
.collect()
}

Expand Down

0 comments on commit 480b95b

Please sign in to comment.