Skip to content

feat: add revocable trusted contract authorization - #115

Open
afeezorobsco-cyber wants to merge 5 commits into
SPulse-Org:mainfrom
afeezorobsco-cyber:feat/revocable-trusted-contracts
Open

feat: add revocable trusted contract authorization#115
afeezorobsco-cyber wants to merge 5 commits into
SPulse-Org:mainfrom
afeezorobsco-cyber:feat/revocable-trusted-contracts

Conversation

@afeezorobsco-cyber

Copy link
Copy Markdown

##close #85

Summary

Introduces explicit revocation and restoration for trusted cross-contract dependencies.

Previously, trusted contract addresses could be replaced but there was no explicit emergency state in which a dependency could be completely disabled. This change adds revocable trust while preserving existing authorization behavior when dependencies are enabled.

Changes

  • Added explicit enabled/revoked trust state.
  • Added authorized revoke/restore management operations.
  • Protected privileged cross-contract paths against revoked dependencies.
  • Prevented revoked contracts from restoring their own authority.
  • Added typed failures for revoked dependencies.
  • Added trust-state events/readers where appropriate.
  • Preserved existing admin/multisig authorization semantics.
  • Added comprehensive revocation/restoration tests.
  • Documented emergency trust revocation and recovery procedures.

Security

A revoked trusted contract has no privileged authority until explicitly restored by the authorized administrator/multisig.

Revocation is distinct from replacement: the system can enter a deliberate state where no contract is trusted for a capability.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Issue

Closes #[ISSUE_NUMBER]

Cap lives in pulse_token::mint() (DataKey::MaxSupply, instance storage) so every
authorized minter - leaderboard reward/reward_bonus or any future minter -
shares one global ceiling. Result is computed via i128::checked_add before any
write; over-cap or overflow mints reject with MaxSupplyExceeded (SPulse-Org#7) leaving
balance and total_supply untouched. No authoritative tokenomics value exists in
the repo, so the cap is deployer-supplied via initialize(_, max_supply); legacy
instances fail closed until admin declares a cap through set_max_supply, an
admin-only one-way ratchet (cannot raise, cannot go below current supply).

Closes issue SPulse-Org#34.
Market, Bet, Payout, and bettor-index entries in persistent storage could
expire before claim/refund, permanently locking user funds (issue SPulse-Org#9).
Add read-time TTL refresh: claim now also bumps the winner's Payout key,
resolve_market bumps the bettor index/Bets/Payouts it walks, and the
user-facing views (get_market/get_bet/get_payout/get_market_bettors_page)
re-arm the entries they read. Every bump reuses the existing TTL_BUMP/TTL_HIGH
constants; missing/expired state keeps its not-found semantics. Already-expired
entries cannot be resurrected by design.
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.

[HIGH] Trust model has no revocation — a compromised or malicious trusted contract can never be removed

1 participant