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

chore(sozo): update slot due to breaking changes #2530

Merged
merged 3 commits into from
Oct 13, 2024
Merged

chore(sozo): update slot due to breaking changes #2530

merged 3 commits into from
Oct 13, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Oct 13, 2024

ref cartridge-gg/slot#104, cartridge-gg/slot#113

for this fix to work, you need to update slot to 0.19.0 and reauthenticate.

Summary by CodeRabbit

  • New Features

    • Updated dependency for slot to enhance functionality.
    • Streamlined user account handling by consolidating credential access and contract address retrieval.
  • Bug Fixes

    • Improved error handling and logging in the account controller.
  • Documentation

    • Enhanced clarity of documentation comments related to account controller logic.
  • Tests

    • Updated test cases to align with the new user account structure.

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 69.35%. Comparing base (77042b1) to head (181fc46).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/controller/src/lib.rs 80.00% 5 Missing ⚠️
...in/sozo/src/commands/options/account/controller.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2530      +/-   ##
==========================================
+ Coverage   69.32%   69.35%   +0.03%     
==========================================
  Files         388      388              
  Lines       49988    49999      +11     
==========================================
+ Hits        34654    34677      +23     
+ Misses      15334    15322      -12     

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

@kariy kariy marked this pull request as ready for review October 13, 2024 18:28
Copy link

coderabbitai bot commented Oct 13, 2024

Walkthrough

Ohayo, sensei! This pull request introduces several modifications primarily to the Cargo.toml file for dependency management, specifically updating the slot dependency to a new commit reference. Additionally, enhancements have been made to logging and error handling in the controller.rs file, alongside structural updates in the lib.rs file to accommodate changes in user account handling. The overall functionality remains intact, with no significant alterations to exported or public entities beyond the updates mentioned.

Changes

File Change Summary
Cargo.toml Updated slot dependency from commit 942be15 to 1298a30.
bin/sozo/src/commands/options/account/controller.rs Enhanced logging and error handling in create_controller. Updated bail import and logging statements.
crates/katana/controller/src/lib.rs Updated add_controller_account_inner and add_controller_account_json functions to use AccountInfo instead of Account. Adjusted test cases accordingly.

Possibly related PRs

Suggested labels

sozo

Suggested reviewers

  • steebchen

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b8260fc and 181fc46.

📒 Files selected for processing (1)
  • bin/sozo/src/commands/options/account/controller.rs (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/sozo/src/commands/options/account/controller.rs

🪧 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: 0

🧹 Outside diff range and nitpick comments (3)
bin/sozo/src/commands/options/account/controller.rs (3)

64-72: Ohayo, sensei! Excellent logging and error handling improvements!

The added trace logging for loading Slot credentials enhances the function's traceability. The updated contract address handling using pattern matching is more idiomatic Rust and provides a clearer error message when no controller is associated with the account.

Consider adding a log message just before the bail! call to provide more context in the logs:

trace!(target: "account::controller", "No Controller found for account.");
bail!("No Controller is associated with this account.");

220-221: Ohayo, sensei! Fantastic policy logging enhancement!

The addition of detailed trace logging for each policy in the policies_from_abis function is excellent. It provides comprehensive information about each policy, including the contract tag, target address (in hex format), and method name. This level of detail will be invaluable for debugging and auditing policy creation.

Consider using the %x format specifier for the target address to ensure consistent hex formatting:

trace!(target: "account::controller", tag = contract_tag, target = %format!("0x{:x}", policy.target), method = %policy.method, "Adding policy");

193-200: Ohayo, sensei! Great special policy logging!

The addition of trace logging for the declare transaction and UDC deployment policies is a valuable improvement. These logs provide clear visibility into the addition of these special policies, which is crucial for understanding the full scope of policies being applied.

To maintain consistency with the detailed logging in policies_from_abis, consider adding more details to these log messages:

trace!(target: "account::controller", target = %format!("0x{:x}", user_address), method = "__declare_transaction__", "Adding declare transaction policy");
trace!(target: "account::controller", target = %format!("0x{:x}", UDC_ADDRESS), method = "deployContract", "Adding UDC deployment policy");
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 77042b1 and b8260fc.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • bin/sozo/src/commands/options/account/controller.rs (7 hunks)
  • crates/katana/controller/src/lib.rs (7 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Cargo.toml
🧰 Additional context used
🔇 Additional comments (11)
crates/katana/controller/src/lib.rs (5)

30-35: Ohayo, sensei! LGTM on the account structure update.

The change from Account to AccountInfo and the updated retrieval logic for credentials and contract address align well with the new user account structure. This modification streamlines the handling of user data and should improve code clarity.


39-39: Ohayo again, sensei! Nice catch on updating the logging.

The adjustment to log the correct contract address is a good attention to detail. It ensures consistency with the earlier changes and maintains accurate logging.


54-54: Konnichiwa, sensei! Solid update on contract address handling.

The change to use the existing contract_address instead of generating a new one is crucial. It ensures that we're working with the correct, pre-existing contract address associated with the account. This modification maintains consistency between the AccountInfo and the genesis allocation.


88-89: Ohayo once more, sensei! Consistency is key, and you've nailed it.

The updates to credential and contract address retrieval in add_controller_account_json mirror the changes in add_controller_account_inner. This consistency ensures that both functions work harmoniously with the new AccountInfo structure. Well done on maintaining uniformity across related functions!


225-239: Sugoi, sensei! Excellent work on updating the test case.

The modifications to the test case for add_controller_account are spot-on. By updating the test data structure to use AccountInfo and including all necessary fields, you've ensured that the test accurately reflects the changes in the main code. This comprehensive update will help maintain the reliability of our testing suite. Great job on keeping the tests in sync with the code changes!

Also applies to: 244-244

bin/sozo/src/commands/options/account/controller.rs (6)

3-3: Ohayo, sensei! Nice import update!

The addition of bail from anyhow suggests an improvement in error handling. This change is likely to enhance the code's ability to handle and report errors more effectively.


37-39: Ohayo, sensei! Documentation clarity level up!

The rephrasing of the documentation comment enhances clarity without changing the underlying meaning. It now better explains the behavior of the Controller account creation process.


Line range hint 79-93: Ohayo, sensei! Superb session logging enhancements!

The additional logging in the session handling part of create_controller significantly improves observability. The use of structured logging with details about session expiration, policy counts, and changes is excellent. This will greatly aid in debugging and understanding the session creation and update process.


103-103: Ohayo, sensei! Excellent new session logging!

The added log message for new session creation is well-crafted. It includes crucial details like the username and chain ID (in hex format), which will be invaluable for tracking session creation across different environments.


154-154: Ohayo, sensei! Nice policy collection logging!

The addition of a trace log message in the collect_policies function is a great touch. It provides a quick way to verify the number of policies extracted from the project, which can be crucial for debugging and ensuring the correct setup.


Line range hint 1-300: Ohayo, sensei! Overall excellent improvements to logging and error handling!

The changes in this file significantly enhance the observability and robustness of the code. The addition of detailed, structured logging throughout the file will greatly aid in debugging and understanding the flow of execution, especially in complex scenarios involving session creation and policy management.

Key improvements include:

  1. Enhanced error handling with the addition of bail! from anyhow.
  2. More detailed and structured logging across various functions.
  3. Improved documentation clarity.
  4. Consistent use of the target: "account::controller" in log messages for better log filtering.

These changes will make it easier to maintain and troubleshoot the code in the future. Great work on improving the code quality!

@kariy kariy merged commit 73a82b3 into main Oct 13, 2024
15 checks passed
@kariy kariy deleted the update-slot branch October 13, 2024 20:09
@kariy kariy changed the title fix(sozo): update slot due to breaking changes chore(sozo): update slot due to breaking changes Oct 13, 2024
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.

1 participant