Fix/issue referral cache invalidation - #189
Open
praizeD10 wants to merge 2 commits into
Open
Conversation
added 2 commits
August 24, 2026 12:44
…er cache The prediction_market contract cached HasReferrer per bettor at first bet and never invalidated it. A user who registered with no referrer, then later added one, would still be treated as having no referrer — referral fees were lost. Changes: - Implement referral_registry contract (was empty) with credit() that checks Referrer storage directly on every call - Remove HasReferrer cache from prediction_market entirely - Remove DataKey::HasReferrer variant - Always invoke referral contract to determine referrer status The referral contract now handles the no-referrer case by returning the fee to the bettor instead of sending it to the contract.
Muyideen-js
requested changes
Aug 24, 2026
Muyideen-js
left a comment
Contributor
There was a problem hiding this comment.
@praizeD10, the PR addresses the cache invalidation issue by removing the HasReferrer cache and checking Referrer storage directly. However, there are critical issues: 1) In prediction_market, the XLM transfer to the referral contract is missing; only invoke_contract is called, so the referral fee is never sent. 2) In referral_registry's credit(), the caller (market contract) is not authenticated via require_auth, allowing unauthorized calls. 3) No tests were added to verify the new behavior. 4) CI status is missing; please provide CI results. Please fix these issues and add tests before merging.
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.
closes #162
Problem
The prediction_market contract cached
HasReferrerper bettor at first betand never invalidated it. A user who registered with no referrer, then
later added one, would still be treated as having no referrer — referral
fees were silently returned to the bettor instead of paid to the referrer.
Solution
credit()thatchecks
Referrerstorage directly on every call — no cachingHasReferrercache from prediction_market entirelyDataKey::HasReferrervariantBehavior
Files Changed
referral_registry/src/lib.rs— full implementation (347 lines)prediction_market/src/lib.rs— removed cache, always invoke credit()