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

Cache factory.ownerSplit() #89

Open
code423n4 opened this issue Oct 10, 2021 · 1 comment
Open

Cache factory.ownerSplit() #89

code423n4 opened this issue Oct 10, 2021 · 1 comment
Labels
bug Warden finding G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

pauliax

Vulnerability details

Impact

function handleFees calls factory.ownerSplit() twice. To save some gas and reduce the number of external calls, you should save the value after the first call and re-use it later.

Recommended Mitigation Steps

Cache factory.ownerSplit() in a local variable and re-use it.

code423n4 added a commit that referenced this issue Oct 10, 2021
@frank-beard frank-beard added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Nov 6, 2021
@GalloDaSballo
Copy link
Collaborator

Agree with the warden, specifically you would want to cache this in memory, doing a STATICCALL (view method) is 40 gas plus the cost for reading storage (2100 after first time iirc)

Would cost just 3 gas to store and 3 gas for each subsequent memory read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Warden finding G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants