Omniscia Nexera Audit
RestrictedStatesRecoverFractionsFacetStorage Code Style Findings
RestrictedStatesRecoverFractionsFacetStorage Code Style Findings
RSF-01C: Inefficient Initialization Protection
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | RestrictedStatesRecoverFractionsFacetStorage.sol:L65-L83 |
Description:
The RestrictedStatesRecoverFractionsFacetStorage::initRecoverFractionsStateFacet function will protect the contract against incorrect initializations yet does so in a non-standard way.
Example:
52function initRecoverFractionsStateFacet(53 Layout storage l,54 bytes calldata initRecoverFractionsStateData55) internal returns (uint256[] memory) {56 if (l.isInitialized) revert AlreadyInitialized();57 l.isInitialized = true;58
59 uint256[] memory restrictedRecoverFractionsStates = abi.decode(initRecoverFractionsStateData, (uint256[]));60
61 uint256 length = restrictedRecoverFractionsStates.length;62
63 if (length == 0) revert InvalidZeroLengthForRestrictedRecoverFractionsStates();64
65 l.isRestrictedRecoverFractionsState[0] = true; // state 0 should always be restricted! Cannot recover for NON_CREATED!66
67 bool isStateZeroPassed; // will check if state 0 is restricted and reverts otherwise after for loop!68
69 for (uint256 i; i < length; ) {70 uint256 restrictedState = restrictedRecoverFractionsStates[i];71
72 if (restrictedState == 0) {73 isStateZeroPassed = true;74 } else {75 l.isRestrictedRecoverFractionsState[restrictedState] = true;76 }77
78 unchecked {79 i += 1;80 }81 }82
83 if (!isStateZeroPassed) revert NonProvidedZeroAsRestrictedState();84
85 return restrictedRecoverFractionsStates;86}Recommendation:
We advise the code to ensure that the first restrictedRecoverFractionsStates passed in is 0, permitting validation of the first data entry and a normal loop for the remaining entries to occur optimally.
Alleviation (d682057ecb0e254069773d64f32c068cedb71e2a):
The code was optimized per our recommendation, ensuring that the index 0 data entry is efficiently evaluated and assigned only once.
RSF-02C: Inexistent Documentation of Storage Slot
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | RestrictedStatesRecoverFractionsFacetStorage.sol:L28 |
Description:
The referenced STORAGE_SLOT does not have its actual result specified in its in-line documentation as it remains a TO-DO.
Example:
26/** ================================================== STORAGE =================================================27 * @dev Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula.28 * STORAGE_SLOT: TO-DO29 */30bytes32 internal constant STORAGE_SLOT =31 keccak256(32 abi.encode(uint256(keccak256("Evergonlabs.Tmi-Tokenizer.storage.RestrictedStatesRecoverFractionsFacetStorage")) - 1)33 ) & ~bytes32(uint256(0xff));Recommendation:
We advise the 0xbe345676766d268d01b777c1220bbbe7e1beb5acf10dd19c6755d6a98e4a1500 storage slot to be properly specified in its comments, aiding in debugging of the contract's structure.
Alleviation (d682057ecb0e254069773d64f32c068cedb71e2a):
The correct storage slot has been specified as advised.
