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

hotfix(katana): include missing udc class if custom genesis is specified #2575

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Oct 24, 2024

Summary by CodeRabbit

  • New Features

    • Improved handling of Universal Deployer Contracts (UDC) with centralized management logic.
    • Simplified GenesisJson structure by removing unused fields.
  • Bug Fixes

    • Enhanced error handling for class path resolution and duplicate class names during conversion processes.
  • Tests

    • Updated test cases to validate new UDC handling logic and ensure correct deployment of classes and contracts.

Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

Ohayo, sensei! This pull request introduces significant modifications to the chain_spec.rs and genesis/json.rs files within the Katana project. Key changes include the addition of constants and a new helper function for managing Universal Deployer Contracts (UDC) in chain_spec.rs, enhancing the organization of UDC handling. In genesis/json.rs, two fields related to fee tokens have been removed from the GenesisJson struct, streamlining its structure while maintaining the integrity of the conversion logic. Test cases have also been updated to validate the new UDC handling.

Changes

File Path Change Summary
crates/katana/primitives/src/chain_spec.rs - Added function add_default_udc(states: &mut StateUpdatesWithDeclaredClasses)
- Added constants DEFAULT_LEGACY_UDC_CASM and DEFAULT_LEGACY_UDC_COMPILED_CLASS_HASH
- Modified state_updates method to use add_default_udc for UDC management.
crates/katana/primitives/src/genesis/json.rs - Removed fields fee_token and universal_deployer from GenesisJson struct.
- Retained #[serde(default)] for accounts and contracts fields.

Possibly related PRs


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

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.59%. Comparing base (4930450) to head (901aaaf).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2575   +/-   ##
=======================================
  Coverage   69.58%   69.59%           
=======================================
  Files         401      401           
  Lines       50745    50760   +15     
=======================================
+ Hits        35312    35327   +15     
  Misses      15433    15433           

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

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

🧹 Outside diff range and nitpick comments (1)
crates/katana/primitives/src/chain_spec.rs (1)

219-237: Ohayo, sensei! Consider adding error handling for entry operations.

The new helper function looks good, but we should consider handling potential errors from the entry operations, even though they're unlikely to fail in this context.

Consider adding error handling:

 fn add_default_udc(states: &mut StateUpdatesWithDeclaredClasses) {
     // declare UDC class
-    states
+    if let Err(e) = states
         .declared_compiled_classes
         .entry(DEFAULT_LEGACY_UDC_CLASS_HASH)
-        .or_insert_with(|| DEFAULT_LEGACY_UDC_CASM.clone());
+        .or_insert_with(|| DEFAULT_LEGACY_UDC_CASM.clone()) {
+        log::warn!("Failed to insert UDC compiled class: {}", e);
+    }

Also, let's add a docstring to explain the function's purpose:

+/// Adds the default Universal Deployer Contract (UDC) to the state updates.
+/// This includes declaring the UDC class and deploying the UDC contract if not already present.
 fn add_default_udc(states: &mut StateUpdatesWithDeclaredClasses) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c2adb54 and 901aaaf.

📒 Files selected for processing (1)
  • crates/katana/primitives/src/chain_spec.rs (3 hunks)
🔇 Additional comments (3)
crates/katana/primitives/src/chain_spec.rs (3)

16-17: LGTM! Constants are well-organized.

The new UDC-related constants are properly integrated with existing constants, maintaining code organization.


134-134: LGTM! Clean refactoring of UDC initialization.

The UDC initialization has been cleanly extracted into a dedicated helper function, improving code organization.


219-237: Verify UDC initialization in tests.

The function's behavior should be verified when the UDC is already present in the state.

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