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

internal/ethapi: eth_call block parameter is optional (#28165) #1095

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

colinlyguo
Copy link
Member

@colinlyguo colinlyguo commented Dec 2, 2024

1. Purpose or design rationale of this PR

this PR cherry-picks this commit: ethereum@adb9b31

since in the API spec, the block tag is optional: https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/eth/execute.yaml#L9

as the cherry-picked PR described: "So apparently in the spec the base block parameter of eth_call is optional. I agree that "latest" is a sane default for this that most people would use."

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

Summary by CodeRabbit

  • New Features

    • Enhanced flexibility in the Call method, allowing for optional block number or hash input.
  • Bug Fixes

    • Improved error handling for revert reasons in the Call method.
  • Chores

    • Incremented patch version from 25 to 26 for the go-ethereum library.

So apparently in the spec the base block parameter of eth_call is optional.
I agree that "latest" is a sane default for this that most people would use.
Copy link

coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces modifications to the Call method in the PublicBlockChainAPI struct located in internal/ethapi/api.go. The method now accepts a pointer to rpc.BlockNumberOrHash, allowing for nil values, which defaults to the latest block number if not specified. Additionally, the VersionPatch constant in params/version.go is incremented from 25 to 26, reflecting a new patch release. Minor adjustments to comments and formatting are also included, but they do not affect functionality.

Changes

File Path Change Summary
internal/ethapi/api.go Updated Call method signature to accept a pointer to rpc.BlockNumberOrHash; enhanced nil handling.
params/version.go Incremented VersionPatch constant from 25 to 26 for a new patch release.

Possibly related PRs

  • fix(api): change gas_price to use pending block #1082: The changes in the GasPrice method in internal/ethapi/api.go are related to the Call method in the same file, as both methods are part of the PublicBlockChainAPI struct and involve modifications to how parameters are handled, enhancing the overall API functionality.

Suggested reviewers

  • Thegaram
  • omerfirmak
  • 0xmountaintop
  • jonastheis

🐇 In the code, a change we see,
A pointer now, how nice to be!
With version bumped, we hop along,
To better calls, we sing our song!
So let us cheer, with joy and glee,
For every patch, brings harmony! 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9fff27e and b85da39.

📒 Files selected for processing (2)
  • internal/ethapi/api.go (1 hunks)
  • params/version.go (1 hunks)
🔇 Additional comments (3)
params/version.go (1)

27-27: LGTM: Version bump is appropriate

Incrementing the patch version is correct for this backwards-compatible API enhancement.

internal/ethapi/api.go (2)

1090-1094: LGTM: Block parameter is now optional with appropriate default

The changes correctly implement optional block parameter support:

  1. Parameter type changed to pointer to allow nil values
  2. Default to latest block when parameter is nil
  3. Implementation aligns with Ethereum execution APIs specification

This enhancement maintains backward compatibility while adding flexibility.


1090-1094: Verify callers of the Call method

Let's ensure all callers are compatible with the pointer parameter change.

✅ Verification successful

Let me analyze the search results and generate additional verification scripts to get more context.

The first script will help us understand the full implementation of the Call method, while the second script will help find direct references to this specific Call method with 4 parameters.


Based on the search results, I can now generate the final response since I have enough context about the Call method and its usage.

No impact from pointer parameter change

The change to make blockNrOrHash a pointer parameter in the Call method is safe because:

  1. The method already handles nil values by defaulting to latest block
  2. All internal usage through DoCall expects the dereferenced value
  3. No direct external callers of this method were found in the codebase

The change is actually an improvement as it makes the parameter handling more explicit and consistent with common Go patterns for optional parameters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Call method invocations to verify parameter handling
rg -A 3 "Call\(" --type go

Length of output: 81131


Script:

#!/bin/bash
# Search for Call method in the specific file to understand the changes
rg -A 10 "Call\(" internal/ethapi/api.go

# Search for references to this specific Call method
ast-grep --pattern 'Call($_, $_, $_, $_)' 

Length of output: 1655


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

@colinlyguo colinlyguo merged commit d2fe42b into develop Dec 3, 2024
1 check passed
@colinlyguo colinlyguo deleted the fix-remove-block-tag-in-eth-call branch December 3, 2024 06:32
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.

4 participants