Submitted by 00xSEV
Currently, if there are 50 fast updates followed by no updates, a Chainlink Oracle will be considered dead, even though its normal behavior. Chainlink Oracles update either after some time has passed or upon a price change.
How it will revert:
There is a _chainLinkIsDead function that returns true if the last update took longer than the heartbeat. See here.
Its essentially called on every request to the Chainlink Oracle, before the actual call, to ensure the price is up to date.
How does recalibrate work?
heartBeat is updated when recalibrate/recalibrateBulk is called. Anyone can call them. Both of these functions call _recalibrate. See here.
In _recalibratePreview, we see that currentSecondBiggest is returned, representing the second-largest difference between updates. Thus, heartBeat is set to the second-largest time difference between two consecutive updates in the last 50 updates. iterationCount is capped by MAX_ROUND_COUNT in _getIterationCount, which is set to 50.
How do Chainlink updates work?
If you check Show more details here, you can see that for most feeds, deviation is set to 1-2% and heartbeat is 86400s = 24 hours. However, some feeds are set to 0.5% or even less.
If theres a period of high volatility followed by no volatility, its possible that heartBeat in Wise will be set to a low value. Consequently, the Chainlink feed will be considered dead after a short period of no updates.
E.g., if there are 50 updates, once every minute, followed by 10 hours of no updates, and then no updates for an additional 24 hours, the heartBeat will be set to 1 minute in Wise. Consequently, the Oracle will be considered dead after 1 minute of no updates. This means it will be considered dead for the initial 10 hours, then considered alive for 1 minute, and then considered dead again for the following 24 hours.
Examples demonstrating similar events in the wild can be seen in this Dune dashboard.
The Chainlink Oracle is considered dead for a substantial amount of time, affecting liquidations, deposits, withdrawals, and all other functions using this Oracle.
The attacker can disable the entire market that uses the Oracle by calling recalibrate. This can lead to bad debt (the price changes rapidly, but the Oracle still reverts after the first update), griefing (users cannot use the protocol), etc.
It can be even worse if combined with block stuffing or when the gas price is too high and Chainlink does not update. The updates stop coming as often as usual, and the feed is considered dead long enough to accrue bad debt. For example, if the last 50 updates occurred every minute, a sudden spike in demand for block space could make updates come only once an hour, preventing liquidations for 1-2 hours.
forge test -f https://mainnet.infura.io/v3/YOUR_KEY -vvv --mt testOne --mc ChainlinkDies$
contracts/Tests/ChainlinkDies.t.sol
Consider setting Chainlinks native heartbeat instead. Also consider adding access control to recalibrate functions and only calling it when it will not lead to DoS.
Oracle
vonMangoldt (Wise Lending) commented:
Trust (judge) commented:
vm06007 (Wise Lending) commented:
Wise Lending commented:
