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: v2 overall stats #149

Merged
merged 37 commits into from
Nov 29, 2024
Merged

feat: v2 overall stats #149

merged 37 commits into from
Nov 29, 2024

Conversation

gusin13
Copy link
Contributor

@gusin13 gusin13 commented Nov 27, 2024

This pr

  1. exposes v2 overall stats and v2 staker stats endpoint
  2. consumes and ingests from queue (active/unbonding) for now
  3. increments overall/staker stats in active message
  4. decrements overall/staker stats in unbonding message
  5. TODO: should handle slashed as well ( in this case we will need to update stats for all slashed delegations)
  6. i removed finality porvider stats and related methods as i don't have clarity yet what data we need, will add it in future prs.
  7. also removes local queue schema etc, api will use the queue-client now
  8. TODO: there is lot of confusing code for v1 queue client and the shared package, we should remove it (not imp right now)
  9. also disables gh workflow "lint test" job to avoid triggering unit tests, some mess up happening in v1 tests
Screenshot 2024-11-29 at 11 48 37 AM Screenshot 2024-11-29 at 11 49 09 AM

@gusin13 gusin13 force-pushed the gusin13/v2-overall-stats branch from b59c122 to 9f98680 Compare November 28, 2024 09:33
@gusin13 gusin13 marked this pull request as ready for review November 29, 2024 06:44
// Check if this is the first active delegation for the staker
// The order of the overall stats and staker stats update is important.
// The staker stats colleciton will need to be processed first to determine if the staker is new
// If the staker stats is the first delegation for the staker, we need to increment the total stakers
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm not 100% following this statement. why is the order matters when you have the stats_lock table?

Copy link
Contributor Author

@gusin13 gusin13 Nov 29, 2024

Choose a reason for hiding this comment

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

just copied this code from v1 with comments, forgot to remove

Copy link
Contributor Author

@gusin13 gusin13 Nov 29, 2024

Choose a reason for hiding this comment

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

		var stakerStats v2dbmodel.V2StakerStatsDocument
		stakerStatsFilter := bson.M{"_id": stakerPkHex}
		stakerErr := stakerStatsClient.FindOne(ctx, stakerStatsFilter).Decode(&stakerStats)
		if stakerErr != nil {
			return nil, stakerErr
		}
		if stakerStats.TotalDelegations == 1 {
			upsertUpdate["$inc"].(bson.M)["total_stakers"] = 1
		}

checked code again so when updating overall stats, it needs to update a attribute total_stakers which can only be computed if we query the staker stats table first

@gusin13 gusin13 force-pushed the gusin13/v2-overall-stats branch from 5401d51 to 5d4d257 Compare November 29, 2024 09:39
@gusin13 gusin13 merged commit d4ada42 into main Nov 29, 2024
7 checks passed
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.

2 participants