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

fix(sidecar): local blob building #152

Merged
merged 10 commits into from
Jul 22, 2024
Merged

Conversation

thedevbirb
Copy link
Contributor

@thedevbirb thedevbirb commented Jul 19, 2024

Fixes various problems in the local block building problems, such as:

  • missing kzg commitments in the bid header
  • missing actual blob gas used in the bid header

Summary by CodeRabbit

  • New Features

    • Enhanced logging functionality for improved traceability and debugging.
    • Integrated KZG commitments into the LocalBuilder for complex payload generation.
    • Improved gas usage tracking within the payload builder context.
    • Added a method to retrieve execution payloads from the GetPayloadResponse.
  • Bug Fixes

    • Updated transaction generation process for enhanced randomness and security.
  • Refactor

    • Streamlined method signatures and logic for clarity and efficiency in handling new parameters.

Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Walkthrough

The changes across the codebase enhance the functionality and logging capabilities of the LocalBuilder and related components in the blockchain application. Notably, KZG commitments are integrated into the bidding process, and blob gas usage is more accurately tracked within the payload builder. Additionally, transaction generation now utilizes dynamic random data for improved security, reflecting a shift towards more adaptable and robust resource management in transaction processing.

Changes

Files Change Summary
bolt-sidecar/src/api/builder.rs, bolt-sidecar/src/api/spec.rs Improved error handling for payload integrity with the introduction of LocalPayloadIntegrityError and the check_locally_built_payload_integrity function for comprehensive integrity checks.
bolt-sidecar/src/builder/mod.rs Modified LocalBuilder to handle KZG commitments: updated imports, method signature, and internal logic for creating signed bids with blob KZG commitments.
bolt-sidecar/src/builder/payload_builder.rs Improved Context struct with blob_gas_used: u64 for better gas management; removed blob_gas_used from Hints, aligning with new tracking methods.
bolt-spammer/src/utils.rs Updated generate_random_blob_tx function to use dynamically generated random bytes instead of a static string, and revised gas fee parameters for greater adaptability.
bolt-sidecar/src/primitives/mod.rs Added the execution_payload method to GetPayloadResponse, improving access to execution payloads across different variants.

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.

@thedevbirb thedevbirb changed the title fix(sidecar): sent local blob also to the mempool fix(sidecar): local blob building Jul 19, 2024
@thedevbirb
Copy link
Contributor Author

image

@thedevbirb thedevbirb marked this pull request as ready for review July 19, 2024 18:31
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 3e4ad89 and 66d3b0b.

Files selected for processing (4)
  • bolt-sidecar/src/api/builder.rs (1 hunks)
  • bolt-sidecar/src/builder/mod.rs (4 hunks)
  • bolt-sidecar/src/builder/payload_builder.rs (5 hunks)
  • bolt-spammer/src/utils.rs (2 hunks)
Additional comments not posted (10)
bolt-spammer/src/utils.rs (2)

28-29: LGTM! Enhanced randomness and security.

The changes improve the randomness and security of the transaction data by generating random bytes.


39-40: Verify the usage of constants for gas fees.

Ensure that the constants NOICE_GAS_PRICE and NOICE_GAS_PRICE / 10 are defined and used correctly across the codebase.

Verification successful

The constants NOICE_GAS_PRICE and NOICE_GAS_PRICE / 10 are defined and used correctly across the codebase.

  • NOICE_GAS_PRICE is defined in bolt-spammer/src/constants.rs and bolt-spammer-helder/src/constants.rs with the value 69_420_000u128.
  • The constant is used appropriately in bolt-spammer/src/utils.rs and bolt-spammer-helder/src/utils.rs for setting gas prices and priority fees.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of constants for gas fees.

# Test: Search for the definition and usage of `NOICE_GAS_PRICE`. Expect: Defined and used correctly.
rg --type rust 'NOICE_GAS_PRICE'

Length of output: 703


Script:

#!/bin/bash
# Description: Verify the definition and usage of NOICE_GAS_PRICE.

# Verify the definition of NOICE_GAS_PRICE in bolt-spammer/src/constants.rs
echo "Definition in bolt-spammer/src/constants.rs:"
rg --type rust 'NOICE_GAS_PRICE' -A 3 bolt-spammer/src/constants.rs

# Verify the definition of NOICE_GAS_PRICE in bolt-spammer-helder/src/constants.rs
echo "Definition in bolt-spammer-helder/src/constants.rs:"
rg --type rust 'NOICE_GAS_PRICE' -A 3 bolt-spammer-helder/src/constants.rs

# Verify the usage of NOICE_GAS_PRICE in bolt-spammer/src/utils.rs
echo "Usage in bolt-spammer/src/utils.rs:"
rg --type rust 'NOICE_GAS_PRICE' -A 3 bolt-spammer/src/utils.rs

# Verify the usage of NOICE_GAS_PRICE in bolt-spammer-helder/src/utils.rs
echo "Usage in bolt-spammer-helder/src/utils.rs:"
rg --type rust 'NOICE_GAS_PRICE' -A 3 bolt-spammer-helder/src/utils.rs

Length of output: 1834

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

105-105: LGTM! Proper handling of KZG commitments.

The changes ensure that the builder has access to the necessary KZG commitments when creating signed bids.


169-174: LGTM! Enhanced functionality with KZG commitments.

The changes enhance the functionality by integrating KZG commitments into the builder's operations.


178-178: LGTM! Proper integration of KZG commitments.

The changes ensure that the constructed bid contains relevant KZG commitment data.

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

171-171: LGTM! Improved logging for better traceability.

The changes improve the traceability and debugging capabilities of the logging mechanism by including the versioned_bid variable.

bolt-sidecar/src/builder/payload_builder.rs (4)

79-79: LGTM! New field blob_gas_used added to Context struct.

The addition of blob_gas_used: u64 to the Context struct enhances the tracking of blob gas usage.


92-92: LGTM! Field blob_gas_used removed from Hints struct.

The removal of blob_gas_used: Option<u64> from the Hints struct aligns with the new context-based tracking of blob gas usage.


176-179: LGTM! Calculating blob_gas_used in build_fallback_payload.

The calculation of blob_gas_used by iterating over transactions ensures accurate tracking of blob gas usage.


386-386: LGTM! Using context.blob_gas_used in build_header_with_hints_and_context.

The usage of context.blob_gas_used ensures that the blob gas usage is accurately reflected in the header.

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 66d3b0b and 00ce1b1.

Files selected for processing (5)
  • bolt-sidecar/src/api/builder.rs (5 hunks)
  • bolt-sidecar/src/api/spec.rs (2 hunks)
  • bolt-sidecar/src/builder/mod.rs (4 hunks)
  • bolt-sidecar/src/builder/payload_builder.rs (6 hunks)
  • bolt-sidecar/src/primitives/mod.rs (1 hunks)
Additional comments not posted (13)
bolt-sidecar/src/api/spec.rs (1)

67-68: LGTM! Verify the usage of LocalPayloadIntegrityError.

The addition of the LocalPayloadIntegrity variant improves the error handling for payload integrity issues.

However, ensure that the LocalPayloadIntegrityError type is correctly used and handled throughout the codebase.

Verification successful

Verified: The LocalPayloadIntegrityError type is correctly used and handled throughout the codebase, ensuring detailed error information for payload integrity issues.

  • LocalPayloadIntegrityError is defined with a descriptive error message and fields for detailed mismatch information.
  • The usage of LocalPayloadIntegrityError::FieldMismatch in the codebase confirms proper error handling.
Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the usage of `LocalPayloadIntegrityError`. Expect: Proper handling and usage.
rg --type rust 'LocalPayloadIntegrityError'

Length of output: 398


Script:

#!/bin/bash
# Description: Extract and review the definition and usage of `LocalPayloadIntegrityError` in `bolt-sidecar/src/api/builder.rs`.

# Extract the definition of `LocalPayloadIntegrityError`.
rg --type rust -A 10 'pub enum LocalPayloadIntegrityError' bolt-sidecar/src/api/builder.rs

# Extract the usage instances of `LocalPayloadIntegrityError`.
rg --type rust -A 5 'LocalPayloadIntegrityError::' bolt-sidecar/src/api/builder.rs

Length of output: 713

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

4-4: LGTM!

The addition of the KzgCommitment import is necessary for the new payload processing logic.


166-166: LGTM! Verify the usage of blob_kzg_commitments.

The additional parameter blob_kzg_commitments allows the method to directly process KZG commitments, enhancing its functionality.

However, ensure that the blob_kzg_commitments are correctly used and handled throughout the codebase.

Also applies to: 171-171, 175-175

Verification successful

The usage of blob_kzg_commitments is correct and properly handled.

The additional parameter blob_kzg_commitments is correctly converted to a List type and used in constructing the BuilderBid instance within the create_signed_builder_bid method.

  • bolt-sidecar/src/primitives/mod.rs: Declaration in BuilderBid struct.
  • bolt-sidecar/src/builder/mod.rs: Passed as a parameter, converted to List, and used in BuilderBid.
Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the usage of `blob_kzg_commitments`. Expect: Proper handling and usage.
rg --type rust 'blob_kzg_commitments'

Length of output: 429


Script:

#!/bin/bash
# Extract lines around the identified usages of `blob_kzg_commitments` for context.

# Extract context around the declaration in `bolt-sidecar/src/primitives/mod.rs`
rg --type rust --context 5 'pub blob_kzg_commitments' bolt-sidecar/src/primitives/mod.rs

# Extract context around the parameter and its usage in `bolt-sidecar/src/builder/mod.rs`
rg --type rust --context 5 'blob_kzg_commitments' bolt-sidecar/src/builder/mod.rs

Length of output: 1346


104-104: LGTM! Verify the usage of kzg_commitments.

The cloning operation for kzg_commitments ensures that the builder has access to the necessary KZG commitments when creating signed bids.

However, ensure that the kzg_commitments are correctly used and handled throughout the codebase.

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

199-205: LGTM! Verify the usage of the execution_payload method.

The execution_payload method enhances the usability of the GetPayloadResponse type by providing a straightforward way to access execution payloads.

However, ensure that the execution_payload method is correctly used and handled throughout the codebase.

Verification successful

Let's gather more detailed context around the usage of the execution_payload method in the identified files to ensure it is correctly used and handled.


Verified: The execution_payload method is correctly used and handled throughout the codebase.

The detailed context shows that the method is used appropriately to retrieve the execution payload and compare its fields to other payloads or headers, ensuring proper handling and usage.

  • bolt-sidecar/src/api/builder.rs
  • bolt-sidecar/src/primitives/mod.rs
  • bolt-sidecar/src/builder/mod.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for the usage of the `execution_payload` method. Expect: Proper handling and usage.
rg --type rust 'execution_payload'

Length of output: 3505


Script:

#!/bin/bash
# Description: Gather detailed context around the usage of the `execution_payload` method in the identified files.

# Extract 5 lines of context before and after each match for better understanding.
rg --type rust 'execution_payload' -A 5 -B 5

Length of output: 16991

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

268-279: LGTM!

The introduction of the LocalPayloadIntegrityError enum enhances the robustness of error reporting.


281-298: LGTM!

The introduction of the assert_payload_fields_eq macro improves code organization and reusability.


300-409: LGTM!

The introduction of the check_locally_built_payload_integrity function improves code organization and reusability.


196-200: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to check_locally_built_payload_integrity handle the new integrity checks correctly.

Verification successful

Verified: The function usage is handled correctly.

The function check_locally_built_payload_integrity is only called once in the codebase, and the integrity checks are correctly handled at this call site.

  • bolt-sidecar/src/api/builder.rs: Line 196
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `check_locally_built_payload_integrity` handle the new integrity checks correctly.

# Test: Search for the function usage. Expect: Only occurrences of the new integrity checks.
rg --type rust -A 5 $'check_locally_built_payload_integrity'

Length of output: 1020


144-149: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to fetch_payload handle the new control flow correctly.

Verification successful

Verify fetch_payload usage in bolt-sidecar/src/primitives/mod.rs

The changes in bolt-sidecar/src/api/builder.rs are approved. However, ensure that the function calls to fetch_payload in bolt-sidecar/src/primitives/mod.rs handle the new control flow correctly.


Ensure all fetch_payload calls handle the new control flow correctly

The changes in bolt-sidecar/src/api/builder.rs are approved. However, the fetch_payload function call in bolt-sidecar/src/primitives/mod.rs does not follow the new control flow pattern. Ensure all instances of fetch_payload calls handle the new control flow correctly.


LGTM! But verify the function usage in the codebase.

The code changes are approved. The fetch_payload function calls in bolt-sidecar/src/api/builder.rs handle the new control flow correctly. There are no calls to fetch_payload in bolt-sidecar/src/primitives/mod.rs that require updates.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `fetch_payload` handle the new control flow correctly.

# Test: Search for the function usage. Expect: Only occurrences of the new control flow.
rg --type rust -A 5 $'fetch_payload'

Length of output: 1863


Script:

#!/bin/bash
# Description: Verify the function calls to `fetch_payload` in `bolt-sidecar/src/primitives/mod.rs` handle the new control flow correctly.

# Test: Search for the function usage in `bolt-sidecar/src/primitives/mod.rs`. Expect: Correct handling of the new control flow.
rg --type rust -A 5 $'fetch_payload' bolt-sidecar/src/primitives/mod.rs

Length of output: 600


Script:

#!/bin/bash
# Description: Find all instances where `fetch_payload` is called to ensure all usages handle the new control flow correctly.

# Test: Search for all calls to `fetch_payload`. Expect: Correct handling of the new control flow.
rg --type rust 'fetch_payload' --context 5

Length of output: 2858

bolt-sidecar/src/builder/payload_builder.rs (3)

79-79: LGTM!

The addition of the blob_gas_used field enhances the tracking of blob gas usage within the Context structure.


Line range hint 87-87:
LGTM!

The removal of the blob_gas_used field indicates a strategic shift towards a more definitive tracking method encapsulated within the Context structure.


386-386: LGTM!

The changes streamline the code and ensure consistency in how blob gas values are derived.

Comment on lines +112 to +113
BuilderApiError::LocalPayloadIntegrity(err) => {
(StatusCode::BAD_REQUEST, err.to_string()).into_response()
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

Response handling for LocalPayloadIntegrity is not tested.

The implementation for BuilderApiError::LocalPayloadIntegrity correctly provides a BAD_REQUEST response with the error message. However, there are no test cases found for BuilderApiError or LocalPayloadIntegrity in the codebase, indicating that the response handling is not adequately tested.

  • Please add test cases for BuilderApiError::LocalPayloadIntegrity to ensure the response handling is verified.
Analysis chain

LGTM! Verify the response handling for LocalPayloadIntegrity.

The IntoResponse implementation for LocalPayloadIntegrity correctly provides a BAD_REQUEST response with the error message.

However, ensure that the response handling for LocalPayloadIntegrity is correctly implemented and tested.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the response handling for `LocalPayloadIntegrity` in the codebase.

# Test: Search for the response handling of `LocalPayloadIntegrity`. Expect: Proper implementation and testing.
rg --type rust 'LocalPayloadIntegrity'

Length of output: 483


Script:

#!/bin/bash
# Description: Verify the response handling and testing for `LocalPayloadIntegrityError`.

# Search for test cases related to `LocalPayloadIntegrityError`.
rg --type rust 'LocalPayloadIntegrityError' --glob '*test*'

# Search for response handling in the codebase.
rg --type rust 'into_response' -A 5

Length of output: 3474


Script:

#!/bin/bash
# Description: Verify the testing for `BuilderApiError::LocalPayloadIntegrity`.

# Search for test cases related to `BuilderApiError`.
rg --type rust 'BuilderApiError' --glob '*test*'

# Search for test cases related to `LocalPayloadIntegrity`.
rg --type rust 'LocalPayloadIntegrity' --glob '*test*'

Length of output: 103


Script:

#!/bin/bash
# Description: List all test files in the codebase to verify the presence of tests.

# List all test files in the codebase.
fd --type f --glob '*test*.rs'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the presence of tests for `BuilderApiError` and `LocalPayloadIntegrity` in `bolt-sidecar/src/test_util.rs`.

# Search for `BuilderApiError` in the test file.
rg --type rust 'BuilderApiError' bolt-sidecar/src/test_util.rs

# Search for `LocalPayloadIntegrity` in the test file.
rg --type rust 'LocalPayloadIntegrity' bolt-sidecar/src/test_util.rs

Length of output: 131

@thedevbirb thedevbirb merged commit cab5ff0 into unstable Jul 22, 2024
2 checks passed
@thedevbirb thedevbirb deleted the fix/sidecar/local-blob branch July 22, 2024 08:00
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.

2 participants