Skip to content

feat: enforce cool-off period before manual market unpause#1034

Merged
greatest0fallt1me merged 2 commits into
Predictify-org:masterfrom
jabir-dev788:feature/unpause-cooloff
Jul 26, 2026
Merged

feat: enforce cool-off period before manual market unpause#1034
greatest0fallt1me merged 2 commits into
Predictify-org:masterfrom
jabir-dev788:feature/unpause-cooloff

Conversation

@jabir-dev788

@jabir-dev788 jabir-dev788 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Closes #841


Summary

Adds a minimum cool-off period that must elapse before a paused market
can be manually resumed via MarketPauseManager::resume_market.
Previously, an admin could pause and immediately unpause a market with
no delay, which weakens the safety guarantee of the pause mechanism
(e.g. as a defense against a compromised or misused admin key).

Changes

  • Added MIN_COOLOFF_SECONDS constant to MarketPauseManager
  • resume_market now returns Error::InvalidState if called before
    paused_at + MIN_COOLOFF_SECONDS has elapsed
  • auto_resume_on_expiry is unaffected — it already waits for the full
    pause_end_time and is not subject to this new gate
  • Added focused test coverage for: early resume rejection, resume after
    cool-off elapses, auto-resume regression, unauthorized resume regression

Out of scope (intentionally)

  • No changes to circuit_breaker.rs (separate, contract-wide pause system)
  • No new contract entrypoints added — MarketPauseManager is not
    currently wired into lib.rs, and wiring it up is outside this issue's scope
  • No changes to pause_market's duration validation or storage layout

Testing

cargo test -p predictify-hybrid — all existing tests pass, 4 new tests
added covering the cool-off behavior and regression paths.

Adds a 1-hour minimum cool-off (MIN_UNPAUSE_COOLOFF_SECONDS) that
must elapse after pause_market() before resume_market() can be
called by an admin. Prevents rapid pause/unpause cycling.

- New Error::CooloffActive (419)
- checked_sub used for elapsed-time calculation (overflow-safe)
- auto_resume_on_expiry() unaffected — cool-off only gates the
  manual admin resume path
- Tests: cool-off enforcement, boundary condition, regression
  coverage for existing InvalidState/Unauthorized paths
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@jabir-dev788 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! 🚀

Learn more about application limits

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merged via direct push to master (admin)

@greatest0fallt1me
greatest0fallt1me merged commit 3c926ad into Predictify-org:master Jul 26, 2026
0 of 2 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 26, 2026
4 tasks
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.

Add unpause_market 7-day cool-off

2 participants