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): new registry (V1) #202

Merged
merged 248 commits into from
Oct 21, 2024
Merged

Conversation

merklefruit
Copy link
Collaborator

@merklefruit merklefruit commented Aug 23, 2024

Commitment registry with external collateral

Closes #196
Closes #36
Closes #244
Closes #273

Registration procedure

  1. Validator registers in BoltValidators. There is a registerValidatorUnsafe method that skips all verifications (BLS signature check and SSZ validator existence check). This function will be useful to test and until Pectra will be live on public testnets. We can also start testing with the precompile on Pectra EF devnets for now.
  2. Operators register in BoltManager via registerSymbioticOperator()
  3. Operators do all of their Symbiotic-related authorization steps on the Vaults they want to operate on
  4. Vaults register in BoltManager via registerSymbioticVault() (currently no check on collateral asset used)

The BoltManager contract allows read access into the current stake of any operator in the network
at any given time, for any asset:

function getSymbioticOperatorStakeAt(
		address operator,   // the operator for which to get the stake
        address collateral, // the collateral asset address to query for
        uint48 timestamp    // the timestamp at which the query is made
    ) external view returns (uint256);

It also allows to query if an operator is authorized to emit commitments for a specific validator:

function isSymbioticOperatorAuthorizedForValidator(
        address operator,
        bytes32 pubkeyHash
    ) external view returns (bool);

The actual staking, unstaking, and slashing downstream logics are left to Symbiotic for now.

Diagrams

shapes at 24-09-03 10 51 15

Missing & TODO

  • should we gate the collateral assets behind a whitelist?
  • ability to verify aggregated bls12_381 signature for batch registration
  • ability for Validators to pause or change the currently authorized Operator

Meta

Summary by CodeRabbit

  • New Features

    • Introduced a Continuous Integration (CI) workflow for automated testing of smart contracts.
    • Added new mock contracts for testing collateralized debt positions and ERC20 tokens.
    • Enhanced documentation with a structured Table of Contents and detailed integration guides.
  • Bug Fixes

    • Improved error handling for non-existent operators and validators in the testing framework.
  • Documentation

    • Expanded README with comprehensive explanations of the Bolt ecosystem components and security considerations.
  • Tests

    • Implemented a robust testing suite for BoltManager and BoltValidators, validating key functionalities and interactions.

@merklefruit merklefruit self-assigned this Aug 29, 2024
@merklefruit merklefruit added C: smart-contracts Component: smart contracts T: feature Type: Feature labels Aug 29, 2024
@merklefruit merklefruit added this to the v0.3: Holesky 1 milestone Aug 29, 2024
@merklefruit merklefruit changed the base branch from unstable to holesky-1 August 29, 2024 11:53
@merklefruit merklefruit changed the title feat(registry): stub initial rewrite: register and deposit feat(contracts): new registry Aug 30, 2024
@merklefruit merklefruit changed the base branch from holesky-1 to unstable September 6, 2024 14:52
@merklefruit merklefruit marked this pull request as ready for review September 9, 2024 11:41
@merklefruit
Copy link
Collaborator Author

Ready for a first round of review. In scope:

Contracts:

  • BoltManager.sol
  • BoltValidators.sol
  • Imported libraries and interfaces

Flows:

  • registering as a validator (tested)
  • opting in via Symbiotic (tested)
  • reading the active stake (tested)
  • slashing flow (not tested)

@merklefruit
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

Ahoy there! The changes in this pull request introduce a Continuous Integration (CI) workflow for the Bolt contracts project, enhancing the automation of testing smart contracts. It also includes updates to various files such as .gitignore, .gitmodules, and several Solidity contracts and interfaces, while adding mock contracts for testing purposes. The documentation has been expanded to cover new functionalities and integration processes, ensuring a clearer understanding for developers.

Changes

File(s) Change Summary
.github/workflows/contracts_ci.yml Introduced a CI workflow for testing smart contracts with steps for checking out code, installing the Foundry toolchain, and running tests.
.gitignore, bolt-contracts/.gitignore Added entries to ignore .DS_Store, .env, and .vscode files, enhancing repository cleanliness.
.gitmodules Added a submodule entry for bolt-contracts/lib/core, indicating a new dependency.
bolt-contracts/README.md Expanded documentation with a Table of Contents, detailed sections on components, registration processes, integration guides, testing instructions, and a "Security Considerations" section.
foundry.toml Updated configuration for the Foundry project, including compiler version, RPC endpoints, formatting options, and fuzz testing parameters.
bolt-contracts/src/contracts/*.sol Introduced new contracts (BoltManager, BoltValidators, BoltChallenger) with various functionalities for managing validators, operators, and collateral, as well as implementing slashing mechanisms.
bolt-contracts/src/interfaces/*.sol Added interfaces (IBoltManager, IBoltValidators) defining functionalities for managing operators and validators.
bolt-contracts/test/*.t.sol Created test contracts for BoltManager and BoltValidators, validating functionalities and interactions, along with mock contracts for collateral management.
bolt-contracts/src/lib/*.sol Introduced libraries for managing state with timestamps (MapWithTimeData), BLS signature verification (BLSSignatureVerifier), and utilities for the Beacon Chain (BeaconChainUtils).
bolt-contracts/src/lib/bls/*.sol Added a library for BLS12-381 elliptic curve operations, crucial for cryptographic functionalities in the blockchain context.
bolt-contracts/src/lib/ssz/*.sol Updated SSZ library for verifying proofs and managing validator inclusion in the Beacon Chain.

Possibly related issues

  • tracking(holesky): smart contracts #206: The objectives regarding the redesign of the validator registry and the addition of authentication methods could be addressed by the changes made in the BoltValidators and BoltManager contracts.

Possibly related PRs

  • feat(sidecar): github CI #139: Directly relates to the CI workflow introduced in this PR, enhancing the testing processes for the Bolt contracts project.

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: 26

bolt-contracts/remappings.txt Outdated Show resolved Hide resolved
bolt-contracts/test/BoltValidators.t.sol Outdated Show resolved Hide resolved
bolt-contracts/src/lib/ssz/ValidatorProver.sol Outdated Show resolved Hide resolved
bolt-contracts/src/interfaces/IBoltValidators.sol Outdated Show resolved Hide resolved
bolt-contracts/src/lib/MapWithTimeData.sol Show resolved Hide resolved
bolt-contracts/src/lib/bls/BLS12381.sol Show resolved Hide resolved
bolt-contracts/src/lib/bls/BLS12381.sol Outdated Show resolved Hide resolved
bolt-contracts/src/lib/bls/BLS12381.sol Show resolved Hide resolved
bolt-contracts/src/lib/bls/BLS12381.sol Show resolved Hide resolved
bolt-contracts/src/lib/bls/BLS12381.sol Show resolved Hide resolved
using BLS12381 for *;

/// @dev The domain separation tag for the BLS signature
function dst() internal pure returns (bytes memory) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: this will probably be the commit-boost signing domain

@merklefruit merklefruit linked an issue Sep 10, 2024 that may be closed by this pull request
@merklefruit merklefruit removed this from the v0.3: Holesky 1 milestone Sep 13, 2024
@merklefruit
Copy link
Collaborator Author

Big milestone, LFG!

@merklefruit merklefruit merged commit f2a8be1 into unstable Oct 21, 2024
6 checks passed
@merklefruit merklefruit deleted the nico/feat/commitment-registry branch October 21, 2024 14:44
@merklefruit merklefruit restored the nico/feat/commitment-registry branch October 21, 2024 14:45
@fmosterts
Copy link
Contributor

Let's go!! congratss

@mempirate mempirate deleted the nico/feat/commitment-registry branch October 21, 2024 14:54
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 T: feature Type: Feature
Projects
None yet
5 participants