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

Inforamationational / Gas findings

Summary

The following list presents findings related to information and gas optimization. These findings are provided exclusively to facilitate code improvement.

[I-1] Usage of onlyOwner() modifier instead of an if statement

Adding an onlyOwner() modifier instead of an if statement in the PasswordStore::getPassword() can improve the code readability.

+ modifier onlyOwner()
+ {
+ if (msg.sender != s_owner) {
+ revert PasswordStore__NotOwner();
+ }
+ _;
+ }
-function getPassword() external returns (string memory) {
+function getPassword() external view onlyOwner returns (string memory) {
- if (msg.sender != s_owner) { //line 36
- revert PasswordStore__NotOwner(); //line 37
- } //line 38
...
}

[I-2] @Natspec declaration

Incomplete @Natspec declaration in the PasswordStore::setPassword() and PasswordStore::getPassword(). Suggested these minimum tags to implement for clarity:

  • @author

  • @title

  • @notice

  • @param

  • @return (if applicable)

[I-3] Wrong @param in getPassword()

@param in PasswordStore::getPassword() is defined as: "newPassword. The new password to set". But the PasswordStore::getPassword() doesn't accept any input so there isn't any newPassord to set.

[I-4] Typo in the event naming in SetNetPassword();

The event name should be PasswordStore::SetNewPassword() instead of SetNetPassword().

Gas

[G-1] Storage variable declaration

In the PasswordStore contract define the string private s_password (32 bytes) variable before the address private s_owner (20 bytes) for a better slot memory allocation.

- address private s_owner; //line 13
- string private s_password; //line 14
+ string private s_password;
+ address private s_owner;

[G-2] s_owner immutable

The PasswordStore::s_owner can be defined immutable for saving gas.

- address private s_owner; //line 13
+ 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: Non-acceptable severity

Support

FAQs

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