Skip to content

Optimize state variable initialization to save gas#261

Closed
mingbaile wants to merge 1 commit intobeefyfinance:masterfrom
mingbaile:master
Closed

Optimize state variable initialization to save gas#261
mingbaile wants to merge 1 commit intobeefyfinance:masterfrom
mingbaile:master

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 might either be missing updates or could be optimized for gas efficiency. Would you find our results useful? Your feedback would be invaluable in improving our tool!

These modifiers save gas by avoiding storage (SLOAD costs ~100 gas) and embedding values directly into bytecode. 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:

StrategyTombTSHARE.sol
State variable: withdrawPeriod, withdrawEpochs

    uint256 public withdrawPeriod = 7200; // 2 Hours to withdraw before next lock
    uint256 public withdrawEpochs = 6; // Each Epoch is 6 hours

Thanks for your time! Looking forward to your thoughts.

Copy link

@0xdanielvigo 0xdanielvigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effective gas saving

@kexleyBeefy
Copy link
Member

Acknowledged, but this commit was made on a legacy strategy no longer in production.

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