Omniscia Gnosis Guild Audit

Topology Code Style Findings

Topology Code Style Findings

TYG-01C: Ineffectual Usage of Safe Arithmetics

TypeSeverityLocation
Language SpecificTopology.sol:L118

Description:

The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

packages/evm/contracts/Topology.sol
117for (uint256 i = start; i < end; ++i) {
118 result.children[i - start] = typeTree(conditions, i, bounds);

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 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.

TYG-02C: Loop Iterator Optimization

TypeSeverityLocation
Gas OptimizationTopology.sol:L117

Description:

The linked for loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X).

Example:

packages/evm/contracts/Topology.sol
117for (uint256 i = start; i < end; ++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:

The referenced loop iterator increment statement has been relocated to the end of the for loop body and wrapped in an unchecked code block, optimizing its execution.