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(spammer): add blob txs #140

Merged
merged 9 commits into from
Jul 17, 2024
Merged

feat(spammer): add blob txs #140

merged 9 commits into from
Jul 17, 2024

Conversation

namn-grg
Copy link
Contributor

@namn-grg namn-grg commented Jul 17, 2024

fixes #134

Summary by CodeRabbit

  • New Features

    • Added new commands for sending blob preconfirmation transactions.
  • Functionality Enhancements

    • Improved error handling with more specific error types and better messages.
    • Added functions to retrieve operator and registrant information.
    • Introduced support for blob transactions.
  • Refactor

    • Transitioned from Ethers to Alloy for Ethereum operations.
    • Updated transaction signing to work with EthereumWallet.
  • Testing

    • Added extensive unit tests for registry contract interactions.

Copy link
Contributor

coderabbitai bot commented Jul 17, 2024

Warning

Rate limit exceeded

@namn-grg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 55 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 5562d81 and e890b51.

Walkthrough

The changes introduce a new target send-blob-preconf in the Justfile to support sending blob transactions via CLI. Dependencies in bolt-spammer-helder are updated, including replacing ethers with alloy. Significant refactoring in several modules improves error handling, transaction generation, and signing. New functions and extensive unit tests for contract interactions are added, enhancing functionality and reliability.

Changes

File(s) Change Summary
Justfile Added a new target send-blob-preconf for sending blob preconfirmations.
Cargo.toml Removed ethers dependency; added alloy, url, and reth-primitives dependencies.
rustfmt.toml Introduced Rustfmt configuration settings.
src/contract.rs Refactored contract interaction logic, improved error handling, added new functions and unit tests.
src/main.rs Modified imports, struct definitions, function calls, and variable assignments, added blob transaction support.
src/utils.rs Migrated from ethers to alloy, updated transaction generation and signing logic, introduced blob transactions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Justfile
    participant MainRS
    participant ContractRS
    participant UtilsRS

    User->>Justfile: Run `just send-blob-preconf`
    Justfile->>MainRS: Invoke main function with blob flag
    MainRS->>UtilsRS: Generate blob transaction
    UtilsRS->>ContractRS: Interact with BoltRegistry contract
    ContractRS->>UtilsRS: Return transaction data
    UtilsRS->>MainRS: Sign transaction using EthereumWallet
    MainRS->>User: Confirmation of blob preconfirmation sent
Loading

Assessment against linked issues

Objective (Issue #134) Addressed Explanation
Extend CLI spammer to support blob transactions
Introduce new command just blob-preconf

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.

@namn-grg namn-grg marked this pull request as ready for review July 17, 2024 12:48
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 0af46f9 and 82c4511.

Files ignored due to path filters (1)
  • bolt-spammer-helder/Cargo.lock is excluded by !**/*.lock
Files selected for processing (6)
  • Justfile (1 hunks)
  • bolt-spammer-helder/Cargo.toml (2 hunks)
  • bolt-spammer-helder/rustfmt.toml (1 hunks)
  • bolt-spammer-helder/src/contract.rs (1 hunks)
  • bolt-spammer-helder/src/main.rs (3 hunks)
  • bolt-spammer-helder/src/utils.rs (2 hunks)
Additional comments not posted (16)
bolt-spammer-helder/rustfmt.toml (1)

1-11: Configuration settings for rustfmt are appropriate.

The settings chosen in rustfmt.toml are standard and align well with best practices for Rust formatting, promoting consistency and readability in the codebase.

bolt-spammer-helder/Cargo.toml (1)

20-22: Updated dependencies in Cargo.toml look good, but verify compatibility.

The changes to dependencies are aligned with the refactoring efforts described in the PR. However, it's crucial to ensure that the new libraries (alloy, url, reth-primitives) are compatible with the existing project setup and are stable enough for production use.

Verification successful

Updated dependencies in Cargo.toml look good, but verify compatibility.

The changes to dependencies are aligned with the refactoring efforts described in the PR. However, it's crucial to ensure that the new libraries (alloy, url, reth-primitives) are compatible with the existing project setup and are stable enough for production use.

  • alloy version: 0.2.0 with features: ["full"]
  • url version: 2.5.2
  • reth-primitives from Git revision: 71c404d
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the stability and compatibility of new dependencies.

# Test: Check the latest version and compatibility of `alloy`, `url`, and `reth-primitives`.
cat Cargo.toml | grep -E 'alloy|url|reth-primitives'

Length of output: 97


Script:

#!/bin/bash
# Locate the Cargo.toml file in the repository
fd Cargo.toml

Length of output: 94


Script:

#!/bin/bash
# Verify the dependencies in the bolt-spammer-helder/Cargo.toml file
cat bolt-spammer-helder/Cargo.toml | grep -E 'alloy|url|reth-primitives'

Length of output: 222

bolt-spammer-helder/src/utils.rs (4)

24-32: Refactored function generate_random_tx is well-implemented.

The function has been updated to use the alloy library's TransactionRequest. The implementation is clean and follows best practices for generating random transactions.


34-48: Refactored function generate_random_blob_tx is well-implemented.

The function now handles blob transactions using the alloy library. The use of SidecarBuilder and BlobTransactionSidecar is appropriate and aligns with the intended functionality of handling blob transactions efficiently.


53-66: Updated transaction signing logic in sign_transaction.

The function has been updated to use EthereumWallet for signing transactions, which is a change from the previous implementation using Signer from ethers. The new implementation is more streamlined and uses modern Rust async features effectively.


82-83: Improved error handling in current_slot function.

The function now handles potential errors more robustly, improving the reliability of fetching the current slot from the beacon API.

bolt-spammer-helder/src/main.rs (4)

49-50: Updated wallet and transaction signer initialization.

The initialization of wallet and transaction_signer has been updated to use PrivateKeySigner and EthereumWallet respectively. This change is aligned with the new dependency on the alloy library and enhances the security and flexibility of the signing process.


54-55: New BoltRegistry struct usage is effective.

The use of the BoltRegistry struct for managing registry-related operations is a good practice, promoting cleaner and more modular code.


73-84: Robust error handling in transaction preconfirmation logic.

The error handling in the next_preconfer_from_registry method is robust, providing clear feedback and handling different outcomes effectively.


86-97: Conditional transaction generation based on blob flag is implemented correctly.

The logic to conditionally generate blob or regular transactions based on the blob flag is correct and efficiently handles different transaction types.

Justfile (1)

103-112: Review of the new send-blob-preconf target

The new target send-blob-preconf appears well-configured and consistent with the existing structure of the Justfile. It correctly sets up the necessary parameters for sending a blob preconfirmation to the bolt devnet. This aligns with the PR objectives to extend the spammer functionality.

bolt-spammer-helder/src/contract.rs (5)

17-26: Introduction of BoltRegistry struct

The new BoltRegistry struct encapsulates the contract interaction logic, which is a good practice for modularity and maintainability. The constructor method new is well-implemented, making use of the builder pattern for the Provider.


28-37: Method get_sidecar_rpc_url_for_validator Review

This method is well-designed, handling potential cases where the operator might not be found in the registry gracefully. The use of Option in the return type to signify the absence of data is appropriate.


74-118: Functionality next_preconfer_from_registry

This method efficiently retrieves the next pre-confirmation slot and proposer RPC URL. The loop and error handling are correctly implemented. Logging is used effectively to provide insights during the operation, which aids in debugging and monitoring.


122-155: Solidity Interface Definition within sol! Macro

The interface definition for BoltRegistryContract is clear and well-structured. The use of custom structs and enums within the interface helps in maintaining clear and type-safe interactions with the contract.


158-241: Comprehensive Unit Tests

The unit tests provided are comprehensive and cover the functionalities of the BoltRegistry struct extensively. The use of mock data and assertions ensures that the contract interactions are being tested rigorously.

bolt-spammer-helder/src/contract.rs 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 82c4511 and 5562d81.

Files selected for processing (1)
  • bolt-spammer-helder/src/utils.rs (2 hunks)
Additional comments not posted (5)
bolt-spammer-helder/src/utils.rs (5)

1-7: Updated imports to use Alloy instead of Ethers.

The shift from ethers to alloy aligns with the PR's goal of enhancing Ethereum operations. The new imports include crucial modules for transaction and sidecar management which are essential for the new blob transaction functionality.


24-31: Refactored generate_random_tx to use TransactionRequest.

The refactoring from TypedTransaction to TransactionRequest is a significant change. This update simplifies the transaction generation process and aligns with the new Alloy usage.


34-48: Introduced generate_random_blob_tx for blob transaction generation.

This new function aligns with the PR's objectives to support blob transactions. The use of SidecarBuilder and BlobTransactionSidecar is appropriate for handling the specifics of blob transactions.


53-64: Updated sign_transaction to use EthereumWallet and handle errors.

The function now uses EthereumWallet instead of a generic Signer, which is more specific and appropriate given the context of Alloy's capabilities. The error handling with the else block is a good practice, ensuring that transaction signing failures are properly managed.


80-81: Refactored current_slot for improved readability and efficiency.

The function has been streamlined to directly retrieve and return the current slot, improving both readability and performance by reducing unnecessary variable assignments.

@merklefruit merklefruit merged commit f18df79 into unstable Jul 17, 2024
1 check failed
@merklefruit merklefruit deleted the ng/feat/blob-spammer branch July 17, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blob tx spammer via CLI
2 participants