Merge/pr 467 - #509
Merged
Merged
Conversation
- 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
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 #
Changes
Testing
Checklist
cargo fmtappliedcargo clippy --features testutils -- -D warningspassescargo test --features testutilspassesCHANGELOG.mdupdated under[Unreleased]closes #467