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): skip legacy class when fetching compiled class hash #2998

Merged
merged 1 commit into from
Feb 9, 2025

Conversation

kariy
Copy link
Member

@kariy kariy commented Feb 7, 2025

legacy class doesn't have a compiled class hash. in the ClassDeclarations table, we don't distinguish between legacy and non-legacy class. right now, we differentiate them based on whether they have a corresponding compiled class hash or not (in the CompiledClassHashes table).

Summary by CodeRabbit

  • Refactor
     - Enhanced internal data processing to better handle scenarios with missing values in state updates, improving overall system stability and reliability without altering visible functionality.

Copy link

coderabbitai bot commented Feb 7, 2025

Ohayo, sensei!

Walkthrough

The change updates the return types for closures in the dup_entries and state_update functions within the DbProvider implementation. They now return ProviderResult<Option> (using Ok(Some(...))) instead of ProviderResult. This modification enables explicit handling of absent values in both entry duplication and state updates, while the overall control flow remains unchanged. No public API declarations were modified.

Changes

File(s) Change Summary
crates/katana/storage/provider/src/…/db/mod.rs Modified closures in dup_entries and state_update functions to return ProviderResult<Option> (using Ok(Some(...))) instead of ProviderResult.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Caller
    participant Provider as DbProvider (dup_entries)
    participant Closure as EntryProcessor

    Client->>Provider: call dup_entries(entries, f)
    Provider->>Closure: Process each entry with closure f
    alt Valid entry present
        Closure-->>Provider: return Ok(Some(result))
    else No valid entry
        Closure-->>Provider: return Ok(None)
    end
    Provider-->>Client: return ProviderResult<Option<result>>
Loading
sequenceDiagram
    participant Client as Caller
    participant Provider as DbProvider (state_update)
    participant Closure as UpdateProcessor

    Client->>Provider: call state_update(state_changes, f)
    Provider->>Closure: Process nonce, class, and storage updates with closure f
    alt Valid update available
        Closure-->>Provider: return Ok(Some(updated_value))
    else No update
        Closure-->>Provider: return Ok(None)
    end
    Provider-->>Client: return ProviderResult<Option<updated_value>>
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 99d2e60 and 2d330a4.

📒 Files selected for processing (1)
  • crates/katana/storage/provider/src/providers/db/mod.rs (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: docs
  • GitHub Check: ensure-wasm
  • GitHub Check: build
🔇 Additional comments (4)
crates/katana/storage/provider/src/providers/db/mod.rs (4)

260-276: Ohayo! The changes to dup_entries look good, sensei!

The modification to handle Option<T> in the closure return type is a good improvement, allowing for explicit handling of absent values while maintaining the function's core functionality.


289-292: The state update closures are properly aligned with the new signature, sensei!

All three closures have been correctly updated to return Ok(Some(...)), maintaining consistency with the dup_entries function's new signature.

Also applies to: 300-302, 330-332


374-378: Nice improvement in handling legacy classes, sensei!

The explicit handling of missing compiled class hashes aligns perfectly with the PR objective. The code now gracefully skips legacy classes instead of failing.


403-403: The deployed_contracts closure is properly updated, sensei!

The change to return Ok(Some(...)) maintains consistency with other closures in the codebase.


🪧 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

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 57.13%. Comparing base (99d2e60) to head (2d330a4).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...es/katana/storage/provider/src/providers/db/mod.rs 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2998      +/-   ##
==========================================
- Coverage   57.14%   57.13%   -0.01%     
==========================================
  Files         429      429              
  Lines       56834    56833       -1     
==========================================
- Hits        32477    32474       -3     
- Misses      24357    24359       +2     

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

@kariy kariy merged commit c3882b9 into main Feb 9, 2025
13 of 15 checks passed
@kariy kariy deleted the katana/fix-state-update branch February 9, 2025 18:26
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