fix(subscriptions): enforce minimum interval_seconds to prevent allowance draining (#47) - #73
Open
ghzhost wants to merge 1 commit into
Open
Conversation
…ance draining (StellarSend#47) - Define MIN_SUBSCRIPTION_INTERVAL_SECS = 60s named constant in SubscriptionService - Reject create requests with interval_seconds < MIN_SUBSCRIPTION_INTERVAL_SECS with AppError::Validation - Add migration 012_min_subscription_interval.sql adding CHECK (interval_seconds >= 60) - Add unit test verifying MIN_SUBSCRIPTION_INTERVAL_SECS bound
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #47 by establishing a minimum interval constraint on recurring subscriptions (
interval_seconds >= 60).Context & Problem
Previously,
SubscriptionService::createonly checkedinterval_seconds <= 0and the database migration hadCHECK (interval_seconds > 0). A subscription created withinterval_seconds = 1would become due again immediately after execution, causing the keeper background loop to repeatedly execute against the payer's on-chain allowance on every single poll pass.Solution
pub const MIN_SUBSCRIPTION_INTERVAL_SECS: i64 = 60;inSubscriptionService.SubscriptionService::createnow returnsAppError::Validationwhenreq.interval_seconds < MIN_SUBSCRIPTION_INTERVAL_SECS.migrations/012_min_subscription_interval.sqlupdating theCHECKconstraint onsubscriptions.interval_secondsto enforce>= 60.MIN_SUBSCRIPTION_INTERVAL_SECSbound is configured properly.Closes #47