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

Potential for out-of-gas errors #101

Open
mrarashel opened this issue Mar 6, 2023 · 0 comments
Open

Potential for out-of-gas errors #101

mrarashel opened this issue Mar 6, 2023 · 0 comments

Comments

@mrarashel
Copy link

Summary

The batchCreateHats function loops through arrays of potentially large sizes. If these arrays become too huge, the transaction may fail due to a lack of gas.

Vulnerability Detail

function batchCreateHats(

The function batchCreateHats loops through several arrays of potentially large sizes to create hats. This means that for each hat creation, a certain amount of gas is required. If the arrays are too large, there is a risk of running out of gas and the transaction failing. This could happen because the amount of gas specified by the user may not be enough to cover the gas costs of creating all the hats.

Impact

The function will consume more gas than expected, resulting in an out-of-gas error and transaction failure.

Code Snippet

 for (uint256 i = 0; i < length;) {
            createHat(
                _admins[i],
                _details[i],
                _maxSupplies[i],
                _eligibilityModules[i],
                _toggleModules[i],
                _mutables[i],
                _imageURIs[i]
            );

            unchecked {
                ++i;
            }
        }

        success = true;

Tool used

Manual Review

Recommendation

Properly estimate the gas costs of creating the hats and to ensure that the gas limit specified by the user is sufficient. We can also split the creation of the hats into smaller batches to reduce the amount of gas used for each batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant