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: registry coordinator unit test improvements #121

Merged
merged 50 commits into from
Jan 9, 2024

Conversation

ChaoticWalrus
Copy link
Contributor

Initially marking as a draft since this work is definitely not complete.

ChaoticWalrus and others added 5 commits December 20, 2023 13:46
note that the `test_createQuorum` test is currently failing because
initialization already sets up the max number of quorums

something will need to be adjusted here
#116)

* docs: update reg coord to include pubkey registration and service manager usage

* docs: add service manager to tech docs intro

* fix: update table of contents

* docs: add docs for BLSSignatureChecker and OperatorStateRetriever

* docs: address feedback
* docs: standardize capitalization of Operator since thats what we do everywhere else

* docs: add BLSApkRegistry docs

* chore: remove old files

- i've incorporated all the info from these files into the current docs, so i'm removing them

* docs: add wip for IndexRegistry and StakeRegistry, and fix spacing in StakeRegistry

* docs: add IndexRegistry docs

* docs: Add StakeRegistry

* docs: clarify wording
@ChaoticWalrus ChaoticWalrus changed the title feat: registry manager unit test improvements feat: registry coordinator unit test improvements Jan 2, 2024
also fix a couple test names
set up one less than the max number of quorums in a single test's setup,
rather than the full max number,
so that the test will properly allow the creation of a new quorum

also fix a typo in a test name
note that the `test_createQuorum` test is currently failing because
initialization already sets up the max number of quorums

something will need to be adjusted here
also fix a couple test names
set up one less than the max number of quorums in a single test's setup,
rather than the full max number,
so that the test will properly allow the creation of a new quorum

also fix a typo in a test name
also improve some formatting + fix some typos, and add a touch more documentation
@ChaoticWalrus
Copy link
Contributor Author

ChaoticWalrus commented Jan 3, 2024

This is looking better now.
TODOs (editing as I add coverage):
testing for updateOperators, updateOperatorsForQuorum, getQuorumBitmapIndicesAtBlockNumber, getQuorumBitmapAtBlockNumberByIndex,_registerOperator, _deregisterOperator, _updateOperator, and _updateOperatorBitmap

also clarify somewhat ambiguous wording in the tree file
This was causing a *lot* of CI failures, including for merge commits

With this commit, CI will still check the _latest_ commit for meeting conventions,
it just won't run over all commits in a PR

This may lead to a few more "unconventional" commits making it through,
but the CI should still flag when someone is just not using conventional commits at all,
which I think was the original goal.
@ChaoticWalrus
Copy link
Contributor Author

I'm unsure if adding coverage for _updateOperator to these unit tests makes sense, as it is mostly a call to the StakeRegistry / feels a bit more apt as an "integration test".
Going to give a little more thought to the testing of the view functions.
Otherwise this PR is now looking good, I think.

note: this commit also adds a TODO around a currently-failing test.
I plan to discuss the correct path forwards here and then push another commit.
…s registered

the logic is now more in-line with the logic in the StakeRegistry -- for reference, see:

https://github.com/layr-labs/eigenlayer-middleware/blob/
98f8844/src/StakeRegistry.sol#L297-L299
Comment on lines 1525 to 1526
// TODO: any additional checks here? mostly this just calls the StakeRegistry, so more appropriate for an integration test
registryCoordinator.updateOperators(operatorsToUpdate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably worth having a test that checks that if the StakeRegistry returns quorums to remove from the operator, that they're removed?

Copy link
Contributor Author

@ChaoticWalrus ChaoticWalrus Jan 9, 2024

Choose a reason for hiding this comment

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

hmm yeah, I wasn't sure if this made more sense in "integration" tests. right now these tests use a mock harnessed StakeRegistry; I'll see if I can cook a good test up here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's definitely getting hit in integration tests, so up to you if you want to leave it out!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test added in 1f1a840
I think this test worked as a minimal version, but I added a more thorough fuzzed one.

Copy link
Collaborator

@wadealexc wadealexc left a comment

Choose a reason for hiding this comment

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

Looks clean - a few small requests, but I'm gonna go ahead and approve. Just make sure the latest m2-mainnet is merged in, since it looks like this is a merge rather than a rebase :)

also improve some formatting + fix some typos, and add a touch more documentation
also clarify somewhat ambiguous wording in the tree file
This was causing a *lot* of CI failures, including for merge commits

With this commit, CI will still check the _latest_ commit for meeting conventions,
it just won't run over all commits in a PR

This may lead to a few more "unconventional" commits making it through,
but the CI should still flag when someone is just not using conventional commits at all,
which I think was the original goal.
note: this commit also adds a TODO around a currently-failing test.
I plan to discuss the correct path forwards here and then push another commit.
…s registered

the logic is now more in-line with the logic in the StakeRegistry -- for reference, see:

https://github.com/layr-labs/eigenlayer-middleware/blob/
98f8844/src/StakeRegistry.sol#L297-L299
@ChaoticWalrus ChaoticWalrus merged commit fb6864b into m2-mainnet Jan 9, 2024
3 checks passed
@ChaoticWalrus ChaoticWalrus deleted the feat-RegistryManager-Unit-Test-Improvements branch January 9, 2024 23:05
8sunyuan added a commit that referenced this pull request Jan 10, 2024
* test: refactor and add tests to bitmap unit

* test: added tests and using asserts

* chore: remove single quote

* feat: addNumberToBitmap function

* test: tree file and Alexs bitmap fix

* test: add back updated stakeRegistry tests

* test: config tests

setMinimumStake tests
addStrategies tests
initializeQuorum tests

* refactor: using MockAVSDeployer for test file

* test: more config tests

* refactor: stake registry harness weighting

* fix: stake weighting refactor

removed overriding weightOfOperator functions
in StakeRegistry and fixed broken tests using the helper
_setOperatorWeight()

* test: refactor and add tests to bitmap unit

* test: added tests and using asserts

* chore: remove single quote

* feat: addNumberToBitmap function

* test: tree file and Alexs bitmap fix

* test: add back updated stakeRegistry tests

* test: config tests

setMinimumStake tests
addStrategies tests
initializeQuorum tests

* refactor: using MockAVSDeployer for test file

* test: more config tests

* refactor: stake registry harness weighting

* fix: stake weighting refactor

removed overriding weightOfOperator functions
in StakeRegistry and fixed broken tests using the helper
_setOperatorWeight()

* fix: undo change

* chore: rebase fixes

* test: voteweighing tests

* chore: updated eigenlayer-contract ref to m2-mainnet head (#119)

* updated eigenlayer-contract ref to m2-mainnet head

* fixed test - interface mismatch from previous update

* docs: update reg coord to include pubkey registration and service man… (#116)

* docs: update reg coord to include pubkey registration and service manager usage

* docs: add service manager to tech docs intro

* fix: update table of contents

* docs: add docs for BLSSignatureChecker and OperatorStateRetriever

* docs: address feedback

* docs: add documentation for each registry (#125)

* docs: standardize capitalization of Operator since thats what we do everywhere else

* docs: add BLSApkRegistry docs

* chore: remove old files

- i've incorporated all the info from these files into the current docs, so i'm removing them

* docs: add wip for IndexRegistry and StakeRegistry, and fix spacing in StakeRegistry

* docs: add IndexRegistry docs

* docs: Add StakeRegistry

* docs: clarify wording

* test: fix unit tests

* feat: registry coordinator unit test improvements (#121)

* feat: add tree diagram for RegistryManager

* chore: reorder and rename tests

* feat: add a couple simple tests

note that the `test_createQuorum` test is currently failing because
initialization already sets up the max number of quorums

something will need to be adjusted here

* docs: update reg coord to include pubkey registration and service man… (#116)

* docs: update reg coord to include pubkey registration and service manager usage

* docs: add service manager to tech docs intro

* fix: update table of contents

* docs: add docs for BLSSignatureChecker and OperatorStateRetriever

* docs: address feedback

* docs: add documentation for each registry (#125)

* docs: standardize capitalization of Operator since thats what we do everywhere else

* docs: add BLSApkRegistry docs

* chore: remove old files

- i've incorporated all the info from these files into the current docs, so i'm removing them

* docs: add wip for IndexRegistry and StakeRegistry, and fix spacing in StakeRegistry

* docs: add IndexRegistry docs

* docs: Add StakeRegistry

* docs: clarify wording

* chore: fix tree file name

* chore: add a couple post-checks on state

also fix a couple test names

* chore: fix breaking test

set up one less than the max number of quorums in a single test's setup,
rather than the full max number,
so that the test will properly allow the creation of a new quorum

also fix a typo in a test name

* feat: add tree diagram for RegistryManager

* chore: reorder and rename tests

* feat: add a couple simple tests

note that the `test_createQuorum` test is currently failing because
initialization already sets up the max number of quorums

something will need to be adjusted here

* chore: fix tree file name

* chore: add a couple post-checks on state

also fix a couple test names

* chore: fix breaking test

set up one less than the max number of quorums in a single test's setup,
rather than the full max number,
so that the test will properly allow the creation of a new quorum

also fix a typo in a test name

* feat: add a test for partial deregistration

also improve some formatting + fix some typos, and add a touch more documentation

* feat: expose more internal functions in harnessed contract

* feat: add some simple coverage for the internal `_registerOperator` fnc

* feat: add test coverage for the internal `deregisterOperator` fnc

also clarify somewhat ambiguous wording in the tree file

* feat: add simple test coverage for the internal `_updateOperatorBitmap` fnc

* chore: remove commitlint job that reviews all commits in PR from CI

This was causing a *lot* of CI failures, including for merge commits

With this commit, CI will still check the _latest_ commit for meeting conventions,
it just won't run over all commits in a PR

This may lead to a few more "unconventional" commits making it through,
but the CI should still flag when someone is just not using conventional commits at all,
which I think was the original goal.

* feat: add some coverage for `updateOperators(ForQuorums)` fncs

* feat: add testing for `updateOperatorsForQuorum` function

* feat: add some coverage for complex view functions

note: this commit also adds a TODO around a currently-failing test.
I plan to discuss the correct path forwards here and then push another commit.

* chore: clarify NatSpec comments

* fix: make `getQuorumBitmapIndicesAtBlockNumber` revert if operator was registered

the logic is now more in-line with the logic in the StakeRegistry -- for reference, see:

https://github.com/layr-labs/eigenlayer-middleware/blob/
98f8844/src/StakeRegistry.sol#L297-L299

* feat: add simple unit test for `getQuorumBitmapIndicesAtBlockNumber`

also improve wording in the 'tree' file

* chore: move `_getQuorumBitmapIndexAtBlockNumber` into the section with other internal fncs

* chore: remove unnecessary require statement + improve code clarity

* fix: correct a compiler error for implicit type conversion

* feat: address TODOs in tests

* feat: add tree diagram for RegistryManager

* chore: fix tree file name

* feat: add a test for partial deregistration

also improve some formatting + fix some typos, and add a touch more documentation

* feat: expose more internal functions in harnessed contract

* feat: add some simple coverage for the internal `_registerOperator` fnc

* feat: add test coverage for the internal `deregisterOperator` fnc

also clarify somewhat ambiguous wording in the tree file

* feat: add simple test coverage for the internal `_updateOperatorBitmap` fnc

* chore: remove commitlint job that reviews all commits in PR from CI

This was causing a *lot* of CI failures, including for merge commits

With this commit, CI will still check the _latest_ commit for meeting conventions,
it just won't run over all commits in a PR

This may lead to a few more "unconventional" commits making it through,
but the CI should still flag when someone is just not using conventional commits at all,
which I think was the original goal.

* feat: add some coverage for `updateOperators(ForQuorums)` fncs

* feat: add testing for `updateOperatorsForQuorum` function

* feat: add some coverage for complex view functions

note: this commit also adds a TODO around a currently-failing test.
I plan to discuss the correct path forwards here and then push another commit.

* chore: clarify NatSpec comments

* fix: make `getQuorumBitmapIndicesAtBlockNumber` revert if operator was registered

the logic is now more in-line with the logic in the StakeRegistry -- for reference, see:

https://github.com/layr-labs/eigenlayer-middleware/blob/
98f8844/src/StakeRegistry.sol#L297-L299

* feat: add simple unit test for `getQuorumBitmapIndicesAtBlockNumber`

also improve wording in the 'tree' file

* chore: move `_getQuorumBitmapIndexAtBlockNumber` into the section with other internal fncs

* chore: remove unnecessary require statement + improve code clarity

* fix: correct a compiler error for implicit type conversion

* feat: address TODOs in tests

---------

Co-authored-by: Alex <[email protected]>

* Test: bitmap utils unit tests (#101)

* test: refactor and add tests to bitmap unit

* test: added tests and using asserts

* chore: remove single quote

* feat: addNumberToBitmap function

* chore: remove unused bitmap functions

* feat: addNumberToBitmap function

* test: tree file and Alexs bitmap fix

* test: add back updated stakeRegistry tests

* test: config tests

setMinimumStake tests
addStrategies tests
initializeQuorum tests

* refactor: using MockAVSDeployer for test file

* test: more config tests

* refactor: stake registry harness weighting

* fix: stake weighting refactor

removed overriding weightOfOperator functions
in StakeRegistry and fixed broken tests using the helper
_setOperatorWeight()

* feat: addNumberToBitmap function

* test: add back updated stakeRegistry tests

* test: config tests

setMinimumStake tests
addStrategies tests
initializeQuorum tests

* refactor: using MockAVSDeployer for test file

* test: more config tests

* refactor: stake registry harness weighting

* fix: stake weighting refactor

removed overriding weightOfOperator functions
in StakeRegistry and fixed broken tests using the helper
_setOperatorWeight()

* chore: rebase fixes

* fix: undo change

* test: voteweighing tests

* test: fix unit tests

* fix: rebase errors

* fix: broken tests from rebase

---------

Co-authored-by: Samuel Laferriere <[email protected]>
Co-authored-by: Alex <[email protected]>
Co-authored-by: ChaoticWalrus <[email protected]>
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