Lively Arctic Robin - Lack of Delegatee Eligibility Check May Result in Successful Staking but Immediately No Rewards due to no Update in Earning Power #93
Labels
Won't Fix
The sponsor confirmed this issue will not be fixed
Lively Arctic Robin
Medium
Lack of Delegatee Eligibility Check May Result in Successful Staking but Immediately No Rewards due to no Update in Earning Power
Summary
The current implementation of the
_stake
and_stakeMore
cfunction in the smart contract does not verify whether the delegatee is eligible for staking before proceeding with the staking operation. This oversight can lead to users being unaware that their stake has been processed without earning any rewards if the delegatee is ineligible. Additionally, thebumpEarningPower
function, which is used to update the earning power of deposits, checks delegatee eligibility and prevents updates for unqualified delegatees. This creates a mismatch between the two functions—staking is allowed without validation, but earning power cannot be updated if the delegatee is unqualified. The report recommends separating thegetEarningPower
(used for querying) andgetNewEarningPower
(used for staking and earning power updates) to improve clarity and functionality.Vulnerability Detail
The existing code has two main issues:
Staking without Delegatee Eligibility Check:
_stake
and_stakeMore
function does not validate whether the delegatee is eligible before proceeding with the staking operation. This can result in successful staking but without earning any rewards if the delegatee’s earning power is zero.Mismatch Between Staking and Earning Power Update Logic:
bumpEarningPower
function checks if the delegatee is eligible using thegetNewEarningPower
function and requires the delegatee to be qualified before updating the earning power. However, the staking function does not perform this check. This discrepancy means that while staking can be performed with an unqualified delegatee, updates to the earning power viabumpEarningPower
will be blocked if the delegatee is unqualified.Impact
bumpEarningPower
function prevents updates for unqualified delegatees, staking does not. This inconsistency can create frustration for users who attempt to update their earning power after staking with an invalid delegatee.Code Snippet
Current implementation:
staker/src/GovernanceStaker.sol:_stake#L571-L73
staker/src/GovernanceStaker.sol:_stakeMore#L605-L610
The following code snippet shows the current behavior of the
bumpEarningPower
function, which checks delegatee eligibility before updating earning power:staker/src/GovernanceStaker.sol:bumpEarningPower#L485-L490
The above code prevents updates if the delegatee is not qualified (
_isQualifiedForBump
), which causes an issue when the delegatee is unqualified during staking, especially stakers just finish their staking .Tool Used
Manual Review
Recommendation
To address these issues and enhance the functionality of the staking system, we recommend the following changes:
Delegatee Eligibility Check on Staking:
_stake
function before proceeding with the staking operation. This will ensure that only qualified delegatees can receive stakes and avoid situations where the earning power is zero due to an unqualified delegatee.Clarify Usage of
getEarningPower
andgetNewEarningPower
:getEarningPower
should be used for querying the current earning power of a deposit, as it does not modify the state and provides a simple snapshot of the rewards a user can earn.getNewEarningPower
should be used for staking and earning power update operations. This function already checks delegatee eligibility and should be called only after ensuring the delegatee is eligible. This will prevent inconsistencies in how earning power is updated.The text was updated successfully, but these errors were encountered: