Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skinny Shadow Sparrow - Redundant Calculation of Total Earning Power in Delegatee Change Process #91

Open
sherlock-admin4 opened this issue Dec 22, 2024 · 0 comments
Labels
Won't Fix The sponsor confirmed this issue will not be fixed

Comments

@sherlock-admin4
Copy link
Contributor

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

@sherlock-admin3 sherlock-admin3 added the Won't Fix The sponsor confirmed this issue will not be fixed label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't Fix The sponsor confirmed this issue will not be fixed
Projects
None yet
Development

No branches or pull requests

2 participants