Omniscia Evergon Labs Audit
CreateFractionsSkeleton Code Style Findings
CreateFractionsSkeleton Code Style Findings
CFS-01C: Inefficient mapping Lookups
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | CreateFractionsSkeleton.sol:L53-L56 |
Description:
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
53generalStorage.infoForId[campaignId].creator = account;54generalStorage.infoForId[campaignId].fractionsCreated = fractionsCreated;55generalStorage.infoForId[campaignId].nftId = nftId;56generalStorage.infoForId[campaignId].isMinting = isMinting;Recommendation:
As the lookups internally perform an expensive keccak256 operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping in case of primitive types or holds a storage pointer to the struct contained.
As the compiler's optimizations may take care of these caching operations automatically at-times, we advise the optimization to be selectively applied, tested, and then fully adopted to ensure that the proposed caching model indeed leads to a reduction in gas costs.
Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):
All referenced inefficient mapping lookups have been optimized to the greatest extent possible, significantly reducing the gas cost of the functions the statements were located in.
