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

Submit constraints only after commitments deadline + block template refactor #117

Merged
merged 168 commits into from
Jul 18, 2024

Conversation

thedevbirb
Copy link
Contributor

@thedevbirb thedevbirb commented Jul 4, 2024

This PR refactors the block template by using the signed constraints list instead of the transactions signed. This allows a more granular control over the current state of the pre-confirmations accepted, by dropping an entire set of constraints in case some of its pre-confirmed transactions have been invalidated.

Summary by CodeRabbit

  • New Features

    • Introduced pre-confirmation spammer for Helder testnet with environment variable configuration.
    • Added functions for generating random Ethereum transactions and fetching the current slot using a Beacon API client.
  • Enhancements

    • Improved commitment validation and signing processes.
    • Integrated constraints into the execution state with enhanced retry logic for constraint submissions.
    • Optimized gas-related adjustments and transaction handling across various modules.
  • Bug Fixes

    • Refined error handling for hexadecimal parsing and decoding.
  • Chores

    • Added .env to .gitignore to exclude sensitive information from version control.
    • Updated dependencies in Cargo.toml to reflect new project requirements.
  • Documentation

    • Updated README.md to provide instructions for running the new pre-confirmation spammer.
    • Added rustfmt.toml for consistent code formatting.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Walkthrough

The changes across the files primarily focus on enhancing the commitment and constraint handling logic within the Bolt Sidecar project. Significant updates include the introduction of parameters for ExecutionState initialization, refactoring of commitment validation, updated signing processes, caching of pre-confirmations until the commitment deadline, and gas-related transaction adjustments. New functionalities such as fetching the blob base fee and generating random Ethereum transactions were added, along with the introduction of new dependencies and configuration changes.

Changes

Files / Grouped Files Summary of Changes
bolt-sidecar/bin/sidecar.rs Added parameter for ExecutionState initialization, updated commitment validation and signing, integrated constraints, enhanced retry logic, gas adjustments.
bolt-sidecar/src/api/builder.rs Refactored BuilderProxyServer struct, updated error handling and logging, managed local payload caching, gas adjustments.
bolt-sidecar/src/builder/mod.rs Refactored build_new_local_payload method, gas adjustments, enhanced payload construction logic.
bolt-sidecar/src/builder/template.rs Transitioned to managing constraints within block template, gas adjustments, enhanced constraint handling logic.
bolt-sidecar/src/client/rpc.rs Refined error handling for get_chain_id, added get_blob_basefee method, gas adjustments.
bolt-sidecar/src/common.rs Updated function signatures to use PooledTransactionsElement, refined imports, introduced TransactionExt, gas adjustments.
bolt-sidecar/src/json_rpc/api.rs Modified handling of CommitmentRequest, introduced gas adjustments, enhanced commitment request processing logic.
bolt-sidecar/src/primitives/commitment.rs Shifted transaction handling to PooledTransactionsElement, updated serialization and deserialization functions.
bolt-sidecar/src/primitives/constraint.rs Imported Address and PooledTransactionsElement, added sender field to Constraint, adjusted functions for sender, gas adjustments.
bolt-sidecar/src/primitives/mod.rs Modified AccountState, GetPayloadResponse, added TransactionExt trait, gas adjustments.
bolt-sidecar/src/state/execution.rs Reorganized imports, added error variants for fee validation, introduced max_commitments_per_slot, updated method signatures, gas adjustments.
bolt-sidecar/src/state/fetcher.rs Added get_blob_basefee method to StateFetcher trait and its implementation, gas adjustments.
bolt-sidecar/src/state/mod.rs Refactored test module, gas adjustments, streamlined test suite organization.
bolt-spammer/.gitignore Added .env file to the list of ignored files.
bolt-spammer/Cargo.toml Removed ethers, added new dependencies like rand, beacon-api-client, dotenvy, alloy, url, updated clap with new features.
bolt-spammer/README.md Introduced a pre-confirmation spammer for the Helder testnet, including functionality and instructions for setting environment variables.
bolt-spammer/rustfmt.toml Introduced configuration options for Rust code formatting, specifying settings for import ordering, comments, code style, and documentation comments.
bolt-spammer/src/constants.rs Introduced public constants defining values such as slots per epoch, gas price, dead address string, and chain ID.
builder/builder/builder.go Introduced constraintsCache, utilized within Builder methods, refined constraint handling logic.
builder/builder/eth_service.go Added shardmap import, modified BuildBlock method signatures to include constraintsCache, updated implementations.
bolt-spammer/src/utils.rs Introduced functions for generating random Ethereum transactions, preparing RPC requests, and retrieving current slot using Beacon API client.

Sequence Diagrams

Old Flow (Commitment Submission)

sequenceDiagram
    participant User
    participant Sidecar
    participant MEVBoost
    participant Builder

    User->>Sidecar: Send transaction
    Sidecar->>MEVBoost: Submit constraints
    MEVBoost->>Builder: Forward constraints
    Builder->>MEVBoost: Validate and respond
    MEVBoost->>Sidecar: Receive validation
    Sidecar->>User: Acknowledge receipt
Loading

New Flow (Commitment Submission After Deadline)

sequenceDiagram
    participant User
    participant Sidecar
    participant MEVBoost
    participant Builder

    User->>Sidecar: Send transaction
    Sidecar->>Sidecar: Cache constraints
    Sidecar->>MEVBoost: After deadline, submit constraints
    MEVBoost->>Builder: Forward constraints
    Builder->>MEVBoost: Validate and respond
    MEVBoost->>Sidecar: Receive validation
    Sidecar->>User: Acknowledge receipt
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Submit constraints only after the commitment deadline (#109)
Check user balance and nonce before sending commitments (#102)
Invalidate past state (#125)

These validations ensure that the changes align with the primary objectives of the issues by adjusting the submission timing of constraints, checking balances and nonces before commitments, and clearing past states appropriately.


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.

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 025d296 and f82395c.

Files selected for processing (7)
  • bolt-sidecar/bin/sidecar.rs (3 hunks)
  • bolt-sidecar/src/builder/template.rs (3 hunks)
  • bolt-sidecar/src/config/mod.rs (3 hunks)
  • bolt-sidecar/src/primitives/constraint.rs (5 hunks)
  • bolt-sidecar/src/primitives/mod.rs (1 hunks)
  • bolt-sidecar/src/state/execution.rs (6 hunks)
  • bolt-sidecar/src/state/mod.rs (11 hunks)
Additional comments not posted (33)
bolt-sidecar/src/primitives/constraint.rs (4)

1-2: New imports look good.

The new imports for Address and TransactionSigned are necessary for the added fields and methods.


33-35: Deriving Default for SignedConstraints is appropriate.

This change is useful for creating default instances of the struct.


42-44: Deriving Default for ConstraintsMessage and adding sender parameter in build method are appropriate.

These changes enhance the functionality and usability of the struct and method.

Also applies to: 54-61


92-97: Adding tx_decoded and sender fields to Constraint and updating from_inclusion_request method are appropriate.

These changes are necessary for the enhanced functionality related to transaction handling.

Also applies to: 102-114

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

4-4: New import for NonZero looks good.

This import is necessary for the changes to the max_commitments and max_commitments_per_slot fields.


43-43: Changes to max_commitments and max_commitments_per_slot fields are appropriate.

Using Option<NonZero<usize>> and NonZero<usize> ensures that the values are non-zero, which is important for the logic that relies on these fields.

Also applies to: 127-133

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

35-35: Deriving Default for AccountState is appropriate.

This change is useful for creating default instances of the struct.

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

32-33: Passing max_commitments_per_slot to ExecutionState::new is appropriate.

This change is necessary to initialize the ExecutionState with the new parameter.


81-91: Calling check_commitment_validity to validate commitment request and retrieve sender is appropriate.

This change enhances the validation logic by incorporating the sender information.


103-103: Calling ConstraintsMessage::build with the new sender parameter is appropriate.

This change is necessary to include the sender information in the constraints message.


105-106: Initializing SignedConstraints with message and signature is appropriate.

This change is necessary to create a signed constraints instance.


107-107: Calling execution_state.add_constraint to add signed constraints is appropriate.

This change is necessary to update the execution state with the new constraints.


133-147: Calling mevboost_client.submit_constraints with retry logic is appropriate.

The retry logic ensures robustness in submitting constraints to the MEV-Boost client.

bolt-sidecar/src/builder/template.rs (8)

12-15: Import changes look good.

The new imports are necessary for the added constraint-related functionality.


30-31: Struct changes look good.

The new field signed_constraints_list is necessary for storing the signed constraints associated with the block.


41-71: Method changes look good.

The add_constraints method correctly updates the state diff and adds the signed constraints to the block template.


73-79: Method changes look good.

The transactions method correctly returns a clone of all transactions from the signed constraints list.


83-87: Method changes look good.

The transactions_len method correctly returns the length of the transactions in the block template.


91-99: Method changes look good.

The blob_count method correctly returns the blob count of the block template.


103-136: Method changes look good.

The remove_constraints_at_index method correctly removes all signed constraints at the specified index and updates the state diff.


140-179: Method changes look good.

The retain method correctly removes any transactions that conflict with the given account state.

bolt-sidecar/src/state/mod.rs (6)

70-71: Import changes look good.

The NonZero type import is necessary for the new ExecutionState::new method signature.


114-116: Test case changes look good.

The test_valid_inclusion_request test case correctly uses the new ExecutionState::new method signature.


150-152: Test case changes look good.

The test_invalid_inclusion_request_nonce test case correctly uses the new ExecutionState::new method signature.


189-191: Test case changes look good.

The test_invalid_inclusion_request_balance test case correctly uses the new ExecutionState::new method signature.


229-231: Test case changes look good.

The test_invalid_inclusion_request_basefee test case correctly uses the new ExecutionState::new method signature.


270-272: Test case changes look good.

The test_invalidate_inclusion_request test case correctly uses the new ExecutionState::new method signature.

bolt-sidecar/src/state/execution.rs (6)

4-5: Import changes look good.

The NonZero type import is necessary for the new ExecutionState struct and method signatures.


34-36: Enum changes look good.

The new variant MaxCommitmentsReachedForSlot is necessary for handling the new max_commitments_per_slot parameter.


82-83: Struct changes look good.

The new field max_commitments_per_slot is necessary for handling the new parameter.


91-100: Method changes look good.

The new method correctly initializes the ExecutionState struct with the new max_commitments_per_slot parameter.


Line range hint 123-190:
Method changes look good.

The check_commitment_validity method correctly handles the new max_commitments_per_slot parameter and validates the commitment request.


196-201: Method changes look good.

The add_constraint method correctly commits the transaction to the target block.

@thedevbirb thedevbirb force-pushed the fix/sidecar/constraints-deadline branch from f82395c to 260e7b5 Compare July 4, 2024 20:09
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 f82395c and 260e7b5.

Files selected for processing (7)
  • bolt-sidecar/bin/sidecar.rs (3 hunks)
  • bolt-sidecar/src/builder/template.rs (3 hunks)
  • bolt-sidecar/src/config/mod.rs (3 hunks)
  • bolt-sidecar/src/primitives/constraint.rs (5 hunks)
  • bolt-sidecar/src/primitives/mod.rs (1 hunks)
  • bolt-sidecar/src/state/execution.rs (6 hunks)
  • bolt-sidecar/src/state/mod.rs (11 hunks)
Additional comments not posted (33)
bolt-sidecar/src/primitives/constraint.rs (6)

Line range hint 33-37:
LGTM!

The SignedConstraints struct is well-defined and follows the required serialization and deserialization traits.


Line range hint 42-52:
LGTM!

The ConstraintsMessage struct is well-defined and follows the required serialization and deserialization traits.


54-63: LGTM!

The build method correctly constructs the ConstraintsMessage struct from an inclusion request and metadata.


92-97: Verify the necessity of skipping fields during serialization.

The tx_decoded and sender fields are skipped during serialization. Verify if these fields are needed for external use.


102-114: LGTM!

The from_inclusion_request method correctly constructs the Constraint struct from an inclusion request and metadata.


Line range hint 116-122:
LGTM!

The as_bytes method correctly converts the Constraint to a byte representation for signing.

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

35-38: LGTM!

The AccountState struct is well-defined and follows the required traits.

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

7-7: LGTM!

The changes ensure that the commitment-related fields have valid non-zero values.

Also applies to: 46-46, 132-132, 138-138

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

31-32: LGTM!

The ExecutionState initialization now includes the max_commitments_per_slot parameter, ensuring proper configuration.


81-91: LGTM!

The commitment request handling now includes validation and parsing of constraints, ensuring proper processing.


100-107: LGTM!

The constraints are now parsed and signed with the sidecar signer, ensuring proper signing.


133-147: LGTM!

The constraints are now submitted to MEV-Boost with retry logic, ensuring proper submission.


149-150: LGTM!

The local payload is now built using the transactions from the block template, ensuring proper payload construction.

bolt-sidecar/src/builder/template.rs (8)

12-15: Imports look good.

The new imports for AccountState, Constraint, and SignedConstraints are necessary and correctly used.


30-31: Struct definition update looks good.

The addition of signed_constraints_list to the BlockTemplate struct is correctly defined and integrated.


41-71: add_constraints method looks good.

The method correctly handles the addition of signed constraints and updates the state diff.


73-79: transactions method looks good.

The method correctly retrieves and clones all transactions from the signed constraints list.


83-87: transactions_len method looks good.

The method correctly calculates the length of the transactions in the block template.


91-99: blob_count method looks good.

The method correctly calculates the blob count of the block template.


103-136: remove_constraints_at_index method looks good.

The method correctly handles the removal of signed constraints and updates the state diff.


140-179: retain method looks good.

The method correctly identifies and removes transactions that conflict with the given account state.

bolt-sidecar/src/state/mod.rs (6)

71-72: Imports look good.

The new import for NonZero is necessary and correctly used.


116-118: test_valid_inclusion_request test case looks good.

The test case correctly initializes ExecutionState with the max_commitments_per_slot parameter and validates the expected behavior.


152-154: test_invalid_inclusion_request_nonce test case looks good.

The test case correctly initializes ExecutionState with the max_commitments_per_slot parameter and validates the expected behavior.


191-193: test_invalid_inclusion_request_balance test case looks good.

The test case correctly initializes ExecutionState with the max_commitments_per_slot parameter and validates the expected behavior.


231-233: test_invalid_inclusion_request_basefee test case looks good.

The test case correctly initializes ExecutionState with the max_commitments_per_slot parameter and validates the expected behavior.


272-274: test_invalidate_inclusion_request test case looks good.

The test case correctly initializes ExecutionState with the max_commitments_per_slot parameter and validates the expected behavior.

bolt-sidecar/src/state/execution.rs (6)

4-5: Imports look good.

The new import for NonZero is necessary and correctly used.


82-83: Struct definition update looks good.

The addition of max_commitments_per_slot to the ExecutionState struct is correctly defined and integrated.


91-100: new method looks good.

The method correctly initializes ExecutionState with the max_commitments_per_slot parameter.


Line range hint 123-190:
check_commitment_validity method looks good.

The method correctly checks the validity of commitments with respect to the max_commitments_per_slot parameter.


196-201: add_constraint method looks good.

The method correctly handles the addition of signed constraints to the block template.


Line range hint 237-244:
refresh_templates method looks good.

The method correctly refreshes the block templates and retains only valid signed constraints based on the canonical account states.

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 260e7b5 and 48a471e.

Files selected for processing (7)
  • bolt-sidecar/bin/sidecar.rs (3 hunks)
  • bolt-sidecar/src/builder/template.rs (3 hunks)
  • bolt-sidecar/src/config/mod.rs (3 hunks)
  • bolt-sidecar/src/primitives/constraint.rs (5 hunks)
  • bolt-sidecar/src/primitives/mod.rs (1 hunks)
  • bolt-sidecar/src/state/execution.rs (6 hunks)
  • bolt-sidecar/src/state/mod.rs (11 hunks)
Additional comments not posted (27)
bolt-sidecar/src/primitives/constraint.rs (4)

1-2: LGTM! New imports are appropriate.

The imports for Address and TransactionSigned are necessary for the new fields added to the Constraint struct.


Line range hint 33-37:
LGTM! SignedConstraints struct addition is appropriate.

The SignedConstraints struct is essential for handling signed constraints and includes necessary serialization and debugging traits.


Line range hint 42-60:
LGTM! ConstraintsMessage struct and build method addition is appropriate.

The ConstraintsMessage struct and its build method, which includes a new sender parameter, are crucial for creating constraint messages with the sender's address.


92-114: LGTM! Constraint struct and from_inclusion_request method updates are appropriate.

The new fields tx_decoded and sender in the Constraint struct, along with the updated from_inclusion_request method to include the sender parameter, are necessary for internal use and to capture the sender's address.

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

Line range hint 35-39:
LGTM! AccountState struct addition is appropriate.

The AccountState struct is essential for handling minimal account state needed for commitment validation and includes necessary serialization and debugging traits.

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

31-32: LGTM! ExecutionState initialization update is appropriate.

The ExecutionState initialization now includes config.limits.max_commitments_per_slot, ensuring that the maximum number of commitments per slot is properly configured.


81-91: LGTM! Commitment validity check addition is appropriate.

The new code checks the validity of the commitment and retrieves the sender's address, ensuring the validity of commitments before processing them.


102-107: LGTM! Constraints message creation and signing is appropriate.

The new code creates a constraints message and signs it with the sidecar signer, which is necessary for processing and signing constraints messages.


133-147: LGTM! Retry logic for submitting constraints is appropriate.

The new code includes retry logic for submitting constraints to mevboost_client, ensuring successful submission of constraints even in the face of transient errors.


150-150: LGTM! Local payload building addition is appropriate.

The new code builds a new local payload at the slot deadline, ensuring that local payloads are built and submitted on time.

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

7-7: LGTM! Field updates are appropriate.

The max_commitments field is updated to use NonZero<usize>, and the max_commitments_per_slot field is updated to use NonZero<usize> and is now required, ensuring that the values are non-zero and preventing invalid configurations.

Also applies to: 49-49


139-145: LGTM! Limits struct update is appropriate.

The Limits struct is updated to use NonZero<usize> for max_commitments_per_slot, with a default value of 6, ensuring that the value is non-zero and providing a sensible default.

bolt-sidecar/src/builder/template.rs (7)

41-71: LGTM! Ensure the state diffs are accurately updated.

The function implementation looks good, but please ensure that the state diffs are accurately updated and that the constraints are correctly added.


73-79: LGTM!

The function implementation looks good and correctly returns a vector of transactions from the signed constraints list.


83-87: LGTM!

The function implementation looks good and correctly returns the length of the transactions in the block template.


91-99: LGTM!

The function implementation looks good and correctly returns the count of EIP-4844 transactions in the block template.


103-136: LGTM! Ensure the state diffs are accurately updated.

The function implementation looks good, but please ensure that the state diffs are accurately updated and that the constraints are correctly removed.


140-179: LGTM!

The function implementation looks good and correctly retains only the valid transactions by checking the account state.


Line range hint 263-267: LGTM!

The function implementation looks good and correctly returns a tuple of the nonce and balance diff for the given address.

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

116-118: LGTM!

The function implementation looks good and correctly initializes the ExecutionState with a new max_commitments_per_slot parameter.

bolt-sidecar/src/state/execution.rs (7)

34-36: LGTM!

The addition of the new variant MaxCommitmentsReachedForSlot in the ValidationError enum looks good and aligns with the changes in the ExecutionState.


94-104: LGTM!

The function implementation looks good and correctly initializes the ExecutionState with a new max_commitments_per_slot parameter.


Line range hint 127-194: LGTM!

The function implementation looks good and correctly validates the commitment request against the state and checks for maximum commitments per slot.


200-205: LGTM!

The function implementation looks good and correctly adds constraints to the block template.


Line range hint 249-253: LGTM!

The function implementation looks good and correctly refreshes the block templates with the latest account states and removes any invalid transactions.


Line range hint 256-267: LGTM!

The function implementation looks good and correctly returns the account state for the given address, including any intermediate block templates state.


Line range hint 270-272: LGTM!

The function implementation looks good and correctly gets the block template for the given slot number and removes it from the cache.

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 job overall. One general nit: in Milan we had agreed to always use the term preconfirmation which we use across other Bolt components, so it would be great if we kept consistent with it instead of having both it and pre-confirmation in the codebase

bolt-sidecar/bin/sidecar.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/state/execution.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/state/execution.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/state/execution.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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 48a471e and 96634a7.

Files selected for processing (8)
  • bolt-sidecar/bin/sidecar.rs (3 hunks)
  • bolt-sidecar/src/api/builder.rs (4 hunks)
  • bolt-sidecar/src/api/spec.rs (2 hunks)
  • bolt-sidecar/src/client/mod.rs (1 hunks)
  • bolt-sidecar/src/client/test_util/mod.rs (1 hunks)
  • bolt-sidecar/src/primitives/mod.rs (3 hunks)
  • bolt-sidecar/src/state/execution.rs (7 hunks)
  • bolt-sidecar/src/state/head_tracker.rs (3 hunks)
Additional comments not posted (23)
bolt-sidecar/src/client/mod.rs (1)

8-10: LGTM!

The re-export of BeaconClient and the addition of the test_util module under test configuration are appropriate and don't introduce any issues.

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

35-37: LGTM!

The addition of the AccountState struct with a default implementation is correct and aligns with the requirement for minimal account state needed for commitment validation.

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

31-32: LGTM!

The initialization of ExecutionState with config.limits.max_commitments_per_slot ensures that the max_commitments_per_slot limit is correctly passed to the ExecutionState.


81-91: LGTM!

The addition of the check_commitment_validity method call ensures that the commitment is validated before proceeding, which is crucial for maintaining the integrity of the commitments.


102-110: LGTM!

The addition of constraints signing and submission logic ensures that the constraints are signed and added to the ExecutionState correctly. The retry logic for submitting constraints to mevboost_client is also handled appropriately.

Also applies to: 132-146

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

38-40: LGTM!

The addition of the BuilderProxyServer struct provides a proxy server for the builder API, forwarding requests to the target after interception. The fields proxy_target, local_payload, and payload_fetcher are correctly initialized.

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

85-86: LGTM!

The addition of the max_commitments_per_slot field to the ExecutionState struct ensures that the maximum number of commitments per slot is tracked.


94-104: LGTM!

The initialization of ExecutionState with max_commitments_per_slot ensures that the max_commitments_per_slot limit is correctly passed to the ExecutionState.


Line range hint 127-194:
LGTM!

The addition of the check_commitment_validity method ensures that the commitment is validated before proceeding, which is crucial for maintaining the integrity of the commitments.


200-205: LGTM!

The addition of the add_constraint and refresh_templates methods ensures that constraints are handled correctly and block templates are refreshed with the latest account states.

Also applies to: 247-249

bolt-sidecar/src/client/test_util/mod.rs (5)

1-32: LGTM! Imports and utility function are appropriate.

The imports are relevant and the make_get_payload_response function correctly creates a default GetPayloadResponse.


34-43: LGTM! MockMevBoost struct and its implementation are correct.

The MockMevBoost struct and its new function are correctly implemented for creating a mock MEV boost client.


45-79: LGTM! BuilderApi implementation for MockMevBoost is correct.

The methods return appropriate mock responses, ensuring the mock client behaves as expected.


81-100: LGTM! ConstraintsApi implementation for MockMevBoost is correct.

The methods return appropriate mock responses, ensuring the mock client behaves as expected.


102-110: LGTM! Test function is correct.

The test function correctly reads and parses the JSON file, ensuring the GetPayloadResponse can be deserialized.

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

Line range hint 1-15:
LGTM! Imports and HeadTracker struct are appropriate.

The imports are relevant and the HeadTracker struct is correctly defined for tracking the most recent head of the beacon chain.


Line range hint 16-22:
LGTM! NewHeadsTopic struct and its implementation are correct.

The NewHeadsTopic struct is correctly implemented for subscribing to new head events.


Line range hint 23-74:
LGTM! HeadTracker implementation and logging updates are correct.

The HeadTracker implementation includes methods for starting, stopping, and subscribing to new head events. The logging messages have been correctly updated to include retry indications.


Line range hint 75-100:
LGTM! Test function is correct.

The test function correctly initializes a HeadTracker and fetches the next head event, ensuring the tracker works as expected.

bolt-sidecar/src/api/spec.rs (4)

Line range hint 1-29:
LGTM! Imports and API paths are appropriate.

The imports are relevant and the API paths are correctly defined for the builder and constraints APIs.


Line range hint 30-45:
LGTM! ErrorResponse struct and helper function are appropriate.

The ErrorResponse struct and the helper function are correctly implemented for error handling.


Line range hint 46-117:
LGTM! BuilderApiError enum and its IntoResponse implementation are correct.

The BuilderApiError enum and its IntoResponse implementation are correctly updated to include and handle the new Generic variant.


Line range hint 118-153:
LGTM! BuilderApi and ConstraintsApi traits are appropriate.

The BuilderApi and ConstraintsApi traits are correctly defined for the builder and constraints APIs.

@thedevbirb thedevbirb added C: bolt-sidecar Component: bolt-sidecar T: feature Type: Feature labels Jul 15, 2024
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: 5

Outside diff range comments (1)
bolt-sidecar/src/state/execution.rs (1)

Line range hint 147-226: Use req.slot in the error message for MaxCommitmentsReachedForSlot.

The error message for MaxCommitmentsReachedForSlot should use req.slot instead of self.max_commitments_per_slot.get().

-                return Err(ValidationError::MaxCommitmentsReachedForSlot(
-                    self.max_commitments_per_slot.get(),
-                ));
+                return Err(ValidationError::MaxCommitmentsReachedForSlot(req.slot));
Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 96634a7 and ec3a42b.

Files selected for processing (12)
  • bolt-sidecar/bin/sidecar.rs (4 hunks)
  • bolt-sidecar/src/builder/state_root.rs (1 hunks)
  • bolt-sidecar/src/builder/template.rs (3 hunks)
  • bolt-sidecar/src/client/rpc.rs (1 hunks)
  • bolt-sidecar/src/common.rs (3 hunks)
  • bolt-sidecar/src/crypto/bls.rs (1 hunks)
  • bolt-sidecar/src/primitives/commitment.rs (4 hunks)
  • bolt-sidecar/src/primitives/constraint.rs (5 hunks)
  • bolt-sidecar/src/primitives/mod.rs (5 hunks)
  • bolt-sidecar/src/state/execution.rs (10 hunks)
  • bolt-sidecar/src/state/fetcher.rs (4 hunks)
  • bolt-sidecar/src/state/mod.rs (16 hunks)
Additional comments not posted (38)
bolt-sidecar/src/common.rs (2)

Line range hint 32-39:
LGTM!

The function max_transaction_cost has been correctly updated to use PooledTransactionsElement.


Line range hint 46-58:
LGTM!

The function validate_transaction has been correctly updated to use PooledTransactionsElement.

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

Line range hint 17-79:
LGTM!

The test function test_trace_call is well-implemented. It includes initialization, tracing, and state root verification.

bolt-sidecar/src/primitives/constraint.rs (5)

Line range hint 33-38:
LGTM!

The SignedConstraints struct is correctly implemented.


Line range hint 42-49:
LGTM!

The ConstraintsMessage struct is correctly implemented.


54-62: LGTM!

The build function is correctly updated to include the sender parameter.


93-94: LGTM!

The sender field is correctly added to the Constraint struct.


99-107: LGTM!

The from_transaction function is correctly updated to include the sender parameter.

bolt-sidecar/src/crypto/bls.rs (1)

65-70: LGTM!

The random method in the Signer struct is correctly implemented.

bolt-sidecar/src/primitives/commitment.rs (4)

5-5: Verify the usage of PooledTransactionsElement.

Ensure that PooledTransactionsElement is correctly used and integrated with the rest of the codebase.

Verification successful

Verify the usage of PooledTransactionsElement.

The usage of PooledTransactionsElement appears to be consistent and correctly integrated across various files in the codebase. The changes seem to be correctly applied without any issues.

  • common.rs
  • mod.rs
  • state/mod.rs
  • state/execution.rs
  • constraint.rs
  • commitment.rs
  • builder/template.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PooledTransactionsElement` in the codebase.

# Test: Search for the usage of `PooledTransactionsElement`. Expect: Correct integration and usage.
rg --type rust 'PooledTransactionsElement'

Length of output: 4205


85-85: Verify the correctness of the digest method.

Ensure that the digest method correctly computes the hash by including tx.hash().


85-85: Ensure correct integration of the sender field in Constraint.

The sender field should be correctly integrated and utilized in the Constraint struct.

Verification successful

Verified integration of the sender field in Constraint.

The sender field is correctly integrated and utilized in the Constraint struct and the ConstraintsMessage::build method.

  • Constraint struct includes a sender field.
  • ConstraintsMessage::build method uses the sender field to create a Constraint instance.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `sender` field in `Constraint`.

# Test: Search for the usage of `Constraint` and ensure the `sender` field is correctly utilized.
rg --type rust 'Constraint'

Length of output: 4689


Script:

#!/bin/bash
# Description: Verify the integration of the `sender` field in `Constraint`.

# Search for the definition of the `Constraint` struct and inspect its fields.
rg --type rust 'pub struct Constraint' -A 10

# Search for the `build` method in `ConstraintsMessage` to see how the `sender` field is integrated.
rg --type rust 'impl ConstraintsMessage' -A 20

Length of output: 4004


37-37: Ensure correct integration of the sender field in ConstraintsMessage.

The sender field should be correctly integrated and utilized in the ConstraintsMessage struct.

Verification successful

The sender field is correctly integrated and utilized in ConstraintsMessage.

  • The sender field is passed to the Constraint::from_transaction method and stored in the Constraint struct.
  • The ConstraintsMessage struct uses this method to create constraints with the sender field.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `sender` field in `ConstraintsMessage`.

# Test: Search for the usage of `ConstraintsMessage` and ensure the `sender` field is correctly utilized.
rg --type rust 'ConstraintsMessage'

Length of output: 1178


Script:

#!/bin/bash
# Description: Extract the definition and methods of `ConstraintsMessage` to verify the integration of the `sender` field.

# Extract the definition of `ConstraintsMessage`
rg --type rust -A 20 'pub struct ConstraintsMessage' | sed '/^$/q'

# Extract methods of `ConstraintsMessage`
rg --type rust 'impl ConstraintsMessage' -A 20

Length of output: 3180


Script:

#!/bin/bash
# Description: Extract the definition and methods of `Constraint` to verify the utilization of the `sender` field.

# Extract the definition of `Constraint`
rg --type rust -A 20 'pub struct Constraint' | sed '/^$/q'

# Extract methods of `Constraint`
rg --type rust 'impl Constraint' -A 20

Length of output: 10545

bolt-sidecar/src/state/fetcher.rs (2)

163-165: Ensure correct implementation of get_blob_basefee method in StateClient.

The get_blob_basefee method should be correctly implemented and integrated in the StateClient struct.

Verification successful

The get_blob_basefee method is correctly implemented and integrated within the StateClient struct.

  • The method is defined and used in bolt-sidecar/src/state/fetcher.rs.
  • It is also referenced in bolt-sidecar/src/state/execution.rs and bolt-sidecar/src/client/rpc.rs.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and integration of the `get_blob_basefee` method in `StateClient`.

# Test: Search for the usage of `StateClient` and ensure the `get_blob_basefee` method is correctly utilized.
rg --type rust 'StateClient'

Length of output: 1408


Script:

#!/bin/bash
# Description: Verify the usage of the `get_blob_basefee` method in the relevant files.

# Test: Search for the usage of `get_blob_basefee` method in the relevant files.
rg --type rust 'get_blob_basefee' bolt-sidecar/src/state/mod.rs bolt-sidecar/bin/sidecar.rs

Length of output: 91


Script:

#!/bin/bash
# Description: Verify the usage of the `get_blob_basefee` method in the entire codebase.

# Test: Search for the usage of `get_blob_basefee` method in the entire codebase.
rg --type rust 'get_blob_basefee'

Length of output: 734


36-37: Ensure correct definition of get_blob_basefee method in StateFetcher trait.

The get_blob_basefee method should be correctly defined and integrated in the StateFetcher trait.

Verification successful

The get_blob_basefee method is correctly defined, implemented, and integrated.

  • The method is defined in the StateFetcher trait in bolt-sidecar/src/state/fetcher.rs.
  • It is implemented in the StateClient struct.
  • It is used in the ExecutionState struct in bolt-sidecar/src/state/execution.rs.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and integration of the `get_blob_basefee` method in `StateFetcher` trait.

# Test: Search for the usage of `StateFetcher` trait and ensure the `get_blob_basefee` method is correctly utilized.
rg --type rust 'StateFetcher'

Length of output: 306


Script:

#!/bin/bash
# Description: Verify the definition, implementation, and usage of the `get_blob_basefee` method in the `StateFetcher` trait.

# Test: Check the definition of `get_blob_basefee` method in `StateFetcher` trait.
rg --type rust 'get_blob_basefee' -A 5 bolt-sidecar/src/state/fetcher.rs

# Test: Check the implementation of `get_blob_basefee` method in `StateClient`.
rg --type rust 'get_blob_basefee' -A 10 bolt-sidecar/src/state/fetcher.rs

# Test: Check the usage of `get_blob_basefee` method in the `ExecutionState` struct.
rg --type rust 'get_blob_basefee' -A 10 bolt-sidecar/src/state/execution.rs

Length of output: 2421

bolt-sidecar/src/builder/template.rs (5)

31-31: Ensure correct handling of signed_constraints_list.

The signed_constraints_list should be correctly handled and integrated with the rest of the codebase.

Verification successful

Correct handling of signed_constraints_list verified.

The signed_constraints_list is correctly handled and integrated within the codebase, as evidenced by its usage in various methods and operations.

  • bolt-sidecar/src/builder/template.rs: Multiple methods manipulate and access signed_constraints_list.
  • bolt-sidecar/bin/sidecar.rs: Used in constraint submission logic.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of `signed_constraints_list` in the codebase.

# Test: Search for the usage of `signed_constraints_list`. Expect: Correct handling and integration.
rg --type rust 'signed_constraints_list'

Length of output: 838


Script:

#!/bin/bash
# Description: Extract more context around each usage of `signed_constraints_list` to verify its handling.

# Extract 5 lines before and after each match to understand the context of usage.
rg --type rust 'signed_constraints_list' -A 5 -B 5

Length of output: 6661


73-82: Ensure correct calculation of blob_count.

The blob_count method should correctly calculate the blob count of the block template.


121-159: Verify the correctness of the retain method.

Ensure that the retain method correctly removes any transactions that conflict with the given account state.


10-10: Verify the usage of PooledTransactionsElement and TransactionSigned.

Ensure that PooledTransactionsElement and TransactionSigned are correctly used and integrated with the rest of the codebase.


40-47: Verify the correctness of the transactions method.

Ensure that the transactions method correctly returns the cloned list of transactions from the constraints.

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

109-109: Ensure correct implementation of add_constraint method.

The add_constraint method should be correctly implemented and integrated to add constraints to the execution state.

Verification successful

Implementation and integration of add_constraint method are correct.

The add_constraint method is correctly implemented in bolt-sidecar/src/state/execution.rs and properly integrated with the add_constraints method in bolt-sidecar/src/builder/template.rs.

  • bolt-sidecar/src/state/execution.rs:232-240: Implementation of add_constraint.
  • bolt-sidecar/src/builder/template.rs:89-103: Implementation of add_constraints.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and integration of the `add_constraint` method.

# Test: Search for the usage of `add_constraint` and ensure it is correctly utilized.
rg --type rust 'add_constraint'

Length of output: 780


Script:

#!/bin/bash
# Description: Gather implementation details of `add_constraint` and related method `add_constraints`.

# Fetch the implementation of `add_constraint` in `bolt-sidecar/src/state/execution.rs`
ast-grep --lang rust --pattern 'pub fn add_constraint(&mut self, target_slot: u64, signed_constraints: SignedConstraints) { $$$ }'

# Fetch the implementation of `add_constraints` in `bolt-sidecar/src/builder/template.rs`
ast-grep --lang rust --pattern 'pub fn add_constraints(&mut self, constraints: SignedConstraints) { $$$ }'

Length of output: 2261


137-148: Ensure robust submission of constraints to mevboost_client.

The submission logic for constraints to mevboost_client should be robust and handle retries correctly.

Verification successful

Ensure robust submission of constraints to mevboost_client.

The submission logic for constraints to mevboost_client is robust. The submit_constraints method sends a POST request with the constraints and checks the response status. If the status is not OK, it returns a custom error type. The retry logic in sidecar.rs handles transient errors effectively by retrying the submission.

  • bolt-sidecar/src/client/mevboost.rs:
    • submit_constraints method implementation confirms error handling and response status checks.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the submission logic for constraints to `mevboost_client`.

# Test: Search for the usage of `submit_constraints` and ensure the submission logic is robust.
rg --type rust 'submit_constraints'

Length of output: 343


Script:

#!/bin/bash
# Extract the implementation of the `submit_constraints` method from `mevboost.rs`.
ast-grep --lang rust --pattern 'async fn submit_constraints($$_) { $$$ }' --debug bolt-sidecar/src/client/mevboost.rs

Length of output: 337


Script:

#!/bin/bash
# Extract the implementation of the `submit_constraints` method from `mevboost.rs`.
ast-grep --lang rust --pattern 'async fn submit_constraints($$_) { $$$ }' --debug-query bolt-sidecar/src/client/mevboost.rs

Length of output: 216


Script:

#!/bin/bash
# Search for the definition of the `submit_constraints` method in `mevboost.rs` and include context lines.
rg 'async fn submit_constraints' -A 20 bolt-sidecar/src/client/mevboost.rs

Length of output: 722


31-32: Verify the initialization of ExecutionState with max_commitments_per_slot.

Ensure that ExecutionState is correctly initialized with max_commitments_per_slot.

Verification successful

Verify the initialization of ExecutionState with max_commitments_per_slot.

The ExecutionState::new method correctly initializes the max_commitments_per_slot parameter, ensuring consistency with the rest of the codebase.

  • bolt-sidecar/bin/sidecar.rs: Correctly initializes ExecutionState with max_commitments_per_slot.
  • bolt-sidecar/src/state/execution.rs: The new method accepts max_commitments_per_slot and initializes it properly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization of `ExecutionState` with `max_commitments_per_slot`.

# Test: Search for the usage of `ExecutionState` and ensure it is correctly initialized.
rg --type rust 'ExecutionState'

Length of output: 1323


Script:

#!/bin/bash
# Description: Retrieve the definition of `ExecutionState::new` to verify its initialization.

# Test: Search for the definition of `ExecutionState::new`.
ast-grep --lang rust --pattern 'impl<C: StateFetcher> ExecutionState<C> {
  pub async fn new($_, $_) -> Result<$_, $_> {
    $$$
  }
}'

Length of output: 137


Script:

#!/bin/bash
# Description: Retrieve the definition of `ExecutionState::new` to verify its initialization.

# Test: Search for the `new` method within the `ExecutionState` implementation block.
rg 'impl<C: StateFetcher> ExecutionState<C> {[^}]*fn new' -A 20 bolt-sidecar/src/state/execution.rs

Length of output: 277


Script:

#!/bin/bash
# Description: Retrieve the definition of `ExecutionState::new` to verify its initialization.

# Test: Search for the `new` method within the `ExecutionState` implementation block.
rg 'impl<C: StateFetcher> ExecutionState<C> \{[^}]*fn new' -A 20 bolt-sidecar/src/state/execution.rs

Length of output: 102


Script:

#!/bin/bash
# Description: Retrieve the definition of `ExecutionState::new` to verify its initialization.

# Test: Search for any `new` method within the `ExecutionState` implementation block.
rg 'fn new' -A 20 bolt-sidecar/src/state/execution.rs

Length of output: 714


82-92: Ensure correct implementation of validate_commitment_request method.

The validate_commitment_request method should be correctly implemented and integrated to validate the commitment request.

Verification successful

The validate_commitment_request method is correctly implemented and integrated.

The method includes comprehensive validation checks and is well-integrated into the codebase, with multiple test cases ensuring its correctness.

  • bolt-sidecar/src/state/execution.rs: Implementation of validate_commitment_request.
  • bolt-sidecar/src/state/mod.rs: Multiple test cases validating different scenarios.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and integration of the `validate_commitment_request` method.

# Test: Search for the usage of `validate_commitment_request` and ensure it is correctly utilized.
rg --type rust 'validate_commitment_request'

Length of output: 810


Script:

#!/bin/bash
# Extract the implementation of the `validate_commitment_request` method from `bolt-sidecar/src/state/execution.rs`
ast-grep --lang rust --pattern 'pub async fn validate_commitment_request($_, $_) { $$$ }'

# Extract the context of the usage of `validate_commitment_request` in `bolt-sidecar/src/state/mod.rs`
rg --type rust -A 5 'validate_commitment_request' bolt-sidecar/src/state/mod.rs

Length of output: 1482


Script:

#!/bin/bash
# Extract the implementation of the `validate_commitment_request` method from `bolt-sidecar/src/state/execution.rs`
rg --type rust -A 20 'pub async fn validate_commitment_request' bolt-sidecar/src/state/execution.rs

Length of output: 964


Script:

#!/bin/bash
# Extract additional lines from the implementation of the `validate_commitment_request` method in `bolt-sidecar/src/state/execution.rs`
rg --type rust -A 40 'pub async fn validate_commitment_request' bolt-sidecar/src/state/execution.rs

Length of output: 1973


Script:

#!/bin/bash
# Extract additional lines from the implementation of the `validate_commitment_request` method in `bolt-sidecar/src/state/execution.rs`
rg --type rust -A 60 'pub async fn validate_commitment_request' bolt-sidecar/src/state/execution.rs

Length of output: 2818

bolt-sidecar/src/primitives/mod.rs (2)

224-230: LGTM!

The TransactionExt trait definition looks good.


232-259: LGTM!

The implementation of TransactionExt for PooledTransactionsElement looks good.

bolt-sidecar/src/state/mod.rs (8)

Line range hint 22-44: LGTM!

The CommitmentDeadline struct and its methods look good.


Line range hint 71-87: LGTM!

The test_commitment_deadline test case looks good.


Line range hint 117-143: LGTM!

The test_valid_inclusion_request test case looks good.


Line range hint 153-180: LGTM!

The test_invalid_inclusion_request_nonce test case looks good.


Line range hint 192-220: LGTM!

The test_invalid_inclusion_request_balance test case looks good.


Line range hint 232-261: LGTM!

The test_invalid_inclusion_request_basefee test case looks good.


Line range hint 270-342: LGTM!

The test_invalidate_inclusion_request test case looks good.


346-406: LGTM!

The test_invalidate_stale_template test case looks good.

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

105-122: LGTM!

The new method looks good.


232-237: LGTM!

The add_constraint method looks good.


253-260: LGTM!

The update_head method looks good.


Line range hint 282-289: LGTM!

The refresh_templates method looks good.

bolt-sidecar/src/builder/template.rs Show resolved Hide resolved
bolt-sidecar/src/builder/template.rs Show resolved Hide resolved
coderabbitai[bot]

This comment was marked as duplicate.

@thedevbirb thedevbirb force-pushed the fix/sidecar/constraints-deadline branch from 8940909 to 0d1ce4a Compare July 17, 2024 14:01
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 8940909 and abf9eb8.

Files selected for processing (2)
  • bolt-sidecar/bin/sidecar.rs (3 hunks)
  • bolt-sidecar/src/client/rpc.rs (6 hunks)
Additional comments not posted (3)
bolt-sidecar/bin/sidecar.rs (3)

31-32: Initialization of ExecutionState with new parameter.

The addition of config.limits.max_commitments_per_slot to the ExecutionState constructor aligns with the objective to manage constraints more effectively. This change should help in enforcing limits on the number of commitments per slot, as described in issue #109.


81-85: Enhanced validation for commitment requests.

The addition of execution_state.validate_commitment_request(&request) is a crucial update for ensuring that constraints are only submitted after thorough validation. This aligns with the objectives from issue #109 and #102 to enhance the reliability and correctness of transaction handling.


146-146: Error handling in local payload building.

The error handling here is critical, especially since it's marked as "CRITICAL". This suggests that failing to build a local payload at the slot deadline could have significant negative impacts. Ensure that there are adequate fallback mechanisms or recovery strategies in place.

Verification successful

Adequate fallback mechanisms identified.

The build_new_local_payload method includes a fallback mechanism by attempting to build a fallback payload using self.fallback_builder.build_fallback_payload(&transactions).await?. This indicates that there is a strategy in place to handle errors during the payload building process.

  • Location:
    • bolt-sidecar/src/builder/mod.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that adequate error handling or fallback mechanisms are in place for building local payloads.

# Test: Search for error handling strategies in local builder. Expect: Fallback mechanisms or recovery strategies.
rg --type rust -A 5 $'tracing::error'

Length of output: 11348


Script:

#!/bin/bash
# Description: Search for the implementation of the `build_new_local_payload` method in the `local_builder` to verify error handling and fallback mechanisms.

# Find the implementation of the `build_new_local_payload` method.
ast-grep --lang rust --pattern 'impl $_ {
  async fn build_new_local_payload(&self, $_) -> $_ {
    $$$
  }
}'

Length of output: 112


Script:

#!/bin/bash
# Description: Search for the definition of the `build_new_local_payload` method in the codebase to verify error handling and fallback mechanisms.

# Search for the `build_new_local_payload` method definition.
rg 'async fn build_new_local_payload' -A 10

Length of output: 827


Script:

#!/bin/bash
# Description: Retrieve the full implementation of the `build_new_local_payload` method to verify error handling and fallback mechanisms.

# Extract the full implementation of the `build_new_local_payload` method.
rg 'pub async fn build_new_local_payload' -A 50 bolt-sidecar/src/builder/mod.rs

Length of output: 2240

Comment on lines +123 to +144
let Some(template) = execution_state.remove_block_template(slot) else {
tracing::warn!("No block template found for slot {slot} when requested");
continue;
};

if let Err(e) = local_builder.build_new_local_payload(template.transactions).await {
tracing::trace!(?template.signed_constraints_list, "Submitting constraints to MEV-Boost");

// TODO: fix retry logic, and move this to separate task
let max_retries = 5;
let mut i = 0;
'inner: while let Err(e) = mevboost_client
.submit_constraints(&template.signed_constraints_list)
.await
{
tracing::error!(err = ?e, "Error submitting constraints, retrying...");
tokio::time::sleep(Duration::from_millis(100)).await;
i+=1;
if i >= max_retries {
tracing::error!("Max retries reached while submitting to MEV-Boost");
break 'inner
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor retry logic for constraint submission.

The retry logic for submitting constraints is critical but the implementation can be improved. Making retry parameters configurable, as suggested in the previous review, would allow the system to adapt better to various network conditions.

- let max_retries = 5;
- let mut i = 0;
+ let max_retries = config.retry.max_retries;
+ let mut i = config.retry.initial_retry_count;
- tokio::time::sleep(Duration::from_millis(100)).await;
+ tokio::time::sleep(config.retry.retry_delay).await;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let Some(template) = execution_state.remove_block_template(slot) else {
tracing::warn!("No block template found for slot {slot} when requested");
continue;
};
if let Err(e) = local_builder.build_new_local_payload(template.transactions).await {
tracing::trace!(?template.signed_constraints_list, "Submitting constraints to MEV-Boost");
// TODO: fix retry logic, and move this to separate task
let max_retries = 5;
let mut i = 0;
'inner: while let Err(e) = mevboost_client
.submit_constraints(&template.signed_constraints_list)
.await
{
tracing::error!(err = ?e, "Error submitting constraints, retrying...");
tokio::time::sleep(Duration::from_millis(100)).await;
i+=1;
if i >= max_retries {
tracing::error!("Max retries reached while submitting to MEV-Boost");
break 'inner
}
}
let Some(template) = execution_state.remove_block_template(slot) else {
tracing::warn!("No block template found for slot {slot} when requested");
continue;
};
tracing::trace!(?template.signed_constraints_list, "Submitting constraints to MEV-Boost");
// TODO: fix retry logic, and move this to separate task
let max_retries = config.retry.max_retries;
let mut i = config.retry.initial_retry_count;
'inner: while let Err(e) = mevboost_client
.submit_constraints(&template.signed_constraints_list)
.await
{
tracing::error!(err = ?e, "Error submitting constraints, retrying...");
tokio::time::sleep(config.retry.retry_delay).await;
i+=1;
if i >= max_retries {
tracing::error!("Max retries reached while submitting to MEV-Boost");
break 'inner
}
}

bolt-sidecar/bin/sidecar.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: 12

Outside diff range comments (2)
bolt-spammer-helder/README.md (1)

Line range hint 14-17:
Clarify the instruction on fetching validators and sending pre-confirmations.

The instruction should be more explicit about the process and expected outcome.

- It will fetch all the validators of the current epoch,
- and try to send a pre-confirmation to the first one registered on the Bolt registry.
- If no validators are found, the program will gracefully exit. Please try again in the next epoch!
+ The spammer will fetch all validators of the current epoch,
+ and attempt to send a pre-confirmation to the first validator registered on the Bolt registry.
+ If no validators are found, the program will gracefully exit. Please try again in the next epoch.
bolt-spammer-helder/Cargo.toml (1)

[!TIP]
Codebase Verification

Impact of removing reth-primitives

The reth-primitives dependency is used extensively in the codebase, particularly in the bolt-sidecar module. Its removal will likely break the code and affect functionality that relies on Ethereum primitives.

Files and lines with reth-primitives usage:

  • bolt-sidecar/src/test_util.rs
  • bolt-sidecar/src/common.rs
  • bolt-sidecar/src/primitives/constraint.rs
  • bolt-sidecar/src/primitives/mod.rs
  • bolt-sidecar/src/primitives/commitment.rs
  • bolt-sidecar/src/state/execution.rs
  • bolt-sidecar/src/builder/payload_builder.rs
  • bolt-sidecar/src/builder/compat.rs
  • bolt-sidecar/src/builder/template.rs

A thorough review and refactoring are needed to replace or remove the reth-primitives dependency properly.

Analysis chain

Line range hint 1-21:
Verify the impact of removing reth-primitives.

Ensure that the removal of the reth-primitives dependency does not affect any functionality that relies on Ethereum primitives.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `reth-primitives`.

# Test: Search for any usage of `reth-primitives` in the codebase. Expect: No usage found.
rg --type rust 'reth-primitives'

Length of output: 32


Script:

#!/bin/bash
# Description: Verify if there are any indirect dependencies on `reth-primitives`.

# Search for any mention of `reth-primitives` in the Cargo.lock file.
rg 'reth-primitives' Cargo.lock

Length of output: 82


Script:

#!/bin/bash
# Description: Verify if there are any references to Ethereum primitives in the codebase.

# Search for common Ethereum primitive types or functions that might have been provided by `reth-primitives`.
rg --type rust 'Address|U256|H256|H160|Block|Transaction|Receipt'

Length of output: 27346

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between abf9eb8 and 67d5c3c.

Files ignored due to path filters (2)
  • bolt-spammer-helder/Cargo.lock is excluded by !**/*.lock
  • bolt-spammer/Cargo.lock is excluded by !**/*.lock
Files selected for processing (12)
  • bolt-spammer-helder/.env.example (1 hunks)
  • bolt-spammer-helder/Cargo.toml (1 hunks)
  • bolt-spammer-helder/README.md (1 hunks)
  • bolt-spammer-helder/src/main.rs (3 hunks)
  • bolt-spammer-helder/src/utils.rs (3 hunks)
  • bolt-spammer/.gitignore (1 hunks)
  • bolt-spammer/Cargo.toml (1 hunks)
  • bolt-spammer/README.md (1 hunks)
  • bolt-spammer/rustfmt.toml (1 hunks)
  • bolt-spammer/src/constants.rs (1 hunks)
  • bolt-spammer/src/main.rs (2 hunks)
  • bolt-spammer/src/utils.rs (1 hunks)
Additional context used
Markdownlint
bolt-spammer/README.md

1-1: null
First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

Additional comments not posted (11)
bolt-spammer/.gitignore (1)

2-2: Good practice: Ignore .env file.

Adding the .env file to .gitignore is a good practice to prevent sensitive information from being committed to version control.

bolt-spammer/src/constants.rs (1)

1-4: LGTM! Constants are appropriately defined.

The constants SLOTS_PER_EPOCH, NOICE_GAS_PRICE, DEAD_ADDRESS, and KURTOSIS_CHAIN_ID are appropriately defined and follow best practices for naming and usage.

bolt-spammer/rustfmt.toml (1)

1-11: LGTM! Formatting rules are appropriately defined.

The formatting rules defined in rustfmt.toml are appropriate and follow best practices for Rust code formatting.

bolt-spammer/Cargo.toml (1)

11-21: Verify the impact of removing ethers and adding new dependencies.

Ensure that the removal of the ethers dependency does not affect any functionality and that the new dependencies are correctly integrated.

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

Line range hint 14-22:
LGTM!

The function correctly sets the gas limit and gas price for the transaction.


33-41: LGTM!

The function correctly sets the gas-related parameters for the transaction.


Line range hint 53-57:
LGTM!

The function correctly retrieves the current slot from the beacon API client.

bolt-spammer/src/utils.rs (3)

17-23: LGTM!

The function correctly sets the gas limit and gas price for the transaction.


27-41: LGTM!

The function correctly sets the gas-related parameters for the transaction.


53-57: LGTM!

The function correctly retrieves the current slot from the beacon API client.

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

27-36: Consider adding documentation for struct fields.

Add documentation for the fields in the Opts struct to improve code readability and maintainability.

#[derive(Parser)]
struct Opts {
    /// EL node URL to send transactions to
    #[clap(short = 'p', long, default_value = "https://rpc.helder-devnets.xyz", env)]
    el_provider_url: Url,
    /// CL node URL to fetch the beacon chain info from
    #[clap(short = 'c', long, default_value = "http://localhost:4000", env)]
    beacon_client_url: Url,
    /// Address of the Bolt Registry smart contract
    #[clap(short = 'r', long, default_value = "0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9", env)]
    registry_address: Address,
    /// Private key to sign transactions with
    #[clap(short = 'k', long, env)]
    private_key: String,
    // Flag for generating a blob tx instead of a regular tx
    #[clap(short, long, default_value = "false")]
    blob: bool,
}

Likely invalid or redundant comment.

Comment on lines +6 to +7
PRIVATE_KEY=<your account private key with ETH on Helder>
BEACON_CLIENT_URL=<your beacon client HTTP endpoint>
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the placeholder values for environment variables.

The placeholders for PRIVATE_KEY and BEACON_CLIENT_URL should be more descriptive to guide the user.

- PRIVATE_KEY=<your account private key with ETH on Helder>
- BEACON_CLIENT_URL=<your beacon client HTTP endpoint>
+ PRIVATE_KEY=<your Helder account private key with sufficient ETH>
+ BEACON_CLIENT_URL=<your Helder beacon client HTTP endpoint>
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
PRIVATE_KEY=<your account private key with ETH on Helder>
BEACON_CLIENT_URL=<your beacon client HTTP endpoint>
PRIVATE_KEY=<your Helder account private key with sufficient ETH>
BEACON_CLIENT_URL=<your Helder beacon client HTTP endpoint>

Comment on lines +3 to +6

# these can be used as defaults
EL_PROVIDER_URL=https://rpc.helder-devnets.xyz
REGISTRY_ADDRESS=0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure the removal of variables is intentional.

The variables BEACON_CLIENT_URL, PRIVATE_KEY, and REGISTRY_ABI_PATH are still being referenced in multiple files across the codebase. Please verify if their removal from the .env.example file is intentional and does not affect the functionality.

  • BEACON_CLIENT_URL

    • bolt-web-demo/frontend/src/lib/types.ts
    • bolt-web-demo/frontend/src/app/page.tsx
    • bolt-web-demo/backend/src/types.ts
    • bolt-web-demo/backend/src/server.ts
    • bolt-spammer-helder/README.md
    • bolt-spammer/README.md
  • PRIVATE_KEY

    • testnets/helder/README.md
    • bolt-web-demo/frontend/src/lib/wallet.ts
    • bolt-contracts/script/RegisterValidators.s.sol
    • bolt-contracts/script/DeployRegistry.s.sol
    • bolt-spammer-helder/README.md
    • bolt-sidecar/src/builder/payload_builder.rs
    • bolt-contracts/README.md
    • bolt-spammer/README.md
  • REGISTRY_ABI_PATH

    • bolt-spammer/README.md
Analysis chain

LGTM! Ensure the removal of variables is intentional.

The changes to update the EL_PROVIDER_URL and REGISTRY_ADDRESS values, and to remove BEACON_CLIENT_URL, PRIVATE_KEY, and REGISTRY_ABI_PATH, are appropriate for the example environment configuration.

However, ensure that the removal of BEACON_CLIENT_URL, PRIVATE_KEY, and REGISTRY_ABI_PATH is intentional and does not affect the functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of `BEACON_CLIENT_URL`, `PRIVATE_KEY`, and `REGISTRY_ABI_PATH` is intentional.

# Test: Search for the usage of the removed variables in the codebase. Expect: No occurrences.
rg --type python 'BEACON_CLIENT_URL|PRIVATE_KEY|REGISTRY_ABI_PATH'

Length of output: 99


Script:

#!/bin/bash
# Description: Verify the removal of `BEACON_CLIENT_URL`, `PRIVATE_KEY`, and `REGISTRY_ABI_PATH` is intentional.

# Test: Search for the usage of the removed variables in the codebase. Expect: No occurrences.
rg 'BEACON_CLIENT_URL|PRIVATE_KEY|REGISTRY_ABI_PATH'

Length of output: 2173

Comment on lines +23 to +33
provider_url: Url,
#[clap(short = 'c', long, default_value = "http://localhost:4000")]
beacon_client_url: String,
beacon_client_url: Url,
#[clap(short = 'b', long)]
bolt_sidecar_url: String,
#[clap(short = 'k', long)]
private_key: String,
#[clap(short = 'n', long)]
nonce: Option<u16>,
#[clap(short = 'B', long, default_value_t = false)]
blob: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding documentation for struct fields.

Add documentation for the fields in the Opts struct to improve code readability and maintainability.

#[derive(Parser)]
struct Opts {
    #[clap(short = 'p', long, default_value = "http://localhost:8545")]
    provider_url: Url,
    #[clap(short = 'c', long, default_value = "http://localhost:4000")]
    beacon_client_url: Url,
    #[clap(short = 'b', long)]
    bolt_sidecar_url: String,
    #[clap(short = 'k', long)]
    private_key: String,
    #[clap(short = 'n', long)]
    nonce: Option<u16>,
    #[clap(short = 'B', long, default_value_t = false)]
    blob: bool,
    #[clap(short = 's', long, default_value = "head")]
    slot: String,
}

Committable suggestion was skipped due to low confidence.

#[clap(short = 's', long, default_value = "head")]
slot: String,
}

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
tracing::info!("starting bolt-spammer");
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a log statement indicating the successful parsing of options.

Add a log statement to indicate that the options have been successfully parsed.

tracing::info!("starting bolt-spammer");

let opts = Opts::parse();
+ tracing::info!("Parsed options: {:?}", opts);

Committable suggestion was skipped due to low confidence.

@@ -0,0 +1,17 @@
## A pre-confirmation spammer for the Helder testnet
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a top-level heading.

The first line should be a top-level heading as per Markdownlint.

- ## A pre-confirmation spammer for the Helder testnet
+ # A pre-confirmation spammer for the Helder testnet
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## A pre-confirmation spammer for the Helder testnet
# A pre-confirmation spammer for the Helder testnet
Tools
Markdownlint

1-1: null
First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

Comment on lines +15 to +17
Then, just run the spammer with `cargo run`. It will fetch all the validators of the current epoch,
and try to send a pre-confirmation to the first one registered on the Bolt registry.
If no validators are found, the program will gracefully exit. Please try again in the next epoch!
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the instruction on fetching validators and sending pre-confirmations.

The instruction should be more explicit about the process and expected outcome.

- Then, just run the spammer with `cargo run`. It will fetch all the validators of the current epoch,
- and try to send a pre-confirmation to the first one registered on the Bolt registry.
- If no validators are found, the program will gracefully exit. Please try again in the next epoch!
+ Then, just run the spammer with `cargo run`. The spammer will fetch all validators of the current epoch,
+ and attempt to send a pre-confirmation to the first validator registered on the Bolt registry.
+ If no validators are found, the program will gracefully exit. Please try again in the next epoch.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Then, just run the spammer with `cargo run`. It will fetch all the validators of the current epoch,
and try to send a pre-confirmation to the first one registered on the Bolt registry.
If no validators are found, the program will gracefully exit. Please try again in the next epoch!
Then, just run the spammer with `cargo run`. The spammer will fetch all validators of the current epoch,
and attempt to send a pre-confirmation to the first validator registered on the Bolt registry.
If no validators are found, the program will gracefully exit. Please try again in the next epoch.

Comment on lines +6 to +11
EL_PROVIDER_URL=https://rpc.helder-devnets.xyz
BEACON_CLIENT_URL=
REGISTRY_ADDRESS=0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9
PRIVATE_KEY=
REGISTRY_ABI_PATH=./registry_abi.json
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the placeholder values for environment variables.

The placeholders for the environment variables should be more descriptive to guide the user.

- EL_PROVIDER_URL=https://rpc.helder-devnets.xyz
- BEACON_CLIENT_URL=
- REGISTRY_ADDRESS=0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9
- PRIVATE_KEY=
- REGISTRY_ABI_PATH=./registry_abi.json
+ EL_PROVIDER_URL=https://rpc.helder-devnets.xyz (Helder RPC endpoint)
+ BEACON_CLIENT_URL=<your Helder beacon client HTTP endpoint>
+ REGISTRY_ADDRESS=0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9 (Bolt registry address)
+ PRIVATE_KEY=<your Helder account private key with sufficient ETH>
+ REGISTRY_ABI_PATH=./registry_abi.json (Path to the registry ABI file)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
EL_PROVIDER_URL=https://rpc.helder-devnets.xyz
BEACON_CLIENT_URL=
REGISTRY_ADDRESS=0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9
PRIVATE_KEY=
REGISTRY_ABI_PATH=./registry_abi.json
```
EL_PROVIDER_URL=https://rpc.helder-devnets.xyz (Helder RPC endpoint)
BEACON_CLIENT_URL=<your Helder beacon client HTTP endpoint>
REGISTRY_ADDRESS=0xdF11D829eeC4C192774F3Ec171D822f6Cb4C14d9 (Bolt registry address)
PRIVATE_KEY=<your Helder account private key with sufficient ETH>
REGISTRY_ABI_PATH=./registry_abi.json (Path to the registry ABI file)

Comment on lines +2 to 8
eips::eip2718::Encodable2718,
hex,
network::EthereumWallet,
network::{EthereumWallet, TransactionBuilder},
primitives::{keccak256, Address},
providers::{Provider, ProviderBuilder},
signers::{local::PrivateKeySigner, Signer},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider organizing imports.

Organize imports to improve readability.

use alloy::{
    eips::eip2718::Encodable2718,
    hex,
    network::{EthereumWallet, TransactionBuilder},
    primitives::{keccak256, Address},
    providers::{Provider, ProviderBuilder},
    signers::{local::PrivateKeySigner, Signer},
};

Committable suggestion was skipped due to low confidence.

@@ -42,16 +46,17 @@
tracing_subscriber::fmt::init();
tracing::info!("starting bolt-spammer-helder");

let path = dotenvy::dotenv()?;
tracing::info!("loaded environment variables from {:?}", path);
let _ = dotenvy::dotenv();
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a log statement indicating the successful parsing of options.

Add a log statement to indicate that the options have been successfully parsed.

tracing::info!("starting bolt-spammer-helder");

let _ = dotenvy::dotenv();
let opts = Opts::parse();
+ tracing::info!("Parsed options: {:?}", opts);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let _ = dotenvy::dotenv();
tracing::info!("starting bolt-spammer-helder");
let _ = dotenvy::dotenv();
let opts = Opts::parse();
tracing::info!("Parsed options: {:?}", opts);

let tx = if opts.blob { generate_random_blob_tx() } else { generate_random_tx() };
let mut tx = if opts.blob { generate_random_blob_tx() } else { generate_random_tx() };
tx.set_from(sender);
tx.set_nonce(provider.get_transaction_count(sender).await?);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding error handling for transaction nonce retrieval.

Add error handling for the transaction nonce retrieval to ensure robustness.

tx.set_nonce(provider.get_transaction_count(sender).await?);
+ if let Err(e) = provider.get_transaction_count(sender).await {
+     tracing::error!("Failed to retrieve transaction nonce: {:?}", e);
+     return Err(e.into());
+ }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tx.set_nonce(provider.get_transaction_count(sender).await?);
if let Err(e) = provider.get_transaction_count(sender).await {
tracing::error!("Failed to retrieve transaction nonce: {:?}", e);
return Err(e.into());
} else {
tx.set_nonce(provider.get_transaction_count(sender).await?);
}

@thedevbirb thedevbirb merged commit 7366aef into unstable Jul 18, 2024
2 checks passed
@thedevbirb thedevbirb deleted the fix/sidecar/constraints-deadline branch July 18, 2024 07:33
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
4 participants