59866 sc high the delegator s rewards in period 1 cannot be claimed
Description
Brief / Intro
Vulnerability Details
func (s *Staker) AddDelegation(...) (*big.Int, error) {
//...
// add delegation on the next iteration - val.CurrentIteration() + 1,
current, err := val.CurrentIteration(currentBlock)
if err != nil {
return nil, err
}
delegationID, err := s.delegationService.Add(validator, current+1, stake, multiplier)
//...
}
func (v *Validation) CurrentIteration(currentBlock uint32) (uint32, error) {
// Unknown, Queued return 0
if v.Status == StatusUnknown || v.Status == StatusQueued {
return 0, nil
}
// Exited, from active or queued
if v.Status == StatusExit {
return v.CompletedPeriods, nil
}
// Active(signaled exit)
// Once signaled exit, complete iterations is set to the current
// iteration of the time that exit is signaled
if v.CompletedPeriods > 0 {
return v.CompletedPeriods, nil
}
// Active
if currentBlock < v.StartBlock {
return 0, errors.New("curren block cannot be less than start block")
}
if v.Period == 0 {
return 0, errors.New("period cannot be zero")
}
elapsedBlocks := currentBlock - v.StartBlock
completedPeriods := elapsedBlocks / v.Period
return completedPeriods + 1, nil
}Impact Details
Proof of Concept
References
Previous59863 sc high over claim of delegation rewards after exitNext59904 sc high it s possible to decrease twice delegator stake in certain conditions
Was this helpful?