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: contracts middleware interface #235

Merged

Conversation

thedevbirb
Copy link
Contributor

@thedevbirb thedevbirb commented Sep 20, 2024

This PR introduces the IBoltMiddleware interface and decouples many functionalities of the BoltManager contract into two separate contracts: BoltEigenLayerMiddleware and BoltSymbioticMiddleware.
Moreover, the BoltManager contract is now agnostic of the available restaking protocols.

Summary by CodeRabbit

  • New Features

    • Introduced BoltEigenLayerMiddleware and BoltSymbioticMiddleware for enhanced integration with the Bolt Protocol.
    • Updated registration processes for operators and vaults to streamline user interactions.
    • Added functionalities for managing operator and collateral stakes, including epoch management.
  • Bug Fixes

    • Clarified and updated integration steps in the documentation for better user understanding.
  • Refactor

    • Simplified the BoltManager by removing EigenLayer and Symbiotic-related functionalities and focusing on restaking protocols.
  • Documentation

    • Enhanced the README.md to reflect changes in the integration process and middleware structure.

Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

Really like the direction

bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we keep track of whitelisted assets by protocol or in a single mapping?
e.g. symbioticWhitelistedCollaterals or just whitelistedCollaterals?

In theory once a collateral token is approved it should be used anywhere, if possible.
Just an observation

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'd love a more abstracted mapping but I think it makes more sense to keep them closer to the restaking protocol since they might have different definition of "collateral". In the context of EigenLayer we are fine with whitelisted ERC20 addresses but in Symbiotic you need to specify the contract instances of "Collateral".

Having a single mapping might be ambiguous because you might think you can use any of such collaterals in any restaking protocol but that's not the case.

What do you think? Not trying to force a point but I think we should genuinely analyse this further

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a single mapping might be ambiguous because you might think you can use any of such collaterals in any restaking protocol but that's not the case.

totally agree with this, however on the flip side having separate whitelists means having governance specific to the middleware instead of keeping all bolt governance stuff on the BoltManager. It doesn't make a huge difference except complicating things a little bit...

@thedevbirb thedevbirb marked this pull request as ready for review September 23, 2024 12:36
@chainbound chainbound deleted a comment from coderabbitai bot Sep 23, 2024
@thedevbirb
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

Ahoy mateys! The changes in this here pull request be all about reorganizin' and clarifying the integration process fer the Bolt network and its middleware. The README.md got a tidy-up, removin' references to Symbiotic Operators and Vaults, and now focusin' on operator stakes and proposer statuses. New contracts like BoltEigenLayerMiddleware and BoltSymbioticMiddleware be introduced, makin' the whole system more streamlined and efficient, while the BoltManager be shifted to support restakin' protocols instead of EigenLayer functionalities.

Changes

Files Change Summary
bolt-contracts/README.md Reorganized integration process, removed Symbiotic Operators and Vaults, updated steps for opting into Bolt, and clarified roles of components. Method signatures updated to reflect new middleware structure.
bolt-contracts/script/Deploy.s.sol Introduced DeployBolt contract replacing DeployBoltManager, modified deployment to include new middleware contracts and updated parameters.
bolt-contracts/src/contracts/ Introduced BoltEigenLayerMiddleware and BoltSymbioticMiddleware, implementing middleware functionalities, managing operators, strategies, and collateral addresses. BoltManager updated to focus on restaking protocols, removing EigenLayer functionalities and adding methods for managing restaking protocols.
bolt-contracts/src/interfaces/ New interface IBoltMiddleware added, defining functions and error types for middleware operations. Significant reductions in IBoltManager interface, removing many functions related to collateral and operator management.
bolt-contracts/test/ Updated test contracts to utilize new middleware contracts instead of the BoltManager, adjusting method calls and assertions to reflect the new structure.

Possibly related PRs

  • feat(sidecar): integrate local builder with builder api #97: The changes in this PR involve significant updates to the signing mechanisms and integration with the commit-boost feature, which aligns with the main PR's focus on middleware and operator registration processes.
  • feat(sidecar): commit-boost integration #203: This PR introduces commit-boost integration, which is directly related to the enhancements in the middleware and operator functionalities discussed in the main PR, particularly regarding the handling of operator stakes and statuses.

Suggested labels

C: bolt-sidecar, T: feature


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 28

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 8f6bf3e and 70cb8e7.

Files selected for processing (9)
  • bolt-contracts/README.md (3 hunks)
  • bolt-contracts/script/Deploy.s.sol (2 hunks)
  • bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol (1 hunks)
  • bolt-contracts/src/contracts/BoltManager.sol (3 hunks)
  • bolt-contracts/src/contracts/BoltSymbioticMiddleware.sol (1 hunks)
  • bolt-contracts/src/interfaces/IBoltManager.sol (0 hunks)
  • bolt-contracts/src/interfaces/IBoltMiddleware.sol (1 hunks)
  • bolt-contracts/test/BoltManager.EigenLayer.t.sol (11 hunks)
  • bolt-contracts/test/BoltManager.Symbiotic.t.sol (10 hunks)
Files not reviewed due to no reviewable changes (1)
  • bolt-contracts/src/interfaces/IBoltManager.sol
Additional comments not posted (32)
bolt-contracts/README.md (2)

51-54: Ahoy, me hearties! These changes be shipshape and Bristol fashion!

Ye've done a fine job of updatin' the key features, ye scurvy dog! By removin' the specific mentions of Symbiotic Operators and Vaults, ye've made the BoltManager more flexible than a seasoned sailor's back. This be allowin' for smoother sailin' with different restakin' protocols. Well done, ye bilge rat!


66-68: Blimey! These steps be clearer than a lighthouse on a foggy night!

Ye've done a right proper job of updatin' the Symbiotic Integration guide, ye crafty corsair! By replacin' BoltManager with BoltSymbioticMiddleware and usin' more generic method names, ye've made the process smoother than a well-oiled cannon. Any landlubber could follow these steps now!

bolt-contracts/script/Deploy.s.sol (3)

26-27: BoltValidators deployment is smooth sailing

Well done, matey! The BoltValidators contract be deployed properly. All hands can rest easy.


32-38: Deployment of BoltEigenLayerMiddleware looks shipshape

Aye, the way ye've set sail with the BoltEigenLayerMiddleware deployment be looking good. No squalls on the horizon here.


40-47: Verify parameters match BoltSymbioticMiddleware constructor

Heed me words! Make sure the order of the parameters passed to BoltSymbioticMiddleware be matching its constructor. We wouldn't want any mischief aboard because of a mismatched crew.

Run the following script to verify the constructor parameters:

bolt-contracts/src/contracts/BoltManager.sol (1)

36-38: Aye, the addition of restakingProtocols be a fine move.

The use of EnumerableSet to keep track of supported restaking protocols ensures no duplicate entries sneak into the ship's ledger.

bolt-contracts/test/BoltManager.EigenLayer.t.sol (12)

8-8: Ahoy! Imported the middleware contract smartly.

Bringing in BoltEigenLayerMiddleware looks proper and sets sail for modular code.


29-29: Added the middleware variable—smooth sailing ahead!

Declaring BoltEigenLayerMiddleware public middleware; readies ye for utilizing the middleware in yer tests.


52-57: Middleware initialization—shipshape but mind the details.

Ye've instantiated the middleware correctly with necessary parameters. Ensure all addresses, especially those of avsDirectory, delegationManager, and strategyManager, be accurate to avoid any mutinies in deployment.


64-67: Whitelisting collateral through middleware—aye, that's the way!

Adding and verifying the whitelisted collateral via middleware is correctly handled.


132-132: Calculating operator registration digest hash—spot on!

Using avs: address(middleware) in the digest hash aligns with the middleware's role as the AVS. Well done!


142-145: Registering operator to AVS via middleware—smooth seas ahead.

The registration and subsequent check confirm that the operator is properly registered through the middleware.


162-166: Operator and strategy registration—executed with finesse!

Ye've successfully registered the operator and strategy using the middleware, and the assertions confirm their enabled status.


172-173: Deregistering operator from AVS—handled gracefully.

The operator is correctly deregistered, and the status check verifies the action.


225-225: Handling non-existent proposer status—smartly done.

Expecting a revert when fetching a non-existent proposer is a good check to ensure proper error handling.


230-230: Fetching whitelisted collaterals—everything's shipshape.

Retrieving the collaterals through the middleware works as expected, confirming the whitelisting.


238-238: Removing whitelisted collateral—verify access control, mate.

When calling middleware.removeWhitelistedCollateral, ensure that only the rightful captain (authorized personnel) can perform this action to prevent any unwanted meddling.

Ye can check the onlyAdmin modifier or equivalent access control in the middleware contract to confirm proper enforcement.


244-244: Expecting revert on registering strategy with non-whitelisted collateral—aye, that's proper testing.

Ye've correctly anticipated the revert due to CollateralNotWhitelisted, ensuring yer contract behaves as intended when facing improper inputs.

bolt-contracts/test/BoltManager.Symbiotic.t.sol (14)

25-26: Aye, importing IBoltMiddleware be sound.


29-29: Ye've added BoltSymbioticMiddleware import smartly.


43-43: Introduced middleware variable correctly.


155-161: Set sail with the new BoltSymbioticMiddleware, looks shipshape.


164-166: Whitelisting collateral be done rightly.


178-178: Set the middleware on the network service, savvy move.


207-208: Vault be registered and confirmed enabled. Good work.


210-211: Operator be registered and enabled, all hands on deck.


255-255: Stake from middleware matches delegator's stake, and both be zero. Well done.

Also applies to: 257-258


285-287: Total stake checks out across epochs, wisely done.


290-292: Stake from middleware now matches delegator and is 1 ether, as expected. Nicely navigated.


349-349: Test for nonexistent proposer status be properly verifying the revert. Aye, good.


353-355: Retrieving whitelisted collaterals looks good, mate.


360-360: Test for non-whitelisted collateral be correctly expecting revert when registering vault. Well plotted.

Also applies to: 363-364

bolt-contracts/README.md Outdated Show resolved Hide resolved
bolt-contracts/README.md Show resolved Hide resolved
bolt-contracts/script/Deploy.s.sol Outdated Show resolved Hide resolved
bolt-contracts/script/Deploy.s.sol Outdated Show resolved Hide resolved
@merklefruit merklefruit added the C: smart-contracts Component: smart contracts label Sep 25, 2024
Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

LGTM

@merklefruit merklefruit merged commit 2cd43db into nico/feat/commitment-registry Sep 30, 2024
4 checks passed
@merklefruit merklefruit deleted the lore/feat/middleware-interface branch September 30, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: smart-contracts Component: smart contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants