func (s *State) ExitValidator(index uint32, status uint64, c *config.Config) error {
	validator := s.ValidatorRegistry[index]
	prevStatus := validator.Status

	if prevStatus == ExitedWithPenalty {
		return nil
	}

	validator.Status = status
	validator.LatestStatusChangeSlot = s.Slot

	if status == ExitedWithPenalty {
		whistleblowerIndex, err := s.GetBeaconProposerIndex(s.Slot-1, c)
		if err != nil {
			return err
		}
		whistleblowerReward := s.GetEffectiveBalance(index, c) / c.WhistleblowerRewardQuotient

		s.ValidatorBalances[whistleblowerIndex] += whistleblowerReward
		s.ValidatorBalances[index] -= whistleblowerReward
	}

	s.ValidatorRegistryExitCount++
	validator.ExitCount = s.ValidatorRegistryExitCount
	deltaChainTip, err := GetNewValidatorRegistryDeltaChainTip(s.ValidatorRegistryDeltaChainTip, index, validator.Pubkey, ExitFlag)
	if err != nil {
		return err
	}
	s.ValidatorRegistryDeltaChainTip = deltaChainTip

	for i := range s.Proposals {
		participation := s.Proposals[i].Participation

		if participation[index/8]&(1<<uint(index%8)) != 0 {
			// switch the participation bit off
			s.Proposals[i].Participation[index/8] &= ^(1 << uint(index%8))
		}
	}
	return nil
}
// ExitValidator handles state changes when a validator exits.
ExitValidator handles state changes when a validator exits.
// ExitValidator handles state changes when a validator exits .
func (s *State) ExitValidator(index uint32, status uint64, c *config.Config) error {
	validator := s.ValidatorRegistry[index]
	prevStatus := validator.Status
	if prevStatus == ExitedWithPenalty {
		return nil
	}
	validator.Status = status
	validator.LatestStatusChangeSlot = s.Slot
	if status == ExitedWithPenalty {
		whistleblowerIndex, err := s.GetBeaconProposerIndex(s.Slot-1, c)
		if err != nil {
			return err
		}
		whistleblowerReward := s.GetEffectiveBalance(index, c) / c.WhistleblowerRewardQuotient
		s.ValidatorBalances[whistleblowerIndex] += whistleblowerReward
		s.ValidatorBalances[index] -= whistleblowerReward
	}
	s.ValidatorRegistryExitCount++
	validator.ExitCount = s.ValidatorRegistryExitCount
	deltaChainTip, err := GetNewValidatorRegistryDeltaChainTip(s.ValidatorRegistryDeltaChainTip, index, validator.Pubkey, ExitFlag)
	if err != nil {
		return err
	}
	s.ValidatorRegistryDeltaChainTip = deltaChainTip
	for i := range s.Proposals {
		participation := s.Proposals[i].Participation
		if participation[index/8]&(1<<uint(index%8)) != 0 {
			s.Proposals[i].Participation[index/8] &= ^(1 << uint(index%8))
		}
	}
	return nil
}
func ( s * State ) ExitValidator ( index uint32 , status uint64 , c * config . Config ) error { validator := s . ValidatorRegistry [ index ] prevStatus := validator . Status if prevStatus == ExitedWithPenalty { return nil } validator . Status = status validator . LatestStatusChangeSlot = s . Slot if status == ExitedWithPenalty { whistleblowerIndex , err := s . GetBeaconProposerIndex ( s . Slot - 1 , c ) if err != nil { return err } whistleblowerReward := s . GetEffectiveBalance ( index , c ) / c . WhistleblowerRewardQuotient s . ValidatorBalances [ whistleblowerIndex ] += whistleblowerReward s . ValidatorBalances [ index ] -= whistleblowerReward } s . ValidatorRegistryExitCount ++ validator . ExitCount = s . ValidatorRegistryExitCount deltaChainTip , err := GetNewValidatorRegistryDeltaChainTip ( s . ValidatorRegistryDeltaChainTip , index , validator . Pubkey , ExitFlag ) if err != nil { return err } s . ValidatorRegistryDeltaChainTip = deltaChainTip for i := range s . Proposals { participation := s . Proposals [ i ] . Participation if participation [ index / 8 ] & ( 1 << uint ( index % 8 ) ) != 0 { s . Proposals [ i ] . Participation [ index / 8 ] &= ^ ( 1 << uint ( index % 8 ) ) } } return nil }
ExitValidator handles state changes when a validator exits.
ExitValidator handles state changes when a validator exits .
// switch the participation bit off