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: adjust compendium for per-avs deployment #97

Merged

Conversation

ChaoticWalrus
Copy link
Contributor

@ChaoticWalrus ChaoticWalrus commented Dec 7, 2023

Using a shared BLSPubkeyCompendium impacts separation of concerns, so we would like to transition to operators registering a public key with each AVS independently.
This means we can absorb the BLSPubkeyCompendium into the BLSApkRegistry (possibly re-re-named to BLSPubkeyRegistry?), which this PR looks to accomplish.

PR initially marked as draft; will request review when I think it's ready. See later updates / I edited this message and crossed out some items.

Open items + open questions:

- fix tests (marked a few things with TODOs)
- decide on combined 'register operator + register pubkey' flow / function (completed / merged into this PR in #100)
- renaming functions / cleaning up interfaces (completed in #102)
- settle the message hash for operators -- see discussion here #97 (comment) and here #100 (comment) (completed in #102)
- fix contract code size limits issue arising after resolving merge conflicts (completed in #105)

requires changing a bunch of files to make things work.
I had to comment out a few calls in tests (now marked with a `TODO`) to get this past the compiler.
Will have to do additional cleanup to get this ready for review.
These changes appear to fix all existing tests.
I've done what I can to at least comment specifically where harnessed functions are used, as this pattern could give some false assurance and I'd like to avoid that.
I created this mock while trying to sort out compilation issues and test failures
This mock is no longer being used anywhere, so I am deleting it for cleanup
this commit fixes a ton of compiler warnings on build, in particular.
@ChaoticWalrus
Copy link
Contributor Author

OK, tests are now passing once again.
Updating with my current thoughts -- I am now planning to split renaming + the combined flow into separate PRs based off of this branch, so we can break things into more discrete parts and make some of those decisions non-blocking for merging others.
If you are reviewing this and disagree with this approach, let me know!

@ChaoticWalrus ChaoticWalrus marked this pull request as ready for review December 11, 2023 21:30
operator,
address(this),
block.chainid,
"EigenLayer_BN254_Pubkey_Registration"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should probably change the message hash "EigenLayer_BN254_Pubkey_Registration" to something that's more AVS specific, or just remove entirely since there won't be a singleton compendium contract anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, perhaps we can just delete the EigenLayer_ part?
it's overkill to have this at all, but it's another input to help protect from any kind of replay issues, so...I feel like it's not a bad idea to have some string here at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

realized I should probably just convert this to use EIP-712 instead; will add that to my TODOs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed as part of #102 -- I think these changes are quite appropriate

…stryCoordinator

also make a version of `RegistryCoordinator. registerOperator`
that accepts these inputs
new function passes these inputs on appropriately

TODO:
remove old `registerOperator` function and fix associated tests
…ubkey registration inputs

also fix tests to use the new method
note: code is currently not compiling due to a stack-too-deep error
error here:
 src/RegistryCoordinator.sol:254:69:
    |
254 |                 _deregisterOperator(operatorKickParams[i].operator, quorumNumbers[i:i+1]);
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.

This looks great -- pulling out from Slack:

My suggestion for adding pubkey registration to the workflow is to:

  1. add a new method to the reg coord: registerOperatorAndPubkey
  2. change ApkRegistry.registerBLSPublicKey to be called by reg coord only
  3. change ApkRegistry.registerBLSPublicKey to accept a param for the operator address rather than using msg.sender.

registerOperatorAndPubkey works just like registerOperator, except it includes the pubkey params needed for the ApkRegistry. It fails if the operator already has a registered pubkey.

see reasoning here
#100 (comment)
this allows undoing a previous fix for a stack-too-deep error, which...
helps make the logic a little clearer / easier to parse here.
NOTE: this changes the IBLSApkRegistry interface
to make `registerBLSPublicKey` return a bytes32 object
`pubkeyRegistrationParams` => `params`
see discussion here:
#100 (comment)
…ation-flow

Feat: combined operator registration flow
this commit also moves the definition to the RegistryCoordinator contract
and updates the function naming to be clearer
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.

Since I've approved your other chore/cleanup PR, i'm going to go ahead and approve this one as well - so you can merge em all at once (assuming you're happy)

I reviewed the additional changes to operatorId fetching from the last PR, and as mentioned the cleanup PR looks great!

Thanks for putting these together 😄

…hanges

Chore: cleanup for compendium changes
these weren't caught in merging but were causing compiler errors
I previously implemented this fix, then reverted it as not needed.
Now upon merging with m2-mainnet, `registerOperatorWithChurn` has an additional input.
This is reintroducing the same stack-too-deep error
so I am reintroducing the same fix (one less local var)
see suggestion here:
#102 (comment)

saves ~0.25kb in code size
ChaoticWalrus and others added 9 commits December 13, 2023 12:53
also reduce memory copying operations (I think, at least) in
the `registerOperator` function
specifically, only copy the `numOperatorsPerQuorum` returned by
the internal `_registerOperator` function
The `operatorId` in this check is already fetched from the `blsApkRegistry`
With the other changes, this return data is no longer necessary at all
I believe this change cuts down on the memory copying being done here
Likely not the ideal fix, but it gets the job done for the moment, at least.
`RegistryCoordinatorHarness.sol` -> `RegistryCoordinatorHarness.t.sol`
…-issues

fix: address contract code size issues
@ChaoticWalrus ChaoticWalrus merged commit c08a0a3 into m2-mainnet Dec 13, 2023
2 of 3 checks passed
@ChaoticWalrus ChaoticWalrus deleted the feat-adjust-compendium-for-per-avs-deployment branch December 13, 2023 21:59
@ChaoticWalrus
Copy link
Contributor Author

Summary of key changes ultimately contained in this PR:

  • merge BLSPubkeyCompendium into BLSApkRegistry
  • define a PubkeyRegistrationParams struct in the IBLSApkRegistry interface, and add it as an input to the RegistryCoordinator.registerOperator and RegistryCoordinator.registerOperatorWithChurn functions -- operators now make a single call to these functions instead of needing to make a separate, earlier call to register a pubkey -- this input is ignored if the caller (the operator) has already registered a pubkey
  • better define the message hash that operators sign when registering a pubkey, and move the definition of this message hash from the compendium to the RegistryCoordinator

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.

3 participants