Skip to content
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

fix: ready endpoint already checks for fully hydrated cache #2553

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Apr 3, 2025

Add is_ready() Method to Cache Trait and Update Ready Endpoint

Description

This PR updates the Hermes /ready endpoint to return OK only when the cache is fully hydrated by:

  1. Adding a new is_ready() method to the Cache trait that checks if the cache contains sufficient data to serve requests
  2. Updating the /ready endpoint to check both the aggregate readiness and cache readiness
  3. Enhancing the response metadata to include both readiness states

The cache is now considered fully hydrated when all of the following conditions are met:

  • has_completed_recently: The latest completed update is recent (within the staleness threshold)
  • is_not_behind: The latest completed slot isn't too far behind the latest observed slot
  • is_metadata_loaded: Price feeds metadata is not empty
  • The cache contains sufficient data to serve requests (checked via the new Cache::is_ready() method)

Link to Devin run

https://app.devin.ai/sessions/7467a93d13ab41adb52d38f5d6404e21

Requested by

Tejas Badadare ([email protected])

Copy link
Contributor Author

devin-ai-integration bot commented Apr 3, 2025

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

vercel bot commented Apr 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2025 6:51pm
component-library ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2025 6:51pm
entropy-debugger ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2025 6:51pm
insights ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2025 6:51pm
proposals ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2025 6:51pm
staking ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2025 6:51pm

Comment on lines 279 to 282
async fn is_cache_ready(&self) -> bool {
let message_cache = self.into().message_cache.read().await;
!message_cache.is_empty()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache should be considered "ready" if it's full, not just if it's non-empty. See the store_accumulator_messages() impl for an example of checking if the cache is full.

@@ -274,6 +275,14 @@ where
let cache = self.into().wormhole_merkle_state_cache.read().await;
Ok(cache.get(&slot).cloned())
}

///
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot to finish this docstring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant