In the UpdateWeightRunner contract, there are functions called setQuantAMMSwapFeeTake and setQuantAMMUpliftFeeTake that sets the swap and uplift fee percentage charged on every swap and uplift operations. However, there is no validation to restrict identical or redundant fee percentage updates. This oversight could result in unnecessary gas consumption and inefficient event emissions.
While this may appear to be an admin input validation issue, there is a high likelihood that an admin might overlook the last updated fee value, especially since this function is not frequently used. Given this context, the chances of omission are high. It would, therefore, be better to include a check to restrict redundant updates.
See the code snippet below:
UpdateWeightRunner::setQuantAMMSwapFeeTakeUpdateWeightRunner::setQuantAMMUpliftFeeTakeFunctions lack a condition to verify whether the new fee value (_quantAMMSwapFeeTake and _quantAMMUpliftFeeTake) are identical to the current fee value (quantAMMSwapFeeTake and quantAMMUpliftFeeTake). This can lead to:
Redundant updates to the fee value.
Unnecessary state changes.
Emission of redundant events.
Unnecessary Gas Consumption:
Redundant updates result in unnecessary state changes, incurring additional gas costs. Even if the new fee value is identical to the existing one, the contract performs a write operation to the blockchain, wasting resources.
Increased Transaction Costs for Users:
Since gas fees are proportional to the number of operations in a transaction, redundant updates will result in higher transaction costs for users (e.g., admins) without making any meaningful changes to the contract’s state.
Blockchain Bloat:
Every transaction that modifies the contract's state is recorded on-chain. Allowing redundant updates increases the size of the blockchain unnecessarily, contributing to blockchain bloat. Over time, this can affect Ethereum's scalability and performance.
Unnecessary Event Emissions:
Emitting events for redundant updates adds unnecessary logs to the blockchain, which consumes additional gas and increases blockchain storage requirements.
Event Log Pollution:
Redundant events clutter the transaction logs, making it harder to query meaningful changes. This can confuse users or developers who rely on these logs to monitor the contract's behavior.
Manual Review
Add a condition to restrict redundant and identical fee percentage updates. This will ensure efficient gas usage and prevent unnecessary event emissions.
Below is the updated code with the necessary validation added:
Prevents redundant state updates and event emissions.
Saves gas costs by avoiding unnecessary write operations.
Reduces blockchain bloat and ensures meaningful event logs.
Improves contract efficiency and user experience.
Here’s the grammatically corrected and polished version of your markdown:
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.