Omniscia Evergon Labs Audit

CreateFractionsEligibilityMixerStorage Code Style Findings

CreateFractionsEligibilityMixerStorage Code Style Findings

CFM-01C: Inefficient Code Structure

Description:

The CreateFractionsEligibilityMixerStorage::checkFractionCreationEligibility function is presently inefficient as it keeps track of a local isOneSuccessful variable to signal whether a revert error should be emitted in the !allSuccessfulRequired configuration.

Example:

packages/contracts/contracts/internalFacets/createFractionsPhaseFacets/createFractionsEligibilityFacets/CreateFractionsEligibilityMixerStorage.sol
85bool isOneSuccessful;
86
87for (uint256 i; i < length; i++) {
88 bytes4 selector = selectors[i];
89
90 bytes memory callDataInput = abi.encodeWithSelector(selector, account);
91 (bool success, bytes memory result) = address(this).call(callDataInput);
92
93 // if we need all checks to be successful then every step needs success,
94 // but if we need only one, if there is success we can break and not do other checks.
95 if (allSuccessfulRequired) {
96 if (!success) {
97 assembly {
98 revert(add(result, 32), mload(result))
99 }
100 }
101 } else if (success) {
102 isOneSuccessful = true;
103 break;
104 }
105}
106
107if (!allSuccessfulRequired) {
108 if (!isOneSuccessful) revert NonEligibleCreator(account);
109}

Recommendation:

We advise the isOneSuccessful variable to be omitted and the code to return immediately when a successful eligibility check has been performed.

The final if clause should be updated to only evaluate the allSuccessfulRequired as false which would indicate that we did not return early and thus we need to revert.

Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):

The code was refactored as advised, optimizing its execution gas cost.

CFM-02C: Non-Standard Storage Slot Definition

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:

packages/contracts/contracts/internalFacets/createFractionsPhaseFacets/createFractionsEligibilityFacets/CreateFractionsEligibilityMixerStorage.sol
21bytes32 internal constant STORAGE_SLOT = keccak256("Evergonlabs.Tmi-Tokenizer.storage.CreateFractionsEligibilityMixerStorage");

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 (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):

The referenced slot definition has been updated to its standardized EIP-7201 representation, addressing this exhibit.