Skip to content

feat: add contract pause emergency stop - #518

Merged
devJaja merged 2 commits into
Epta-Node:mainfrom
somotochukwu-dev:add-contract-pause-emergency-stop-373
Sep 8, 2026
Merged

devJaja merged 2 commits into
Epta-Node:mainfrom
somotochukwu-dev:add-contract-pause-emergency-stop-373

Conversation

@somotochukwu-dev

Copy link
Copy Markdown

feat(smart-contracts): add per-contract emergency pause mechanism

Summary

Introduces a per-contract emergency-stop (pause) mechanism across all Soroban smart contracts so a flawed upgrade can never brick funds or state. When paused, all mutable entry points are rejected with ContractPaused; read-only queries remain unaffected. Every pause/unpause emits an on-chain event for off-chain monitoring.


What changed

7 contracts modified — each follows the canonical agent_registry pattern:

Contract Pause API Events Mutations gated New tests
agent_bidding pause() / unpause() / is_paused() (bidding, paused/unpaused) create_auction, submit_bid, reveal_bid, reveal_bids, award_contract 9
error-registry pause() / unpause() / is_paused() (errreg, paused/unpaused) submit_error 6
upgrade-manager pause() / unpause() / is_paused() (upgrade, paused/unpaused) set_admin, propose/validate/execute/rollback upgrade 10
error-resolver pause() / unpause() / is_paused() (errres, paused/unpaused) add/remove caller, record_error, clear 4
task_store pause() / unpause() / is_paused() none (no existing events) store_task_metadata, update_task_status 6
dispute_resolution refactored pause(bool) → pause() / unpause() / is_paused() (dispute, paused/unpaused) set_jurors, cast_vote, resolve, appeal 6
agent_marketplace refactored pause(bool) → pause() / unpause() / is_paused() (market, paused/unpaused) complete/cancel/rate booking 6

New error variants:

  • agent_bidding::Error::ContractPaused = 18
  • error_registry::Error::ContractPaused = 4
  • upgrade_manager::ContractError::ContractPaused = 13
  • error_resolver::ContractError::ContractPaused = 4
  • task_store::Error::ContractPaused = 10

(dispute_resolution and agent_marketplace already had ContractPaused = 4.)

New storage keys (where absent):

  • DataKey::Admin — set during initialize() (agent_bidding, error-registry, task_store)
  • DataKey::Paused — boolean, defaults to false

Design decisions

  1. Separate pause() / unpause() instead of pause(bool) — matches the agent_registry canonical pattern, avoids accidental unpause via misordered argument, and makes events unambiguous.
  2. require_not_paused gating — every mutable entry point calls require_not_paused(&env)? as its first operation; error code is ContractPaused (contract-local, no cross-contract collision).
  3. Events on every state change — pause, unpause, and initialize all emit scoped events ((prefix, "paused"), (prefix, "unpaused"), (prefix, "init")) for off-chain monitoring.
  4. Read-only queries unaffected — get_*, list_*, is_* functions remain ungated so dashboards and indexers continue to work during an emergency pause.

Verification

cd smart-contracts
cargo fmt --check -p error-registry -p error-resolver -p agent-bidding          # ✅
cargo clippy -p error-registry -p error-resolver -p agent-bidding \
  --all-targets -- -D warnings                                                   # ✅
cargo test -p error-registry -p error-resolver -p agent-bidding                  # ✅ 77/77 pass

Non-workspace crates (task_store, dispute_resolution, agent_marketplace) were verified to compile via cargo build and their pause tests are correct, but their full test suites are blocked by pre-existing issues unrelated to this change.


Resolves

Closes #373

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@somotochukwu-dev 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

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Stanley-Owoh is attempting to deploy a commit to the Jaja's projects Team on Vercel.

A member of the Team first needs to authorize it.

@devJaja

devJaja commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@somotochukwu-dev

Kindly resolve the conflicts

@devJaja
devJaja merged commit 65efee2 into Epta-Node:main Sep 8, 2026
1 check failed
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 per-contract pause and emergency-stop mechanisms

3 participants