Merged
Conversation
2ff5fdc to
61203ce
Compare
61203ce to
a685439
Compare
andor0
approved these changes
Aug 4, 2021
| let asset_pair = (x, y); | ||
| match prices.read().unwrap().get(&asset_pair) { | ||
| Some(latest_price) => with_status(json(latest_price), StatusCode::OK), | ||
| // TODO: how to 404 without content??? |
Contributor
There was a problem hiding this comment.
yes, can respond 404 without content because oracle only has response.code != 200 check (https://github.com/ComposableFi/composable-node-beta/blob/main/pallets/oracle/src/lib.rs#L606)
| .await | ||
| .expect("connection to pyth-client failed"); | ||
|
|
||
| // TODO: subscribe to all asset prices? cli configurable? |
Contributor
There was a problem hiding this comment.
or can add subscription on a new asset by an oracle request
Contributor
|
LGFM. |
Contributor
Author
|
Thanks! I merge this now and open a second PR for the integration with the oracle pallet! |
Contributor
|
nice job! @hussein-aitlahcen |
haroldsphinx
added a commit
that referenced
this pull request
Jan 27, 2022
# This is the 1st commit message: fetch depth # The commit message #2 will be skipped: # Update checkout action # The commit message #3 will be skipped: # Update checkout action # The commit message #4 will be skipped: # Update checkout action # The commit message #5 will be skipped: # Update checkout action # The commit message #6 will be skipped: # Update checkout action # The commit message #7 will be skipped: # Update checkout action # The commit message #8 will be skipped: # Update checkout action # The commit message #9 will be skipped: # Update checkout action # The commit message #10 will be skipped: # Update checkout action
haroldsphinx
added a commit
that referenced
this pull request
Jan 27, 2022
# This is the 1st commit message: fetch depth # The commit message #2 will be skipped: # Update checkout action # The commit message #3 will be skipped: # Update checkout action # The commit message #4 will be skipped: # Update checkout action # The commit message #5 will be skipped: # Update checkout action # The commit message #6 will be skipped: # Update checkout action # The commit message #7 will be skipped: # Update checkout action # The commit message #8 will be skipped: # Update checkout action # The commit message #9 will be skipped: # Update checkout action # The commit message #10 will be skipped: # Update checkout action # The commit message #11 will be skipped: # Update checkout action # The commit message #12 will be skipped: # Update checkout action # The commit message #13 will be skipped: # Update checkout action # The commit message #14 will be skipped: # Update checkout action # The commit message #15 will be skipped: # Update checkout action # The commit message #16 will be skipped: # Update checkout action # The commit message #17 will be skipped: # Update checkout action
dzmitry-lahoda
added a commit
that referenced
this pull request
Dec 14, 2022
# This is the 1st commit message: lfs # This is the commit message #2: staging migration Signed-off-by: Dzmitry Lahoda <dzmitry@lahoda.pro> # This is the commit message #3: picasso # This is the commit message #4: yamlgit add .git add . # This is the commit message #5: fmt; reuse; clean Signed-off-by: Dzmitry Lahoda <dzmitry@lahoda.pro> # This is the commit message #6: trying replace nixops devnet # This is the commit message #7: fixed container # This is the commit message #8: zombies in compose # This is the commit message #9: getting routes # This is the commit message #10: ops mapping # This is the commit message #11: returned garbage for happy refactoring # This is the commit message #12: more # This is the commit message #13: revert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will introduce the first draft of the price server we are going to use for the oracle pallet.
Assuming we have pairs of assets such as
BTC/USD, we provide a HTTP endpointGET /price/BTC/USDfor the offchain worker.The returned object is of type
{ "timestamp": UNIXEPOCH, "value": price }wheretimestampis the time at which the latest price notification has been received.Why not directly use the pythd websocket or any other source directly? The offchain worker are targeting WASM and pyth-client is written in C++. C++ FFI for Rust is not supported by WASM target. More than that, the offchain worker is only able to fire HTTP calls, not anything more sophisticated such as websocket...
The other side of the server is connected to
pyth-clientdaemon and subscribe to price events for asset pairs. It only store the latest received (timestamped) price.Currently, the implementation handle only one feed, which is provided by the pyth daemon.
By default, I hardcoded the subscriptions because I don't know whether we want to make this thing more dynamic (perhaps cli option?).
When all the subscriptions are dropped, either because of network failure or because of pyth daemon, the server will gracefully exit; is this a desired behavior or should we make it crash?
If we want to handle multiple feeds, we will have to think about either merging the price directly at the server level (this involve some kind of synchronisation because for X feed, their latest price might be spaced by a bit of time?).
Finally, as you will notice, there is no tests yet... Because I don't really know how to test this kind of "networked" stuff (most of the code is synchronisation and networking stuff). Feel free to give me any advice :)!
NOTE:
If you want to test it out, you will have to use my patch of pyth-client, their JSONRPC implementation of subscription was... not common.
I provided a nix shell script inside the
price-feedsubdirectory that will make bothpythdandpyth_txrunning locally.