fix for the slashing spans calculation during withdrawals
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
0f9c0aa1f6
commit
5db96fa8f1
@ -2,7 +2,7 @@
|
|||||||
name = "ghost-eye"
|
name = "ghost-eye"
|
||||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||||
version = "0.3.68"
|
version = "0.3.69"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://git.ghostchain.io/ghostchain"
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||||
|
@ -4,6 +4,7 @@ use subxt::{
|
|||||||
backend::rpc::RpcClient,
|
backend::rpc::RpcClient,
|
||||||
client::OnlineClient,
|
client::OnlineClient,
|
||||||
config::substrate::DigestItem,
|
config::substrate::DigestItem,
|
||||||
|
ext::sp_runtime::Saturating,
|
||||||
ext::sp_core::crypto::{
|
ext::sp_core::crypto::{
|
||||||
AccountId32, Ss58AddressFormat, Ss58Codec,
|
AccountId32, Ss58AddressFormat, Ss58Codec,
|
||||||
},
|
},
|
||||||
@ -14,7 +15,7 @@ use subxt::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
action::Action,
|
action::Action,
|
||||||
casper_network::runtime_types::{ghost_networks::NetworkType, pallet_staking::RewardDestination, sp_consensus_slots},
|
casper_network::runtime_types::{ghost_networks::NetworkType, pallet_staking::RewardDestination, sp_consensus_slots},
|
||||||
types::{EraInfo, EraRewardPoints, Gatekeeper, Nominations, Nominator, SessionKeyInfo, SystemAccount, UnlockChunk},
|
types::{EraInfo, EraRewardPoints, Gatekeeper, Nominations, Nominator, SlashingSpan, SessionKeyInfo, SystemAccount, UnlockChunk},
|
||||||
CasperAccountId, CasperConfig
|
CasperAccountId, CasperConfig
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -592,7 +593,20 @@ pub async fn get_slashing_spans(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let slashing_spans_length = super::raw_calls::staking::slashing_spans(api, None, account_id)
|
let slashing_spans_length = super::raw_calls::staking::slashing_spans(api, None, account_id)
|
||||||
.await?
|
.await?
|
||||||
.map(|spans| spans.prior.len())
|
.map(|spans| {
|
||||||
|
let mut last_start = spans.last_start;
|
||||||
|
let mut index = spans.span_index;
|
||||||
|
let last = SlashingSpan { index, start: last_start, length: None };
|
||||||
|
let prior = spans.prior.iter().cloned().map(move |length| {
|
||||||
|
let start = last_start.saturating_sub(length);
|
||||||
|
last_start = start;
|
||||||
|
index.saturating_reduce(1);
|
||||||
|
|
||||||
|
SlashingSpan { index, start, length: Some(length) }
|
||||||
|
});
|
||||||
|
|
||||||
|
std::iter::once(last).chain(prior).count()
|
||||||
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
action_tx.send(Action::SetSlashingSpansLength(slashing_spans_length, *account_id))?;
|
action_tx.send(Action::SetSlashingSpansLength(slashing_spans_length, *account_id))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -19,5 +19,6 @@ pub use nominator::Nominator;
|
|||||||
pub use nominator::Nominations;
|
pub use nominator::Nominations;
|
||||||
pub use staking::UnlockChunk;
|
pub use staking::UnlockChunk;
|
||||||
pub use staking::RewardDestination;
|
pub use staking::RewardDestination;
|
||||||
|
pub use staking::SlashingSpan;
|
||||||
pub use networks::Gatekeeper;
|
pub use networks::Gatekeeper;
|
||||||
pub use networks::BlockRange;
|
pub use networks::BlockRange;
|
||||||
|
@ -8,6 +8,13 @@ pub struct UnlockChunk {
|
|||||||
pub era: u32,
|
pub era: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, Decode)]
|
||||||
|
pub struct SlashingSpan {
|
||||||
|
pub index: u32,
|
||||||
|
pub start: u32,
|
||||||
|
pub length: Option<u32>
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
||||||
pub enum RewardDestination {
|
pub enum RewardDestination {
|
||||||
#[default]
|
#[default]
|
||||||
|
Loading…
Reference in New Issue
Block a user