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: add is operator set quorum function #513

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions chainio/clients/avsregistry/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,24 @@ func (r *ChainReader) IsOperatorRegistered(
return registeredWithAvs, nil
}

// Receives a quorum number and returns if that quorum is an operator set quorum based
// on its stake type, that means true if the quorum is an M2 quorum and the avs is an
// operator set avs (new workflow)
func (r *ChainReader) IsOperatorSetQuorum(
opts *bind.CallOpts,
quorumNumber uint8,
) (bool, error) {
if r.stakeRegistry == nil {
return false, errors.New("StakeRegistry contract not provided")
}
isOperatorSet, err := r.stakeRegistry.IsOperatorSetQuorum(opts, quorumNumber)
if err != nil {
return false, err
}

return isOperatorSet, nil
}

// Queries existing operators for a particular block range.
// Returns two arrays. The first one contains the addresses
// of the operators, and the second contains their corresponding public keys.
Expand Down
12 changes: 12 additions & 0 deletions chainio/clients/avsregistry/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,16 @@ func TestReaderMethods(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 0, len(address_to_sockets))
})

t.Run("Is operator set quorum", func(t *testing.T) {
// A quorum registered in the old workflow should return false
isOperatorSet, err := chainReader.IsOperatorSetQuorum(
&bind.CallOpts{},
0,
)
require.NoError(t, err)
require.False(t, isOperatorSet)

// TODO: Make a test with the new workflow testing a case returning true
})
}