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

feat(dojo-lang): add systems to contract's manifest and fix DojoAuxData gathering #2309

Merged
merged 4 commits into from
Aug 16, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Aug 16, 2024

All dojo contracts are starknet contract under the hood. However, the way we were gathering the data was always falling back into StarkNetAuxData instead of actually using the DojoAuxData.

This was due to the fact that a dojo contract module_id was actually the parent module, and not the contract's module itself, hence never found in the artifacts paths.

This PR also adds a new entry in the manifest for dojo contract with the list of systems, which are all the functions that are not returning any data.

Summary by CodeRabbit

  • New Features

    • Introduced new systems fields in various contract configurations to enhance functionality and organization.
    • Updated DojoContract structure to include a list of systems, improving its capability to manage system-related information.
    • Enhanced artifact management processes for better clarity and accuracy.
  • Bug Fixes

    • Streamlined handling of contract deployments and artifact management for improved correctness.
  • Documentation

    • Improved data model clarity related to contracts within the Dojo plugin.
  • Chores

    • Removed unused imports and simplified code across multiple files for better maintainability.

Copy link

coderabbitai bot commented Aug 16, 2024

Walkthrough

Ohayo, sensei! The recent changes enhance contract management in the Dojo framework by introducing a systems field, allowing contracts to maintain a list of system names. There’s a reorganization of auxiliary data handling, improving clarity and efficiency by removing unused imports and streamlining complex logic. These updates foster better maintenance and understanding of the codebase while refining the interactions between contracts and modules.

Changes

Files Change Summary
crates/dojo-lang/src/compiler.rs, crates/dojo-lang/src/contract.rs, crates/dojo-lang/src/plugin.rs Added a systems field to contracts, refined logic for artifact handling, and reorganized auxiliary data structures for clarity.
crates/dojo-lang/src/inline_macros/*.rs Cleaned up inline macros by simplifying context handling and removing unnecessary tuple structures.
crates/dojo-lang/src/utils.rs, crates/dojo-lang/src/semantics/utils.rs Removed unused imports, static variables, and functions related to module and function read/write operations.
examples/spawn-and-move/manifests/*.toml, examples/spawn-and-move/manifests/dev/deployment/*.json Enhanced example manifests by adding systems fields to improve contract functionalities and clarify associated actions.
crates/dojo-world/src/manifest/types.rs, crates/dojo-world/src/migration/mod.rs Updated contract definitions to include systems, adjusting method return types to convey additional information.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Contract
    participant System

    User->>Contract: Deploy contract
    Contract->>System: Register systems
    System->>Contract: Acknowledge registration
    Contract->>User: Provide contract details
Loading
sequenceDiagram
    participant User
    participant Contract
    participant Plugin

    User->>Contract: Call function
    Contract->>Plugin: Process request
    Plugin->>Contract: Return results
    Contract->>User: Send response
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Outside diff range, codebase verification and nitpick comments (3)
crates/dojo-lang/src/plugin.rs (2)

101-101: Review added logging for debugging.

A logging statement has been added to print module_ast. Confirm that this addition aids debugging without exposing sensitive information.


68-69: Ohayo, sensei! It looks like the transition from systems to contracts in the DojoAuxData struct isn't fully consistent across the codebase. Here are some points to consider:

  • systems Field: This field is still present and used in plugin.rs, contract.rs, and compiler.rs.
  • contracts Field: This field is correctly used in several places, but the presence of systems suggests incomplete transition.

Please review these areas to ensure that the DojoAuxData struct consistently uses contracts where intended.

Analysis chain

Check reorganization in DojoAuxData.

The DojoAuxData struct now holds contracts instead of systems. Ensure this change is consistent across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `DojoAuxData` to ensure the new `contracts` field is correctly utilized.

# Test: Search for the struct usage. Expect: Correct handling of the new field.
rg --type rust 'DojoAuxData' crates/dojo-lang/src/

Length of output: 1039


Script:

#!/bin/bash
# Description: Verify the usage of the `contracts` field in `DojoAuxData` and check for any remaining `systems` references.

# Test: Search for the usage of `contracts` in DojoAuxData.
rg --type rust 'contracts' crates/dojo-lang/src/

# Test: Search for any remaining references to `systems` in DojoAuxData.
rg --type rust 'systems' crates/dojo-lang/src/

Length of output: 6196

crates/dojo-lang/src/compiler.rs (1)

136-136: Remove debug print statements before merging.

The println! statement is likely used for debugging and should be removed for cleaner production code.

- println!("Decl qualified path: {:?}", qualified_path);

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 89.79592% with 5 lines in your changes missing coverage. Please review.

Project coverage is 67.04%. Comparing base (454f2b2) to head (2ac0897).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/dojo-lang/src/contract.rs 87.50% 2 Missing ⚠️
crates/dojo-lang/src/inline_macros/delete.rs 50.00% 2 Missing ⚠️
crates/sozo/ops/src/migration/migrate.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2309      +/-   ##
==========================================
- Coverage   69.59%   67.04%   -2.55%     
==========================================
  Files         352      352              
  Lines       46032    45819     -213     
==========================================
- Hits        32034    30718    -1316     
- Misses      13998    15101    +1103     

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

@glihm
Copy link
Collaborator Author

glihm commented Aug 16, 2024

Coverage is affected by this PR due to the fact that we don't build the 3 tests in debug mode, which is almost doubling the test time.

We anyway build those projects in the CI, but not directly from the code, so codecov can't see this coverage.

@glihm glihm changed the title feat: add systems to contract's manifest and fix DojoAuxData gathering feat(dojo-lang): add systems to contract's manifest and fix DojoAuxData gathering Aug 16, 2024
@glihm glihm merged commit c1ebf1b into dojoengine:main Aug 16, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant