A misconfigured max_v2_duration
parameter allows gas-intensive loops in ScrvusdOracleV2.vy
, causing transactions to exceed block gas limits and permanently halt price updates.
1. Loop Structure in _obtain_price_params
:
2. Configurable max_v2_duration
:
Gas Cost Per Iteration: Each loop iteration consumes ~20,000 gas due to storage writes and arithmetic operations.
Worst-Case Scenario:
192 iterations * 20,000 gas = 3,840,000 gas
per transaction, exceeding Ethereum’s average per-block gas limit (~30M gas) and standard transaction gas limits (often set to 1-2M gas).
Price updates fail due to gas exhaustion, rendering the oracle unusable.
Manual Code Review
Identified unbounded loop dependent on admin-controlled max_v2_duration
.
Gas Estimation
Calculated worst-case gas costs using Ethereum’s average opcode costs.
MAX_V2_DURATION
to Prevent Gas ExhaustionRevised Code:
python
Invalid, `bound` here has a different meaning from Python's `range(a, b)`. It is a bound of maximum iterations, meaning the loop will only go to the bounded `MAX_V2_DURATION` when `number_of_periods >= MAX_V2_DURATION`
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.