feat(circle): add configurable cooldown period between payout rounds - #187
Open
fridaypetra55-afk wants to merge 1 commit into
Open
feat(circle): add configurable cooldown period between payout rounds#187fridaypetra55-afk wants to merge 1 commit into
fridaypetra55-afk wants to merge 1 commit into
Conversation
trigger_payout could previously be called back-to-back with no minimum interval between rounds. Adds payout_cooldown_seconds to CircleConfig/Circle (defaults to 0, i.e. no cooldown, for existing callers that don't set it) and last_payout_timestamp to Circle, updated on every successful payout. trigger_payout now rejects with the new CircleError::PayoutCooldownActive if called again before last_payout_timestamp + payout_cooldown_seconds has elapsed. The first payout of a circle (current_round == 0) is never gated, since there's no prior round to cool down from. Adds test_trigger_payout_enforces_cooldown_between_rounds, which verifies a second round's payout is rejected immediately after the first and succeeds once the cooldown window has elapsed. Also fixes the same pre-existing, unrelated `Ok()` -> `Ok(())` compile break in this file described in cocor-tech#117's PR (confirmed present on a clean checkout of upstream/master) — required to build/test this change in isolation. Closes cocor-tech#115
|
@fridaypetra55-afk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
payout_cooldown_seconds: u64toCircleConfig/Circleandlast_payout_timestamp: u64toCircle(updated on every successfultrigger_payout).trigger_payoutnow rejects with the newCircleError::PayoutCooldownActiveif called again beforelast_payout_timestamp + payout_cooldown_secondshas elapsed since the previous round's payout.current_round == 0) is never gated — there's no prior round to cool down from, andlast_payout_timestampdefaults to0, which would otherwise collide with a genuine ledger timestamp of0in tests.payout_cooldown_secondsdefaults to0(no cooldown), so this is opt-in and backward compatible with existing configs/behavior when left unset.test_trigger_payout_enforces_cooldown_between_rounds: triggers round 0's payout, immediately attempts round 1's payout (expectsPayoutCooldownActive), advances the ledger clock past the cooldown window, and confirms the payout then succeeds.Note on a pre-existing, unrelated build break
Same as noted in #117's PR:
packages/circle/src/contract.rscurrently fails to compile onmaster(confirmed on a cleanupstream/mastercheckout) because 15 functions end their body with the bareOk()instead ofOk(()). Fixed here too since this PR also has to touch and build this file. If #117 merges first, this branch will need a rebase to drop the now-redundant part of that fix — that's expected for two PRs concurrently touching the same file.cargo build -p circleandcargo test -p circleboth pass locally (6/6 tests, including the new one). Test snapshot JSON diffs for existing tests are just the newCirclestruct fields showing up in ledger storage entries.Closes #115