Omniscia Stakewise Audit
PoolValidators Code Style Findings
PoolValidators Code Style Findings
PVS-01C: Redundant Root Validations
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | Informational | PoolValidators.sol:L73-L76 |
Description:
The validations performed in the linked require check are all redundant as they are validated one-to-one in the ensuing require check. In detail, the length of "" casted to bytes is zero meaning that the length comparisons actually cover the inequality with "" case and if the keccak256 results of two bytes members are different so are their values (note: the opposite relation is not necessarily true).
Example:
contracts/pool/PoolValidators.sol
73require(74 initializeMerkleRoot != "" && finalizeMerkleRoot != "" && finalizeMerkleRoot != initializeMerkleRoot,75 "PoolValidators: invalid merkle roots"76);77require(78 bytes(initializeMerkleProofs).length != 0 && bytes(finalizeMerkleProofs).length != 0 &&79 keccak256(bytes(initializeMerkleProofs)) != keccak256(bytes(finalizeMerkleProofs)),80 "PoolValidators: invalid merkle proofs"81);Recommendation:
We advise the require check to be omitted to optimize the gas cost of the function.
Alleviation:
The Stakewise team confirmed this exhibit, however, they will retain the current implementation in place.