code-423n4 / 2023-11-panoptic-findings

0 stars 0 forks source link

Re: Revert Usage #624

Closed c4-bot-6 closed 9 months ago

c4-bot-6 commented 9 months ago

Lines of code

https://github.com/code-423n4/2023-11-panoptic/blob/main/contracts/types/TokenId.sol#L463

Vulnerability details

Impact

The usage of multiple revert statements could consume more gas than required and lead to higher transaction costs.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

Tools Used

Recommended Mitigation Steps

Review the error handling logic and consolidate checks wherever possible. Combine related checks to reduce the number of revert statements used in the function.

function validate(uint256 self) internal pure returns (uint64) { uint256 errorFlag;

if (self.optionRatio(0) == 0) {
    errorFlag = 1;
} else {
    unchecked {
        for (uint256 i = 0; i < 4; ++i) {
            if (self.optionRatio(i) == 0) {
                if ((self >> (64 + 48 * i)) != 0) {
                    errorFlag = 1;
                    break;
                }

                break;
            }

            // Validation logic for legs...

            if (/* Validation conditions */) {
                errorFlag = 1;
                break;
            }
        }
    }
}

if (errorFlag == 1) {
    revert Errors.InvalidTokenIdParameter(1);
}

return self.univ3pool();

}

Assessed type

Error

c4-judge commented 9 months ago

Picodes marked the issue as unsatisfactory: Overinflated severity