Skip to content

Merge/pr 467 - #509

Merged
FaveTeamz merged 3 commits into
mainfrom
merge/pr-467
Aug 1, 2026
Merged

Merge/pr 467#509
FaveTeamz merged 3 commits into
mainfrom
merge/pr-467

Conversation

@FaveTeamz

Copy link
Copy Markdown
Owner

Summary

Closes #

Changes

Testing

Checklist

  • cargo fmt applied
  • cargo clippy --features testutils -- -D warnings passes
  • cargo test --features testutils passes
  • New tests added for new behaviour
  • CHANGELOG.md updated under [Unreleased]
  • Docs updated if public API or behaviour changed

closes #467

ola196 and others added 3 commits July 27, 2026 14:52
- Add ContractError::CapOutOfRange (code 12) to errors.rs
- Add get_global_cap() / set_global_cap() persistent storage helpers
  to storage.rs with key 'g_cap'; falls back to GLOBAL_APP_LIMIT (15)
  when no override is stored
- Add emit_emergency_cap_updated() event helper to events.rs,
  publishing topic 'emrg_cap' with (old_cap, new_cap) data;
  intentionally distinct from any GlobalCapUpdated event
- Implement emergency_set_global_cap(admin, new_cap) in lib.rs:
  - Requires admin auth
  - Validates new_cap in [0, 100], returns CapOutOfRange (12) otherwise
  - Reads old cap, persists new cap, bumps instance TTL
  - Emits EmergencyCapUpdated event
- Wire apply_for_issue, get_global_application_capacity, and
  is_global_application_limit_reached to use get_global_cap()
  so emergency overrides take effect immediately
- Create docs/runbooks/cap-emergency-increase.md with:
  - When-to-use criteria
  - Triage checklist and two-approver matrix (testnet vs mainnet)
  - Pre-flight, invoke, and verify execution steps
  - Rollback procedure with caveat on existing applications
  - Monitoring alert: EmergencyCapChangedFrequently (>2 emrg_cap
    events in 24 h = P1)
  - Post-incident actions

Closes #355
Add sequential state-transition invariant property tests covering all
apply/withdraw and assign/complete/revoke operation sequences.

Rust (proptest):
- prop_global_count_invariant_sequence: drives arbitrary apply/withdraw
  sequences against a BTreeSet reference model, asserts
  get_global_application_count == |active applications| at every step.
- prop_org_count_invariant_sequence: drives arbitrary apply/assign/
  complete/revoke sequences, asserts get_org_assignment_count ==
  |active assignments| at every step.
Both run 1 000 cases with sequences of up to 60 operations; any
counterexample is automatically shrunk by proptest.

TypeScript (fast-check):
- prop_global_app_limit.test.ts: 5 properties × 1 000 cases covering
  count invariant, hard ceiling, apply-withdraw no-op, reject on
  non-existent withdraw, and reject at cap.
- prop_org_assign_limit.test.ts: 6 properties × 1 000 cases covering
  count invariant, org cap ceiling, assign-complete/revoke no-op,
  reject at cap, and reject on non-existent complete/revoke.

Bug fixes included in this commit:
- Fix BTreeSet::size_hint() (iterator method) → .len() in
  prop_org_count_invariant_sequence (would have failed to compile).
- Rename is_global_application_limit_reached →
  is_global_app_limit_reached to stay within the Soroban 32-char
  contract function name limit.
- Run cargo update to resolve transitive rand 0.8/0.9 version conflict
  introduced by proptest pulling rand 0.9.

Closes #354
- CHANGELOG.md: merged both sets of additions; kept HEAD API server entries
  plus PR #467's prop-test and rename entries; added 'Changed' section for
  is_global_app_limit_reached rename
- Cargo.lock: took PR #467 version (newer rand 0.8.7)
- docs/runbooks/cap-emergency-increase.md: took PR #467's detailed runbook
- src/errors.rs: kept CapOutOfRange=12 and MaintainerNotFound=17 from PR #467
- src/events.rs: removed duplicate emit_emergency_cap_updated (old single-arg
  version); kept PR #467 version with (old_cap, new_cap) signature; removed
  duplicate emit_maintainer_deregistered
- src/lib.rs: kept set_global_cap from HEAD; updated InvalidCap -> CapOutOfRange;
  used PR #467 detailed docstring for emergency_set_global_cap; used old_cap
  signature for emit_emergency_cap_updated; renamed global_app_limit_reached ->
  is_global_app_limit_reached; added seed_assignment test helper
- src/storage.rs: kept HEAD's full storage (global_cap + org_cap); removed
  duplicate global_cap block added by PR #467
- src/test.rs: kept all HEAD tests; appended PR #467's sequential invariant
  prop tests (prop_global_count_invariant_sequence, prop_org_count_invariant_sequence)
- tests/unit/prop_global_app_limit.test.ts: took PR #467's improved model
- tests/unit/prop_org_assign_limit.test.ts: took PR #467's improved model
@FaveTeamz
FaveTeamz merged commit 3e4832f into main Aug 1, 2026
1 of 17 checks passed
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.

2 participants