Omniscia Sovryn Audit
InitializableOwnable Code Style Findings
InitializableOwnable Code Style Findings
IOL-01C: Bytecode Optimization
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | Informational | InitializableOwnable.sol:L40-L43 |
Description:
The way modifier implementations work in Solidity is by inserting code on each function with a modifier each time. This leads to a significant increase in bytecode and deployment cost if the modifier contains complex statements, such as a require with a long error message.
Example:
contracts/helpers/InitializableOwnable.sol
40modifier onlyOwner() {41 require(isOwner(), "InitializableOwnable: caller is not the owner");42 _;43}Recommendation:
We strongly recommend an internal function to be created instead called _onlyOwner() that is in turn invoked by the onlyOwner modifier thus only inserting a jump instruction on each modifier-boasting function.
Alleviation:
An internal function performing the exact same require checks as the modifier previously did was introduced called _onlyOwner and consequently invoked by the modifier of the exhibit.