The SpiceAuction::removeAuctionConfig()
function doesn't allow the config for the first ever spice auction (auction id 1) to be removed unless the auction is in cooldown period. If the cooldown period is 0, then the auction config can never be removed.
NOTE
Auction id isn't a state variable. It is used to better represent the latest auction number. Auction config is set for the_currentEpochId
+ 1 index, and the_currentEpochId
variable lags behind the auction id by 1 until the auction starts. Then the_currentEpochId
is incremented, and epoch info is set.
The SpiceAuction::removeAuctionConfig()
function can be used to remove the config set for an auction before it starts or when it's in cooldown period. This works correctly for all auctions with id greater than 1, however, for auction id 1, which has not started yet (epoch info hasn't been set, with epoch id at 0 and auction id at 1), the function will always revert.
Consider the following code segment from the SpiceAuction
contract,
Suppose, auction config has been set using the SpiceAuction::setAuctionConfig()
function with id 1. However, epoch id isn't incremented and epoch info isn't set until SpiceAuction::startAucion()
function is called. So the SpiceAuction::removeAuctionConfig()
function reads a non-existent epoch info (with id 0). All fields in the EpochInfo
struct hold value 0. This will cause a revert at L#113.
It is to be noted that auction config can be removed once the auction starts and is in cooldown period. However, what makes this issue severe is that spice auctions can have no cooldown period. This can be seen in the following code segment from SpiceAuction::setAuctionConfig()
,
There is no check to see if the starting cooldown period is greater than 0.
In case where the first spice auction needs to be taken down, the dao executer won't be able to do so unless the auction has started and is in cooldown period. However, if the auction config for the first spice auction has no cooldown period, then the auction can never be removed.
Add the following test function to the SpiceAuctionTest
contract in ./protocol/test/forge/templegold/SpiceAuction.t.sol
,
The test runs successfully, with the following logs,
Manual review, and Foundry for writing POC and tests.
Make the following changes to SpiceAuction::removeAuctionConfig()
function,
Now let's unit test the changes. Add the following test to the SpiceAuctionTest
contract in ./protocol/test/forge/templegold/SpiceAuction.t.sol
,
The test passes with the following logs,
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.