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

2 stars 0 forks source link

Gas Optimizations #273

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago
  1. Use Custom Error instead of Revert String to Save Gas

Custom error from solidity 0.8.4 are cheaper than revert strings, custom error are defined using the error statement can use insideand outside the contract.

source https://blog.soliditylang.org/2021/04/21/custom-errors/

POC : https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L167 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L168 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L169 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L170 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L171 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L211 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L214 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L217 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L220 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L224 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L228 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L263 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L269 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L272 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L307 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L323 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L328 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L329 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L330 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L353 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L353 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L436 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L437 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L438 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L456 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/CallyNft.sol#L15 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/CallyNft.sol#L16 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/CallyNft.sol#L36 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/CallyNft.sol#L42

i suggest replacing revert error strings with custom error.