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

refactor: handle zero bitmap #332

Merged
merged 1 commit into from
Sep 4, 2024
Merged

Conversation

renlulu
Copy link
Contributor

@renlulu renlulu commented Aug 29, 2024

A followup PR of #331. The functions works well with our system internally, but i just realized that if the bitmap is 0, the result array would be empty too. So is it better that we populate all existing quorums with default value (which is false in this case) to the result to be more consistent. Also wrap some errors this time.

What Changed?

Reviewer Checklist

  • Code is well-documented
  • Code adheres to Go naming conventions
  • Code deprecates any old functionality before removing it

}
numBits := value.BitLen()
var quorums []bool
for i := 0; i < numBits; i++ {
quorums = append(quorums, value.Int64()&(1<<i) != 0)
}
if len(quorums) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a comment explaining when/why this case is possible? When does GetCurrentQuorumBitmap return a value of 0 bitlen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if operator has opt out from all quorums (or been ejected), the contract could return 0, you can see here:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

meant in the code, because it's surprising when reading the code why it could ever be 0.

@samlaf samlaf merged commit 6f4461d into Layr-Labs:dev Sep 4, 2024
4 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