Omniscia Arcade XYZ Audit
PromissoryNote Code Style Findings
PromissoryNote Code Style Findings
PNE-01C: Inefficient Renunciation of Role
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PromissoryNote.sol:L119 |
Description:
The PromissoryNote::initialize
function will invoke the AccessControl::renounceRole
function for revoking the ADMIN_ROLE
from the msg.sender
, however, this is inefficient as it will perform unnecessary checks.
Example:
contracts/PromissoryNote.sol
113function initialize(address loanCore) external onlyRole(ADMIN_ROLE) {114 // Grant mint/burn role to loanCore115 _setupRole(MINT_BURN_ROLE, loanCore);116
117 // Revoke admin role from msg.sender. Since there is no ROLE_ADMIN,118 // nobody can ever get ADMIN_ROLE again.119 renounceRole(ADMIN_ROLE, msg.sender);120}
Recommendation:
We advise the code to instead invoke the AccessControl::_revokeRole
function with the same input arguments, optimizing the function's gas cost.
Alleviation (7a4e1dc948e94ded7385dbb74818bcf93ecc207c):
The Arcade XYZ team stated that the AccessControl::_revokeRole
function is private
within its dependency as the codebase utilizes 4.3.2
whereas the latest versions of the library specify the function as internal
.
As such, we consider this exhibit nullified as the described optimization cannot be applied.