Skip to content

fix: Add RequestHash header field for SDK compatibility #1133

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Thegaram
Copy link

@Thegaram Thegaram commented Mar 5, 2025

1. Purpose or design rationale of this PR

...

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • fix: A bug fix

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • Enhanced block data capabilities now provide richer insights through additional header details, offering improved metrics for block composition and resource usage.
  • Chores

    • Updated the patch version to reflect the latest maintenance improvements.

Copy link

coderabbitai bot commented Mar 5, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes add a new optional field RequestsHash to the Header struct for EIP-7685 compatibility. The CopyHeader function now performs a deep copy of RequestsHash if it is not nil. New accessor methods (BeaconRoot, RequestsHash, ExcessBlobGas, and BlobGasUsed) are introduced in the Block struct to provide safe, pointer-based access to the corresponding fields. Additionally, the patch version in params/version.go is incremented from 20 to 21.

Changes

File(s) Change Summary
core/types/block.go Added optional field RequestsHash *common.Hash in Header; updated CopyHeader to deep copy RequestsHash if not nil; added methods BeaconRoot(), RequestsHash(), ExcessBlobGas(), and BlobGasUsed() to Block.
params/.../version.go Updated constant VersionPatch from 20 to 21.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Block as Block Object
    participant Header as Header Data

    Client->>Block: BeaconRoot()
    Block->>Header: Retrieve beacon root
    Header-->>Block: Beacon value
    Block-->>Client: Return beacon value

    Client->>Block: RequestsHash()
    Block->>Header: Retrieve requests hash
    Header-->>Block: Return requests hash
    Block-->>Client: Return requests hash

    Client->>Block: ExcessBlobGas()
    Block->>Header: Retrieve excess blob gas value
    Header-->>Block: Return value or nil
    Block-->>Client: Return value

    Client->>Block: BlobGasUsed()
    Block->>Header: Retrieve blob gas used value
    Header-->>Block: Return value or nil
    Block-->>Client: Return value
Loading
sequenceDiagram
    participant Caller as Caller
    participant CopyFunc as CopyHeader()
    participant Header as Header Data

    Caller->>CopyFunc: Call CopyHeader(oldHeader)
    CopyFunc->>Header: Check if RequestsHash is not nil
    alt RequestsHash exists
        Header-->>CopyFunc: Provide deep copy of RequestsHash
    else No RequestsHash
        Header-->>CopyFunc: No action needed
    end
    CopyFunc-->>Caller: Return copied header
Loading

Suggested labels

bump-version

Suggested reviewers

  • jonastheis
  • colinlyguo

Poem

Oh, what a joyful day in code-land bright,
Updates hop in, a delightful sight!
I’m a little rabbit 🐰 with a heart so light,
Copying headers and patching versions just right.
Bugs, beware—my changes take flight!
Happy coding to all, from morning till night!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@Thegaram Thegaram requested review from ranchalp and colinlyguo March 5, 2025 07:54
Copy link

@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

🧹 Nitpick comments (1)
core/types/block.go (1)

403-405: Consider implementing deep copy for consistency with other accessors

The BeaconRoot() and RequestsHash() methods return direct pointers to the header fields, which is inconsistent with other similar accessor methods like ExcessBlobGas() and BlobGasUsed() that create deep copies.

For consistency with other pointer-returning accessor methods, consider implementing deep copies:

-func (b *Block) BeaconRoot() *common.Hash   { return b.header.ParentBeaconRoot }
-func (b *Block) RequestsHash() *common.Hash { return b.header.RequestsHash }
+func (b *Block) BeaconRoot() *common.Hash {
+  var beaconRoot *common.Hash
+  if b.header.ParentBeaconRoot != nil {
+    beaconRoot = new(common.Hash)
+    *beaconRoot = *b.header.ParentBeaconRoot
+  }
+  return beaconRoot
+}
+
+func (b *Block) RequestsHash() *common.Hash {
+  var requestsHash *common.Hash
+  if b.header.RequestsHash != nil {
+    requestsHash = new(common.Hash)
+    *requestsHash = *b.header.RequestsHash
+  }
+  return requestsHash
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c454e7 and e247123.

📒 Files selected for processing (2)
  • core/types/block.go (3 hunks)
  • params/version.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • params/version.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (6)
core/types/block.go (6)

118-119: Field addition aligns with EIP-7685 for SDK compatibility

The new RequestsHash field is correctly added to the Header struct with appropriate JSON and RLP tags. This field supports EIP-7685 compatibility as mentioned in the PR objectives.


336-339: Deep copy implementation is correct

The implementation properly handles the deep copy of the RequestsHash field in the CopyHeader function, ensuring that modifications to the copied header won't affect the original.


406-413: ExcessBlobGas() implementation is correct

The method properly handles the nil case and creates a deep copy of the value when returning it, protecting the internal state of the header from external modifications.


415-422: BlobGasUsed() implementation is correct

The implementation follows the same pattern as ExcessBlobGas(), correctly handling the nil case and creating a deep copy of the value when returning it.


118-119:

✅ Verification successful

Verify patch version update in params/version.go

According to the AI summary, this PR also updates the patch version in params/version.go. Let's verify this update has been properly implemented.


🏁 Script executed:

#!/bin/bash
# Check if the patch version has been updated

# Look for the version update in params/version.go
echo "Checking for patch version update..."
cat params/version.go | grep -A 2 VersionPatch

Length of output: 369


Patch Version Update Verified in params/version.go
The patch version is correctly updated to 21 in params/version.go as expected. The file correctly reflects the change via VersionPatch = 21 along with the associated metadata, and no further modifications are required.


320-339:

❓ Verification inconclusive

Verify that all code using these new fields is updated

The changes look good, but it's important to verify that any code that processes block headers is updated to handle the new RequestsHash field, particularly in functions that serialize or deserialize block headers.


🏁 Script executed:

#!/bin/bash
# Check for other places in the codebase that might need updates for the RequestsHash field

# Look for places where block headers are encoded/decoded
echo "Checking RLP encoding/decoding implementations..."
rg -A 3 -B 3 "func.*Encode.*Header" --type go

# Check for places that might need to handle RequestsHash
echo "Checking for functions that might need to handle the new RequestsHash field..."
rg -A 3 -B 3 "func.*Header" --type go | grep -i "hash\|encode\|decode\|marshal\|unmarshal"

# Look for JSON handling of headers that might need to be updated
echo "Checking JSON marshaling of headers..."
rg -A 3 -B 3 "json.*Header" --type go

Length of output: 74601


Review: Verify Serialization & Deserialization Updates for RequestsHash

The new block header copy logic in core/types/block.go (lines 320–339) correctly copies the RequestsHash field. However, our initial searches for header encoding/decoding did not show clear evidence that the RequestsHash field is handled—especially in the JSON serialization (see core/types/gen_header_json.go) or in RLP encoding functions. Please make sure that:

  • The JSON marshaling/unmarshaling routines (e.g. in core/types/gen_header_json.go) are updated to include RequestsHash if needed.
  • Any RLP encode/decode functions or other serializer/deserializer routines used for block headers account for the new field.
  • Downstream components that expect complete header data (such as consensus logic, API endpoints, and tests) correctly process the RequestsHash field.

Please review these areas manually to ensure complete integration of the new RequestsHash field.

@Thegaram Thegaram marked this pull request as draft March 5, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants