add logs when diff is detected for RPC
This commit is contained in:
parent
71706729b8
commit
62b40ad8be
|
@ -368,6 +368,7 @@ pub fn build_current_stakes(
|
|||
//log::trace!("get_program_accounts:{:?}", response);
|
||||
//use btreemap to always sort the same way.
|
||||
let mut stakes_aggregated = BTreeMap::<String, (u64, u64)>::new();
|
||||
let mut rpc_stakes = BTreeMap::<String, Vec<solana_sdk::stake::state::Delegation>>::new();
|
||||
for (pubkey, account) in response {
|
||||
// Zero-length accounts owned by the stake program are system accounts that were re-assigned and are to be
|
||||
// ignored
|
||||
|
@ -386,10 +387,13 @@ pub fn build_current_stakes(
|
|||
.or_insert((0, 0)))
|
||||
.0 += stake.delegation.stake;
|
||||
}
|
||||
let st_list = rpc_stakes.entry(pubkey.to_string()).or_insert(vec![]);
|
||||
st_list.push(stake.delegation);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
let mut local_stakes = BTreeMap::<String, Vec<solana_sdk::stake::state::Delegation>>::new();
|
||||
stake_map
|
||||
.iter()
|
||||
.filter(|(pubkey, stake)| is_stake_to_add(**pubkey, &stake.stake, current_epoch_info))
|
||||
|
@ -402,6 +406,10 @@ pub fn build_current_stakes(
|
|||
.entry(stake.stake.voter_pubkey.to_string())
|
||||
.or_insert((0, 0)))
|
||||
.1 += stake.stake.stake;
|
||||
let st_list = local_stakes
|
||||
.entry(stake.stake.voter_pubkey.to_string().to_string())
|
||||
.or_insert(vec![]);
|
||||
st_list.push(stake.stake);
|
||||
});
|
||||
|
||||
//verify the list
|
||||
|
@ -412,9 +420,38 @@ pub fn build_current_stakes(
|
|||
.collect();
|
||||
if diff_list.len() > 0 {
|
||||
log::warn!(
|
||||
"Aggregated stakes list differs for vote accounts:{:?}",
|
||||
"VERIF Aggregated stakes list differs for vote accounts:{:?}",
|
||||
diff_list
|
||||
);
|
||||
//Print all associated stakes
|
||||
let rpc_diff_list: Vec<(
|
||||
&String,
|
||||
u64,
|
||||
u64,
|
||||
&Vec<solana_sdk::stake::state::Delegation>,
|
||||
)> = diff_list
|
||||
.iter()
|
||||
.filter_map(|(pk, (rpc, local))| {
|
||||
rpc_stakes
|
||||
.get(pk)
|
||||
.map(|acc_list| ((pk, *rpc, *local, acc_list)))
|
||||
})
|
||||
.collect();
|
||||
let local_diff_list: Vec<(
|
||||
&String,
|
||||
u64,
|
||||
u64,
|
||||
&Vec<solana_sdk::stake::state::Delegation>,
|
||||
)> = diff_list
|
||||
.iter()
|
||||
.filter_map(|(pk, (rpc, local))| {
|
||||
local_stakes
|
||||
.get(pk)
|
||||
.map(|acc_list| ((pk, *rpc, *local, acc_list)))
|
||||
})
|
||||
.collect();
|
||||
log::warn!("VERIF RPC accounts:{rpc_diff_list:?}",);
|
||||
log::warn!("VERIF LOCAL accounts:{local_diff_list:?}",);
|
||||
}
|
||||
stakes_aggregated
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ async fn run_loop<F: Interceptor>(mut client: GeyserGrpcClient<F>) -> anyhow::Re
|
|||
//log::trace!("Geyser receive new account");
|
||||
match account.owner {
|
||||
solana_sdk::stake::program::ID => {
|
||||
log::info!("Geyser New stake account:{}", account);
|
||||
log::info!("Geyser Notif stake account:{}", account);
|
||||
if let Err(err) = stakestore.notify_change_stake(
|
||||
account,
|
||||
current_epoch_state.current_epoch_end_slot(),
|
||||
|
|
|
@ -46,6 +46,7 @@ fn stake_map_notify_stake(
|
|||
// if stake.stake.deactivation_epoch < current_epoch {
|
||||
// return;
|
||||
// }
|
||||
log::info!("stake_map_notify_stake stake:{stake:?}");
|
||||
let remove = match map.entry(stake_account) {
|
||||
// If value already exists, then increment it by one
|
||||
std::collections::hash_map::Entry::Occupied(occupied) => {
|
||||
|
@ -54,7 +55,7 @@ fn stake_map_notify_stake(
|
|||
//several instructions can be done in the same slot.
|
||||
if strstake.last_update_slot <= stake.last_update_slot {
|
||||
if stake.is_activated(current_epoch) {
|
||||
log::info!("Stake store updated stake: {stake_account} old_stake:{strstake:?} stake:{stake:?}");
|
||||
log::info!("stake_map_notify_stake Stake store updated stake: {stake_account} old_stake:{strstake:?} stake:{stake:?}");
|
||||
*strstake = stake;
|
||||
false
|
||||
} else {
|
||||
|
@ -67,14 +68,14 @@ fn stake_map_notify_stake(
|
|||
// If value doesn't exist yet, then insert a new value of 1
|
||||
std::collections::hash_map::Entry::Vacant(vacant) => {
|
||||
if stake.is_activated(current_epoch) {
|
||||
log::info!("Stake store insert stake: {stake_account} stake:{stake:?}");
|
||||
log::info!("stake_map_notify_stake Stake store insert stake: {stake_account} stake:{stake:?}");
|
||||
vacant.insert(stake);
|
||||
}
|
||||
false
|
||||
}
|
||||
};
|
||||
if remove {
|
||||
log::info!("Stake store remove stake: {stake_account}");
|
||||
log::info!("stake_map_notify_stake Stake store remove stake: {stake_account}");
|
||||
map.remove(&stake_account);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue