-
Notifications
You must be signed in to change notification settings - Fork 308
feat(hermes): add uniqueness check for benchmark price #1122
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,13 +97,22 @@ pub async fn get_vaa( | |
| .map(|bytes| base64_standard_engine.encode(bytes)) | ||
| .ok_or(RestError::UpdateDataNotFound)?; | ||
|
|
||
| let publish_time = price_feeds_with_update_data | ||
| let price_feed = price_feeds_with_update_data | ||
| .price_feeds | ||
| .get(0) | ||
| .ok_or(RestError::UpdateDataNotFound)? | ||
| .price_feed | ||
| .get_price_unchecked() | ||
| .publish_time; | ||
| .into_iter() | ||
| .next() | ||
| .ok_or(RestError::UpdateDataNotFound)?; | ||
|
|
||
| let publish_time = price_feed.price_feed.get_price_unchecked().publish_time; | ||
|
|
||
| // Currently Benchmarks API doesn't support returning the previous publish time. So we | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you expect the benchmark service to return 404 if not unique, why do we have this check here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This applies to the cache of Hermes. |
||
| // are assuming that it is doing the same filter as us and returns not found if the | ||
| // price update is not unique. | ||
| if let Some(prev_publish_time) = price_feed.prev_publish_time { | ||
| if prev_publish_time == price_feed.price_feed.get_price_unchecked().publish_time { | ||
| return Err(RestError::BenchmarkPriceNotUnique); | ||
| } | ||
| } | ||
|
|
||
| Ok(Json(GetVaaResponse { vaa, publish_time })) | ||
| } | ||
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.
is this comment also valid here?
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.
yeah i think they don't return it