Repository navigation
fix(distribute): mount orphaned pause module, unify StorageKey::Pause… - #1356
Open
Ahmad12developer wants to merge 1 commit into
Open
Ahmad12developer wants to merge 1 commit into
Ahmad12developer wants to merge 1 commit into
Conversation
|
@Ahmad12developer 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! 🚀 |
Contributor
|
Thanks for the contribution! We reviewed this PR while merging the open queue and couldn't merge it yet. Here's what needs fixing:
This branch also has merge conflicts with |
Ahmad12developer
force-pushed
the
fix/issue-1175-mount-distribute-pause
branch
from
October 15, 2026 15:07
0ba9b75 to
928e102
Compare
CalloraOrg#1175) Problem ------- distribute/src/pause.rs was not declared in lib.rs, leaving it orphaned as dead code. Additionally, it referenced CalloraDistribute and used limits::StorageKey::Paused, while Distribute in lib.rs stored the pause flag under bare Symbol("paused"). These two incompatible storage keys created a latent desynchronization bug where wiring the module would read a different key than the contract writes. Changes ------- * contracts/distribute/src/limits.rs: - Add StorageKey enum with the canonical Paused variant. * contracts/distribute/src/pause.rs: - Implement pause primitives (is_paused, set_paused, require_not_paused, pause, resume). - Wire reads and writes strictly to canonical StorageKey::Paused. - Implement transparent on-the-fly migration: if StorageKey::Paused is absent and legacy Symbol("paused") exists, migrate the boolean value to StorageKey::Paused and prune the legacy symbol key. - Ensure set_paused unconditionally purges any legacy Symbol("paused") key. - Add unit tests validating canonical key usage, symbol key pruning, lazy migration, idempotency, and circuit-breaker gating. * contracts/distribute/src/lib.rs: - Declare pub mod pause; so no undeclared .rs files remain in distribute/src. - Re-export pub use limits::StorageKey; and provide CalloraDistribute type alias. - Remove dead string constant PAUSED_KEY. - Update init, pause, unpause, get_paused, and distribution guards to use pause::set_paused, pause::is_paused, and pause::require_not_paused. - Expose is_paused view entrypoint alongside get_paused. - Make require_admin pub(crate) for internal module reuse. * contracts/distribute/src/test.rs & test_ttl.rs: - Add pause_and_unpause_use_single_storage_key_paused ensuring single key invariant. - Add legacy_symbol_key_migration_via_client verifying end-to-end lazy migration and event equivalence. - Fix type assertion in batch_distribute_total_overflow_returns_typed_error. - Fix test auth in ttl_instances_are_isolated. * contracts/distribute/tests/auth_snap.rs: - Add is_paused check in read_only_views_do_not_require_auth. - Add pause_and_unpause_single_key_invariant integration test. Acceptance Criteria Addressed ----------------------------- [x] Only one pause storage key exists (StorageKey::Paused) [x] No undeclared .rs files remain in distribute/src [x] Pause tests pass against the chosen key [x] Pause/unpause emit the same events regardless of which key is chosen Validation: cargo test -p callora-distribute pause (19/19 passed) Full suite: cargo test -p callora-distribute (87/87 passed) Closes CalloraOrg#1175
Ahmad12developer
force-pushed
the
fix/issue-1175-mount-distribute-pause
branch
from
October 16, 2026 20:02
928e102 to
4cd6531
Compare
Contributor
Author
|
@greatest0fallt1me Thank you for the feedback! I have completely re-implemented the distribute pause refactor on top of the latest
Ready for review! 🚀 |
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
Closes #1175
Problem
contracts/distribute/src/pause.rswas not declared inlib.rs, leaving it orphaned as dead code. Furthermore, it usedlimits::StorageKey::Paused, while the live contract inlib.rsstored the pause flag under rawSymbol("paused"). These two incompatible storage layouts created a latent desynchronization bug where wiring the module would read/write different on-ledger storage slots.Changes
StorageKeyenum with the canonicalPausedvariant.is_paused,set_paused,require_not_paused,pause, andresume.StorageKey::Paused.StorageKey::Pausedis absent and legacySymbol("paused")exists, migrate the boolean value toStorageKey::Pausedand prune the legacy symbol key.set_pausedunconditionally purges any legacySymbol("paused")key so only one pause key exists.pub mod pause;so no undeclared.rsfiles remain indistribute/src.pub use limits::StorageKey;and provideCalloraDistributetype alias.PAUSED_KEY.init,pause,unpause,get_paused, and distribution guards through thepausemodule.is_pausedview entrypoint alongsideget_paused.require_adminpub(crate)for module reuse.pause_and_unpause_use_single_storage_key_pausedensuring single key invariant.legacy_symbol_key_migration_via_clientverifying end-to-end lazy migration and event equivalence.batch_distribute_total_overflow_returns_typed_error.ttl_instances_are_isolated.is_pausedcheck inread_only_views_do_not_require_auth.pause_and_unpause_single_key_invariantintegration test.Acceptance Criteria
StorageKey::Paused)distribute/srcValidation
cargo test -p callora-distribute pause-> 19 passed; 0 failedcargo test -p callora-distribute-> 87 passed; 0 failed