Fix/pausability invariants concurrency verification - #1013
Merged
Junirezz merged 5 commits intoJul 28, 2026
Merged
Conversation
|
@Mosas2000 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! 🚀 |
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
This pull request addresses and resolves four open issues across the Soroban smart contracts and Node/TypeScript backend in YieldVault-RWA:
#960: Implement role-restricted pausability controls allowing a designated Pauser address alongside Admin.$P_{t+1} \ge P_t$ ).
#959: Add unit and property-based invariant test coverage asserting share-price monotonicity (
#957: Introduce optimistic concurrency controls (OCC) in the backend persistence layer.
#968: Add formal verification specifications and executable invariant tests for critical accounting logic.
Issue Breakdowns & Changes Implemented
Role Assignment: Added DataKey::Pauser in DataKey enum and implemented set_pauser(env, pauser) (admin-only) and pauser(env) query.
Role-Restricted Execution: Added pause_with_role(env, caller, reason) and unpause_with_role(env, caller) functions enforcing authorization via permissions::require_pauser_or_admin_auth.
Test Coverage: Added test_role_restricted_pausability_controls in contracts/vault/src/feature_tests.rs.
Vault Invariant Suite: Added test_invariant_share_price_monotonicity_under_yield_accrual and test_invariant_share_price_monotonicity_under_deposits_and_withdrawals in contracts/vault/src/invariant_tests.rs.
Math Fuzz Assertions: Extended contracts/share-price-math/src/fuzz_invariants.rs to assert
Schema Extensions: Added version Int @default(1) column to stateful models (VaultState, BulkExportJob, WebhookEndpoint, EmailQueue, TransactionBackfillJob) in backend/prisma/schema.prisma.
OCC Handler & Retries: Implemented OptimisticConcurrencyError, assertVersionMatch, and executeWithOptimisticConcurrency with exponential backoff and randomized jitter in backend/src/optimisticConcurrency.ts.
Test Coverage: Created backend/src/tests/optimisticConcurrency.test.ts covering version matching, collision detection, and retry bounds.
Mathematical Specification: Created docs/FORMAL_VERIFICATION_ACCOUNTING.md documenting formal theorems for share conversion, share-price monotonicity, solvency bounds, and round-trip loss invariants.
Executable Formal Property Suite: Created contracts/vault/src/formal_verification_tests.rs verifying Theorems 1–3 in Soroban contract tests.
Architecture References: Updated docs/CONTRACTS_ARCHITECTURE.md to index formal verification notes.
Related Issues
Closes Contract: Implement pausability controls with role-restricted access #960
Closes Contract: Add invariant tests for share-price monotonicity #959
Closes Backend: Introduce optimistic concurrency controls in persistence layer #957
Closes Contract: Add formal verification notes for critical accounting logic #968