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

Compute the stake by quorums #37

Merged
merged 4 commits into from
Nov 17, 2023
Merged

Conversation

jianoaix
Copy link
Contributor

@jianoaix jianoaix commented Nov 15, 2023

Why are these changes needed?

This is a simpler and more efficient way to compute stake:

  • It doesn't need to talk to both graph and eth node
  • It doesn't need to issue multiple RPCs (one for each operator) to fetch stakes

It issues just one RPC to just eth node.

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@@ -17,19 +17,21 @@ const (
)

func (s *server) getMetric(ctx context.Context, startTime int64, endTime int64, limit int) (*Metric, error) {
operators, err := s.subgraphClient.QueryOperatorsWithLimit(ctx, limit)
Copy link
Contributor Author

@jianoaix jianoaix Nov 16, 2023

Choose a reason for hiding this comment

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

This is not only inefficient, but also incorrect: if we have more than 10 operators (the default limit), we will not get the total stake.

blockNumber, err := s.transactor.GetCurrentBlockNumber(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get current block number: %w", err)
}
totalStake, err := s.calculateTotalStake(operators, blockNumber)
operatorState, err := s.chainState.GetOperatorState(ctx, uint(blockNumber), []core.QuorumID{core.QuorumID(0)})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gpsanant we are counting on this to get the stakes onchain, let me know if it's not reliable, we'd otherwise merge this PR

@jianoaix jianoaix mentioned this pull request Nov 16, 2023
5 tasks
@jianoaix jianoaix merged commit f595cf9 into Layr-Labs:master Nov 17, 2023
3 of 4 checks passed
hopeyen pushed a commit that referenced this pull request Sep 18, 2024
…eters

[INT-114] chore: add missing help parameters
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.

3 participants