Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 1.48 KB

091.md

File metadata and controls

33 lines (23 loc) · 1.48 KB

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

 totalEarningPower =
      _calculateTotalEarningPower(deposit.earningPower, _newEarningPower, totalEarningPower);
    depositorTotalEarningPower[deposit.owner] = _calculateTotalEarningPower(
      deposit.earningPower, _newEarningPower, depositorTotalEarningPower[deposit.owner]
    );

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