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: refactor config and add ChainConfig #108

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

merklefruit
Copy link
Collaborator

@merklefruit merklefruit commented Jul 3, 2024

Summary by CodeRabbit

  • New Features

    • Introduced ChainConfig for enhanced chain configuration management, providing defaults for commitment deadlines and slot times.
  • Refactor

    • Renamed Chain to ChainConfig across various modules for better clarity and organization.
    • Updated configuration and signature methods to utilize ChainConfig.
    • Reorganized configuration modules to better structure chain and signing options.
  • Chores

    • Removed outdated constants and fields related to commitment_deadline.
    • Enhanced command-line options with new SigningOpts struct for signing configurations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is made to work like before: we have default values for all chains, and CLI arguments "slot_time_in_seconds" and "commitment_deadline" are optional and override the defaults.

@merklefruit merklefruit requested a review from thedevbirb July 3, 2024 17:05
@merklefruit merklefruit added C: bolt-sidecar Component: bolt-sidecar T: feature Type: Feature labels Jul 3, 2024
/// The slot time duration in seconds. If provided,
/// it overrides the default for the selected [Chain].
#[clap(short = 's', long, default_value_t = DEFAULT_SLOT_TIME_IN_SECONDS)]
slot_time_in_seconds: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just do slot_time and add a description saying it's in seconds!

#[clap(short = 'k', long)]
pub(super) private_key: Option<String>,
/// URL for the commit-boost sidecar
#[clap(short = 'C', long, conflicts_with("private_key"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't know conflicts_with, sick!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just ported over, work of @thedevbirb :)

@mempirate
Copy link
Contributor

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The changes refactor the config module in the bolt-sidecar by breaking it down into separate files: mod.rs, chain.rs, and signing.rs. This restructure includes renaming entities, updating references, and improving configuration handling, such as accessing parameters through methods and enhancing chain configuration.

Changes

Files Change Summary
bolt-sidecar/bin/sidecar.rs Updated commitment_deadline access method
bolt-sidecar/src/builder/mod.rs Renamed Chain to ChainConfig in LocalBuilder struct
bolt-sidecar/src/builder/signature.rs Renamed and updated function signatures, test functions, and usage of chain variants to ChainConfig
bolt-sidecar/src/config/chain.rs Introduced ChainConfig struct and related defaults and methods
bolt-sidecar/src/config/mod.rs Refactored module structure, updated Opts and Config structs, removed old constants and enums
bolt-sidecar/src/config/signing.rs Added SigningOpts struct for command-line signing options
bolt-sidecar/src/lib.rs Renamed Chain to ChainConfig in exports

Assessment against linked issues

Objective (#) Addressed Explanation
Refactor config module into separate files (### #106)
Ensure Chain configuration handles commitment deadlines via methods

Poem

Amidst the code, changes sprout anew,
Chains and configs, aligned just right,
Methods now call with deadlines in view,
Wrapping sidecar in a refactored light.
A rabbit smiles, a job well done,
For tidy code, it's always fun!
🌿📜🐇

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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: 0

Outside diff range and nitpick comments (2)
bolt-sidecar/src/config/signing.rs (1)

1-16: Ensure consistency in documentation comments.

The documentation comments for the fields private_key and commit_boost_url are clear and concise. Ensure that similar comments are consistently used throughout the codebase for better readability and maintainability.

bolt-sidecar/src/config/chain.rs (1)

1-31: Ensure consistency in documentation comments.

The documentation comments for constants and fields are clear and concise. Ensure that similar comments are consistently used throughout the codebase for better readability and maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 067346f and 35cd0c6.

Files selected for processing (7)
  • bolt-sidecar/bin/sidecar.rs (1 hunks)
  • bolt-sidecar/src/builder/mod.rs (2 hunks)
  • bolt-sidecar/src/builder/signature.rs (3 hunks)
  • bolt-sidecar/src/config/chain.rs (1 hunks)
  • bolt-sidecar/src/config/mod.rs (7 hunks)
  • bolt-sidecar/src/config/signing.rs (1 hunks)
  • bolt-sidecar/src/lib.rs (1 hunks)
Additional comments not posted (15)
bolt-sidecar/src/lib.rs (1)

28-28: LGTM! Ensure consistency in imports and exports.

The export statement has been updated correctly to export ChainConfig instead of Chain.

bolt-sidecar/src/config/chain.rs (5)

32-47: LGTM! Ensure default values are correctly documented.

The ChainConfig struct and its fields are well-defined with appropriate default values. The documentation comments are clear and concise.


48-57: LGTM! Default implementation is correct.

The Default implementation for ChainConfig is correct and aligns with the defined default values.


58-68: LGTM! Enum definition is clear.

The Chain enum is well-defined and uses the ValueEnum trait for command-line argument parsing.


70-119: LGTM! Methods for ChainConfig are well-defined.

The methods for ChainConfig are well-defined and provide necessary functionality for chain-specific configurations.


122-152: LGTM! Test functions are well-defined.

The test functions for different chain configurations are well-defined and ensure the correctness of the ChainConfig methods.

bolt-sidecar/src/builder/signature.rs (2)

10-18: LGTM! Ensure consistency in function signatures.

The function signature for sign_builder_message has been updated correctly to use ChainConfig.


36-36: LGTM! Ensure consistency in function signatures.

The function signature for verify_signed_builder_message has been updated correctly to use ChainConfig.

bolt-sidecar/src/builder/mod.rs (1)

16-16: LGTM! Ensure consistency in struct definitions.

The LocalBuilder struct has been updated correctly to use ChainConfig instead of Chain.

bolt-sidecar/bin/sidecar.rs (1)

41-41: Ensure the new commitment_deadline method is correctly implemented.

The commitment_deadline is now accessed through config.chain.commitment_deadline(). Verify that this method returns the expected value.

Verification successful

The commitment_deadline method is correctly implemented.

The commitment_deadline method in ChainConfig returns a Duration derived from the commitment_deadline field, which is properly defined and initialized.

  • bolt-sidecar/src/config/chain.rs: pub fn commitment_deadline(&self) -> Duration
  • bolt-sidecar/src/config/chain.rs: commitment_deadline: u64
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `commitment_deadline` method in the `ChainConfig` struct.

# Test: Search for the `commitment_deadline` method definition. Expect: A method that returns the commitment deadline.
rg --type rust $'fn commitment_deadline' --context 5

Length of output: 676


Script:

#!/bin/bash
# Description: Verify the definition and initialization of `commitment_deadline` within the `ChainConfig` struct.

# Test: Search for the `commitment_deadline` field in the `ChainConfig` struct.
rg --type rust 'commitment_deadline' --context 5

Length of output: 10655

bolt-sidecar/src/config/mod.rs (5)

7-9: LGTM! The ChainConfig module is correctly introduced and used.

The ChainConfig module is correctly introduced and used in the Opts and Config structs.


10-11: LGTM! The SigningOpts module is correctly introduced and used.

The SigningOpts module is correctly introduced and used in the Opts struct.


59-61: LGTM! The ChainConfig is correctly used in the Opts struct.

The ChainConfig is correctly used in the Opts struct.


98-98: LGTM! The ChainConfig is correctly used in the Config struct.

The ChainConfig is correctly used in the Config struct.


203-204: LGTM! The ChainConfig is correctly assigned in the try_from implementation.

The ChainConfig is correctly assigned in the try_from implementation for the Config struct.

Copy link
Contributor

@namn-grg namn-grg left a comment

Choose a reason for hiding this comment

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

LGTM, good refactor!

@merklefruit merklefruit merged commit 4f87242 into feat/fallback-builder-api Jul 4, 2024
@merklefruit merklefruit deleted the chore/refactor-config branch July 4, 2024 07:21
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 T: feature Type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants