Omniscia LimeChain Audit

LibGovernance Code Style Findings

LibGovernance Code Style Findings

LGE-01C: Data Update Redundancy

TypeSeverityLocation
Gas OptimizationInformationalLibGovernance.sol:L91-L109, L111-L113

Description:

Whenever the status of a member is adjusted, their administrator is adjusted as well.

Example:

contracts/libraries/LibGovernance.sol
91/// @notice Adds/removes a validator from the member set
92function updateMember(address _account, bool _status) internal {
93 Storage storage gs = governanceStorage();
94 if (_status) {
95 require(
96 gs.membersSet.add(_account),
97 "LibGovernance: Account already added"
98 );
99 } else if (!_status) {
100 require(
101 LibGovernance.membersCount() > 1,
102 "LibGovernance: contract would become memberless"
103 );
104 require(
105 gs.membersSet.remove(_account),
106 "LibGovernance: Account is not a member"
107 );
108 }
109}
110
111function updateMemberAdmin(address _account, address _admin) internal {
112 governanceStorage().membersAdmins[_account] = _admin;
113}

Recommendation:

We advise this functionality to be packed into the existing updateMember function to optimize the gas cost of the codebase.

Alleviation:

The LimeChain team acknowledged the gas optimization but opted to not apply it to the codebase in favor of better code readability.