Omniscia Evergon Labs Audit
BaseDataObject Code Style Findings
BaseDataObject Code Style Findings
BDO-01C: Bytecode Size Optimization
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | BaseDataObject.sol:L226-L234, L260-L264 |
Description:
The BaseDataObject::_diidDataIndex function will inefficiently replicate the statements within the BaseDataObject::_tryDiidDataIndex function.
Example:
226function _diidDataIndex(DataPoint dp, bytes32 diid) internal returns (uint256 diidDataIdx) {227 DataPointStorage storage dps = _dataPointStorage(dp);228 diidDataIdx = dps.diidDataIndexes[diid];229 if (diidDataIdx == 0) {230 // Create new one231 diidDataIdx = ++_diidDataCounter;232 dps.diidDataIndexes[diid] = diidDataIdx;233 }234}235
236function _diidHasData(DataPoint dp, bytes32 diid) internal view returns (bool) {237 DataPointStorage storage dps = _dataPointStorage(dp);238 uint256 diidFromDataIdx = dps.diidDataIndexes[diid];239 return diidFromDataIdx != 0;240}241
242function _moveDataIndexIfTargetEmpty(DataPoint dp, bytes32 diidFrom, bytes32 diidTo, bool allowEmptyFrom) internal returns (bool) {243 DataPointStorage storage dps = _dataPointStorage(dp);244 uint256 diidToDataIdx = dps.diidDataIndexes[diidTo];245 if (diidToDataIdx == 0) {246 uint256 diidFromDataIdx = dps.diidDataIndexes[diidFrom];247 if (diidFromDataIdx == 0) {248 if (allowEmptyFrom) {249 return true;250 }251 revert DiidDataUnavailable(dp, diidFrom);252 }253 dps.diidDataIndexes[diidTo] = diidFromDataIdx;254 dps.diidDataIndexes[diidFrom] = 0;255 return true;256 }257 return false;258}259
260/// @dev Returns 0 if index is not created261function _tryDiidDataIndex(DataPoint dp, bytes32 diid) internal view returns (uint256) {262 DataPointStorage storage dps = _dataPointStorage(dp);263 return dps.diidDataIndexes[diid];264}Recommendation:
We advise the BaseDataObject::_diidDataIndex function to invoke the BaseDataObject::_tryDiidDataIndex function, optimizing the function's bytecode size.
Alleviation (c6b23c23d8bcd8cce85049ad959cbd711a37126b):
The Evergon Labs team evaluated this exhibit and opted to retain the distinct implementations so as to achieve the minimum gas possible for both implementations.
As such, we consider this optimization acknowledged.
BDO-02C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | BaseDataObject.sol:L215, L231 |
Description:
The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Example:
215dpDataIdx = ++_dpDataCounter;Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.
Alleviation (c6b23c23d8bcd8cce85049ad959cbd711a37126b):
An unchecked code block has been introduced around each relevant arithmetic operation optimizing their gas cost safely.
BDO-03C: Redundant Parenthesis Statement
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | BaseDataObject.sol:L145 |
Description:
The referenced statement is redundantly wrapped in parenthesis (()).
Example:
145if ((address(dps.dataIndexImplementation) != sender) && !_isDataPointAdmin(dp, sender)) revert InvalidCaller(dp, sender);Recommendation:
We advise them to be safely omitted, increasing the legibility of the codebase.
Alleviation (c6b23c23d8bcd8cce85049ad959cbd711a37126b):
The redundant parenthesis in the referenced statement have been safely omitted.
