Skip to content

opt(torii-runner): verify contracts deployment in parallel - #3140

Merged
glihm merged 7 commits into
dojoengine:mainfrom
Larkooo:check-contract-deployments-concurrent
Apr 2, 2025
Merged

opt(torii-runner): verify contracts deployment in parallel#3140
glihm merged 7 commits into
dojoengine:mainfrom
Larkooo:check-contract-deployments-concurrent

Conversation

@Larkooo

@Larkooo Larkooo commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Introduced a consolidated set of command-line options, enabling users to control the browser launch for the explorer functionality and to specify whether contract deployments should be verified before running the application.
  • Refactor

    • Enhanced the contract verification process to run concurrently, improving efficiency during application startup.

@coderabbitai

coderabbitai Bot commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

Ohayo, sensei!

Walkthrough

This PR updates the command-line interface and runner behavior. In the CLI module, the explorer field is removed from the ToriiArgs struct and replaced by a new runner field of type RunnerOptions. A new RunnerOptions struct is introduced with explorer and check_contracts boolean flags. The runner logic is updated to check the check_contracts flag and use asynchronous processing for contract verification, along with using the updated explorer flag. Test cases have been adjusted to align with these changes.

Changes

File(s) Change Summary
crates/torii/cli/src/args.rs, crates/torii/cli/src/options.rs CLI Argument Updates: Removed explorer from ToriiArgs, added runner field, and introduced new RunnerOptions struct with explorer and check_contracts flags.
crates/torii/runner/src/lib.rs Runner Logic Enhancements: Introduced conditional check for runner.check_contracts, refactored verify_contracts_deployed to use async concurrency, and updated flag usage.

Sequence Diagram(s)

sequenceDiagram
    participant Runner
    participant RunnerOptions
    participant ContractVerifier

    Runner->>RunnerOptions: Retrieve check_contracts flag
    alt check_contracts enabled
        Runner->>ContractVerifier: Initiate async contract verification
        ContractVerifier-->>Runner: Return verification results
    else
        Runner->>Runner: Skip verification
    end
    Runner->>RunnerOptions: Retrieve explorer flag for UI handling
Loading

Possibly related PRs

Suggested reviewers

  • glihm (sensei)

📜 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 9755a77 and dab19d4.

⛔ Files ignored due to path filters (1)
  • crates/dojo/lang/Scarb.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • crates/torii/cli/src/args.rs (3 hunks)
  • crates/torii/cli/src/options.rs (1 hunks)
  • crates/torii/runner/src/lib.rs (4 hunks)
🔇 Additional comments (8)
crates/torii/cli/src/options.rs (1)

375-394: Ohayo! Clean implementation of RunnerOptions struct!

Nice work adding this well-structured RunnerOptions struct with clear documentation for both fields. The implementation follows the established pattern of other option structs in the file, making it consistent and easy to understand.

crates/torii/cli/src/args.rs (3)

43-45: Good refactoring of explorer option, sensei!

The flattened RunnerOptions struct is a nice improvement over the direct explorer field. This approach groups related runner options together, making the codebase more organized and extensible.


82-82: Well-updated default implementation!

The default constructor properly initializes the new runner field with RunnerOptions::default().


215-215: Test case correctly updated!

The test assertion has been properly updated to verify the default runner options.

crates/torii/runner/src/lib.rs (4)

23-23: Ohayo! Appropriate import for parallel execution!

The import of join_all from futures is necessary for the parallel contract verification implementation.


102-111: Nice conditional contract verification, sensei!

Good implementation of the optional contract verification feature. This makes contract verification configurable through the check_contracts flag while maintaining the same error handling for undeployed contracts.


294-294: Correctly updated explorer reference!

The reference to the explorer flag has been properly updated to use the new structure.


361-382: Excellent parallel contract verification implementation!

The refactoring of verify_contracts_deployed to use futures and join_all for parallel execution is well-implemented. This change should improve performance when verifying multiple contracts by checking them concurrently instead of sequentially.

Key improvements:

  • Each contract verification is mapped to a future
  • All futures execute concurrently with join_all
  • Results are filtered efficiently to collect undeployed contracts
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@codecov

codecov Bot commented Apr 2, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 20.00000% with 28 lines in your changes missing coverage. Please review.

Project coverage is 55.66%. Comparing base (9755a77) to head (b0bfcee).

Files with missing lines Patch % Lines
crates/torii/runner/src/lib.rs 0.00% 26 Missing ⚠️
crates/torii/cli/src/options.rs 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3140      +/-   ##
==========================================
- Coverage   55.66%   55.66%   -0.01%     
==========================================
  Files         443      443              
  Lines       62838    62859      +21     
==========================================
+ Hits        34980    34989       +9     
- Misses      27858    27870      +12     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants