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

TODO: add ref wrapper #717

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

TODO: add ref wrapper #717

wants to merge 6 commits into from

Conversation

Nanle100
Copy link

@Nanle100 Nanle100 commented Mar 10, 2025

Usage related changes

Development related changes

Checklist:

  • Checked out the contribution guidelines
  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/clippy_check.sh
  • No unused dependencies - ./scripts/check_unused_deps.sh
  • No spelling errors - ./scripts/check_spelling.sh
  • Performed code self-review
  • Rebased to the latest commit of the target branch (or merged it into my branch)
    • Once you make the PR reviewable, please avoid force-pushing
  • Updated the docs if needed - ./website/README.md
  • Linked the issues resolvable by this PR - linking info
  • Updated the tests if needed; all passing - execution info

Summary by CodeRabbit

  • New Features
    • Enhanced the fee estimation process with a new method for functional handling of addresses.
    • Improved the conversion process for deprecated contract classes, clarifying the logic.
    • Added new enum variants to enhance the serialization and deserialization of contract classes.
  • Documentation
    • Improved inline documentation readability for a clearer presentation.

Copy link

coderabbitai bot commented Mar 10, 2025

Walkthrough

The changes introduce a new method with_from_address to the EstimateMessageFeeRequestWrapper struct, allowing a closure to operate on a newly created EthAddressWrapper instance. A blank line was added to the documentation comment preceding the configure_tracing function in the main file for improved readability. The existing functionality of methods like get_from_address and deserialization remains unchanged. Additionally, the try_into implementation for DeprecatedContractClass has been modified to clarify the conversion process to CompressedLegacyContractClass. New enum variants and a helper enum for serialization/deserialization have also been introduced.

Changes

File(s) Change Summary
crates/.../starknet-devnet-types/src/rpc/estimate_message_fee.rs Added new method with_from_address to EstimateMessageFeeRequestWrapper that accepts a closure acting on a newly created EthAddressWrapper; removed outdated comment.
crates/.../starknet-devnet/src/main.rs Inserted a blank line in the documentation comment before configure_tracing to improve readability.
crates/.../starknet-devnet-types/src/rpc/contract_class.rs Removed a blank line in the convert_codegen_to_blockifier_compiled_class function; no change to functionality.
crates/.../starknet-devnet-types/src/rpc/contract_class/deprecated/rpc_contract_class.rs Updated try_into implementation for DeprecatedContractClass to clarify conversion to CompressedLegacyContractClass using a two-step process.
crates/.../starknet-devnet-types/src/rpc/contract_class/deprecated/mod.rs Added new enum variants RawJson(Cairo0Json) and Rpc(DeprecatedContractClass) to Cairo0ContractClass; introduced Cairo0ContractClassSerdeHelper for serialization.

Suggested reviewers

  • marioiordanov

Poem

I'm a rabbit with a joyful spin,
Hopping through code where new methods begin.
With closures dancing on a byte-lined street,
And comments now spaced so neat.
Hopping high with each change I greet!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39bec1f and 58030a5.

📒 Files selected for processing (1)
  • crates/starknet-devnet-types/src/rpc/contract_class/deprecated/mod.rs (6 hunks)
🔇 Additional comments (8)
crates/starknet-devnet-types/src/rpc/contract_class/deprecated/mod.rs (8)

15-17: New enum variants added to support multiple contract class representations.

The addition of RawJson and Rpc variants to the Cairo0ContractClass enum provides a more explicit type-safe way to handle different representations of Cairo 0 contracts. This change improves type safety and clarity in the codebase.


19-24: Good use of a helper enum for serialization/deserialization.

The introduction of Cairo0ContractClassSerdeHelper with a tagged enum representation is a good approach for serializing/deserializing the polymorphic Cairo0ContractClass type. The #[serde(tag = "type", content = "contract_class")] attribute ensures a clean JSON representation.


31-36: Properly implemented serialization using the helper enum.

The serialization implementation correctly matches on the Cairo0ContractClass variants and delegates to the corresponding helper enum variant. This pattern ensures consistent serialization across different contract class representations.


44-49: Well-implemented deserialization using the helper enum.

The deserialization implementation first deserializes into the helper enum and then constructs the appropriate Cairo0ContractClass variant. This approach maintains consistency with the serialization implementation and handles all variants correctly.


52-62: Appropriate implementations for the From trait.

The From trait implementations for both Cairo0Json and DeprecatedContractClass correctly map to the corresponding enum variants, making conversion between types ergonomic.


66-73: Hash generation implementation handles all variants.

The generate_hash method correctly matches on all variants of Cairo0ContractClass and delegates to the appropriate implementation. The added blank line before the implementation improves readability.


77-84: Conversion to CompressedLegacyContractClass covers all variants.

The try_into implementation correctly handles conversion from both RawJson and Rpc variants to CompressedLegacyContractClass, ensuring all contract class representations can be converted when needed.


88-95: Conversion to ContractClassV0 properly implemented for all variants.

The TryFrom implementation for converting to blockifier's ContractClassV0 correctly matches on all variants and delegates to the appropriate conversion logic.

✨ Finishing Touches
  • 📝 Generate Docstrings

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

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/starknet-devnet-types/src/rpc/estimate_message_fee.rs (1)

48-48: Consider performance impact of cloning.

While appropriate in this context, be aware that this clone operation happens on every method call. If this method is called frequently in performance-critical paths, it might be worth considering optimizations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb779e6 and f536056.

📒 Files selected for processing (2)
  • crates/starknet-devnet-types/src/rpc/estimate_message_fee.rs (2 hunks)
  • crates/starknet-devnet/src/main.rs (1 hunks)
🔇 Additional comments (3)
crates/starknet-devnet/src/main.rs (1)

59-59: Minor formatting improvement.

Adding a blank line here enhances documentation readability, which is a good practice.

crates/starknet-devnet-types/src/rpc/estimate_message_fee.rs (2)

41-50: Good use of the closure pattern for safe object access.

This is an excellent approach to providing safe access to dynamically created objects without returning references. The pattern allows consumers to work with the EthAddressWrapper by reference within a controlled scope, avoiding potential ownership and lifetime issues.

The implementation correctly clones the inner value to create a temporary wrapper that lives for the duration of the closure execution.


93-93:

❓ Verification inconclusive

Confirm that the implementation macros work as expected.

The impl_wrapper_deserialize! macro is unchanged, but it's important to verify that it handles the new with_from_address method correctly, especially if the macro generates code that interacts with the struct's fields or methods.


🏁 Script executed:

#!/bin/bash
# Check where the macro is defined and how it's implemented
fd -t f "impl_wrapper_deserialize" --exec grep -A 10 "macro_rules! impl_wrapper_deserialize" {}

Length of output: 97


Manual Verification Needed: Confirm Macro Behavior for with_from_address

The search script did not locate the definition for impl_wrapper_deserialize!. Please manually verify that the macro’s implementation (whether defined locally or imported from an external module) correctly supports the new with_from_address method. In particular, check that the generated code properly handles field interactions and any logic related to with_from_address.

  • Verify the macro’s definition in the relevant module or crate.
  • Confirm that its generated code correctly adapts to the new method in use at crates/starknet-devnet-types/src/rpc/estimate_message_fee.rs (line 93).

@Nanle100
Copy link
Author

Please make it clear, which part should i adjust

…ement tagged serde for Cairo0ContractClass

- Added helper enum for serde with  and  fields.
- Enables proper variant tagging during serialization/deserialization.
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