Skip to content

Commit

Permalink
feat: add is operator set quorum function (#513)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomás Grüner <[email protected]>
  • Loading branch information
maximopalopoli and MegaRedHand authored Feb 6, 2025
1 parent 52cc060 commit 3c89e44
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions chainio/clients/avsregistry/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,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
})
}

0 comments on commit 3c89e44

Please sign in to comment.