Omniscia Evergon Labs Audit
Erc1155RewardMinterFacetStorage Code Style Findings
Erc1155RewardMinterFacetStorage Code Style Findings
ERG-01C: Inefficient ABI Encoding Mechanism
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | Erc1155RewardMinterFacetStorage.sol:L194 |
Description:
The referenced ABI encoding mechanism utilizes a string literal rather than the actual function signature of IERC1155Extended::mint to generate the relevant payload.
Example:
192// Call Reward Asset Handler to execute mint on the reward token contract with receiver being `to` address193bytes memory data = abi.encodeWithSignature(194 "mint(address,uint256,uint256,bytes)",195 to,196 tokenId,197 amountToTransfer,198 ""199);Recommendation:
We advise the abi.encodeWithSelector function to be utilized instead by importing the relevant IERC1155Extended interface and utilizing the IERC1155Extended.mint.selector syntax, optimizing the code's gas cost and syntax.
Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):
The abi.encodeWithSelector variant was incorporated into the codebase, addressing this exhibit as advised.
ERG-02C: Inefficient mapping Lookups
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | Erc1155RewardMinterFacetStorage.sol:L200 |
Description:
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
184for (uint256 i = 0; i < length; i++) {185 address tokenAddress = campaignPacketInfo.tokenAddresses[i];186 uint256 tokenId = campaignPacketInfo.tokenIds[i];187
188 uint256 amountToTransfer = campaignPacketInfo.amountOfTokensPerPacket[tokenAddress] * amountOfPackets;189
190 // IMPORTANT: The campaign's reward asset handler should have minter role on every reward token[i]191
192 // Call Reward Asset Handler to execute mint on the reward token contract with receiver being `to` address193 bytes memory data = abi.encodeWithSignature(194 "mint(address,uint256,uint256,bytes)",195 to,196 tokenId,197 amountToTransfer,198 ""199 );200 ICampaignAssetManager(GeneralStorage.layout().campaignsInfo[campaignId].rewardAssetHandler).execute(201 tokenAddress,202 data203 );204}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 (b64b659786cf3c84bea52feb3a69f546ba3601f0):
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.
ERG-03C: Non-Standard Storage Slot Definition
| Type | Severity | Location |
|---|---|---|
| Standard Conformity | ![]() | Erc1155RewardMinterFacetStorage.sol:L56 |
Description:
The referenced declaration will define a storage slot for use by a facet of the system's main EIP-2535 Diamond, however, the way it is declared does not adhere to the latest standards.
Example:
54/// @dev Unique identifier for the storage slot where the Layout struct is stored.55bytes32 internal constant STORAGE_SLOT =56 keccak256("evergonlabs.Staking.mintReward.storage.Erc1155RewardMinterFacetStorage");Recommendation:
We advise the EIP-7201 name-spaced layout approach to be adhered to similarly to OpenZeppelin and other relevant standard libraries, ensuring consistency among the ecosystem's widely utilized libraries and conforming to the latest standards.
Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):
The referenced slot definition has been updated to its standardized EIP-7201 representation, addressing this exhibit.
ERG-04C: Repetitive Value Literal
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | Erc1155RewardMinterFacetStorage.sol:L117 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
117if (GeneralStorage.layout().campaignsInfo[campaignId].state != 1) {Recommendation:
We advise it to be set to a constant variable instead, optimizing the legibility of the codebase.
In case the constant has already been declared, we advise it to be properly re-used across the code.
Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):
The referenced literal has been properly introduced as part of the GeneralStakingStorage declarations and specifically as an ON_CREATION state, addressing this exhibit.
