Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

s_owner not being set to immutable wastes gas

Summary

The 'PasswordStore::s_owner' variable is unable to be changed, and therefore should be immutable to save gas.

Vulnerability Details

'''solidity
contract PasswordStore {
error PasswordStore__NotOwner();

@> address private s_owner;
string private s_password;
'''
If a variable never changes, then reading from storage is less gas efficient, and instead we should read from the bytecode. Using an immutable variable will enable the protocol to save gas on reading the 'PasswordStore::s_owner' variable.

Impact

Wastes gas.
'''...diff
address private s_owner; 542818 gas.
address private immutable s_owner; 516936 gas
'''

Tools Used

-slither

  • foundry

Recommendations

Set s_owner to immutable
...diff

  • address private s_owner;

  • address private immutable s_owner;
    ...

Updates

Lead Judging Commences

inallhonesty Lead Judge
almost 2 years ago
inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Gas optimizations

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.