Repository navigation
fix(amm): eliminate duplicate unlock calls and pre-panic unlocks [SC-… - #1991
Open
thelmaoffiong wants to merge 1 commit into
Open
thelmaoffiong wants to merge 1 commit into
thelmaoffiong wants to merge 1 commit into
Conversation
…059] Redundant Self::unlock(&env) calls appeared at the end of add_liquidity, remove_liquidity, swap_a_for_b, and swap_b_for_a — the result of copy-paste from an earlier pattern where unlock preceded the return statement, then a second was added before the event emission without removing the first. Additionally, manual Self::unlock calls before panic_with_error! in every early-exit path were removed. In Soroban, panic_with_error! triggers a host trap that rolls back all storage changes for the current invocation, so temporary storage written by Self::lock is automatically discarded; a manual unlock before the panic is not only redundant but creates a window where the guard is absent while execution is still live. Changes: - Remove duplicate trailing Self::unlock in add_liquidity, remove_liquidity, swap_a_for_b, and swap_b_for_a (each now has exactly one unlock at the single successful-exit point). - Remove Self::unlock calls that preceded every panic_with_error! in those four functions; the transaction rollback is the correct cleanup mechanism. - Add seven fuzz-style tests in test.rs verifying that the reentrancy mutex key (RG_KEY) is absent from temporary storage after every operation, whether the call succeeds or fails. Closes StellarDevHub#1856
|
@thelmaoffiong is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@thelmaoffiong 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 branch has not been deployed
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.
Redundant Self::unlock(&env) calls appeared at the end of add_liquidity, remove_liquidity, swap_a_for_b, and swap_b_for_a — the result of copy-paste from an earlier pattern where unlock preceded the return statement, then a second was added before the event emission without removing the first.
Additionally, manual Self::unlock calls before panic_with_error! in every early-exit path were removed. In Soroban, panic_with_error! triggers a host trap that rolls back all storage changes for the current invocation, so temporary storage written by Self::lock is automatically discarded; a manual unlock before the panic is not only redundant but creates a window where the guard is absent while execution is still live.
Changes:
Closes #1856