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

Revert Usage in getPassword Function is NOT gas efficient

Summary

Optimize the getPassword function in the PasswordStore contract by replacing the revert statement with a gas-efficient access control modifier, improving code efficiency and readability.

Vulnerability Details

  • In the PasswordStore contract, replace the use of revert in the getPassword function with a gas-efficient modifier for access control.

Impact

Enhancing the getPassword function of the PasswordStore contract with a gas-efficient access control modifier improves efficiency, readability, security, and user-friendliness, while reducing gas consumption.

Tools Used

  • Foundry

  • Manual testing

Recommendations

Enhance code readability and efficiency by implementing an access control modifier for owner-restricted functions.

-function getPassword() external view returns (string memory) {
- if (msg.sender != s_owner) {
- revert PasswordStore__NotOwner();
- }
- return s_password;
-}
+function getPassword() onlyOwner external view returns (string memory) {
+ return s_password;
+}
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 2 years ago
inallhonesty Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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