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

Integrate with the Bolt registry to check if pubkeys are registered #340

Merged
merged 15 commits into from
Oct 30, 2024

Conversation

thedevbirb
Copy link
Contributor

@thedevbirb thedevbirb commented Oct 29, 2024

Closes #332.

Introduces new checks for both the commitment signer key and the validator public keys which should correspond to an active operator and validator respectively in the BoltManager contract.

The check is performed at startup, when creating the SidecarDriver::from_components. This is a good spot because both signers (ECDSA, BLS) are abstracted via traits so the check can be safely done in a single pace.

Summary by CodeRabbit

  • New Features

    • Introduced public_key method in the SignerECDSA trait and its implementations, allowing retrieval of the public key as an address.
    • Added BoltManager for enhanced key verification in the SidecarDriver.
    • Launched the onchain_registry module, expanding on-chain management capabilities.
    • Implemented various utility methods in BoltManager for address retrieval and operator/validator verification.
  • Bug Fixes

    • Improved readability of conditional statements and return formats in several methods.
  • Documentation

    • Enhanced comments for clarity in the make_path and test_keystore_signer functions.

@thedevbirb thedevbirb added the C: bolt-sidecar Component: bolt-sidecar label Oct 29, 2024
@thedevbirb thedevbirb added this to the v0.3: Holesky 1 milestone Oct 29, 2024
@thedevbirb thedevbirb force-pushed the lore/feat/check-pubkeys-registry branch from 5470221 to e455d3c Compare October 29, 2024 14:52
@thedevbirb thedevbirb marked this pull request as ready for review October 29, 2024 14:58
bolt-sidecar/src/onchain_registry.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/driver.rs Show resolved Hide resolved
}
}

sol! {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future we should probably do something to keep these interfaces up to date, @coderabbitai please draft an issue

Copy link
Contributor

Choose a reason for hiding this comment

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

@mempirate, I've created an issue to track keeping the interfaces up to date: Issue #341.

🔗 Analysis chain

@mempirate, I've drafted an issue to keep these interfaces up to date.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Create a GitHub issue to track keeping interfaces up to date
gh issue create \
  --title "Maintain Up-to-Date Interfaces in Codebase" \
  --body "As discussed in [this comment](https://github.com/chainbound/bolt/pull/340#discussion_r1821409808) by @mempirate on [PR #340](https://github.com/chainbound/bolt/pull/340), we should implement a process to ensure that interfaces remain up to date." \
  --assignee mempirate

Length of output: 393


✏️ Learnings added
Learnt from: mempirate
PR: chainbound/bolt#340
File: bolt-sidecar/src/onchain_registry.rs:143-143
Timestamp: 2024-10-29T19:21:54.868Z
Learning: Ensure that interfaces in the codebase are kept up to date by implementing a process to maintain them.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Contributor

Choose a reason for hiding this comment

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

Beast

Copy link
Contributor

Choose a reason for hiding this comment

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

@mempirate, happy to help!

(_/)
(^.^)
(")(")

@mempirate
Copy link
Contributor

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Walkthrough

This pull request introduces several enhancements across multiple files, primarily focusing on the SignerECDSA trait and the integration of a new BoltManager struct. The public_key method is added to both SignerECDSA and its implementations, allowing retrieval of public keys as Address. Additionally, a new module, onchain_registry, is created to encapsulate the BoltManager, which manages operator and validator key verification. The changes also include minor formatting updates for improved readability in various methods.

Changes

File Path Change Summary
bolt-sidecar/src/crypto/ecdsa.rs Added public_key method to SignerECDSA trait and its implementation in PrivateKeySigner.
bolt-sidecar/src/driver.rs Introduced BoltManager struct; updated from_components method to verify keys using BoltManager.
bolt-sidecar/src/lib.rs Added new module onchain_registry and exported BoltManager.
bolt-sidecar/src/onchain_registry.rs Created BoltManager with methods for address retrieval, instance creation, and key verification.
bolt-sidecar/src/signer/commit_boost.rs Added public_key method to CommitBoostSigner for converting ECDSA public key to Address.
bolt-sidecar/src/signer/keystore.rs Minor comment formatting changes in make_path and test_keystore_signer functions.
bolt-sidecar/src/state/consensus.rs Reformatted conditional statements and return statements in validate_request, furthest_slot, and fetch_proposer_duties methods for readability.

Assessment against linked issues

Objective Addressed Explanation
Check if validator and operator public keys are registered (#332)

Possibly related PRs

Suggested labels

T: feature

Suggested reviewers

  • thedevbirb

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between bac4a76 and a68065b.

📒 Files selected for processing (7)
  • bolt-sidecar/src/crypto/ecdsa.rs (2 hunks)
  • bolt-sidecar/src/driver.rs (2 hunks)
  • bolt-sidecar/src/lib.rs (1 hunks)
  • bolt-sidecar/src/onchain_registry.rs (1 hunks)
  • bolt-sidecar/src/signer/commit_boost.rs (2 hunks)
  • bolt-sidecar/src/signer/keystore.rs (2 hunks)
  • bolt-sidecar/src/state/consensus.rs (4 hunks)
🔇 Additional comments (12)
bolt-sidecar/src/lib.rs (1)

51-52: Verify module documentation.

The module addition and export look good and align with the PR objectives for Bolt registry integration. However, ensure that the onchain_registry module has proper documentation.

✅ Verification successful

Module documentation is present and comprehensive

The onchain_registry module has proper documentation. The main BoltManager struct is well-documented with a clear description, and its methods have detailed doc comments explaining their functionality. The documentation covers the purpose and behavior of key components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the onchain_registry module has documentation
# Expect: Module documentation should be present

rg -U "(?s)/// .*\nmod onchain_registry" "bolt-sidecar/src/onchain_registry.rs"

Length of output: 79


Script:

#!/bin/bash
# Let's check the actual content of the onchain_registry.rs file
cat bolt-sidecar/src/onchain_registry.rs

Length of output: 6051

bolt-sidecar/src/crypto/ecdsa.rs (2)

3-6: LGTM: Clean import organization

The imports are well-organized and properly scoped for the new Address type requirement.


71-74: LGTM: Clean implementation with proper delegation

The implementation correctly delegates to the existing address() method. Let's verify the address format consistency.

bolt-sidecar/src/signer/commit_boost.rs (1)

3-3: LGTM: Import addition is appropriate.

The addition of Address from alloy::primitives aligns with the new functionality.

bolt-sidecar/src/state/consensus.rs (4)

120-121: LGTM: Improved readability of deadline check.

The condition is now more readable while maintaining the correct logic for checking if the request is within the commitment deadline.


204-206: LGTM: Improved readability of slot calculation.

The furthest slot calculation is now more readable with proper line breaks.


328-329: LGTM: Improved readability of epoch calculation.

The epoch calculation from slot is now more readable with proper line breaks.


164-165: 🧹 Nitpick (assertive)

Consider implementing the registry integration.

There's a TODO comment about registry integration in validate_request. Since this PR is about integrating with the Bolt registry, we should implement this check.

Let's verify if there are any other TODO comments about registry integration:

Would you like help implementing the registry integration for validator verification?

bolt-sidecar/src/signer/keystore.rs (2)

206-207: LGTM!

The comment reformatting improves readability while maintaining clarity.


305-306: LGTM!

The comment reformatting improves readability while maintaining clarity.

bolt-sidecar/src/driver.rs (2)

33-34: New dependencies are correctly imported

The added imports (BoltManager, BuilderProxyConfig, CommitBoostSigner, etc.) are appropriate and correspond to the new functionality introduced.


168-171: Verify the association between operator and validators

As previously noted, it's important to verify that the provided operator is active for the specified validators to ensure correct linkage and system integrity.

bolt-sidecar/src/crypto/ecdsa.rs Show resolved Hide resolved
bolt-sidecar/src/onchain_registry.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/onchain_registry.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/onchain_registry.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/driver.rs Outdated Show resolved Hide resolved
@chainbound chainbound deleted a comment from coderabbitai bot Oct 29, 2024
@thedevbirb thedevbirb requested a review from mempirate October 30, 2024 10:31
Etherscan links usually does some checks like user agent for dos
protection, to avoid that we should call the api with a proper API key
@thedevbirb thedevbirb force-pushed the lore/feat/check-pubkeys-registry branch from 2992eb5 to 5e8bb1f Compare October 30, 2024 10:32
ValidatorDoesNotExist now returns also the public key hash
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.

Great!

bolt-sidecar/src/chain_io/manager.rs Show resolved Hide resolved
bolt-sidecar/src/chain_io/utils.rs Outdated Show resolved Hide resolved
@thedevbirb thedevbirb force-pushed the lore/feat/check-pubkeys-registry branch from 440775e to 4c0c9ee Compare October 30, 2024 12:12
@thedevbirb thedevbirb force-pushed the lore/feat/check-pubkeys-registry branch from 4c0c9ee to abd3843 Compare October 30, 2024 12:13
Copy link
Contributor

@mempirate mempirate left a comment

Choose a reason for hiding this comment

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

Last nit, great work

bolt-sidecar/src/config/chain.rs Outdated Show resolved Hide resolved
@thedevbirb thedevbirb force-pushed the lore/feat/check-pubkeys-registry branch from 5a89cf9 to bc54408 Compare October 30, 2024 13:47
@thedevbirb thedevbirb force-pushed the lore/feat/check-pubkeys-registry branch from bc54408 to c589453 Compare October 30, 2024 13:49
@thedevbirb thedevbirb merged commit cacf9bb into unstable Oct 30, 2024
4 checks passed
@thedevbirb thedevbirb deleted the lore/feat/check-pubkeys-registry branch October 30, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: bolt-sidecar Component: bolt-sidecar
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate with the Bolt registry to check if pubkeys are registered
3 participants