Omniscia Alliance Block Audit
OneStakerFeature Code Style Findings
OneStakerFeature Code Style Findings
OSF-01C: Data Mutability Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | OneStakerFeature.sol:L8, L10-L13 |
Description:
The setStaker
function is meant to assign the _staker
to its contract-level variable only once as it is invoked solely within constructor
s in the codebase of the project.
Example:
contracts/pool-features/OneStakerFeature.sol
10function setStaker(address _staker) public {11 require(staker == address(0x0), "OneStakerFeature::setStaker staker was already sey");12 staker = _staker;13}
Recommendation:
As the variables are only assigned to once during derivative contract constructor
s, we advise that the code block within setStaker
is instead set to be of a constructor
that performs the exact same statements, permitting the introduction of the immutable
mutability specifier in the variable declarations of L8, greatly optimizing the codebase.
Alleviation:
The setter function was replaced by a constructor
allowing the utilization of the immutable
mutability specifier on the linked variable and greatly optimizing the codebase.