Omniscia Alliance Block Audit

StakeLock Code Style Findings

StakeLock Code Style Findings

SLK-01C: Data Mutability Optimization

TypeSeverityLocation
Gas OptimizationInformationalStakeLock.sol:L7, L9-L13

Description:

The setLockEnd function is meant to sanitize the input _lockEndBlock of the StakeLock contract and assign it to its contract-level variable only once as it is invoked solely within constructors in the codebase of the project.

Example:

contracts/StakeLock.sol
9function setLockEnd(uint256 _lockEndBlock) internal {
10 require(_lockEndBlock > block.number, "setLockEnd::Lock end needs to be in the future");
11 require(lockEndBlock == 0, "setLockEnd::Lock end was already set");
12 lockEndBlock = _lockEndBlock;
13}

Recommendation:

As the variable is only assigned to once during derivative contract constructors, we advise that the code block within setLockEnd 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 declaration L7, greatly optimizing the codebase.

Alleviation:

The setter function was omitted in favor of a constructor that takes advantage of the immutable trait.