1

How do we know if the validation of checking stale data is sufficient? Is only checking timestamp data sufficient?

(uint256 roundId,,, uint256 updatedAt, uint80 answeredInRound) = 
AggregatorV3Interface(feed).latestRoundData();```

Is checking for updateAt timestamp sufficient to know if it's stale data?

   if (block.timestamp < updatedAt + feedConfig.priorityPeriodThreshold) return returnValues;

Is there a need to also check for roundId?

require(answeredInRound >= roundID, "Stale price");

2 Answers 2

0

To determine if data is stale, check both roundId to ensure you're using the latest round and updatedAt to verify recentness using the provided round and timestamp information. Chainlink Docs.

roundId: The round in which the answer was updated updatedAt: The timestamp when the answer was computed

Also, refer to this post : Chainlink `latestRoundData()` security / fresh data check usage

2
  • I understand, but isn't timestamp validation sufficient? Sep 9, 2023 at 3:03
  • Relying solely on timestamp validation isn't enough when using Chainlink Data Feeds. You should also check for data deviations, pay attention to heartbeat triggers, and be aware of different thresholds for assets and blockchains. When using data from multiple sources, consider potential discrepancies that can affect your calculations. docs.chain.link/…
    – DevCrypto
    Sep 9, 2023 at 4:13
0

please refer to check the timestamp of the latest answer.

Chainlink Data Feeds do not provide streaming data. Rather, the aggregator updates its latestAnswer when the value deviates beyond a specified threshold or when the heartbeat idle time has passed

Data feed updates depending on 2 conditions: heartbeat and deviation threshold. if (block.timestamp < updatedAt + feedConfig.priorityPeriodThreshold) return returnValues; cannot promise the price data is the latest because the data feed will be updated if the price alternates more than the deviation threshold.

If you want to make sure you are using the latest data from Chainlink data feed, please call the data feed when you plan to use it.

If you want to make sure that data feed you rely on is working, please refer to Chainlink latestRoundData() security / fresh data check usage mentioned in @DevCrypto's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.