sherlock-audit / 2024-06-magicsea-judging

8 stars 5 forks source link

Amusing Turquoise Cormorant - Unnecessary usage of `storage` instead of `memory`, leads to excessively high gas fees #708

Closed sherlock-admin2 closed 4 months ago

sherlock-admin2 commented 4 months ago

Amusing Turquoise Cormorant

Low/Info

Unnecessary usage of storage instead of memory, leads to excessively high gas fees

Summary

Unnecessary usage of storage instead of memory, leads to excessively high gas fees

Vulnerability Detail

Reading from storage can be many times more expensive to perform and it's not needed when the function doesn't change the state of the the blockchain.

Impact

Users pay excessively high gas fees for nothing

Code Snippet

https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L240

Tool used

Manual Review

Recommendation

if the function is view(only reads from blockchain but doesn't change it's state) use memory instead of storage for gas saving