code-423n4 / 2021-07-sherlock-findings

0 stars 0 forks source link

Unnecessary require + if combination. #121

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

tensors

Vulnerability details

Impact

The if+require combination from L213-216 uses extra gas an accomplishes very little that can't be achieved in one statement. If ps.govPool = 0 then it follows that _govPool must have also been 0 also. Depending on what exactly you want this function to do you can rewrite it, for example requiring only the _govPool to be nonzero and not having an if statement.

Proof of Concept

https://github.com/code-423n4/2021-07-sherlock/blob/d9c610d2c3e98a412164160a787566818debeae4/contracts/facets/Gov.sol#L213-L216

Recommended Mitigation Steps

Rewrite the require+if statements in as one statement.

Evert0x commented 3 years ago

_govPool can be non zero, as the tokenInit() can be called multiple times.

ghoul-sol commented 3 years ago

per sponsor comment, invalid