Omniscia Gnosis Guild Audit
Packer Code Style Findings
Packer Code Style Findings
PRE-01C: Loop Iterator Optimizations
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | Packer.sol:L23, L50 |
Description:
The linked for
loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X
).
Example:
23for (uint256 i; i < count; ++i) {
Recommendation:
We advise the increment / decrement operations to be performed in an unchecked
code block as the last statement within each for
loop to optimize their execution cost.
Alleviation:
The Gnosis Guild team considered this exhibit but has opted not to apply it to avoid broad usage of the unchecked
paradigm. As such, we consider this exhibit acknowledged.
PRE-02C: Optimization of Array Iteration
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | Packer.sol:L83-L85 |
Description:
As the Integrity::enforce
function guarantees that the parent
entries of the conditions
array are defined in ascending order, it is possible to optimize the referenced comparison.
Example:
79} else {80 uint256 length = conditions.length;81 unchecked {82 for (uint256 j = index + 1; j < length; ++j) {83 if (conditions[j].parent != index) {84 continue;85 }86 if (!_isInline(conditions, j)) {87 return false;88 }89 }90 }91 return true;92}
Recommendation:
We advise the code to perform a continue
operation when conditions[j].parent < index
and a break
operation when conditions[j].parent > index
, significantly optimizing the Packer::_isInline
function's gas cost.
Alleviation:
The code was optimized per our recommendation, performing a continue
or break
operation based on the index
by taking advantage of the conditions
array's ascending order.