Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compute registry data #1

Merged
merged 5 commits into from
Aug 26, 2024
Merged

feat: compute registry data #1

merged 5 commits into from
Aug 26, 2024

Conversation

Sekhmet
Copy link
Member

@Sekhmet Sekhmet commented Aug 22, 2024

Closes: snapshot-labs/sx-monorepo#485
Depends on: snapshot-labs/snapshot.js#1050

This PR adds compute function that creates delegation data for delegateRegistryV1.

Test plan

  1. Run this project
  2. Run this query.
  3. It will return empty response (because we don't wait for data to be computed, only return stored value).
  4. See in logs that computation was started, wait for it to finish.
  5. Repeat the request.
  6. You see values and they are correct (compare with https://snapshot.org/#/delegate/apecoin.eth)

Query:

query Test($id: String!) {
  governance(id: $id) {
    id
    currentDelegates
    totalDelegates
    delegatedVotes
    delegatedVotesRaw
  }
  delegates (where: { governance: $id}) {
    id
    delegatedVotes
    tokenHoldersRepresentedAmount
  }
}

@Sekhmet Sekhmet requested a review from bonustrack August 22, 2024 15:26
@bonustrack
Copy link
Member

bonustrack commented Aug 23, 2024

Can you add something like this in index.ts, it wont work for me and on DigitalOcean without it.

if (process.env.CA_CERT) {
  process.env.CA_CERT = process.env.CA_CERT.replace(/\\n/g, '\n');
}

src/constants.ts Outdated
export const SCORE_API_URL =
process.env.SCORE_API_URL ?? 'https://score.snapshot.org';

export const COMPUTE_DELAY_SECONDS = 30 * 60; // 30 minutes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the delay to recompute score from delegates? If so it's better to set it as 1 day. It would be too much subgraph and RPC requests to allow and update every 30mn.

@bonustrack
Copy link
Member

Just tested with multiple space, it works well so far. I think we will be missing many delegates because:
1: The delegate registry allows for global delegation, I think currently you only gather delegation for specific space
2: There is also plenty of users with voting power that did not delegated their voting power, but still should appear on delegate leaderboard. "delegation" strategy give you voting power even if you dont delegate to yourself.
Would be great to have the first one, the second one would be more tricky we can skip for next cycle, it will requires querying for voters.

@bonustrack
Copy link
Member

FYI: I've already setup an app on DigitalOcean with a Postgres db and proper env

@Sekhmet
Copy link
Member Author

Sekhmet commented Aug 23, 2024

Added support for global delegation, needs update in snapshot.js: snapshot-labs/snapshot.js#1050

@bonustrack bonustrack merged commit 5e2b9d0 into master Aug 26, 2024
1 check passed
@bonustrack bonustrack deleted the sekhmet/compute branch August 26, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: delegateRegistryV1 support for offchain spaces
2 participants