Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mitigation: mintBatch() gas grief #27

Merged
merged 5 commits into from
Aug 12, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/NFTMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract NFTMint is Ownable {
error NFTMint_InvalidPerWalletLimit();
error NFTMint_InvalidMaxMints();
error NFTMint_InvalidOwner();
error NFTMint_InsufficientGas();
error NFTMint_InsufficientFee();

event MintCreated(MintERC1155 indexed mint, MintArgs args);
Expand Down Expand Up @@ -288,8 +289,10 @@ contract NFTMint is Ownable {

delete orders[nextOrderIdToFill_];
nextOrderIdToFill_++;
// If the mint fails with 500_000 gas, the order is still marked as filled.
try currentOrder.mint.mintBatch{ gas: 500_000 }(currentOrder.to, ids, amounts) { } catch { }

if (gasleft() * 63 / 64 < 1_000_000) revert NFTMint_InsufficientGas();
// If the mint fails with 1_000_000 gas, the order is still marked as filled.
try currentOrder.mint.mintBatch{ gas: 1_000_000 }(currentOrder.to, ids, amounts) { } catch { }
}

nextOrderIdToFill = uint96(nextOrderIdToFill_);
Expand Down
Loading