Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hermes/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hermes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hermes"
version = "0.4.2"
version = "0.4.3"
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions hermes/src/aggregate/wormhole_merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn construct_message_states_proofs(
}

pub fn construct_update_data(mut messages: Vec<RawMessageWithMerkleProof>) -> Result<Vec<Vec<u8>>> {
tracing::info!("Constructing update data for {} messages", messages.len());
tracing::debug!("Constructing update data for {} messages", messages.len());

messages.sort_by_key(|m| m.slot);

Expand All @@ -140,7 +140,7 @@ pub fn construct_update_data(mut messages: Vec<RawMessageWithMerkleProof>) -> Re
}
}

tracing::info!(
tracing::debug!(
slot = slot,
"Combining {} messages in a single updateData",
updates.len()
Expand Down
4 changes: 4 additions & 0 deletions hermes/src/api/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub use {
};

pub enum RestError {
BenchmarkPriceNotUnique,
UpdateDataNotFound,
CcipUpdateDataNotFound,
InvalidCCIPInput,
Expand All @@ -42,6 +43,9 @@ pub enum RestError {
impl IntoResponse for RestError {
fn into_response(self) -> Response {
match self {
RestError::BenchmarkPriceNotUnique => {
(StatusCode::NOT_FOUND, "Benchmark price is not unique").into_response()
}
RestError::UpdateDataNotFound => {
(StatusCode::NOT_FOUND, "Update data not found").into_response()
}
Expand Down
9 changes: 9 additions & 0 deletions hermes/src/api/rest/get_price_feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ pub async fn get_price_feed(
.next()
.ok_or(RestError::UpdateDataNotFound)?;

// Currently Benchmarks API doesn't support returning the previous publish time. So we
Copy link
Contributor

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?

Copy link
Collaborator Author

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

// 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);
}
}

// Note: This is a hack to get around the fact that Benchmark doesn't give per price feed
// update data. Since we request only for a single feed then the whole prices update data
// is this price feed update data.
Expand Down
21 changes: 15 additions & 6 deletions hermes/src/api/rest/get_vaa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 }))
}