mento-protocol / mento-core

Core smart contracts of the Mento protocol.
https://mento.org
GNU General Public License v3.0
20 stars 10 forks source link

feat: Make Relayer work with lesser greater #496

Closed bowd closed 1 month ago

bowd commented 1 month ago

Description

When we're redeploying relayers there will be a short period of time where the previous relayer's report is still in SortedOracles which will never expire the last remaining report. Also if we will want to transition existing rate feed Ids to relayed ones, we will also be faced with the situation where there's one report still in SortedOracles and the relayer needs to compute lesser & greater keys for the insert operation.

Given that this is a fringe situation my best solution is to first try reporting without lesser & greater keys, for the 99.9% happy path, and in case of a revert that matches our expected reason, compute lesser greater keys but only for two clear scenarios: (a) There's a single report from another oracle. (b) There's a report from another oracle and one from the relayer.

In both cases we will report and then remove expired. Depending on the timestamp of the report from the other oracle, we will either transition from (a) to a single report from the relayer, if the other oracle report is expired, or from (a) to (b) if the other oracle report isn't yet expired. Then on the next report we will transition from (b) to a single report from the relayer, and get back to the happy path.

Other changes

N/A

Tested

Added unit tests and integration tests to cover the situation.

Related issues

N/A

Backwards compatibility

Yes

Documentation

N/A

openzeppelin-code[bot] commented 1 month ago

feat: Make Relayer work with lesser greater

Generated at commit: 81e2976c32385603dc0d554652347b5a0f359311

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
3
0
13
38
57
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector