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

refactor(dojo): change usage of trace! to avoid path prefix #2830

Merged
merged 1 commit into from
Dec 21, 2024

Conversation

847850277
Copy link
Contributor

@847850277 847850277 commented Dec 20, 2024

Description

@glihm PTAL.

Related issue

close #2829

Tests

  • Yes
  • No, because they aren't needed
  • No, because I need help

Added to documentation?

  • README.md
  • Dojo Book
  • No documentation needed

Checklist

  • I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • I've commented my code
  • I've requested a review after addressing the comments

Summary by CodeRabbit

  • Bug Fixes

    • Simplified logging mechanism across multiple functions by replacing tracing::trace! with trace!, enhancing readability without altering functionality.
  • New Features

    • Enhanced logging capabilities in the new_from_chain function for better tracking of world deployment status.

Copy link

coderabbitai bot commented Dec 20, 2024

Walkthrough

Ohayo, sensei! This PR focuses on optimizing trace logging across multiple Dojo crates by replacing tracing::trace! with the simpler trace! macro. The changes are consistent across files like declarer.rs, deployer.rs, mod.rs, and events_to_remote.rs, streamlining the logging approach without altering the underlying functionality or error handling of the code.

Changes

File Change Summary
crates/dojo/utils/src/tx/declarer.rs Replaced tracing::trace! with trace! in logging calls within the declare method
crates/dojo/utils/src/tx/deployer.rs Simplified logging in is_deployed function by using trace! instead of tracing::trace!
crates/dojo/world/src/diff/mod.rs Added tracing::trace import and replaced tracing::trace! with trace! in new_from_chain function
crates/dojo/world/src/remote/events_to_remote.rs Replaced multiple tracing::trace! calls with trace! in the from_events method

Assessment against linked issues

Objective Addressed Explanation
Optimize trace! logging formats [#2829]

Possibly related PRs

Suggested reviewers

  • kariy
  • glihm

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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

@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/dojo/world/src/diff/mod.rs (1)

Line range hint 175-179: Ohayo sensei! Consider enhancing the deployment check logging.

While the current logging is good, this is a critical deployment check. Consider adding the class hash to provide more context for debugging deployment issues.

 trace!(
     contract_address = format!("{:#066x}", world_address),
+    class_hash = format!("{:#066x}", provider.get_class_hash_at(BlockId::Tag(BlockTag::Pending), world_address).unwrap()),
     "World already deployed."
 );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c0b8033 and afb901b.

📒 Files selected for processing (4)
  • crates/dojo/utils/src/tx/declarer.rs (4 hunks)
  • crates/dojo/utils/src/tx/deployer.rs (1 hunks)
  • crates/dojo/world/src/diff/mod.rs (2 hunks)
  • crates/dojo/world/src/remote/events_to_remote.rs (3 hunks)
✅ Files skipped from review due to trivial changes (2)
  • crates/dojo/utils/src/tx/deployer.rs
  • crates/dojo/world/src/remote/events_to_remote.rs
🔇 Additional comments (4)
crates/dojo/utils/src/tx/declarer.rs (3)

17-17: LGTM! Clean trace logging implementation.

The trace logging provides good visibility with proper hex formatting for the class hash.

Also applies to: 96-101


Line range hint 108-114: LGTM! Comprehensive pre-declaration logging.

The trace provides all necessary context including class hash and casm class hash.


Line range hint 131-137: LGTM! Well-structured post-declaration logging.

The trace provides comprehensive information about the successful declaration, including the transaction hash.

crates/dojo/world/src/diff/mod.rs (1)

15-15: LGTM! Clean import.

The trace import is properly placed with other imports.

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 55.92%. Comparing base (c0b8033) to head (afb901b).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/dojo/utils/src/tx/declarer.rs 66.66% 1 Missing ⚠️
crates/dojo/utils/src/tx/deployer.rs 0.00% 1 Missing ⚠️
crates/dojo/world/src/remote/events_to_remote.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2830   +/-   ##
=======================================
  Coverage   55.92%   55.92%           
=======================================
  Files         439      439           
  Lines       56156    56156           
=======================================
  Hits        31408    31408           
  Misses      24748    24748           

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

@glihm glihm changed the title feat: Optimize trace! refactor(dojo): change usage of trace! to avoid path prefix Dec 21, 2024
Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @847850277 for adding consistency. 👍

@glihm glihm merged commit 12c96ae into dojoengine:main Dec 21, 2024
14 checks passed
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.

Optimize trace!
2 participants