Submitted by 0x3b, also found by AvantGard, MrPotatoMagic, Krace (1, 2), ZdravkoHr, 0xlemon, fibonacci, nuthan2x, trachev, oakcobalt, and Noro
As explained by the sponsor, some collections might want to conduct multiple mints on different days. However, due to the way salesOption 3 works, these multiple mints might encounter issues.
A collection has completed its first mint, where it minted 500 NFTs. However, the collection consists of 1000 NFTs, so the owner plans to schedule another mint, this time using sales option 3.
The first users mint will proceed smoothly since timeOfLastMint falls within the previous mint period. However, the second users mint will fail. The same applies to all other whitelisted users. This issue arises due to the following block:
This calculation extends the allowed time significantly, granting the second minter an allowed time of allowlistStartTime + 1 min * (500-1) = allowlistStartTime + 499 min, which is equivalent to 8 hours and 19 minutes after allowlistStartTime. This enables the second user to mint at 12:19 AM, long after the whitelist has ended and in the middle of the public sale. And if anyone tries to mint, this call will revert with underflow error, as timeOfLastMint > block.timestamp.
Its worth noting that some collections may disrupt the whitelist, while others could brick the entire mint process; especially if there are more minted NFTs or a longer minting period.
For this fix, I am unable to give any suggestion as big parts of the protocol need to be redone. I can only point out the root cause of the problem, which is (gencore.viewCirSupply(col) - 1) in the snippet below.
Error
a2rocket (NextGen) confirmed
0xsomeone (judge) increased severity to High and commented:
