TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: low
Invalid

Early Revert in setAuctionConfig

Summary

The setAuctionConfig() function in the DaiGoldAuction.sol reverts only if the current auction has not ended. This check can be moved earlier in the function to avoid unnecessary state changes before reverting.

Vulnerability Details

In the setAuctionConfig() function, the check if (!epochs[_currentEpochId].hasEnded()) { revert InvalidOperation(); } is performed after some initial checks. This check can be moved to the beginning of the function to revert early and avoid unnecessary state changes, thus gas wasting:

function setAuctionConfig(AuctionConfig calldata _config) external override onlyElevatedAccess {
if (_config.auctionStartCooldown == 0
|| _config.auctionMinimumDistributedGold == 0
|| _config.auctionsTimeDiff == 0)
{ revert CommonEventsAndErrors.ExpectedNonZero(); }
if (!epochs[_currentEpochId].hasEnded()) { revert InvalidOperation(); }
auctionConfig = _config;
emit AuctionConfigSet(_currentEpochId, _config);
}

Impact

Reverting early can save gas and avoid unnecessary state changes, which makes the function more efficient.

Tools Used

Manual review.

Recommendations

Move the check for the auction end status to the beginning of the setAuctionConfig() function.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.