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

Optimizing Variable Initialization to Save Gas #3577

Closed
wants to merge 1 commit into from

Conversation

mingbaile
Copy link

Hi, We are a research group specializing in programming languages and software engineering. We recently studied inconsistent state update vulnerabilities in Solidity and are developing a tool to detect such issues.

After testing our prototype on your repository, we found some state variables that have never been updated, suggesting they might be missing updates or could be optimized for gas efficiency. Would you find our results useful?

These modifiers save gas by embedding values directly into the bytecode instead of using storage. The key difference:
constant: Set at compile time, no runtime cost.
immutable: Assigned in the constructor, slightly more gas usage.
(More details)

Potential Optimizations: In your repository, the following state variables might need attention. If they are meant to remain unchanged, using constant or immutable can optimize gas:

erc721-arbitrary-transferfrom.sol
State variable: maxSupply, maxFree

uint public maxSupply = 1000;
uint public maxFree = 200;

Thanks for your time! Does this modification seem appropriate to you?

@CLAassistant
Copy link

CLAassistant commented Mar 10, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mingbaile
Copy link
Author

I have just signed it. Thank you

@inkz
Copy link
Member

inkz commented Mar 25, 2025

solidity/security/erc721-arbitrary-transferfrom.sol is a test file for SAST tool, not an actual smart contract.

@inkz inkz closed this Mar 25, 2025
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

Successfully merging this pull request may close these issues.

3 participants