Skip to content

LIT-4207 - Implement node price re-fetching when running lit node commands #796

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

Merged
merged 4 commits into from
Feb 10, 2025

Conversation

MaximusHaximus
Copy link
Contributor

Description

Somewhere in all the code shuffling leading up to our current Naga branch, logic that re-fetched node prices was lost. This PR adds it back in.

Details:

  • Moved price feed info fetching to price-feed-info-manager module, which is responsible for handling caching of fetched data and concurrent requests to fetch the data
  • Only 1 fetch promise can be run at a time; concurrent requests chain on any existing pending promise that is already loading price feed data
  • Only fetches new data if it has been > 3 seconds since last fetch; since the nodes only update their on-chain price intermittently, this seems like a reasonable constraint to avoid hammering RPC multiple times per second even though the nodes only sync every few seconds.
  • Updated static method getPriceFeedInfo() on LitContracts class to use the new price feed info manager so any LitContracts SDK consumers get this behaviour
  • Removed tracking of nodePrices from LitCore/LitNodeClient since it would be duplicated state that is already being kept in the new manager module

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Ran local-tests against current lit-assets 'stable' naga commit

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

- Removed unused imports
- Sorted imports
…ce-feed-info-manager` module

- Only 1 fetch promise can be run at a time; concurrent requests chain on pending promises
- Only fetches new data if it has been > 3 seconds since last fetch
- Updated static method `getPriceFeedInfo()` on LitContracts class to use the manager so all consumers get this behaviour
- Export the raw helper functions for consumption by other classes
…om LitCore/LitNodeClient; use price-feed-info-manager instead

- Removed `nodePrices` array from `LitCore` config state; this would be redundant since we cache price feed info in the manager module now
- Update `getMaxPricesForNodeProduct()` on `LitNodeClient` to be an async method, since it will sometimes fetch new prices
- CHORE: Removed unused access control method imports from `lit-node-client-nodejs.ts`
- CHORE: Removed duplicate `export * from...` in constants/index.ts
- Added private `_getNodePrices()` method to LitNodeClient that calls the new `price-feed-info-manager` method w/ args from the current client config
@Ansonhkg Ansonhkg merged commit 1196d13 into feat/naga-fix-bls-wasm-cleanup Feb 10, 2025
3 of 4 checks passed
@Ansonhkg Ansonhkg deleted the LIT-4207-refresh-node-prices branch February 10, 2025 15:44
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.

2 participants