code-423n4 / 2022-05-cudos-findings

1 stars 0 forks source link

Gas Optimizations #109

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Using multiple require statements is cheaper than using && multiple check combinations. There are more advantages, such as easier to read code and better coverage reports.

Tools Used Visual inspection

require( _currentValset.validators.length == _currentValset.powers.length && _currentValset.validators.length == _v.length && _currentValset.validators.length == _r.length && _currentValset.validators.length == _s.length, "Malformed current validator set" );

-> require(_currentValset.validators.length == _currentValset.powers.length); require(_currentValset.validators.length == _v.length); require(_currentValset.validators.length == _r.length); "Malformed current validator set" );