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

Remove call to cartridge_deployController for Controller deployment #2509

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Oct 9, 2024

we no longer need to explicitly call the cartridge_deployController when a Controller account doesn't exist. this is already being handled when the session is being created.

Summary by CodeRabbit

  • New Features

    • Streamlined account creation process by removing the deployment check for controller accounts.
    • Enhanced session management for creating new accounts.
  • Documentation

    • Expanded comments to clarify the behavior of the account creation function regarding supported networks.

Copy link

coderabbitai bot commented Oct 9, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request primarily focus on the create_controller function within the controller.rs file. The deployment check for the controller account has been removed, simplifying the process of creating a session. The function now directly checks for an existing session without any deployment logic. Additionally, the deploy_account_if_not_exist function has been removed, and documentation comments have been enhanced for clarity. Imports have also been adjusted to align with the new functionality.

Changes

File Path Change Summary
bin/sozo/src/commands/options/account/controller.rs - Removed function: deploy_account_if_not_exist
- Updated logic in create_controller to remove deployment check and focus on session management.
- Expanded documentation comments.
- Adjusted imports.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant Session

    User->>Controller: Request to create controller
    Controller->>Session: Check for existing session
    alt Session exists
        Controller->>User: Return existing session
    else No session
        Controller->>Session: Create new session
        Controller->>User: Return new session
    end
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>, 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 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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e591364 and 19914e3.

📒 Files selected for processing (1)
  • bin/sozo/src/commands/options/account/controller.rs (3 hunks)
🧰 Additional context used
🔇 Additional comments (4)
bin/sozo/src/commands/options/account/controller.rs (4)

3-3: Appropriate import of Context and Result from anyhow

Ohayo sensei! The addition of anyhow::{Context, Result} enhances error handling and is correctly included.


14-14: Importing Felt from starknet::core::types is necessary

Ohayo sensei! The import of Felt is essential for operations involving field elements and is appropriately added.


21-21: Adding tracing::trace for logging purposes

Ohayo sensei! The inclusion of use tracing::trace; is appropriate for detailed logging throughout the codebase.


36-45: Removal of deployment logic aligns with PR objectives

Ohayo sensei! The removal of the deployment check within the create_controller function simplifies account creation, as the session creation now handles account deployment. This change aligns perfectly with the PR objectives.

@@ -37,6 +33,16 @@ use super::WorldAddressOrName;
pub type ControllerSessionAccount<P> = SessionAccount<Arc<P>>;

/// Create a new Catridge Controller account based on session key.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the typo in the function description

Ohayo sensei! There's a minor typo in the documentation. The word "Catridge" should be corrected to "Cartridge" to accurately reflect the system's name.

Comment on lines +37 to +39
/// Controller guarantees that if the provided network is among one of the supported networks,
/// then the Controller account should exist. If it doesn't yet exist, it will automatically
/// be created when a session is created (ie during the session registration stage).
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Clarify the documentation in create_controller function

Ohayo sensei! To enhance readability, consider rephrasing the documentation for clarity.

Suggested rewording:

"The Controller guarantees that if the provided network is among the supported networks, the Controller account will exist. If it doesn't yet exist, it will be automatically created during the session registration stage."

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.81%. Comparing base (e591364) to head (19914e3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2509      +/-   ##
==========================================
+ Coverage   67.73%   67.81%   +0.08%     
==========================================
  Files         388      388              
  Lines       50421    50367      -54     
==========================================
+ Hits        34153    34157       +4     
+ Misses      16268    16210      -58     

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

@tarrencev tarrencev merged commit 3f82a31 into main Oct 9, 2024
15 checks passed
@tarrencev tarrencev deleted the sozo/controller branch October 9, 2024 16:06
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.

3 participants