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

feat(rpc): implement debug api #1340

Merged
merged 8 commits into from
Dec 18, 2023
Merged

feat(rpc): implement debug api #1340

merged 8 commits into from
Dec 18, 2023

Conversation

itsdevbear
Copy link
Member

@itsdevbear itsdevbear commented Dec 1, 2023

NOTE: endpoints that require tracing "bad blocks" are currently not supported (debug_traceBadBlock, debug_intermediateRoots, debug_standardTraceBadBlockToFile)

Summary by CodeRabbit

  • New Features

    • Enhanced tracing capabilities with new backend methods for state retrieval at specific blocks and transactions.
    • Expanded API services for "web3" and "debug" namespaces to improve user interactions and debugging processes.
  • Documentation

    • Updated public interface documentation to reflect newly added methods and functionalities.

Copy link

coderabbitai bot commented Dec 1, 2023

Walkthrough

The codebase has been updated to enhance the Ethereum node's capabilities. New interfaces and functions have been introduced to interact with blockchain state data, including the state of specific blocks and transactions. There is also the addition of new API services for web3 and debug functionalities, and the code now supports loading tracer engines, expanding the node's diagnostic and interaction tools.

Changes

File(s) Summary of Changes
.../api_backend.go, .../backend.go Added tracers import, implemented tracers.Backend, added StateAtBlock and StateAtTransaction methods, imported additional packages, added "web3" and "debug" API services, and included tracer engines package loading.
.../chain.go, .../chain_resources.go Removed ChainConfig method from blockchain type, updated ChainResources interface and blockchain struct with new state retrieval methods and parameters.

🐇✨
To the node with care, we add new flair,
Tracers and states, in the blockchain's lair.
Debug and web3, now dance with glee,
A hop, a skip, in code's vast sea. 🌊🥕

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

Copy link

codecov bot commented Dec 1, 2023

Codecov Report

Merging #1340 (2dd2417) into main (58177db) will not change coverage.
The diff coverage is n/a.

❗ Current head 2dd2417 differs from pull request most recent head 5b4279b. Consider uploading reports for the commit 5b4279b to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1340   +/-   ##
=======================================
  Coverage   48.60%   48.60%           
=======================================
  Files          84       84           
  Lines        4917     4917           
=======================================
  Hits         2390     2390           
  Misses       2350     2350           
  Partials      177      177           

eth/polar/backend.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ocnc ocnc left a comment

Choose a reason for hiding this comment

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

lgtm, works locally

@ocnc ocnc marked this pull request as ready for review December 18, 2023 22:34
@ocnc ocnc added backport/v0.0.2-alpha merge me daddy Trigger Beradozer to bulldoze the PR labels Dec 18, 2023
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 58177db and 2dd2417.
Files ignored due to filter (3)
  • eth/go.mod
  • eth/go.sum
  • go.work.sum
Files selected for processing (2)
  • eth/polar/api_backend.go (3 hunks)
  • eth/polar/backend.go (3 hunks)
Additional comments: 9
eth/polar/api_backend.go (3)
  • 44-44: The import statement for the tracers package has been correctly added to support the new debugging functionalities.

  • 60-60: The APIBackend interface now correctly includes the tracers.Backend interface, enabling the backend to support tracing capabilities.

  • 373-387: The StateAtBlock and StateAtTransaction methods have been correctly added to the backend type and are implemented to delegate to the corresponding methods of the polar object. Ensure that the polar object's methods are correctly handling errors and validating parameters as expected.

eth/polar/backend.go (6)
  • 24-54: The new imports are appropriate for the added functionalities related to the debug API and tracing capabilities.

  • 192-198: The addition of the debug namespace to the RPC services is consistent with the PR's objective to introduce debugging capabilities.

  • 237-259: The function stateAtBlock is well-documented and seems to handle state retrieval correctly. Ensure that the documentation is kept up-to-date with any future changes to the function's behavior.

  • 266-313: The function stateAtTransaction correctly sets up the execution environment for a transaction. However, ensure that the error handling is consistent and that all resources are properly released in case of an error.

  • 315-329: The function pathState provides a clear and concise way to retrieve the state at a specific block. The TODO comment indicates future work on historical state support, which should be tracked in the project's issue tracker.

  • 328-328: The error message is clear and indicates that historical state retrieval is not yet implemented. This is consistent with the TODO comment and should be addressed in future updates.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2dd2417 and 9d213b4.
Files selected for processing (4)
  • eth/core/chain.go (1 hunks)
  • eth/core/chain_resources.go (2 hunks)
  • eth/polar/api_backend.go (3 hunks)
  • eth/polar/backend.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • eth/polar/api_backend.go
  • eth/polar/backend.go
Additional comments: 4
eth/core/chain.go (1)
  • 159-161: The loadLastState method logic appears to be correct, assuming that the GetBlockByNumber method correctly handles the case when number is zero. However, ensure that the error message "block is nil at load last state" is consistent with the project's error handling strategy and provides enough context for debugging.
eth/core/chain_resources.go (3)
  • 97-137: The StateAtBlock method has been updated with additional parameters and return types. Ensure that the implementation correctly handles the new parameters and that the returned state and release function are used appropriately in the calling code.

  • 139-186: The StateAtTransaction method has been updated with additional parameters and return types. Review the logic to ensure that the transaction execution environment is correctly set up and that the error handling is consistent with the rest of the codebase. Pay special attention to the error messages to ensure they provide enough context for debugging.

  • 193-196: The Config method has been reintroduced in the blockchain struct. Verify that this reintroduction is intentional and that it does not conflict with the removal of the Config method from the Blockchain interface.

Verification successful

The reintroduction of the Config method in the blockchain struct does not appear to conflict with any interface method, as the verification process did not reveal any interfaces that include a Config method with the specified signature. This suggests that the change is intentional and without conflict.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the declaration of the Config method in the Blockchain interface.
rg --type go "Config\(\) \*params\.ChainConfig" --glob '*chain.go'

Length of output: 68



Script:

#!/bin/bash
# Search for the declaration of the Blockchain interface across all .go files.
rg --type go "interface\s+Blockchain\s+{" -A 10

Length of output: 165



Script:

#!/bin/bash
# Corrected search for the declaration of the Blockchain interface across all .go files.
rg --type go "interface\s+Blockchain\s+\{" -A 10

Length of output: 50



Script:

#!/bin/bash
# Search for the Config method within any interface across all .go files.
rg --type go "interface\s+\{[^}]*Config\(\) \*params\.ChainConfig" -A 3 -B 3

Length of output: 78

eth/core/chain.go Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9d213b4 and 5b4279b.
Files selected for processing (1)
  • eth/polar/backend.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • eth/polar/backend.go

@mergify mergify bot merged commit a41940c into main Dec 18, 2023
11 checks passed
@mergify mergify bot deleted the debug branch December 18, 2023 23:03
mergify bot pushed a commit that referenced this pull request Dec 18, 2023
NOTE: endpoints that require tracing "bad blocks" are currently not supported (debug_traceBadBlock, debug_intermediateRoots, debug_standardTraceBadBlockToFile)

## Summary by CodeRabbit

- **New Features**
  - Enhanced tracing capabilities with new backend methods for state retrieval at specific blocks and transactions.
  - Expanded API services for "web3" and "debug" namespaces to improve user interactions and debugging processes.

- **Documentation**
  - Updated public interface documentation to reflect newly added methods and functionalities.

(cherry picked from commit a41940c)

# Conflicts:
#	go.work.sum
ocnc pushed a commit that referenced this pull request Dec 18, 2023
This is an automatic backport of pull request #1340 done by
[Mergify](https://mergify.com).
Cherry-pick of a41940c has failed:
```
On branch mergify/bp/release/v0.0.2-alpha/pr-1340
Your branch is up to date with 'origin/release/v0.0.2-alpha'.

You are currently cherry-picking commit a41940c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   eth/core/chain.go
	modified:   eth/core/chain_resources.go
	modified:   eth/go.mod
	modified:   eth/go.sum
	modified:   eth/polar/api_backend.go
	modified:   eth/polar/backend.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   go.work.sum

```


To fix up this pull request, you can check it out locally. See
documentation:
https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on
`<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>

Co-authored-by: Devon Bear <itsdevbear@berachain.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.0.2-alpha merge me daddy Trigger Beradozer to bulldoze the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants