Omniscia Nexera Audit
DataPointRegistry Code Style Findings
DataPointRegistry Code Style Findings
DPR-01C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | DataPointRegistry.sol:L37 |
Description:
The linked mathematical operation is guaranteed to be performed safely by logical inference, such as surrounding conditionals evaluated in require checks or if-else constructs.
Example:
37uint256 newCounter = ++_counter;38if (newCounter > type(uint32).max) revert CounterOverflow();Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statement to be wrapped in an unchecked code block thereby optimizing its execution cost.
Alleviation:
The referenced operation has been wrapped in an unchecked code block as advised, optimizing its gas cost.
DPR-02C: Inefficient Invocations of DataPointRegistry::isAdmin
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | DataPointRegistry.sol:L60, L72 |
Description:
The referenced statements will inefficiently invoke the DataPointRegistry::isAdmin function even though they have both locally cached the _accessData lookup to a dpd variable.
Example:
56/// @inheritdoc IDataPointRegistry57function grantAdminRole(DataPoint dp, address account) external returns (bool) {58 DPAccessData storage dpd = _accessData[dp];59 if (msg.sender != dpd.owner) revert InvalidDataPointOwner(dp, msg.sender);60 if (!isAdmin(dp, account)) {61 dpd.isAdmin[account] = true;62 emit DataPointAdminGranted(dp, account);63 return true;64 }65 return false;66}Recommendation:
We advise the local variable to be utilized directly and its isAdmin mapping to be accessed, optimizing the gas cost of both functions.
Alleviation:
The code has been refactored to utilize an EnumerableSet rendering the advised optimization no longer applicable.
