Submitted by 0xA5DF
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/Asset.sol#L102
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/FiatCollateral.sol#L149
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/OracleLib.sol#L14-L31
The Asset.refresh() function calls tryPrice() and catches all errors except errors with empty data.
As explained in the docs the reason empty errors arent caught is in order to prevent an attacker from failing the tryPrice() intentionally by running it out of gas.
However, an error with empty data isnt thrown only in case of out of gas, in the current way that Chainlink deprecates oracles (by setting aggregator to the zero address) a deprecated oracle would also throw an empty error.
Any function that requires refreshing the assets will fail to execute (till the asset is replaced in the asset registry, passing the proposal via governance would usually take 7 days), that includes:
The docs imply in case of deprecation the protocol is expected continue to operate:
The docs also clearly state that refresh() should never revert
Ive tracked a few Chainlink oracles that were deprecated on the Polygon network on Jan 11, the PoC below tests an Asset.refresh() call with a deprecated oracle.
File: test/plugins/Deprecated.test.ts
Modification of hardhat.config.ts to set it to the Polygon network:
Output:
Notes:
At OracleLib.price() catch the error and check if the error data is empty and the aggregator is set to the zero address, if it is a revert with a custom error. Otherwise revert with the original error data (this can be done with assembly).
Another approach might be to check in the refresh() function that the tryPrice() function didnt revert due to out of gas error by checking the gas before and after (in case of out of gas error only ~1/64 of the gas-before would be left). The advantage of this approach is that it would catch also other errors that might revert with empty data.
tbrent (Reserve) acknowledged and commented:
