Skip to content

Calculate Referral Program Cycle Status on Server #1523

@lightwalker-eth

Description

@lightwalker-eth

Prerequisites

#1522

Background

  • In the prerequisite issue 1522 updated API data models are suggested.
    • A potential scalability issue is identified on issue 1522 for how a new middleware for loading referral leaderboards into memory should work. Based on the spec in 1522, there can be any number of referral program cycles to continuously keep refreshing leaderboards for.
  • A utility function for calcReferralProgramStatus (and associated status enum) has been introduced into packages/ens-referrals/src/status.ts.

Goals / Suggested action items

  • Update the data model for the "v1" implementation of referrer leaderboard pagination APIs so that it includes the "Referral Program Status" for the requested leaderboard based on the rules of the requested leaderboard and the accurateAsOf timestamp that will be returned in the response (which should be the value for now passed into calcReferralProgramStatus to generate the correct status value).
    • Note: These status values will be important for UI-related enhancements that are planned on ENSAwards. Depending on the status, the ENSAwards UI will implement dynamic UIs.
  • Update the middleware that loads referral leaderboards into memory for each "Referral Program Cycle".
    • Introduce a constant Duration value named something such as ASSUMED_CHAIN_REORG_SAFE_DURATION and set it to something like 10 minutes in seconds. This value will help us in the case that there is a chain reorg with unfortunate timing.
    • Introduce a utility function named something such as assumeCachedLeaderboardImmutable. This function should return a boolean identifying if we should assume a cached leaderboard is immutable and therefore there's no need to keep rebuilding it over and over again. This function should return true if and only if the "Referral Program Status" for the related referral program cycle had a status of Closed as of ASSUMED_CHAIN_REORG_SAFE_DURATION ago.
    • The logic in this middleware should be updated to make use of assumeCachedLeaderboardImmutable to decide if it should make a refresh of a leaderboard that has already been cached.
  • Update the data model for the "v1" implementation of the new "Referrer Detail" API described in issue 1522.
    • For each referral program cycle returned in the response, include a field representing the "Referral Program Status" for that cycle based on the rules of the associated leaderboard and the accurateAsOf timestamp that will be returned in the response (which should be the value for now passed into calcReferralProgramStatus to generate the correct status value).
    • Note: These status values will be important for UI-related enhancements that are planned on ENSAwards. Depending on the status, the ENSAwards UI will implement dynamic UIs.

Metadata

Metadata

Assignees

Labels

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions