Your Solidity code for the LinearBoostController contract is generally well-structured and adheres to common Solidity practices, but there are some potential vulnerabilities and areas for improvement to consider:
While Solidity 0.8.0 and later versions automatically check for overflow and underflow in arithmetic operations, it’s good practice to validate inputs. However, your use of uint64 for locking durations and maxBoost could lead to unexpected results if not properly constrained.
Zero Locking Duration: The getBoostAmount function currently allows _lockingDuration to be 0, but it is only checked against minLockingDuration. Consider explicitly checking for this in the require statement or reverting if it is 0 since the comment suggests it should be non-zero.
Max Boost Validation: There is no validation on maxBoost in the setMaxBoost function. It should be ensured that the new boost value does not exceed a reasonable limit to prevent unwanted behaviors.
There are no checks in the constructor for valid ranges:
Ensure that _minLockingDuration is non-zero.
Ensure that _maxLockingDuration is greater than or equal to _minLockingDuration.
Validate _maxBoost to ensure it is a sensible value.
While you're correctly emitting events for state changes in setter functions, it would be beneficial to emit an event in the getBoostAmount function as well for traceability, especially in more complex systems.
The contract uses Ownable, which is good for restricting access. However, consider potential future enhancements where you might want more granular access control rather than just an owner. For instance, using roles may provide more flexibility.
Consider using uint256 instead of uint64 for all the state variables since most computations and storage in Ethereum are optimized for uint256. This can reduce complexity when interacting with other contracts or libraries that expect uint256.
Although your current implementation does not involve state-changing functions that interact with external contracts (like token transfers), always be cautious of reentrancy attacks if you later add features that do. You might consider using checks-effects-interactions pattern if you introduce external calls.
minLockingDuration, maxLockingDuration, and maxBoostMake sure these values have sensible defaults or are properly set upon contract deployment. If left uninitialized, they will default to 0, which may lead to unintended behavior.
Here’s how you could modify the constructor and getBoostAmount function to include additional validation:
By implementing these checks and considerations, you can enhance the security and robustness of your smart contract.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.