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: check quorums registered detail #331

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions chainio/clients/avsregistry/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,31 @@ func (r *ChainReader) GetOperatorFromId(
return operatorAddress, nil
}

func (r *ChainReader) QueryRegistrationDetail(
opts *bind.CallOpts,
operatorAddress common.Address,
) ([]bool, error) {
operatorId, err := r.GetOperatorId(opts, operatorAddress)
if err != nil {
return nil, err
}
value, err := r.registryCoordinator.GetCurrentQuorumBitmap(opts, operatorId)
if err != nil {
return nil, err
}
numBits := value.BitLen()
quorums := make([]bool, numBits)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How are you using this quorums array? Wouldn't you rather have a map instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, initially i thought we could use index of the array as the quorum index, but yes i have changed it to use a map for more easier to understand

Copy link
Collaborator

Choose a reason for hiding this comment

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

Think you should only be inputting the non zero quorums into the map? Aka treating it as a set instead of a map. That way you would iterate only on quorums that are nonzero.

Copy link
Contributor Author

@renlulu renlulu Aug 29, 2024

Choose a reason for hiding this comment

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

I think it is better to show zero quorums as well? so one use this function can easily get:

  1. which quorum(s) the operator is in already
  2. which quorum(s) the operator is not in

so he can adjust the strategy accordingly, i.e. re-join the missing quorum again

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. In that case don’t think map is needed and we can revert to array then haha?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted to use array

for i := 0; i < numBits; i++ {
// Check if the ith bit is set
if value.Int64()&(1<<i) != 0 {
quorums[i] = true
} else {
quorums[i] = false
}
}
return quorums, nil
}

func (r *ChainReader) IsOperatorRegistered(
opts *bind.CallOpts,
operatorAddress common.Address,
Expand Down