Omniscia Sova Network Audit

RoleManager Code Style Findings

RoleManager Code Style Findings

RMR-01C: Inefficient Conditional Structure

Description:

The referenced statements are inefficient as they can be condensed to a single return statement.

Example:

src/auth/RoleManager.sol
200if (requiredAdminRole != 0) {
201 // If an explicit admin role is defined, the manager MUST have that specific role.
202 // Use hasAllRoles for strict check against the required composite admin role.
203 return hasAllRoles(manager, requiredAdminRole);
204}
205
206// If no explicit admin role is set in the mapping (requiredAdminRole == 0),
207// management is denied (as owner/PROTOCOL_ADMIN cases were handled).
208// This covers roles not explicitly configured or roles whose admin was set to 0.
209return false;

Recommendation:

We advise this to be done so, optimizing the code's gas cost.

Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):

The inefficient conditional structure has been merged into a single boolean conditional as advised, optimizing the code's gas cost.

RMR-02C: Misleading Constant Documentation

Description:

The documentation of the STRATEGY_ANY and RULES_ANY roles indicates that they are not meant to be granted and are meant to be used for role evaluations, however, no other contract relies on them for role evaluations and they are indeed granted to the deployer of the RoleManager contract through the RoleManager::constructor.

Example:

src/auth/RoleManager.sol
59// Not meant to be granted, but used for role checks
60uint256 public constant STRATEGY_ANY = PROTOCOL_ADMIN | STRATEGY_ADMIN | STRATEGY_OPERATOR;
61uint256 public constant RULES_ANY = PROTOCOL_ADMIN | RULES_ADMIN | KYC_OPERATOR;

Recommendation:

We advise the constants to either be removed or their documentation to be revised, either of which we consider an adequate alleviation of this exhibit.

Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):

The misleading documentation and relevant constant declarations have been omitted as advised.

RMR-03C: Redundant Inclusion of Role

Description:

The referenced OR (|) calculation will redundantly include the PROTOCOL_ADMIN as it is a component of both the STRATEGY_ANY and RULES_ANY roles.

Example:

src/auth/RoleManager.sol
86uint256 rolesAll = PROTOCOL_ADMIN | STRATEGY_ANY | RULES_ANY;

Recommendation:

We advise the PROTOCOL_ADMIN component to be omitted from the referenced bitwise calculation, optimizing the statement's gas cost.

Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):

The rule construction has been optimized to ensure no redundant roles are part of the bitwise merging operations, addressing this exhibit.