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: minimal rpc client #160

Merged
merged 16 commits into from
Jul 26, 2024
Merged

feat: minimal rpc client #160

merged 16 commits into from
Jul 26, 2024

Conversation

merklefruit
Copy link
Collaborator

@merklefruit merklefruit commented Jul 23, 2024

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a command-line interface (CLI) for interacting with the Bolt system, allowing users to manage blockchain transactions with enhanced configuration options.
    • Added a comprehensive README.md file detailing setup instructions, environment variables, and usage examples for the new CLI tool.
    • Implemented functionality to retrieve proposer duties from the beacon API, enriching the data interaction capabilities of the application.
  • Changes

    • Renamed the package from bolt-spammer-helder to bolt-rpc-client to reflect its new focus on RPC functionalities.
    • Adjusted dependency organization for clarity in the project configuration.
    • Removed the .env file from the ignore list to allow tracking of environment variables in version control.
  • Bug Fixes

    • Enhanced error handling and output formatting for improved user experience during transaction submissions.

Copy link
Contributor

coderabbitai bot commented Jul 23, 2024

Walkthrough

The changes primarily focus on renaming and consolidating Rust packages within the bolt-client project. The package bolt-spammer-helder has been renamed to bolt-rpc-client, and enhancements have been made to the CLI application for interacting with the Bolt system. The introduction of a README.md and updates to various source files improve clarity and usability, while modifications to the .gitignore reflect a shift in how sensitive data is managed.

Changes

Files Change Summary
bolt-client/.gitignore Removed line ignoring .env, allowing it to be tracked in version control.
bolt-client/Cargo.toml Renamed package from bolt-spammer-helder to bolt-rpc-client and reorganized dependencies for clarity.
bolt-client/README.md Introduced documentation detailing usage, requirements, and command-line options for the Bolt CLI client.
bolt-client/src/main.rs, bolt-client/src/registry.rs, bolt-client/src/utils.rs Implemented command-line application for blockchain interaction, including transaction submission logic, enhanced testing capabilities, and improved transaction generation and beacon API interactions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant RPC
    participant BeaconAPI

    User->>CLI: Start CLI with options
    CLI->>RPC: Connect using RPC URL
    alt Use Registry
        CLI->>BeaconAPI: Fetch current slot
        BeaconAPI-->>CLI: Return current slot
        CLI->>RPC: Fetch lookahead data
    else No Registry
        CLI->>RPC: Get transaction details
    end
    CLI->>RPC: Submit transaction
    RPC-->>CLI: Transaction response
    CLI-->>User: Display result
Loading

Assessment against linked issues

Objective Addressed Explanation
Rename bolt-spammer-helder to bolt-client (#[163])
Integrate bolt-rpc-client into bolt-client (#[163])
Allow fallback to querying lookahead from the CLI (#[163])

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 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.

@mempirate
Copy link
Contributor

Are we using this as a replacement for the spammer packages?

@merklefruit merklefruit added the C: bolt-rpc Component: bolt-rpc label Jul 25, 2024
@merklefruit
Copy link
Collaborator Author

@mempirate yes, see #163

@merklefruit merklefruit marked this pull request as ready for review July 25, 2024 10:47
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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 6205121 and ea1fafe.

Files ignored due to path filters (2)
  • bolt-client/Cargo.lock is excluded by !**/*.lock
  • bolt-kurtosis-client/Cargo.lock is excluded by !**/*.lock
Files selected for processing (6)
  • bolt-client/.gitignore (1 hunks)
  • bolt-client/Cargo.toml (1 hunks)
  • bolt-client/README.md (1 hunks)
  • bolt-client/src/main.rs (1 hunks)
  • bolt-client/src/registry.rs (2 hunks)
  • bolt-client/src/utils.rs (3 hunks)
Additional context used
LanguageTool
bolt-client/README.md

[uncategorized] ~21-~21: Loose punctuation mark.
Context: ...g on the RPC server: - --use-registry: bool flag to fetch data from a local no...

(UNLIKELY_OPENING_PUNCTUATION)

Additional comments not posted (14)
bolt-client/Cargo.toml (2)

2-2: LGTM! The package renaming aligns with the PR objectives.

The renaming of the package from bolt-spammer-helder to bolt-rpc-client aligns with the consolidation and rebranding objectives outlined in the PR summary.


10-24: LGTM! Dependency reorganization improves readability.

The reorganization of dependencies enhances readability and maintainability of the Cargo.toml file.

bolt-client/README.md (1)

1-29: LGTM! The documentation is clear and informative.

The README.md file provides a comprehensive overview of the Bolt CLI client, including requirements, usage instructions, and environment variables. This will help users get started quickly.

Tools
LanguageTool

[uncategorized] ~21-~21: Loose punctuation mark.
Context: ...g on the RPC server: - --use-registry: bool flag to fetch data from a local no...

(UNLIKELY_OPENING_PUNCTUATION)

bolt-client/src/utils.rs (6)

13-13: LGTM!

The constant NOICE_GAS_PRICE is correctly declared as public.


14-14: LGTM!

The constant DEAD_ADDRESS is correctly declared as public.


16-22: LGTM!

The function generate_random_tx correctly generates a random Ethereum transaction.


Line range hint 25-36:
LGTM!

The function generate_random_blob_tx correctly generates a random blob transaction.


50-52: LGTM!

The function get_current_slot correctly returns the current slot from the beacon client.


54-65: LGTM!

The function get_proposer_duties correctly retrieves and filters proposer duties from the beacon API.

bolt-client/src/main.rs (3)

1-13: LGTM!

The imports are correctly declared and necessary for the functionality of the bolt-client.


21-50: LGTM!

The Opts struct correctly defines the command-line options for the bolt-client.


52-120: LGTM!

The main function correctly initializes the bolt-client, parses command-line options, and sends transactions.

bolt-client/src/registry.rs (2)

30-30: LGTM!

The attribute #[allow(unused)] correctly suppresses warnings related to unused code within the function.


163-163: LGTM!

The import statement for ProposerDuty is correctly added to the test module.

bolt-client/.gitignore Show resolved Hide resolved
bolt-client/README.md Show resolved Hide resolved
Copy link
Contributor

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

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

Great job! Just some clap nerdsnipes and minor things

bolt-client/src/main.rs Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between ea1fafe and 9c0ccde.

Files selected for processing (1)
  • bolt-client/src/main.rs (1 hunks)
Additional comments not posted (2)
bolt-client/src/main.rs (2)

15-19: Ensure modules are defined and used.

Verify that the registry and utils modules are defined and used appropriately in the code.

Verification successful

Modules are defined and used appropriately.

The registry and utils modules are both defined and used in the codebase as expected.

  • BoltRegistry is defined in bolt-client/src/registry.rs and used in bolt-client/src/main.rs.
  • Items from utils are used in bolt-client/src/main.rs.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `registry` and `utils` modules are defined and used.

# Test: Check for module definitions. Expect: Modules are defined.
fd -t f | grep -E 'registry|utils'

Length of output: 1534


Script:

#!/bin/bash
# Description: Verify that `BoltRegistry` and items from `utils` are used in the codebase.

# Check for usage of `BoltRegistry`.
rg 'BoltRegistry' -A 5

# Check for usage of items from `utils`.
rg 'utils::' -A 5

Length of output: 18441


1-13: Ensure all imported modules are used.

Verify that all imported modules are utilized in the code to avoid unnecessary dependencies.

Verification successful

All imported modules are used.

All the imported modules in the provided snippet are utilized in the codebase, and there are no unnecessary dependencies.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all imported modules are used in the code.

# Test: Check for unused imports. Expect: No unused imports.
rg --type rust -A 5 $'use ' | awk '{print $2}' | sort | uniq -c

Length of output: 10496

bolt-client/src/main.rs Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 9c0ccde and 621e7b2.

Files selected for processing (1)
  • bolt-client/src/main.rs (1 hunks)
Additional comments not posted (6)
bolt-client/src/main.rs (6)

1-8: Imports look good!

The necessary imports for the RPC client functionality are included.


15-19: Module declarations look good!

The necessary modules for registry and utilities are correctly declared.


21-50: Command-line options look good!

The Opts struct includes all necessary command-line options with appropriate annotations.


52-58: Initialize dotenv before tracing.

Initialize dotenv before tracing to ensure environment variables are loaded correctly.

-    tracing_subscriber::fmt::init();
-    info!("starting bolt-client");
-
-    let _ = dotenvy::dotenv();
+    let _ = dotenvy::dotenv();
+    tracing_subscriber::fmt::init();
+    info!("starting bolt-client");

65-86: Ensure error handling for reqwest::get response.

Add error handling for the reqwest::get response to avoid potential panics.

-    let lookahead_response = reqwest::get(url).await?.json::<serde_json::Value>().await?;
-    let next_preconfer_slot = lookahead_response[0].get("slot").unwrap().as_u64().unwrap();
+    let lookahead_response = reqwest::get(url).await?.json::<serde_json::Value>().await?;
+    let next_preconfer_slot = lookahead_response.get(0)
+        .and_then(|v| v.get("slot"))
+        .and_then(|v| v.as_u64())
+        .ok_or_else(|| eyre::eyre!("Failed to parse slot from lookahead response"))?;

88-91: Optimize transaction generation and signing.

Consider optimizing the transaction generation and signing process for better performance.

-    let mut tx = if opts.blob { generate_random_blob_tx() } else { generate_random_tx() };
+    let mut tx = match opts.blob {
+        true => generate_random_blob_tx(),
+        false => generate_random_tx(),
+    };

bolt-client/src/main.rs Show resolved Hide resolved
bolt-client/src/main.rs Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
@merklefruit merklefruit requested a review from mempirate July 26, 2024 12:36
@@ -1,21 +1,24 @@
[package]
name = "bolt-spammer-helder"
name = "bolt-rpc-client"
version = "0.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

This actually counts for the sidecar as well, but on the next release we should bump these versions!

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.

LGTM, some minor spec deviations

bolt-client/src/main.rs Outdated Show resolved Hide resolved
bolt-client/src/main.rs Outdated Show resolved Hide resolved
bolt-client/src/utils.rs Outdated Show resolved Hide resolved
bolt-client/src/utils.rs Show resolved Hide resolved
bolt-kurtosis-client/src/main.rs Outdated Show resolved Hide resolved
@mempirate mempirate merged commit db58877 into unstable Jul 26, 2024
2 checks passed
@mempirate mempirate deleted the feat/rpc-client branch July 26, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: bolt-rpc Component: bolt-rpc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: consolidate spammer packages in a single one
3 participants