Skip to content

Expire and protect pending emergency drain proposals #1160

Closed

Description

@greatest0fallt1me

Summary

propose_emergency_drain overwrites any existing PendingEmergencyDrain silently, and proposals never expire once execute_after passes.

Why this matters

An old drain proposal to a since-compromised treasury remains executable indefinitely, and a replacement proposal resets nothing visible to watchers because no 'replaced' signal is emitted.

Scope

Reject proposing while one is pending (require cancel first) or emit a drain_replaced event; add expires_at with a bounded grace window and a dedicated error when executing after expiry.

Relevant code in CalloraOrg/Callora-Contracts:

  • contracts/revenue_pool/src/lib.rs
  • contracts/revenue_pool/src/emergency.rs

Priority

Medium

Acceptance criteria

  • Second propose without cancel fails or emits replacement event
  • Execution after expiry fails and clears the proposal
  • PendingEmergencyDrain exposes expiry
  • Tests cover both behaviours

Validation

cargo test -p callora-revenue-pool emergency

Non-goals

  • Typo-only, formatting-only, or cosmetic changes.
  • Unrelated refactors, dependency upgrades, or broad rewrites.
  • Removing safeguards or weakening validation to make tests pass.

Contributor application

Before coding, describe the affected modules, proposed state/invariant changes, test strategy, compatibility considerations, and an estimate. Wait for assignment before starting implementation.

PR requirements

Use a feature branch and include Closes #<issue-number>. Address every criterion, map criteria to code and tests, explain security and failure-mode handling, and ensure CI passes.

Quality review

A maintainer will assess correctness, completeness, test depth, compatibility, observability, and adverse-case handling. A substantive implementation is required; merge or CI status alone does not guarantee reward eligibility.


Generated by Claude Code

Activity

  1. changed the title [-]Keep leaderboard rank pages deterministic[/-] [+]Add focused test coverage for contracts/hot/tests/auth_snap.rs[/+] on Sep 27, 2026
  2. changed the title [-]Add focused test coverage for contracts/hot/tests/auth_snap.rs[/-] [+]Expire and protect pending emergency drain proposals[/+] on Sep 27, 2026
  3. michljoe commented on Sep 29, 2026

    @michljoe

    @michljoe has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    I would like to work on this issue because, I’ve reviewed the issue details and understand what needs to be done. I’m confident I can work toward resolving it and would appreciate the opportunity to contribute.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @michljoe to this issue.

  4. doncharlie commented on Sep 30, 2026

    @doncharlie
    Contributor

    @doncharlie has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Please Let me work on this issue, I will deliver it ASAP.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @doncharlie to this issue.

  5. MrNova50 commented on Sep 30, 2026

    @MrNova50

    @MrNova50 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    would solve before wave ends kindly assign

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @MrNova50 to this issue.

  6. Rodrigoue9 commented on Oct 3, 2026

    @Rodrigoue9

    Hi @maintainers! I'd like to work on this issue. Here is my proposed technical approach:

    Proposed Technical Approach:

    1. Contract Logic Implementation: Implement the required Soroban smart contract logic in Rust, ensuring strict validation, authorization checks (require_auth), and gas optimization.
    2. Storage Layout & State Management: Maintain safe data key patterns, TTL management, and prevent state inconsistency or unauthorized state mutations.
    3. Events & Error Encoding: Emit strongly typed contract events and return descriptive custom errors for all failure modes.
    4. Comprehensive Test Vectors: Implement Rust unit and integration tests using soroban-sdk::Env verifying both success and failure execution paths.

    Key Files:

    • contracts/**/src/lib.rs (contract entrypoints and interface implementations)
    • contracts/**/src/types.rs or storage.rs (types, data keys, and state)
    • contracts/**/src/test.rs (unit tests and integration vectors)

    Verification & Testing:

    • Run cargo test across all contract crates verifying 100% pass rate.
    • Run cargo clippy --all-targets -- -D warnings and cargo fmt --check.
    • Verify Soroban WASM build: soroban contract build.

    Relevant Track Record:

    I have successfully implemented and merged multiple production PRs across the Stellar ecosystem and Web3 open-source projects (e.g., Bitcoindefi/OpenAO #218, cybermax4200/stellar-did-credit #898 & #900, and FindMalek/sonaraem #416).

    Please feel free to assign this issue to me so I can proceed with the implementation. Thank you!

  7. rupesh-kumar-sah commented on Oct 7, 2026

    @rupesh-kumar-sah

    Hi maintainers,

    I reviewed this issue and would like to contribute the fix.

    Implementation approach:

    1. Audit storage layout and state invariants ensuring strict auth guards.
    2. Implement deterministic state transitions with safe checked arithmetic.
    3. Add hermetic unit and regression tests covering authorized, unauthorized, and boundary edge cases.
    4. Profile instruction and CPU/gas limits under Soroban host environment.

    Could you please assign this issue to me? Looking forward to delivering a clean PR.

  8. spartan124 commented on Oct 16, 2026

    @spartan124

    @spartan124 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I have strong experience with Soroban smart contract development, timelock patterns, and state lifecycle validation in Rust.
    Approach:

    1. Update PendingEmergencyDrain in contracts/revenue_pool/src/emergency.rs to include an explicit expires_at timestamp.
    2. In propose_emergency_drain, reject new proposals if an active, unexpired proposal exists (requiring explicit cancellation first) or emit a dedicated drain_replaced event.
    3. In execute_emergency_drain, verify env.ledger().timestamp() <= proposal.expires_at, failing with a dedicated error (e.g., DrainProposalExpired) and clearing the expired record.
    4. Add unit and integration tests covering the rejection/replacement behavior, expiration enforcement, and state cleanup via cargo test -p callora-revenue-pool emergency.
      ETA: 2–3 hours

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @spartan124 to this issue.

  9. Dannnyhamps commented on Oct 16, 2026

    @Dannnyhamps

    @Dannnyhamps has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi maintainer, I've reviewed the issue and would like to work on it

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Dannnyhamps to this issue.

  10. lienhoatienphung-svg commented on Oct 16, 2026

    @lienhoatienphung-svg

    Hi! I have implemented and verified this in #1382 with full unit test coverage and rustfmt compliance.

  11. Codex723 commented on Oct 16, 2026

    @Codex723

    @Codex723 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I’d love to secure emergency drain proposals by preventing silent overwrites, enforcing expiry, and testing cancellation and cleanup paths; I estimate 2–3 hours for the implementation and tests, so kindly assign it to me.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Codex723 to this issue.

  12. devcarole commented on Oct 17, 2026

    @devcarole

    @devcarole has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I will like to work on this issue. Please assign to me. Thank you.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @devcarole to this issue.

  13. jamal-exe commented on Oct 17, 2026

    @jamal-exe

    @jamal-exe has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi, I’ve carefully examined the issue details and requirements, and I’m confident I can develop a clean, efficient, and maintainable solution. I’ll make sure to consider the existing implementation, follow the project’s conventions, and properly validate the changes before submitting my contribution.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @jamal-exe to this issue.

  14. CodingBabe-1 commented on Oct 18, 2026

    @CodingBabe-1

    @CodingBabe-1 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I would love to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @CodingBabe-1 to this issue.

  15. salimguga247-dotcom commented on Oct 18, 2026

    @salimguga247-dotcom

    @salimguga247-dotcom has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @salimguga247-dotcom to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveStellar Wave Program issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions