code-423n4 / 2022-05-opensea-seaport-findings

1 stars 0 forks source link

Gas Optimizations #154

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

G - Unchecked arithmetic

Using unchecked block for operations that can't overflow/underflow.

This line could be unchecked since if channelIndexPlusOne == 0, thenchannelPreviouslyOpen == false (L138) and if statement on L149 wouldn't be satisfied:

    uint256 removedChannelIndex = channelIndexPlusOne - 1; 

https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/conduit/ConduitController.sol#L152

This lines could be unchecked due to check on L91 _validateOrderAndUpdateStatus -> _verifyTime, so if orderParameters.endTime <= block.timestamp or orderParameters.startTime > block.timestamp - transaction will be reverted before:

        uint256 duration = orderParameters.endTime - orderParameters.startTime;
        uint256 elapsed = block.timestamp - orderParameters.startTime;
        uint256 remaining = duration - elapsed; 

https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/lib/OrderFulfiller.sol#L163-L165

HardlyDifficult commented 2 years ago

It appears these lines are after the conditional and unchecked should provide small savings.