-
Notifications
You must be signed in to change notification settings - Fork 86
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: Move feeders to collection level #1672
Conversation
Already compiling with |
ce58e28
to
dfb8aa2
Compare
It's now quite simple, and I would say it fits our requirements (by now).
|
This is ready @mustermeiszer 🙌🏻 |
.try_into() | ||
.map_err(|_| Error::<T>::NoOracleCollectionChangeId)?; | ||
|
||
Self::update_feeders(collection_id, key, feeders.clone())?; | ||
CollectionInfo::<T>::insert(collection_id, info.clone()); |
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 think we should forbid any non-allowed feeder to feed any further values at this point. Basically, iterate over all keys in the storage and remove unknown feeders.
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.
This is a very good point
Basically, iterate over all keys in the storage and remove unknown feeders.
I would say this could be more complex because some existing keys could have lost some of their feeders (but not all), and then the aggregated values could have changed or not been validated.
Could we consider that if we call apply_update_collection_info()
, then you should call later update_collection()
to reflect those changes? We can understand the current collection as the values the collection had at the moment of updating. If we see this in such a way, then there is no problem if feeders are modified because the collection at that point contained such previous feeders and 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.
If you agree with me, it could be interesting to add a last_updated
field to the collection to know if the content of the collection reflects a moment in the past.
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 add a last_updated field to the collection to know if the content of the collection reflects a moment in the past.
I thought that is already the case?
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.
Could we consider that if we call apply_update_collection_info(), then you should call later update_collection() to reflect those changes? We can understand the current collection as the values the collection had at the moment of updating. If we see this in such a way, then there is no problem if feeders are modified because the collection at that point contained such previous feeders and values.
Yes, that is a good idea. update_collection
will filter them already, right?
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.
Maybe, apply_update_collection_info
should just purge the CachedCollection
storage?
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 think it makes more sense to purge it 👍🏻
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 thought that is already the case?
The timestamp stored in the collection is the timestamp of the older Oracle value, not the timestamp of when the collection was outdated. So now we will store both
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.
So purge or store outdated 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 think we can use both. Store the last_updated
each time we call update_collection()
and purge when apply.
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 have thought about the iteration of the Keys
storage during this review and this is a possibly unbounded iteration.
We should use CountedStorageMap
instead OR restrict register_id
to not store anymore keys if MaxKeysPerCollection
is reached.
That is a very good point! Thanks for your profound review. I think I'll need to do it by myself in |
.try_into() | ||
.map_err(|_| Error::<T>::NoOracleCollectionChangeId)?; | ||
|
||
Self::update_feeders(collection_id, key, feeders.clone())?; | ||
CollectionInfo::<T>::insert(collection_id, info.clone()); |
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 add a last_updated field to the collection to know if the content of the collection reflects a moment in the past.
I thought that is already the case?
.try_into() | ||
.map_err(|_| Error::<T>::NoOracleCollectionChangeId)?; | ||
|
||
Self::update_feeders(collection_id, key, feeders.clone())?; | ||
CollectionInfo::<T>::insert(collection_id, info.clone()); |
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.
Could we consider that if we call apply_update_collection_info(), then you should call later update_collection() to reflect those changes? We can understand the current collection as the values the collection had at the moment of updating. If we see this in such a way, then there is no problem if feeders are modified because the collection at that point contained such previous feeders and values.
Yes, that is a good idea. update_collection
will filter them already, right?
.try_into() | ||
.map_err(|_| Error::<T>::NoOracleCollectionChangeId)?; | ||
|
||
Self::update_feeders(collection_id, key, feeders.clone())?; | ||
CollectionInfo::<T>::insert(collection_id, info.clone()); |
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.
Maybe, apply_update_collection_info
should just purge the CachedCollection
storage?
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.
Thanks for your patience! Thats looks like a good iteration to the final version!
Thanks for all your feedback! Very appreciated and accurate! 🙌🏻 |
Description
Move the feeder concept by collection instead of by key.