change vcote account that participate to the schedule filter. Filter on stake=0
This commit is contained in:
parent
47ccd6c4d2
commit
f28da4ad74
|
@ -296,9 +296,6 @@ fn calculate_leader_schedule_from_stake_map(
|
||||||
|
|
||||||
//log::trace!("calculate_leader_schedule_from_stake_map stake_map:{stake_map:?} current_epoch_info:{current_epoch_info:?}");
|
//log::trace!("calculate_leader_schedule_from_stake_map stake_map:{stake_map:?} current_epoch_info:{current_epoch_info:?}");
|
||||||
for storestake in stake_map.values() {
|
for storestake in stake_map.values() {
|
||||||
//log::info!("Program_accounts stake:{stake:#?}");
|
|
||||||
// if is_stake_to_add(storestake.pubkey, &storestake.stake, ¤t_epoch_info) {
|
|
||||||
// Add the stake in this stake account to the total for the delegated-to vote account
|
|
||||||
//get nodeid for vote account
|
//get nodeid for vote account
|
||||||
let Some(vote_account) = vote_map.get(&storestake.stake.voter_pubkey) else {
|
let Some(vote_account) = vote_map.get(&storestake.stake.voter_pubkey) else {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
|
@ -312,10 +309,16 @@ fn calculate_leader_schedule_from_stake_map(
|
||||||
//on testnet the vote account CY7gjryUPV6Pwbsn4aArkMBL7HSaRHB8sPZUvhw558Tm node_id:6YpwLjgXcMWAj29govWQr87kaAGKS7CnoqWsEDJE4h8P
|
//on testnet the vote account CY7gjryUPV6Pwbsn4aArkMBL7HSaRHB8sPZUvhw558Tm node_id:6YpwLjgXcMWAj29govWQr87kaAGKS7CnoqWsEDJE4h8P
|
||||||
//hasn't vote since a long time but still return on RPC call get_voteaccounts.
|
//hasn't vote since a long time but still return on RPC call get_voteaccounts.
|
||||||
//the validator don't use it for leader schedule.
|
//the validator don't use it for leader schedule.
|
||||||
if vote_account.vote_data.root_slot.unwrap_or(0)
|
if vote_account.vote_data.root_slot.unwrap_or_else(|| {
|
||||||
< current_epoch_info
|
//vote with no root_slot are added. They have just been activated and can have active stake- TODO TO TEST.
|
||||||
.absolute_slot
|
log::info!(
|
||||||
.saturating_sub(ten_epoch_slot_long)
|
"leader schedule vote:{} with None root_slot, add it",
|
||||||
|
vote_account.pubkey
|
||||||
|
);
|
||||||
|
current_epoch_info.absolute_slot
|
||||||
|
}) < current_epoch_info
|
||||||
|
.absolute_slot
|
||||||
|
.saturating_sub(ten_epoch_slot_long)
|
||||||
{
|
{
|
||||||
log::warn!("Vote account:{} nodeid:{} that hasn't vote since 10 epochs. Stake for account:{:?}. Remove leader_schedule."
|
log::warn!("Vote account:{} nodeid:{} that hasn't vote since 10 epochs. Stake for account:{:?}. Remove leader_schedule."
|
||||||
, storestake.stake.voter_pubkey
|
, storestake.stake.voter_pubkey
|
||||||
|
@ -324,14 +327,22 @@ fn calculate_leader_schedule_from_stake_map(
|
||||||
, storestake.stake.stake(current_epoch_info.epoch, stake_history, Some(0)),
|
, storestake.stake.stake(current_epoch_info.epoch, stake_history, Some(0)),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
*(stakes
|
let effective_stake = storestake
|
||||||
.entry(vote_account.vote_data.node_pubkey)
|
|
||||||
.or_insert(0)) += storestake
|
|
||||||
.stake
|
.stake
|
||||||
//TODO us the right reduce_stake_warmup_cooldown_epoch value from validator feature.
|
//TODO us the right reduce_stake_warmup_cooldown_epoch value from validator feature.
|
||||||
.stake(current_epoch_info.epoch, stake_history, Some(0));
|
.stake(current_epoch_info.epoch, stake_history, Some(0));
|
||||||
|
//only vote account with positive stake are use for the schedule.
|
||||||
|
if effective_stake > 0 {
|
||||||
|
*(stakes
|
||||||
|
.entry(vote_account.vote_data.node_pubkey)
|
||||||
|
.or_insert(0)) += effective_stake;
|
||||||
|
} else {
|
||||||
|
log::info!(
|
||||||
|
"leader schedule vote:{} with 0 effective vote",
|
||||||
|
storestake.stake.voter_pubkey
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut schedule_stakes: Vec<(Pubkey, u64)> = vec![];
|
let mut schedule_stakes: Vec<(Pubkey, u64)> = vec![];
|
||||||
|
|
|
@ -395,9 +395,11 @@ async fn run_loop<F: Interceptor>(mut client: GeyserGrpcClient<F>) -> anyhow::Re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
solana_sdk::vote::program::ID => {
|
solana_sdk::vote::program::ID => {
|
||||||
|
log::info!("Geyser notif VOTE account:{}", account);
|
||||||
|
let account_pubkey = account.pubkey;
|
||||||
//process vote accout notification
|
//process vote accout notification
|
||||||
if let Err(err) = votestore.add_vote(account, current_epoch_state.current_epoch_end_slot()) {
|
if let Err(err) = votestore.add_vote(account, current_epoch_state.current_epoch_end_slot()) {
|
||||||
log::warn!("Can't add new stake from account data err:{}", err);
|
log::warn!("Can't add new stake from account data err:{} account:{}", err, account_pubkey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,10 +164,11 @@ fn vote_map_insert_vote(map: &mut VoteMap, vote_account: Pubkey, vote_data: Stor
|
||||||
match map.entry(vote_account) {
|
match map.entry(vote_account) {
|
||||||
std::collections::hash_map::Entry::Occupied(occupied) => {
|
std::collections::hash_map::Entry::Occupied(occupied) => {
|
||||||
let voteacc = occupied.into_mut(); // <-- get mut reference to existing value
|
let voteacc = occupied.into_mut(); // <-- get mut reference to existing value
|
||||||
if voteacc.last_update_slot < vote_data.last_update_slot {
|
if voteacc.last_update_slot <= vote_data.last_update_slot {
|
||||||
log::trace!(
|
log::info!(
|
||||||
"Vote updated for: {vote_account} node_id:{}",
|
"Vote updated for: {vote_account} node_id:{} root_slot:{:?}",
|
||||||
vote_data.vote_data.node_pubkey
|
vote_data.vote_data.node_pubkey,
|
||||||
|
vote_data.vote_data.root_slot,
|
||||||
);
|
);
|
||||||
*voteacc = vote_data;
|
*voteacc = vote_data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue