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

Debug: slash exception from upgrade ChainX v4.0.0 #616

Closed
icodezjb opened this issue Mar 15, 2022 · 5 comments
Closed

Debug: slash exception from upgrade ChainX v4.0.0 #616

icodezjb opened this issue Mar 15, 2022 · 5 comments

Comments

@icodezjb
Copy link
Member

icodezjb commented Mar 15, 2022

Issue:

Since ChainX has been upgraded to v4.0.0 (runtime 11 -> 12), many validators have been slashed for no reason

Analyze:

Before the end of each session, pallet-im-online will submit offline validators to xstaking, and they will all be slashed. There are two conditions for pallet-im-online to determine whether the validator is online:

  • (1) Whether to send heartbeat transactions in this session
  • (2) Whether to produce block in this session

We also notice that the node that should be slashed is not slashed

Root Cause:

we tracked this pr
Force the validators in the waiting list to run an authority node

the XStaking::active_validator_set().collect() return validators which the order is not fixed.

and in pallet-im-online, mark whether to be online in the order of validator, And this is the root cause

let session_index = T::ValidatorSet::session_index();
let keys = Keys::<T>::get();
let current_validators = T::ValidatorSet::validators();

let offenders = current_validators
			.into_iter()
			.enumerate()
			.filter(|(index, id)| !Self::is_online_aux(*index as u32, id))
			.filter_map(|(_, id)| {
				<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
					id.clone()
				).map(|full_id| (id, full_id))
			})
			.collect::<Vec<IdentificationTuple<T>>>();

Fix:

Fix slash exception

/// Returns all the validators and candidates by order
    #[inline]
    pub fn active_candidates() -> Vec<T::AccountId> {
        let mut candidates = Self::active_validator_set()
            .map(|v| (Self::total_votes_of(&v), v))
            .collect::<Vec<_>>();

        candidates.sort_by(|&(ref b1, _), &(ref b2, _)| b2.cmp(b1));

        candidates.into_iter().map(|(_, v)| v).collect()
    }

More rewards for validators

For the security of the ChainX mainnet and to encourage more community users to participate in the ChainX validators selection, we have decided to increase the proportion of system rewards to validators from 10% to 20%
Rewards: 20% for validator and 80% for the reward pot.

@icodezjb icodezjb pinned this issue Mar 15, 2022
@ddozen
Copy link

ddozen commented Mar 15, 2022

Im still getting slashed after upgrade to v4.1.1

@icodezjb
Copy link
Member Author

icodezjb commented Mar 16, 2022

Im still getting slashed after upgrade to v4.1.1

ChainX mainnet is OK now, and you can

  • (1) Check your session keys
  • (2) Try set --state-cache-size=0

@ddozen
Copy link

ddozen commented Mar 17, 2022

It is slashing and i;m loosing 1 pcx everytimne it happens.
(1) i rechecked session keys and even set new ones
(2)state-cache-size=0 is set

@icodezjb
Copy link
Member Author

icodezjb commented Mar 17, 2022

It is slashing and i;m loosing 1 pcx everytimne it happens. (1) i rechecked session keys and even set new ones (2)state-cache-size=0 is set

Are you DOZENODES?
You were slashed during the candidate stage.
If you do not set the correct session keys in the candidate stage, it means that the heartbeat transaction (using the im-online key) cannot be sent to the system, the system thinks you are offline, and then you are slashed

@icodezjb icodezjb unpinned this issue Mar 28, 2022
@icodezjb
Copy link
Member Author

icodezjb commented Mar 28, 2022

Im still getting slashed after upgrade to v4.1.1
@ddozen
Try ChainX v4.2.0 now (runtime version 20). The candidate node would be slashed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants