Skip to content

imp(rpc): increase performance of eth_headerByHash #2856

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

Merged
merged 5 commits into from
Sep 17, 2024

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Sep 16, 2024

Description

CometRPC now supports querying the Header by hash, improving perf since we no longer need to query the entire block.

Other minor improvements were included

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the correct branch (see PR Targeting)

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new method to retrieve transaction logs based on transaction hash.
    • Enhanced the GetPendingTransactions method to accurately fetch the chain ID from the backend.
  • Bug Fixes

    • Resolved an issue where the community pool was nil, ensuring correct inflation mechanism operation.
  • Refactor

    • Streamlined block retrieval methods to enhance clarity and consistency.
    • Simplified the GetTransactionLogs method for improved efficiency.
    • Consolidated backend responsibilities to improve transaction handling.
  • Style

    • Improved code readability by reformatting function signatures.

Copy link
Contributor

coderabbitai bot commented Sep 16, 2024

Walkthrough

The recent changes to the codebase involve significant updates to the Ethereum backend functionality. Key modifications include enhancements to the eth_headerByHash function for improved performance, updates to the Interpreter interface to support custom Opcodes, and the introduction of a new method for retrieving transaction logs. Additionally, several refactoring efforts were made to streamline the backend interfaces and methods, focusing on the use of a new RPC client for block and transaction data retrieval.

Changes

File Change Summary
CHANGELOG.md Documented updates including performance improvements to eth_headerByHash, Interpreter interface updates, bug fixes, and removal of duplicates.
rpc/backend/backend.go Removed CosmosBackend interface, added GetTransactionLogs method, and included rpcClient in Backend struct.
rpc/backend/blocks.go Refactored block retrieval methods to use rpcClient, simplifying logic and enhancing maintainability.
rpc/backend/client_test.go Added functions to simulate various scenarios for header retrieval by hash, improving test coverage and robustness.
tests/nix_tests/test_no_abci_resp.py Modified error handling in test_gas_eth_tx to assert for a different error message regarding block result not found.

Possibly related PRs

Poem

In the code where rabbits hop,
Changes made, we’ll never stop.
With logs and blocks, we dance and play,
Optimized paths lead the way.
Custom Opcodes, a joyful cheer,
Ethereum shines, our goals are clear! 🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ef83fbe and bd2a402.

Files selected for processing (1)
  • tests/nix_tests/test_no_abci_resp.py (1 hunks)
Additional comments not posted (1)
tests/nix_tests/test_no_abci_resp.py (1)

60-60: LGTM!

The updated assertion message aligns with the expected error condition and provides a clearer indication of the test's focus on error handling. The change is valid and does not introduce any issues.


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 generate interesting stats about this repository and render them as a table.
    -- @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.

@github-actions github-actions bot added the tests label Sep 16, 2024
@fedekunze fedekunze marked this pull request as ready for review September 16, 2024 15:33
@fedekunze fedekunze requested a review from a team as a code owner September 16, 2024 15:33
@fedekunze fedekunze requested review from MalteHerrmann, 0xstepit, GAtom22 and ramacarlucho and removed request for a team September 16, 2024 15:33
Copy link
Contributor

@GAtom22 GAtom22 left a comment

Choose a reason for hiding this comment

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

Thanks @fedekunze!!

Left a few comments
Also, unit tests are failing, looking into these...

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: CHILL

Commits

Files that changed from the base of the PR and between c07228d and c3e9c4f.

Files selected for processing (3)
  • rpc/backend/backend_suite_test.go (1 hunks)
  • rpc/backend/blocks_test.go (18 hunks)
  • rpc/backend/client_test.go (2 hunks)
Additional context used
GitHub Check: Run golangci-lint
rpc/backend/client_test.go

[failure] 264-264:
unused-parameter: parameter 'tx' seems to be unused, consider removing or renaming it as _ (revive)

Additional comments not posted (6)
rpc/backend/backend_suite_test.go (1)

81-82: LGTM!

The changes to the SetupTest function look good. The addition of WithClient(mocks.NewClient(suite.T())) enhances the test suite's ability to simulate client interactions during tests by setting up a mock client. The removal of the previous line that set suite.backend.clientCtx.Client to a new mock client indicates a shift in how the client context is managed within the test setup. These changes streamline the client configuration process and ensure that the test suite uses the appropriate mock implementations for its operations.

rpc/backend/client_test.go (3)

261-277: LGTM!

The function correctly sets up a mock response for testing the HeaderByHash RPC method.

Tools
GitHub Check: Run golangci-lint

[failure] 264-264:
unused-parameter: parameter 'tx' seems to be unused, consider removing or renaming it as _ (revive)


279-282: LGTM!

The function correctly sets up a mock error response for testing the HeaderByHash RPC method.


284-287: LGTM!

The function correctly sets up a mock response for testing the HeaderByHash RPC method when the header is not found.

rpc/backend/blocks_test.go (2)

676-677: Approve the refactoring to use a mocked client.

The change to use a mocked client for retrieving block results is a good refactoring that improves the test isolation and control over the test environment. The overall logic flow remains intact.


Line range hint 717-727: Approve the change to use specific header mocking methods.

The change to use RegisterHeaderByHashError and RegisterHeaderByHash methods for mocking the client responses is a good refactoring that improves the specificity of the mocks. The overall logic flow and test cases remain the same.

@fedekunze fedekunze merged commit 1f0432f into main Sep 17, 2024
50 of 52 checks passed
@fedekunze fedekunze deleted the fedekunze/header-by-hash branch September 17, 2024 12:29
@GAtom22
Copy link
Contributor

GAtom22 commented Sep 19, 2024

https://github.com/Mergifyio backport rama/release-v20

Copy link
Contributor

mergify bot commented Sep 19, 2024

backport rama/release-v20

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 19, 2024
* imp(rpc): increase performance of eth_headerByHash

* c++

* update unit tests

* address review comments

---------

Co-authored-by: tom <tomasguerraalda@hotmail.com>
(cherry picked from commit 1f0432f)
GAtom22 added a commit that referenced this pull request Sep 19, 2024
…2870)

* imp(rpc): increase performance of eth_headerByHash (#2856)

* imp(rpc): increase performance of eth_headerByHash

* c++

* update unit tests

* address review comments

---------

Co-authored-by: tom <tomasguerraalda@hotmail.com>
(cherry picked from commit 1f0432f)

* update chlog

---------

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: tom <tomasguerraalda@hotmail.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants