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

fix(katana-rpc-types): proofs types serde #2872

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Conversation

kariy
Copy link
Member

@kariy kariy commented Jan 6, 2025

it should be an array instead of object https://github.com/starkware-libs/starknet-specs/blob/c94df2c5866e11c866abd3d234b0d5df681073c3/api/starknet_api_openrpc.json#L975-L1010

Summary by CodeRabbit

  • Refactor
    • Enhanced serialization and deserialization of proof-related structs by adding #[serde(transparent)] attribute
    • Simplified JSON representation for ClassesProof, ContractStorageProofs, and Nodes structs

Copy link

coderabbitai bot commented Jan 6, 2025

Walkthrough

Ohayo, sensei! The changes involve adding the #[serde(transparent)] attribute to three structs in the Katana RPC types module. This attribute modifies how these structs are serialized and deserialized, essentially allowing them to be represented directly by their inner fields during JSON or other format conversions. The modifications affect ClassesProof, ContractStorageProofs, and Nodes, making their serialization more streamlined and direct.

Changes

File Change Summary
crates/katana/rpc/rpc-types/src/trie.rs - Added #[serde(transparent)] to ClassesProof struct
- Added #[serde(transparent)] to ContractStorageProofs struct
- Added #[serde(transparent)] to Nodes struct

The changes are purely related to serialization behavior and do not modify the underlying data structures or their functionality. The transparent attribute ensures that these structs will serialize and deserialize as if they were their contained fields, providing a more direct representation in data exchange formats.


🪧 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. (Beta)
  • @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.

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.

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)
crates/katana/rpc/rpc-types/src/trie.rs (1)

Line range hint 80-117: Ohayo! Excellent architectural approach to proof type serialization, sensei!

The consistent use of #[serde(transparent)] across all proof wrapper types creates a clean and unified serialization strategy. This approach:

  1. Reduces JSON nesting depth
  2. Maintains type safety through Rust's type system
  3. Improves the developer experience when working with serialized proofs

The changes align perfectly with the PR's objective of enhancing proof types serialization.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6d82d9 and ee26a74.

📒 Files selected for processing (1)
  • crates/katana/rpc/rpc-types/src/trie.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: docs
  • GitHub Check: ensure-wasm
  • GitHub Check: clippy
  • GitHub Check: build
🔇 Additional comments (3)
crates/katana/rpc/rpc-types/src/trie.rs (3)

80-83: Ohayo! Nice use of serde transparent attribute, sensei!

The #[serde(transparent)] attribute is perfectly applied here, as it will serialize ClassesProof directly as its inner nodes field, reducing unnecessary JSON nesting.


105-109: Excellent serialization optimization, sensei!

The #[serde(transparent)] attribute will make ContractStorageProofs serialize directly as its inner Vec<Nodes>, which simplifies the JSON structure.


Line range hint 116-117: Perfect alignment with newtype pattern, sensei!

The #[serde(transparent)] attribute complements the existing Deref/DerefMut implementations, ensuring Nodes behaves consistently as its inner Vec<NodeWithHash> for both runtime operations and serialization.

@glihm glihm enabled auto-merge (squash) January 6, 2025 22:06
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.76%. Comparing base (e6d82d9) to head (ee26a74).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2872      +/-   ##
==========================================
- Coverage   55.77%   55.76%   -0.01%     
==========================================
  Files         447      447              
  Lines       57794    57794              
==========================================
- Hits        32234    32230       -4     
- Misses      25560    25564       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants