The OracleHelper::_chainLinkIsDead function will incorrectly calculate the time elapsed between the latest update and the block.timestamp in the case that the update occurred at the time the OracleHelper::_chainLinkIsDead function was invoked as block.timestamp would be equal to upd.
Impact:
All transactions submitted at the same block the latest Chainlink round was submitted will fail due to an incorrect dead Chainlink error.
Example:
/**
* @dev Check if chainLink feed was
* updated within expected timeFrame
* for single {_tokenAddress}.
*/
function _chainLinkIsDead(
address _tokenAddress
)
internal
view
returns (bool)
{
uint256 upd = latestRoundData(
_tokenAddress
);
upd = block.timestamp > upd
? block.timestamp - upd
: block.timestamp;
return upd > heartBeat[_tokenAddress];
}
Recommendation:
We advise the code to adjust its ternary operator's conditional to be made inclusive, ensuring that an upd value of 0 is calculated when block.timestamp is equal to the upd time.
OHR-02M: Incorrect Assessment of Latest Update Delta
Description:
The
OracleHelper::_chainLinkIsDead
function will incorrectly calculate the time elapsed between the latest update and theblock.timestamp
in the case that the update occurred at the time theOracleHelper::_chainLinkIsDead
function was invoked asblock.timestamp
would be equal toupd
.Impact:
All transactions submitted at the same block the latest Chainlink round was submitted will fail due to an incorrect dead Chainlink error.
Example:
Recommendation:
We advise the code to adjust its ternary operator's conditional to be made inclusive, ensuring that an
upd
value of0
is calculated whenblock.timestamp
is equal to theupd
time.