Skip to content

fix(pulse): reset priceLastUpdatedAt when price IDs are added in updateSubscription #2674

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

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented May 12, 2025

Reset priceLastUpdatedAt when price IDs are added in updateSubscription

Description

This PR fixes an issue in the Scheduler.sol contract where priceLastUpdatedAt was not being reset when the priceIds list was added to in the updateSubscription function. This could prevent immediate calls to updatePriceFeeds after a subscription update because:

  1. heartbeatSeconds enforces a minimum time since priceLastUpdatedAt
  2. New price updates must have a publishTime greater than priceLastUpdatedAt

The fix modifies the _clearRemovedPriceUpdates function to return a boolean indicating whether price IDs have been added, and then resets priceLastUpdatedAt to 0 in updateSubscription when this occurs.

Changes

  • Modified _clearRemovedPriceUpdates to return a boolean indicating if price IDs were added
  • Added logic in updateSubscription to reset priceLastUpdatedAt to 0 when price IDs are added
  • Added a test case in PulseScheduler.t.sol to verify the fix works as expected

Testing

  • Added a new test testUpdateSubscriptionResetsPriceLastUpdatedAt that verifies:
    • priceLastUpdatedAt is reset to 0 when price IDs are added
    • Price updates can be processed immediately after a subscription update
    • Normal heartbeat criteria apply again for subsequent updates
  • All tests pass successfully

Requested by

Tejas Badadare (tejas@dourolabs.xyz)

Link to Devin run

https://app.devin.ai/sessions/143f676aadca48d8a5e491864dff0917

…ubscription

Co-Authored-By: Tejas Badadare <tejas@dourolabs.xyz>
Copy link

vercel bot commented May 12, 2025

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

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
entropy-debugger ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
entropy-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:38pm

Copy link
Contributor Author

🤖 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
Contributor Author

Closing due to inactivity for more than 7 days.

Comment on lines 134 to 144
bool priceIdsChanged = _clearRemovedPriceUpdates(
subscriptionId,
currentParams.priceIds,
newParams.priceIds
);

// Reset priceLastUpdatedAt to 0 if price IDs have changed
if (priceIdsChanged) {
_state.subscriptionStatuses[subscriptionId].priceLastUpdatedAt = 0;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be more accurate to reset priceLastUpdatedAt only when new prices are added (not just on any change to price ids.)

Co-Authored-By: Tejas Badadare <tejas@dourolabs.xyz>
@vercel vercel bot temporarily deployed to Preview – insights May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – staking May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – component-library May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-debugger May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals May 27, 2025 15:54 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-debugger May 27, 2025 16:20 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference May 27, 2025 16:20 Inactive
@vercel vercel bot temporarily deployed to Preview – insights May 27, 2025 16:20 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals May 27, 2025 16:20 Inactive
@vercel vercel bot temporarily deployed to Preview – staking May 27, 2025 16:20 Inactive
@vercel vercel bot temporarily deployed to Preview – component-library May 27, 2025 16:20 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer May 27, 2025 16:21 Inactive
@tejasbadadare tejasbadadare changed the title fix(pulse): reset priceLastUpdatedAt when price IDs change in updateSubscription fix(pulse): reset priceLastUpdatedAt when price IDs are added in updateSubscription May 27, 2025
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