code-423n4 / 2022-08-fiatdao-findings

2 stars 1 forks source link

Gas Optimizations #257

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

1.USING > 0 COSTS MORE GAS THAN != 0 WHEN USED ON A UINT IN A REQUIRE() STATEMENT

INSTANCES

// Links to github file https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/VotingEscrow.sol#L412 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L448 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L449 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L469 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L502 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L529 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L564 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L587 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L621 https://github.com/code-423n4/2022-08-fiatdao/blob/main/contracts/IVotingEscrow.sol#L635

//actual code used
contracts/VotingEscrow.sol:412:        require(_value > 0, "Only non zero amount");
contracts/VotingEscrow.sol:448:        require(_value > 0, "Only non zero amount");
contracts/VotingEscrow.sol:449:        require(locked_.amount > 0, "No lock");
contracts/VotingEscrow.sol:469:            require(locked_.amount > 0, "Delegatee has no lock");
contracts/VotingEscrow.sol:502:        require(locked_.amount > 0, "No lock");
contracts/VotingEscrow.sol:529:        require(locked_.amount > 0, "No lock");
contracts/VotingEscrow.sol:564:        require(locked_.amount > 0, "No lock");
contracts/VotingEscrow.sol:587:        require(toLocked.amount > 0, "Delegatee has no lock");
contracts/VotingEscrow.sol:621:        if (newLocked.amount > 0) {
contracts/VotingEscrow.sol:635:        require(locked_.amount > 0, "No lock");