You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the _alterDelegatee function, the calculation of totalEarningPower and depositorTotalEarningPower[deposit.owner] is performed unnecessarily when the delegatee is changed. This is redundant because the deposit.earningPower is already updated with the new delegatee's earning power, and recalculating the total earning power at this level is inefficient and unnecessary.
Impact
Efficiency Loss: The redundant calculation of totalEarningPower and depositorTotalEarningPower introduces unnecessary computational overhead, increasing gas costs and reducing the efficiency of the function.
Potential for Errors: By performing redundant operations, there's a higher risk of introducing inconsistencies or errors in the future if the logic is modified, especially if these totals are updated elsewhere in the system.
Skinny Shadow Sparrow
Medium
Redundant Calculation of Total Earning Power in Delegatee Change Process
Summary
When trying to change delegatees we do a uselles calculation
Vulnerability Detail
In the _alterDelegatee function, the calculation of totalEarningPower and depositorTotalEarningPower[deposit.owner] is performed unnecessarily when the delegatee is changed. This is redundant because the deposit.earningPower is already updated with the new delegatee's earning power, and recalculating the total earning power at this level is inefficient and unnecessary.
Impact
Efficiency Loss: The redundant calculation of totalEarningPower and depositorTotalEarningPower introduces unnecessary computational overhead, increasing gas costs and reducing the efficiency of the function.
Potential for Errors: By performing redundant operations, there's a higher risk of introducing inconsistencies or errors in the future if the logic is modified, especially if these totals are updated elsewhere in the system.
Code Snippet
https://github.com/sherlock-audit/2024-11-tally/blob/main/staker/src/GovernanceStaker.sol#L374-L378
Tool used
Manual Review
Recommendation
remove this calculation
The text was updated successfully, but these errors were encountered: