Omniscia DUA Audit
ETH_DUAToken Code Style Findings
ETH_DUAToken Code Style Findings
ETH-01C: Inefficient Access Control Role Management
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | ETH_DUAToken.sol:L97, L105, L115, L123, L132 |
Description:
The referenced invocations of AccessControl::grantRole and AccessControl::revokeRole are inefficient as they apply redundant access control on top of the onlyRole(ADMIN_ROLE) access control applied by the DUAToken functions.
Example:
96function addToBlacklist(address account) public onlyRole(ADMIN_ROLE) {97 grantRole(BLACKLISTED_ROLE, account);98}Recommendation:
We advise the underscore-prefixed (_) counterparts of the referenced functions to be utilized (i.e. AccessControl::_grantRole instead of AccessControl::grantRole) to optimize their gas cost.
Alleviation:
All referenced invocations of the AccessControl dependency have been prefixed with an underscore (_) optimizing their execution cost significantly.
ETH-02C: Variable Mutability Specifier (Immutable)
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | ETH_DUAToken.sol:L42 |
Description:
The linked variable is assigned to only once during the contract's constructor.
Example:
40constructor(string memory name, string memory symbol, uint256 cap_, address adminRole, address minterRole, address burnerRole) ERC20(name, symbol) {41 require(cap_ > 0, "DUA: cap is 0");42 _cap = cap_;43
44 _setupRole(ADMIN_ROLE, adminRole);45 _setupRole(MINTER_ROLE, minterRole);46 _setupRole(BURNER_ROLE, burnerRole);47 _setupRole(DEFAULT_ADMIN_ROLE, adminRole);48
49 _destructPause = false;50 _destructMint = false;51 _destructBurn = false;52 _destructAddMinter = false;53 _destructAddAdmin = false;54
55}Recommendation:
We advise it to be set as immutable greatly optimizing its read-access gas cost.
Alleviation:
The _cap variable has been properly set as immutable, optimizing its read-access gas cost significantly.
