In the UpdateWeightRunner contract, the removeOracle function is designed to allow the admin to remove an oracle. However, the function does not follow the Checks-Effects-Interactions (CEI) pattern, resulting in inefficient gas usage. If the function call fails, the admin incurs unnecessary gas costs that could have been avoided by reordering the code.
removeOracleImproper Code Order:
The require check for admin validation is placed after the state update, which violates the CEI pattern.
Gas Wastage:
If the require check fails, gas is still consumed for operations performed before the check, such as setting approvedOracles to false.
Increased Gas Costs:
Admin users will pay unnecessary gas fees on failed calls due to inefficient code placement.
Violation of CEI Pattern:
The Checks-Effects-Interactions pattern is a best practice in Solidity to ensure secure and gas-efficient execution. The current implementation deviates from this standard.
Poor Code Quality:
This issue reflects bad coding practice, potentially reducing the maintainability and readability of the contract.
Manual Review
Reorder the require check to ensure the function adheres to the CEI pattern. This adjustment ensures that the call is validated before performing any state changes or emitting events.
removeOracle FunctionImproved Gas Efficiency:
Prevents unnecessary gas usage by ensuring state changes and events are only executed after the admin check passes.
Adherence to Best Practices:
Aligns the function with the CEI pattern, improving security and maintainability.
Better Developer Experience:
Enhances the readability and robustness of the codebase, making it easier for future developers to work with.
Here’s the refined markdown with proper grammar and expanded sections:
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.