Omniscia Astrolab DAO Audit
AsSequentialSet Code Style Findings
AsSequentialSet Code Style Findings
ASS-01C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | AsSequentialSet.sol:L114, L145 |
Description:
The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Example:
144require(i > 0, "Element not found");145removeAt(q, i - 1);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 (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The referenced arithmetic operations in their relocated AsIterableSet location are still performed using checked arithmetic, rendering this exhibit acknowledged.
ASS-02C: Inefficient Loop Limit Evaluations
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | AsSequentialSet.sol:L114, L250 |
Description:
The linked for loops evaluate their limit inefficiently on each iteration.
Example:
114for (uint256 j = q.data.length; j > i; j--) {Recommendation:
We advise the statements within the for loop limits to be relocated outside to a local variable declaration that is consequently utilized for the evaluations to significantly reduce the codebase's gas cost. We should note the same optimization is applicable for storage reads present in those limits as they are newly read on each iteration (i.e. length members of arrays in storage).
Alleviation (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The former of the two loops is no longer present in the codebase whilst the latter remains unoptimized, rendering this exhibit acknowledged.
ASS-03C: Inexistent Error Message
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | AsSequentialSet.sol:L173 |
Description:
The linked require check has no error message explicitly defined.
Example:
173require(i < q.data.length);Recommendation:
We advise one to be set so to increase the legibility of the codebase and aid in validating the require check's condition.
Alleviation (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The referenced require error remains without an explicit error message or in-line documentation justifying it, rendering this exhibit acknowledged.
ASS-04C: Loop Iterator Optimization
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | AsSequentialSet.sol:L250 |
Description:
The linked for loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X).
Example:
250for (uint256 i = 0; i < q.data.length; i++) {Recommendation:
We advise the increment / decrement operation to be performed in an unchecked code block as the last statement within the for loop to optimize its execution cost.
Alleviation (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The referenced loop iterator's increment statement has been relocated at the end of the for loop's body and has been unwrapped in an unchecked code block, optimizing its gas cost.
ASS-05C: Redundant Deletion Operation
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | AsSequentialSet.sol:L130 |
Description:
The referenced delete operation is redundant as the data entry is overwritten in the ensuing statement.
Example:
127function removeAt(Set storage q, uint256 i) internal {128 require(i < q.data.length, "Index out of bounds");129 if (i < q.data.length - 1) {130 delete q.data[i];131 q.data[i] = q.data[q.data.length - 1];132 }133 q.data.pop();134}Recommendation:
We advise the delete operation to be omitted, optimizing the code's gas cost.
Alleviation (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The redundant delete operation has been safely omitted from the codebase, optimizing the function's gas cost.
