-
Notifications
You must be signed in to change notification settings - Fork 306
feat(pulse-scheduler): add permanent subscriptions, allow permissionless funding, clean up tests #2593
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
feat(pulse-scheduler): add permanent subscriptions, allow permissionless funding, clean up tests #2593
Changes from 1 commit
3ef5e7f
6e4ccc2
f2989ab
06833ca
a35f4a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,33 @@ abstract contract Scheduler is IScheduler, SchedulerState { | |
| bool wasActive = currentParams.isActive; | ||
| bool willBeActive = newParams.isActive; | ||
|
|
||
| // Check for permanent subscription restrictions | ||
| if (currentParams.isPermanent) { | ||
| // Cannot disable isPermanent flag once set | ||
| if (!newParams.isPermanent) { | ||
| revert IllegalPermanentSubscriptionModification(); | ||
| } | ||
|
|
||
| // Cannot remove price feeds from a permanent subscription | ||
| if (newParams.priceIds.length < currentParams.priceIds.length) { | ||
| revert IllegalPermanentSubscriptionModification(); | ||
| } | ||
|
|
||
| // Check that all existing price IDs are preserved | ||
| for (uint i = 0; i < currentParams.priceIds.length; i++) { | ||
| bool found = false; | ||
| for (uint j = 0; j < newParams.priceIds.length; j++) { | ||
| if (currentParams.priceIds[i] == newParams.priceIds[j]) { | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| if (!found) { | ||
| revert IllegalPermanentSubscriptionModification(); | ||
| } | ||
| } | ||
| } | ||
|
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. I think you can also effectively disable a subscription by (1) changing the readerWhitelist or (2) making the gas config so limiting that no tx ever lands on chain? 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. hmm I think you could also do it by changing the updateCriteria 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. yeah good points -- will disallow changing the whitelist or the config. truly "permanent." 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. just realized they can also just set isActive to false 🤦 updated |
||
|
|
||
| // If subscription is inactive and will remain inactive, no need to validate parameters | ||
| if (!wasActive && !willBeActive) { | ||
| // Update subscription parameters | ||
|
|
@@ -487,9 +514,7 @@ abstract contract Scheduler is IScheduler, SchedulerState { | |
|
|
||
| /// BALANCE MANAGEMENT | ||
|
|
||
| function addFunds( | ||
| uint256 subscriptionId | ||
| ) external payable override onlyManager(subscriptionId) { | ||
| function addFunds(uint256 subscriptionId) external payable override { | ||
| if (!_state.subscriptionParams[subscriptionId].isActive) { | ||
| revert InactiveSubscription(); | ||
| } | ||
|
|
@@ -508,6 +533,11 @@ abstract contract Scheduler is IScheduler, SchedulerState { | |
| subscriptionId | ||
| ]; | ||
|
|
||
| // Prevent withdrawals from permanent subscriptions | ||
| if (params.isPermanent) { | ||
| revert IllegalPermanentSubscriptionModification(); | ||
| } | ||
|
|
||
| if (status.balanceInWei < amount) { | ||
| revert InsufficientBalance(); | ||
| } | ||
|
|
||
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.
Heh, we're stuck doing an m x n linear search in Solidity?
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.
we cant create in-memory hashmaps so yeah, back to the basics 🫠