This report identifies a minor code quality issue in the graduateAndUpgrade() function of the LevelOne.sol contract. The function accepts a bytes memory parameter that is not utilized within its current implementation. While this does not pose a direct security risk, unused parameters can lead to code clutter, increase gas costs slightly due to data handling, and potentially confuse developers about its intended purpose or future use.
The graduateAndUpgrade(address _levelTwo, bytes memory) function in LevelOne.sol is designed to handle end-of-session payouts and authorize a contract upgrade. Its signature is:
The second parameter, bytes memory (which is unnamed in the provided code, often indicative of it being unused, or sometimes I've added /* _data */ in previous analyses), is passed to the function but is not subsequently read or used in any logic within the graduateAndUpgrade function itself.
The function primarily calls _authorizeUpgrade(_levelTwo), which is an internal UUPS mechanism that does not require this bytes data. If this parameter was intended for an initialization call to the new _levelTwo implementation, that would typically occur when the proxy's upgradeToAndCall(address newImplementation, bytes calldata data) function is invoked, not within this _authorizeUpgrade step in the current implementation contract.
Code Clutter: Unused parameters make the code slightly harder to read and maintain, as developers might question their purpose.
Minor Gas Inefficiency: Passing unused data incurs a small, often negligible, gas cost for calldata handling.
Potential for Misunderstanding: Developers or auditors might assume the parameter has a purpose or is intended for future functionality that is not yet implemented or documented, leading to incorrect assumptions.
Manual Code Review
To improve code clarity and efficiency, the unused bytes memory parameter should be addressed:
If the parameter is genuinely not needed for the current or foreseeable functionality of graduateAndUpgrade in LevelOne.sol, it should be removed from the function signature.
If the parameter is a placeholder for future functionality (e.g., if graduateAndUpgrade were to be modified to also directly call the proxy's upgradeToAndCall function), its purpose should be clearly documented with comments. However, given that the graduate() reinitializer in LevelTwo.sol currently takes no arguments (function graduate() public reinitializer(2) {}), it's likely the parameter is not needed for initialization data for LevelTwo.sol as it stands.
Assuming the parameter is not needed, the recommendation is to remove it.
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.