fix(referral): mitigate cross-contract reentrancy in distribute_rewards - #70
Merged
merlik787-droi merged 1 commit intoJul 22, 2026
Conversation
Spaully
force-pushed
the
fix/issue-16-reentrancy-protection
branch
3 times, most recently
from
July 22, 2026 10:35
2c6b01b to
aa1547f
Compare
Add reentrancy guard to prevent reentrant calls during token transfers: - Add ReentrancyGuard storage key - Add acquire_guard/release_guard helper functions - Guard is acquired before external token_client.transfer calls - Guard is released after all transfers complete - Panic with 'Reentrancy detected' if guard is already held Update distribute_rewards to: - Use reentrancy guard around external calls - Keep inline event emissions (event module is separate PR) Add test to verify guard is properly released after distribution. Implements Issue Riddlrealm#16
Spaully
force-pushed
the
fix/issue-16-reentrancy-protection
branch
from
July 22, 2026 10:41
aa1547f to
e9b5a57
Compare
3 tasks
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
Add reentrancy guard to prevent reentrant calls during token transfers in
distribute_rewards.Changes
ReentrancyGuardstorage keyacquire_guard/release_guardhelper functionstoken_client.transfercallsReentrancy detectedif guard is already helddistribute_rewards updates
event::emitmodule for consistent event emissionsTests
test_reentrancy_guard_released_after_distribution: verifies guard is properly releasedCloses #16