Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Increasing delegate eligibility score will make some delegatees instantly bumpable (skipping grace period) #37

Open
CergyK opened this issue Dec 7, 2024 · 1 comment
Labels
Low/Info A Low/Info severity issue.

Comments

@CergyK
Copy link
Collaborator

CergyK commented Dec 7, 2024

Description

The BinaryEligibilityOracleEarningPowerCalculator determines the earning power for a delegatee to be either 0 or 100% depending on the score of the delegatee is greater or below a threshold. When a delegatee first crosses below the threshold, a grace period is applied in order for the delegatee to not be instantly punished by a bump which would incentivize delegators to delegate to another.

BinaryEligibilityOracleEarningPowerCalculator.sol#L234-L242:

function _updateDelegateeScore(address _delegatee, uint256 _newScore) internal {
    uint256 _oldScore = delegateeScores[_delegatee];
    bool _previouslyEligible = _oldScore >= delegateeEligibilityThresholdScore;
    bool _newlyEligible = _newScore >= delegateeEligibilityThresholdScore;
    emit DelegateeScoreUpdated(_delegatee, _oldScore, _newScore);
    // Record the time if the new score crosses the eligibility threshold.
>>  if (_previouslyEligible && !_newlyEligible) timeOfIneligibility[_delegatee] = block.timestamp;
    delegateeScores[_delegatee] = _newScore;
}

BinaryEligibilityOracleEarningPowerCalculator.sol#L153-L157:

    if (!_isDelegateeEligible(_delegatee)) {
      bool _isUpdateDelayElapsed =
>>      (timeOfIneligibility[_delegatee] + updateEligibilityDelay) <= block.timestamp;
      return (0, _isUpdateDelayElapsed);
    }

However we can note that in the case the delegate eligibility score is updated, the criteria to see if the delegatee has just become ineligible returns false. This means that the calculator will consider that the delegatee was previously ineligible and the grace period will not apply

Recommendation

Please consider adding a timestamp lastEligibilityScoreUpdated which should also be compared against when determining grace period.

@CergyK CergyK added the Low/Info A Low/Info severity issue. label Dec 7, 2024
@alexkeating
Copy link

Wont fix

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Low/Info A Low/Info severity issue.
Projects
None yet
Development

No branches or pull requests

2 participants