Skip to content

fix: unpause() clears AutoPaused to prevent stuck contract (#452) - #710

Open
Nife-tanny wants to merge 2 commits into
Iris-IV:mainfrom
Nife-tanny:fix/unpause_auto_paused
Open

fix: unpause() clears AutoPaused to prevent stuck contract (#452)#710
Nife-tanny wants to merge 2 commits into
Iris-IV:mainfrom
Nife-tanny:fix/unpause_auto_paused

Conversation

@Nife-tanny

Copy link
Copy Markdown

Description

Fixes the contract getting stuck in an auto-paused state when the campaign that triggered the automatic pause is subsequently cancelled.

Root Cause

When a burst contribution triggers an automatic pause, resume_campaign calls require_active_campaign before clearing the AutoPaused flag. If the triggering campaign is cancelled (making it inactive), resume_campaign fails at the require_active_campaign check, leaving AutoPaused permanently true with no way to clear it — the contract is stuck.

Fix

Updated unpause() in src/admin.rs to clear both pause flags:

env.storage().instance().set(&AdminKey::Paused, &false);
env.storage().instance().set(&AdminKey::AutoPaused, &false);

Previously unpause() only cleared Paused, leaving AutoPaused untouched with no public recovery path.

Changes

  • src/admin.rs: Added env.storage().instance().set(&AdminKey::AutoPaused, &false); to unpause()
  • CHANGELOG.md: Added entry for the fix under [Unreleased]### Fixed
  • Authorization unchanged — assert_admin still gates the function
  • Storage pattern matches existing conventions (instance storage, TTL bump before writes)
  • Event emission unchanged

Tests

The existing regression test test_unpause_clears_auto_pause_when_resume_campaign_blocked in src/tests/test_campaigns.rs validates:

  1. AutoPaused = true → operations blocked
  2. unpause() called → both flags cleared
  3. Operations resume successfully
  4. resume_campaign still fails for cancelled campaigns (unchanged behavior)
  5. Contract fully operational after unpause()

Closes #452

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.

[Bug] resume_campaign requires active campaign to clear global AutoPaused — contract can get permanently stuck

1 participant