Skinny Shadow Sparrow
Medium
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]
);
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.
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.
https://github.com/sherlock-audit/2024-11-tally/blob/main/staker/src/GovernanceStaker.sol#L374-L378
Manual Review
remove this calculation