-
Notifications
You must be signed in to change notification settings - Fork 298
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: on_new_data()
improvements
#937
Comments
All seems reasonable to me. |
I want to add a new point that could be more polemic, but I think it would help a lot to reason about the code:
When things become complex with oracles, it's highly probable that the I have the strong opinion that |
We need solid use cases to determine exactly how we want to do the change. A feature that no one is using is just a maintenance burden. Also (4) is not compatible with (1). We need to have two different hook to achive both goals. |
Why (4) is not compatible with (1)? The resulting signature adding these two points will be: /// Triggers an event saying that a member has updated the key with a new value.
/// If this method fails, the Oracle update is finally not applied.
/// If the user wants to know the value, they should use `DataProvider`.
fn on_new_data(account_id: &AccountId, key: &Key) -> DispatchResult; If the problem is that most implementors of fn on_new_data<Provider: DataProvider>(account_id: &AccountId, key: &Key) -> DispatchResult {
// As an implementor of this:
// 1. I can choose if I really want the oracle to be updated or not returning an Err.
// 2. I can trigger some computation for this event.
// 3. I can read the value as DataProvider::get(key)
} In our use case, we use oracles to set prices. For oracle members, they feed with fiat values, but for Oracle users through |
I see two use cases here:
1 should happen before the value is stored. 2 should happen after the value is stored. |
I think both are the same case because the extrinsic is transactional, so:
|
But a provider can feed multiple values at once. So we need to either
or
Both works but the second way is less overhead. |
Yeah, with several values we have that issue. To avoid choosing between an overhead (example 1) or complexity (example 2) solution, could we agree directly on all values or reject all if some of the value is not correct? From my point of view, it's like if I agree directly on the whole extrinsic called by the oracle member, which could make sense. This would also add point (2) into the game:
So, if there is an error, the member should call again with a correct list of values. |
That could work. We just need to document it clearly. |
Hi,
As a user of
orml_oracle
, we've found some limitations regarding theon_new_data()
callback when the oracle is fed:on_new_data()
should return aDispatchResult
. A user could want to run custom logic that, if it fails, the oracle should not be fed. Right now, from the callback, we have no control over this situation.on_new_data()
should be called once with the whole list instead of one time per value. In our case, we use this callback as a trigger to make some expensive computations. We would save a lot of computation if we could combine this for all values.on_new_data()
should return theWeight
. Because the user can run an expensive operation inside the callback, it will be awesome to reflect it to accurately the block time computation.We can discuss any of the points. If you finally agree with them, I could also make a PR. Thanks!
The text was updated successfully, but these errors were encountered: