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(sozo): remove skipped contracts from manifest #2787

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Dec 9, 2024

Description

During the migration, some contracts can be ignored using the following setting in dojo_<PROFILE>.toml:

[migration]
skip_contracts = ["ns-actions"]

However, even if sozo correctly skips the contract during the resource synchronization, the manifest was including them.

This PR ensures they are removed from the generated manifest file.

Related issue

Fixes #2786.

Summary by CodeRabbit

  • New Features

    • Enhanced resource processing by adding logic to skip resources based on their tags.
    • Improved logging and tracing for skipped resources during contract initialization and permission synchronization.
  • Chores

    • Updated Cargo.toml by removing workspace configuration for the license file.
    • Cleaned up dojo_dev.toml by removing a trailing newline.

Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

Ohayo, sensei! This pull request introduces changes primarily to the Manifest struct's new method in the manifest.rs file, adding a conditional check to skip processing certain resources based on their tags. Additionally, the Cargo.toml file for the katana-feeder-gateway package has had a workspace configuration entry removed, and a trailing newline was eliminated from the dojo_dev.toml configuration file. These modifications ensure that only relevant resources are processed while maintaining existing configurations in other files.

Changes

File Path Change Summary
crates/dojo/world/src/diff/manifest.rs Updated Manifest::new method to include logic for skipping resources based on tags.
crates/katana/feeder-gateway/Cargo.toml Removed license-file.workspace = true from the configuration.
examples/spawn-and-move/dojo_dev.toml Removed trailing newline at the end of the configuration file.
crates/sozo/ops/src/migrate/mod.rs Enhanced logging and tracing for skipped resources in migration methods; refined comments for clarity.

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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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

🧹 Outside diff range and nitpick comments (1)
crates/dojo/world/src/diff/manifest.rs (1)

125-128: Consider extracting skip logic to a trait

Ohayo sensei! While the current implementation works well, we could make the skip functionality more reusable by extracting it to a trait. This would allow other parts of the system to utilize the same skip logic without duplicating code.

Example approach:

trait Skippable {
    fn should_skip(&self, config: &ProfileConfig) -> bool;
}

impl Skippable for Resource {
    fn should_skip(&self, config: &ProfileConfig) -> bool {
        config.is_skipped(&self.tag())
    }
}

Would you like me to elaborate on this suggestion or provide a more detailed implementation?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 36dd785 and f8ac8e4.

⛔ Files ignored due to path filters (3)
  • crates/torii/types-test/Scarb.lock is excluded by !**/*.lock
  • examples/simple/Scarb.lock is excluded by !**/*.lock
  • examples/spawn-and-move/Scarb.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • crates/dojo/world/src/diff/manifest.rs (1 hunks)
  • crates/katana/feeder-gateway/Cargo.toml (0 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)
💤 Files with no reviewable changes (1)
  • crates/katana/feeder-gateway/Cargo.toml
✅ Files skipped from review due to trivial changes (1)
  • examples/spawn-and-move/dojo_dev.toml
🔇 Additional comments (1)
crates/dojo/world/src/diff/manifest.rs (1)

125-128: Ohayo! Clean implementation of the skip functionality!

The addition of the skip check effectively addresses the issue of removing skipped contracts from the manifest, exactly as intended in the PR objectives.

Let's verify the is_skipped functionality with this script:

✅ Verification successful

Let's gather more information about the is_skipped implementation to ensure it's properly tested.


Let's check the actual implementation of is_skipped and any related tests.


Ohayo! The skip functionality looks solid, sensei!

The implementation is properly tested and well-integrated:

  • The is_skipped function is correctly implemented in ProfileConfig, checking against the skip_contracts list
  • The functionality is tested in the config tests with example contract "module::my-contract"
  • Multiple examples in the codebase (dojo_saya.toml, dojo_sepolia.toml, dojo_dev.toml) demonstrate proper usage of skip_contracts

The skip check in the manifest is correctly leveraging this tested functionality, making it a reliable implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify is_skipped implementation and test coverage

# Check for tests of is_skipped
rg -A 5 "is_skipped.*test" 

# Look for toml config examples using skip_contracts
rg -A 3 "skip_contracts.*=.*\[.*\]"

# Check for any existing skip-related test files
fd -t f "skip.*test"

Length of output: 828


Script:

#!/bin/bash
# Check the implementation of is_skipped
ast-grep --pattern 'fn is_skipped'

# Look for any unit tests in the profile_config.rs file
rg -A 10 "#\[test\]" crates/dojo/world/src/config/profile_config.rs

# Check for any integration tests that might test this functionality
fd -t f "test.*rs" crates/dojo/world/src | xargs rg -l "is_skipped"

Length of output: 1245


Script:

#!/bin/bash
# Find the implementation of is_skipped using a more specific pattern
ast-grep --pattern 'impl $_$ {
  $$$
  fn is_skipped($_$) $_$ {
    $$$
  }
  $$$
}'

# Look for any tests that might use skip_contracts
rg -A 5 "skip_contracts" crates/dojo/world/src/config/profile_config.rs

# Check for any manifest-related tests that might verify skip functionality
rg -l "manifest.*test" crates/dojo/world/src/diff/

Length of output: 901

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

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

Project coverage is 56.00%. Comparing base (36dd785) to head (f3b76e4).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/sozo/ops/src/migrate/mod.rs 0.00% 3 Missing ⚠️
crates/dojo/world/src/diff/manifest.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2787   +/-   ##
=======================================
  Coverage   56.00%   56.00%           
=======================================
  Files         434      434           
  Lines       55090    55097    +7     
=======================================
+ Hits        30854    30858    +4     
- Misses      24236    24239    +3     

☔ 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 (2)
crates/sozo/ops/src/migrate/mod.rs (2)

416-416: Consider standardizing the trace message format.

Ohayo sensei! While the trace logging is good, the message format differs slightly from the other skip traces:

  • Line 253: "Contract init skipping resource."
  • Line 348: "Sync permissions skipping resource."
  • Line 416: "Sync skipping resource."

Consider standardizing these messages for consistency in logs.

-                trace!(tag = resource.tag(), "Sync skipping resource.");
+                trace!(tag = resource.tag(), "Resource sync skipping resource.");

Line range hint 253-416: Consider enhancing skip tracing with additional context.

The trace logs could be more informative by including additional context about why the resource was skipped (e.g., configuration setting that triggered the skip).

-                trace!(tag = resource.tag(), "Contract init skipping resource.");
+                trace!(
+                    tag = resource.tag(),
+                    reason = "skip_contracts config",
+                    "Contract init skipping resource."
+                );
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f8ac8e4 and f3b76e4.

📒 Files selected for processing (1)
  • crates/sozo/ops/src/migrate/mod.rs (3 hunks)
🔇 Additional comments (2)
crates/sozo/ops/src/migrate/mod.rs (2)

253-253: LGTM! Trace logging added for skipped contract initialization.

The trace log provides clear visibility into which contracts are being skipped during initialization.


348-348: LGTM! Trace logging added for skipped permission syncing.

The trace log effectively tracks resources being skipped during permission synchronization.

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.

[BUG] Manifest contains skipped contracts
1 participant