Omniscia Evergon Labs Audit

FractionsRoleApprovalFacetStorage Code Style Findings

FractionsRoleApprovalFacetStorage Code Style Findings

FRF-01C: Inefficient Logic Structures

TypeSeverityLocation
Gas OptimizationFractionsRoleApprovalFacetStorage.sol:
I-1: L86-L87, L90, L92
I-2: L102-L103, L106, L108, L110-L111

Description:

The referenced logic structures are inefficient as they will attempt to identify a role in a loop, break, and then execute statements if the role was identified for the account.

Example:

packages/contracts/contracts/skeletonFacets/connectors/createToPurchaseConnectors/fractionsRoleApproval/FractionsRoleApprovalFacetStorage.sol
95function rejectFractions(Layout storage l, uint256 campaignId) internal {
96 address account = ERC2771RecipientStorage.layout()._msgSender();
97 uint256 length = l.eligibleRoles.length;
98
99 bool hasEligibleRole;
100 for (uint256 i; i < length; i++) {
101 if (AccessControlFacetStorage.layout().hasRole(l.eligibleRoles[i], account)) {
102 hasEligibleRole = true;
103 break;
104 }
105 }
106 if (!hasEligibleRole) revert UnauthorizedRejection(account);
107
108 GeneralStorage.IdInfo storage info = GeneralStorage.layout().infoForId[campaignId];
109
110 IFraction(info.fractionsContract).fullyUnlockWrappedAssets(info.creator);
111 IStateFacet(address(this)).changeState(campaignId, l.interferenceState, l.rejectState);
112}

Recommendation:

We advise each segment to execute the relevant statements after its respective for loop within its if conditional, issuing a return statement after they are executed and permitting each function to revert right after the loop.

Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):

The relevant code segments were updated per our recommendation, minimizing their gas cost whilst increasing their legibility.

FRF-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/skeletonFacets/connectors/createToPurchaseConnectors/fractionsRoleApproval/FractionsRoleApprovalFacetStorage.sol
34bytes32 internal constant STORAGE_SLOT = keccak256("allianceblock.Fractionalisation.storage.FractionsRoleApprovalFacetStorage");

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.