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: Add official tevm trace methods #824

Closed
wants to merge 2 commits into from

Conversation

roninjin10
Copy link
Collaborator

@roninjin10 roninjin10 commented Jan 16, 2024

Description

Add the official tevm trace methods. They work the same as call, contract, and script but take extra trace params

Testing

Explain the quality checks that have been done on the code changes

Additional Information

Your ENS/address:

Summary by CodeRabbit

  • New Features

    • Introduced new trace handlers for enhanced debugging capabilities: traceCall, traceContract, and traceScript.
    • Added new JSON-RPC request and response types for tracing functionality.
  • Improvements

    • Reorganized and streamlined eth and debug handler sections for better usability.
    • Refined serialization handling for various types, including bigint.
  • Bug Fixes

    • Adjusted StructLog type declaration to ensure correct export format.
  • Documentation

    • Updated type definitions and parameters for clearer understanding of tracing procedures.
    • Enhanced descriptions for new handler functions and JSON-RPC procedures.

Copy link

changeset-bot bot commented Jan 16, 2024

⚠️ No Changeset found

Latest commit: 8649fe2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
evmts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 2:56am

@roninjin10
Copy link
Collaborator Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

Copy link
Contributor

coderabbitai bot commented Jan 16, 2024

Warning

Rate Limit Exceeded

@roninjin10 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 22 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between f786531 and 8649fe2.

Walkthrough

The update to the Tevm type introduces new trace handlers for calls, contracts, and scripts, reorganizing existing handlers in the process. The changes streamline debugging capabilities, with new types and procedures for tracing operations, and enhance JSON-RPC request and response handling. Serialization utilities have also been refined for better accuracy and control flow.

Changes

File Path Change Summary
.../Tevm.ts Added new trace handlers and reorganized eth and debug handlers.
.../index.ts Exported new types and handlers for tracing and JSON-RPC operations.
.../handlers/index.ts Added exports for TraceCallHandler, TraceScriptHandler, and TraceContractHandler.
.../params/DebugParams.ts Updated types and added readonly to certain fields.
.../params/TraceCallParams.ts Introduced TraceCallParams type for tevm_traceCall handler.
.../params/TraceContractParams.ts Created TraceContractParams type for tevm_traceContract handler.
.../params/TraceScriptParams.ts Added TraceScriptParams type for tevm_traceScript handler.
.../procedure/index.ts Exported new tracing procedures.
.../requests/index.ts Added exports for new trace-related JSON-RPC requests.
.../responses/index.ts Added exports for new trace-related JSON-RPC responses.
.../result/DebugResult.ts Modified StructLog type to be exported.
.../result/TraceCallResult.ts Created type definition for TraceCallResult.
.../result/TraceContractResult.ts Introduced type definition for TraceContractResult.
.../result/TraceScriptResult.ts Added type definition for TraceScriptResult.
.../utils/SerializeToJson.ts Updated serialization handling for various types.
.../handlers/TraceCallHandler.ts Added TraceCallHandler function.
.../handlers/TraceContractHandler.ts Created TraceContractHandler function and related imports.
.../handlers/TraceScriptHandler.ts Introduced TraceScriptHandler function.
.../procedure/TraceCallProcedure.ts Implemented JSON-RPC procedure for tevm_traceCall.
.../procedure/TraceContractProcedure.ts Added JSON-RPC procedure for tevm_traceContract.
.../procedure/TraceScriptProcedure.ts Implemented JSON-RPC procedure for tevm_traceScript.
.../requests/TraceCallJsonRpcRequest.ts Introduced JSON-RPC request type for tevm_traceCall.
.../requests/TraceContractJsonRpcRequest.ts Added JSON-RPC request type for tevm_traceContract.
.../requests/TraceScriptJsonRpcRequest.ts Created JSON-RPC request type for tevm_traceScript.
.../responses/TraceCallJsonRpcResponse.ts Handled JSON-RPC responses for debug_traceCall.
.../responses/TraceContractJsonRpcResponse.ts Introduced JSON-RPC response type for debug_traceContract.
.../responses/TraceScriptJsonRpcResponse.ts Implemented JSON-RPC response type for debug_traceScript.
.../handlers/debug/traceCallHandler.js Refactored traceCallHandler to use async/await and improved event and trace handling.
.../jsonrpc/debug/traceCallProcedure.js Exported traceCallProcedure function for JSON-RPC handling with traceCallHandler.

Poem

To trace a call, a script, a bind,
CodeRabbit hopped through code, refined.
🐇💻 With each leap, a bug's defeat,
In data streams where traces meet.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f786531 and b1a509e.
Files selected for processing (32)
  • vm/api/src/Tevm.ts (2 hunks)
  • vm/api/src/TevmJsonRpcRequestHandler.ts (3 hunks)
  • vm/api/src/handlers/TraceCallHandler.ts (1 hunks)
  • vm/api/src/handlers/TraceContractHandler.ts (1 hunks)
  • vm/api/src/handlers/TraceScriptHandler.ts (1 hunks)
  • vm/api/src/handlers/index.ts (1 hunks)
  • vm/api/src/index.ts (6 hunks)
  • vm/api/src/params/DebugParams.ts (3 hunks)
  • vm/api/src/params/TraceCallParams.ts (1 hunks)
  • vm/api/src/params/TraceContractParams.ts (1 hunks)
  • vm/api/src/params/TraceScriptParams.ts (1 hunks)
  • vm/api/src/params/index.ts (1 hunks)
  • vm/api/src/procedure/TraceCallProcedure.ts (1 hunks)
  • vm/api/src/procedure/TraceContractProcedure.ts (1 hunks)
  • vm/api/src/procedure/TraceScriptProcedure.ts (1 hunks)
  • vm/api/src/procedure/index.ts (1 hunks)
  • vm/api/src/requests/TraceCallJsonRpcRequest.ts (1 hunks)
  • vm/api/src/requests/TraceContractJsonRpcRequest.ts (1 hunks)
  • vm/api/src/requests/TraceScriptJsonRpcRequest.ts (1 hunks)
  • vm/api/src/requests/index.ts (1 hunks)
  • vm/api/src/responses/TraceCallJsonRpcResponse.ts (1 hunks)
  • vm/api/src/responses/TraceContractJsonRpcResponse.ts (1 hunks)
  • vm/api/src/responses/TraceScriptJsonRpcResponse.ts (1 hunks)
  • vm/api/src/responses/index.ts (1 hunks)
  • vm/api/src/result/DebugResult.ts (1 hunks)
  • vm/api/src/result/TraceCallResult.ts (1 hunks)
  • vm/api/src/result/TraceContractResult.ts (1 hunks)
  • vm/api/src/result/TraceScriptResult.ts (1 hunks)
  • vm/api/src/result/index.ts (1 hunks)
  • vm/api/src/utils/SerializeToJson.ts (1 hunks)
  • vm/procedures/src/handlers/debug/traceCallHandler.js (1 hunks)
  • vm/procedures/src/jsonrpc/debug/traceCallProcedure.js (1 hunks)
Files skipped from review due to trivial changes (1)
  • vm/api/src/handlers/TraceContractHandler.ts
Additional comments: 36
vm/api/src/handlers/TraceCallHandler.ts (1)
  • 4-7: The TraceCallHandler type definition is correct and aligns with the expected functionality of a handler that takes TraceCallParams and returns a Promise of TraceCallResult.
vm/api/src/handlers/TraceScriptHandler.ts (1)
  • 4-7: The TraceScriptHandler type definition is correct and aligns with the expected functionality of a handler that takes TraceScriptParams and returns a Promise of TraceScriptResult.
vm/api/src/result/TraceCallResult.ts (1)
  • 4-11: The TraceCallResult type is correctly defined with callResult, failed, and structLogs properties, which are appropriate for a trace call result.
vm/api/src/result/TraceScriptResult.ts (1)
  • 4-11: The TraceScriptResult type is correctly defined with callResult, failed, and structLogs properties, which are appropriate for a trace script result.
vm/api/src/result/TraceContractResult.ts (1)
  • 4-11: The TraceContractResult type is correctly defined with callResult, failed, and structLogs properties, which are appropriate for a trace contract result.
vm/api/src/procedure/TraceCallProcedure.ts (1)
  • 4-12: The TraceCallProcedure type definition is correct and aligns with the expected functionality of a JSON-RPC procedure that takes TraceCallJsonRpcRequest and returns a Promise of TraceCallJsonRpcResponse.
vm/api/src/procedure/TraceScriptProcedure.ts (1)
  • 4-11: The TraceScriptProcedure type definition is correct and aligns with the expected functionality of a JSON-RPC procedure that takes TraceScriptJsonRpcRequest and returns a Promise of TraceScriptJsonRpcResponse.
vm/api/src/result/index.ts (1)
  • 8-10: The new exports for TraceCallResult, TraceScriptResult, and TraceContractResult are correctly added to the index.ts file, expanding the public API to include these new result types.
vm/api/src/handlers/index.ts (1)
  • 8-10: The addition of the exports for TraceCallHandler, TraceScriptHandler, and TraceContractHandler in the index.ts file is correct, making these handlers available for import.
vm/api/src/requests/TraceCallJsonRpcRequest.ts (1)
  • 4-12: The TraceCallJsonRpcRequest type is correctly defined, specifying the method as 'debug_traceCall' and the parameters as SerializeToJson<TraceCallParams>.
vm/api/src/procedure/TraceContractProcedure.ts (1)
  • 4-10: The TraceContractProcedure type definition is correct and aligns with the expected functionality of a JSON-RPC procedure that takes TraceContractJsonRpcRequest and returns a Promise of TraceContractJsonRpcResponse.
vm/api/src/requests/TraceScriptJsonRpcRequest.ts (1)
  • 4-12: The TraceScriptJsonRpcRequest type is correctly defined, specifying the method as 'debug_traceScript' and the parameters as SerializeToJson<TraceScriptParams>.
vm/api/src/requests/TraceContractJsonRpcRequest.ts (1)
  • 4-12: The TraceContractJsonRpcRequest type is correctly defined, specifying the method as 'debug_traceContract' and the parameters as SerializeToJson<TraceContractParams>.
vm/api/src/params/index.ts (1)
  • 9-11: The addition of the exports for TraceCallParams, TraceScriptParams, and TraceContractParams in the index.ts file is correct, indicating an expansion of functionality related to tracing within the API.
vm/api/src/responses/index.ts (1)
  • 9-11: The new exports for trace-related JSON-RPC responses (TraceCallJsonRpcResponse, TraceContractJsonRpcResponse, and TraceScriptJsonRpcResponse) are correctly added to the index.ts file.
vm/api/src/procedure/index.ts (1)
  • 9-11: The addition of the exports for TraceCallProcedure, TraceScriptProcedure, and TraceContractProcedure in the index.ts file is correct, making these procedures available for import.
vm/api/src/requests/index.ts (1)
  • 10-12: The new exports for trace-related JSON-RPC requests (TraceCallJsonRpcRequest, TraceContractJsonRpcRequest, and TraceScriptJsonRpcRequest) are correctly added to the index.ts file.
vm/api/src/result/DebugResult.ts (1)
  • 4-4: The modification to export the StructLog type is correct, allowing it to be accessible outside of its module, which is necessary for the new tracing functionality.
vm/api/src/responses/TraceCallJsonRpcResponse.ts (1)
  • 14-17: The TraceCallJsonRpcResponse type is correctly defined, specifying the method as 'tevm_traceCall' and the result as SerializeToJson<TraceCallResult>, with a placeholder for strongly typed errors.
vm/api/src/responses/TraceScriptJsonRpcResponse.ts (1)
  • 14-17: The TraceScriptJsonRpcResponse type is correctly defined, specifying the method as 'tevm_traceScript' and the result as SerializeToJson<TraceScriptResult>, with a placeholder for strongly typed errors.
vm/api/src/responses/TraceContractJsonRpcResponse.ts (1)
  • 14-17: The TraceContractJsonRpcResponse type is correctly defined, specifying the method as 'tevm_traceContract' and the result as SerializeToJson<TraceContractResult>, with a placeholder for strongly typed errors.
vm/api/src/params/TraceCallParams.ts (1)
  • 14-22: The TraceCallParams type is correctly defined, extending TraceParams and including the necessary properties for a trace call, such as call and optional block.
vm/api/src/params/TraceScriptParams.ts (1)
  • 14-22: The TraceScriptParams type is correctly defined, extending TraceParams and including the necessary properties for a trace script, such as call and optional block.
vm/api/src/params/TraceContractParams.ts (1)
  • 14-22: The TraceContractParams type is correctly defined, extending TraceParams and including the necessary properties for a trace contract, such as call and optional block.
vm/api/src/utils/SerializeToJson.ts (1)
  • 26-33: The SerializeToJson utility type has been updated correctly to handle serialization of new types more accurately and efficiently, including JsonSerializableSet and JsonSerializableArray.
vm/api/src/Tevm.ts (1)
  • 32-34: The Tevm type has been updated to include new trace handlers (traceCall, traceContract, and traceScript) correctly, and the restructuring of the eth and debug handlers is appropriate.
vm/procedures/src/jsonrpc/debug/traceCallProcedure.js (1)
  • 9-35: The traceCallProcedure function is correctly refactored to use async/await syntax and structured to handle events and trace data efficiently.
vm/api/src/params/DebugParams.ts (1)
  • 37-37: The changes in DebugParams.ts are correct, including the removal of CallParameters and its replacement with CallParams, and the addition of readonly to disableStack and transactionHash.
vm/procedures/src/handlers/debug/traceCallHandler.js (1)
  • 13-90: The traceCallHandler function is refactored correctly to use async/await syntax and restructured to handle events and trace data more efficiently.
vm/api/src/TevmJsonRpcRequestHandler.ts (1)
  • 63-65: The addition of TraceCallJsonRpcResponse, TraceContractJsonRpcResponse, and TraceScriptJsonRpcResponse types to TevmJsonRpcRequestHandler.ts is correct, extending the TevmReturnType type with corresponding properties.
vm/api/src/index.ts (6)
  • 2-3: The changes to the exported types in vm/api/src/index.ts are correct, adding new parameters and handlers for tracing scripts, contracts, and calls, as well as additional JSON-RPC requests and responses related to tracing.
  • 111-113: The addition of handler types for tracing (TraceScriptHandler, TraceContractHandler, TraceCallHandler) is correct.
  • 173-174: The addition of result types for tracing (TraceCallResult, TraceScriptResult, TraceContractResult) is correct.
  • 236-240: The addition of JSON-RPC request types for tracing (TraceCallJsonRpcRequest, TraceScriptJsonRpcRequest, TraceContractJsonRpcRequest) is correct.
  • 303-305: The addition of JSON-RPC response types for tracing (TraceScriptJsonRpcResponse, TraceContractJsonRpcResponse, TraceCallJsonRpcResponse) is correct.
  • 366-368: The addition of procedure types for tracing (TraceCallProcedure, TraceScriptProcedure, TraceContractProcedure) is correct.

@roninjin10
Copy link
Collaborator Author

Gonna add trace as a param on regular call contract and script instead

@roninjin10 roninjin10 closed this Feb 12, 2024
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.

1 participant