fix(indexer): restore dense-competitive RANK on referrer leaderboard (GitLab #204) #390
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega!390
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/glab-204-dense-rank-window-regression"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes by fixing the regression flagged in #204 note 3350384677.
What this changes
Removes the
r.referrer ASCtiebreaker from theRANK() OVER (ORDER BY ...)window inindexer/src/api.rs:1921. The outerORDER BY rank ASC, referrer ASCis unchanged — tiebreaker semantics for result ordering are preserved.Root cause
With both
total_charm DESCandr.referrer ASCinside the same windowORDER BY,RANK()only ties rows when BOTH columns match. Since every referrer is distinct, no two rows ever tie andRANK()degrades to page-ordinal (1, 2, 3, 4) — breakingINV-INDEXER-170-REFERRAL-LB-TIE(dense-competitive1, 2, 2, 4pattern from #177).Pre-#204 fix in commit
6d92cc4had the dense-competitive behavior; #204's SQL rewrite (commita57d0d96) regressed it.Verification
Dense-rank test passes on fresh ephemeral DB:
Item 1 still passes on prod-shaped data: local stack indexer rebuilt with the patch, indexer DB wiped + reingested from anvil block 0, leaderboard endpoint returns the two real wallets with correct ranks 1 and 2:
x-schema-version: 1.19.0header confirmed.Item 2 walked on laptop frontend pointed at the patched indexer.
/referralsGuide leaderboard renders both wallets with correctonchain codes registered+recorded buyssublines. Summary tiles showCodes registered: 2,Recorded referral buys: 21,354,Total guide CHARM: 5.82K. The code-only wallet (0xdf37f81d...) appears with rank 2 and0 recorded buys with this referrer code— matching the empty-state copy spec.Items not covered by this MR
ReferralAppliedwon't emit on prod TimeCurve until sale opens. No way to walk without real chain activity.Out of scope
This MR is narrow: rank SQL only. No frontend changes, no schema changes, no doc changes, no migration. The #204 union logic +
codes_registered_countfield continue to work as designed.mentioned in commit
b0b5962e9a