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

[L-02] Redundant Check in 'certified' Function #291

Open
softstackio opened this issue Jan 13, 2025 · 0 comments · May be fixed by #297
Open

[L-02] Redundant Check in 'certified' Function #291

softstackio opened this issue Jan 13, 2025 · 0 comments · May be fixed by #297
Assignees

Comments

@softstackio
Copy link

Likelihood: High

Description
In the 'certified' function of the CertifierHbbft contract, there is a redundant check that unnecessarily complicates the code and may lead to confusion. The function first checks if 'stakingAddress == address(0)' and returns false if so. However, it then always returns 'stakingAddress != address(0)', which is essentially the inverse of the first check. This redundancy does not affect the functionality but reduces code clarity and efficiency.

Recommendation:
Simplify the 'certified' function by removing the redundant check. The function can be rewritten as follows:

function certified(address _who) external view returns (bool) {
   if (_certified[_who]) {
       return true;
   }
   address stakingAddress =
validatorSetContract.stakingByMiningAddress(_who);
   return stakingAddress != address(0);
}
@axel-muller axel-muller self-assigned this Jan 21, 2025
@axel-muller axel-muller linked a pull request Jan 21, 2025 that will close this issue
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 a pull request may close this issue.

2 participants