MAX_DATA_STALENESS should vary based on data feed
A single global MAX_DATA_STALENESS is used for all feeds, but feeds have different update frequencies. A per-feed staleness window better reflects each feed's heartbeat.
Description
The MAX_DATA_STALENESS constant defines the maximum duration for which price data is considered valid. Once this period expires, the data is marked as stale, and the oracle will revert rather than return this outdated data. The staleness check is conducted in the following function:
function _validateLastUpdateDetailsOnRead(bytes32 /* dataFeedId */, uint256 /* lastDataTimestamp */, uint256 lastBlockTimestamp, uint256 lastValue) internal view virtual returns (bool) {return lastValue > 0 && lastBlockTimestamp + MAX_DATA_STALENESS > block.timestamp;}
Since different data feeds have varying update frequencies (heartbeats), the staleness period should also be tailored to each data feed type to ensure accurate and reliable data.
Impact
A blanket staleness window can either be too tight for slow feeds (causing unnecessary reverts) or too loose for fast feeds (allowing reads of data older than the feed's heartbeat).
Recommendation
Implement dynamic staleness periods for different data feeds to accommodate their specific update frequencies.
Resolution
RedStone: This function is virtual and allows the add this logic. However, we wanted to have this param quite high, as for the majority of feeds we cannot predict exact update frequency, as usually it depends on the market volatility.

