Unnecessary SLOAD
s in Factory
#35
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")
Handle
pants
Vulnerability details
The functions
Factory.getProposalWeights()
andFactory.createBasket()
read values from storage multiple times instead of caching them in local variables:Factory.getProposalWeights()
reads_proposals[id]
twice.Factory.createBasket()
reads_proposals[idNumber]
twice.Impact
Storage reads are much more expensive than reading local variables.
Tool Used
Manual code review.
Recommended Mitigation Steps
Read these values from storage once, cache them in local variables and then read them again from the local variables.
The text was updated successfully, but these errors were encountered: