code-423n4 / 2022-06-infinity-findings

4 stars 0 forks source link

Gas Optimizations #190

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Reduce the size of error messages (Long revert Strings)

Shortening revert strings to fit in 32 bytes will decrease deployment time gas and will decrease runtime gas when the revert condition is met.

Revert strings that are longer than 32 bytes require at least one additional mstore, along with additional overhead for computing memory offset, etc.

Instances

contracts/core/InfinityExchange.sol:395:      require(!isUserOrderNonceExecutedOrCancelled[msg.sender][orderNonces[i]], 'nonce already executed or cancelled');
contracts/staking/InfinityStaker.sol:96:    require(newDuration > oldDuration, 'new duration must be greater than old duration');

I suggest shortening the revert strings to fit in 32 bytes, or that using custom errors.

JeeberC4 commented 2 years ago

Warden submitted multiple Gas Optimizations. Will not be judged.