Omniscia Gnosis Guild Audit
Roles Code Style Findings
Roles Code Style Findings
RSE-01C: Inefficient Transfer of Ownership
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | Roles.sol:L61 |
Description:
The referenced statement will transfer the ownership of the contract during its initialization using the OwnableUpgradeable::transferOwnership function which is inefficient as it redundantly applies the onlyOwner modifier.
Example:
48/// @dev There is no zero address check as solidty will check for49/// missing arguments and the space of invalid addresses is too large50/// to check. Invalid avatar or target address can be reset by owner.51function setUp(bytes memory initParams) public override initializer {52 (address _owner, address _avatar, address _target) = abi.decode(53 initParams,54 (address, address, address)55 );56 __Ownable_init();57
58 avatar = _avatar;59 target = _target;60
61 transferOwnership(_owner);62 setupModules();63
64 emit RolesModSetup(msg.sender, _owner, _avatar, _target);65}Recommendation:
We advise its internal counterpart, OwnableUpgradeable::_tranfserOwnership, to be utilized instead minimizing the gas cost required during the contract's initialization.
Alleviation:
The underscore prefixed counterpart of the OwnableUpgradeable::transferOwnership function is now properly utilized by the code, optimizing its deployment cost by avoiding redundant access control checks.
RSE-02C: Loop Iterator Optimization
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | Roles.sol:L79 |
Description:
The linked for loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X).
Example:
79for (uint16 i; i < roleKeys.length; ++i) {Recommendation:
We advise the increment / decrement operation to be performed in an unchecked code block as the last statement within the for loop to optimize its execution cost.
Alleviation:
The Gnosis Guild team considered this exhibit but has opted not to apply it to avoid broad usage of the unchecked paradigm. As such, we consider this exhibit acknowledged.
