-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oracles: Time validation by a max age threshold #1670
Conversation
let (value, timestamp) = T::AggregationProvider::aggregate(fed_values) | ||
.ok_or(Error::<T>::KeyNotInCollection)?; | ||
|
||
Self::ensure_valid_timestamp(collection_id, timestamp)?; | ||
|
||
Ok((value, timestamp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aggregating both values and timestamps and from the aggregated timestamp, I'm checking that it's not outdated.
Another option could be to filter outdated timestamps and aggregate them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option 3:
- Final timestamp is the median of the timestamps,
- If the median is not outdated then the final value is the median of the non-outdated Oracle values.
I see this option quite accurate, but the timestamp probably would be older than the average of used values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final solution (after Frederic sync):
- Filter outdated oracles until a limit N.
- If the limit is overpassed, then
OracleOutdatedError
.
- If the limit is overpassed, then
- Aggregating values & timestamps of the non-outdated oracles
fae22cb
to
77d0cbe
Compare
pub struct CollectionInfo<T: Config> { | ||
/// Maximum duration to consider an oracle value non-outdated. | ||
/// An oracle value is consider updated if its timestamp is higher | ||
/// than `now() - value_lifetime` | ||
pub value_lifetime: Option<T::Timestamp>, | ||
|
||
/// Minimun number of feeders to succesfully aggregate a value. | ||
pub min_feeders: u32, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To catch all casuistics well, I've done a new type that is used as a parameter for the new extrinsic set_collection_info()
to configure a collection with some properties.
min_feeders
force to have at least min_feeders
per key in a collection. That means that the feeder should have fed and should have fed recently if value_lifetime
is different than None
Should be ready then! Thanks for your fast review @mustermeiszer 🙌🏻 |
194f346
to
1f7ac52
Compare
Description
We want, as a requirement, to have oracle values validated with a "max age" threshold. Older oracles values must be considered outdated and it's an error to use them.
This error is generated when:
The threshold is optionally set by the collection by the admin
Tasks