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

fix(sozo): update Controller dependencies #2303

Merged
merged 7 commits into from
Sep 14, 2024
Merged

fix(sozo): update Controller dependencies #2303

merged 7 commits into from
Sep 14, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Aug 15, 2024

includes bunch of dependencies version bump to avoid versioning issues

Summary by CodeRabbit

  • New Features

    • Updated the controller account contract class hash for improved contract interactions.
    • Added a test for validating the new controller account contract class hash.
    • Enhanced session management and handling of policies in the controller.
    • Improved clarity in account type handling, distinguishing between controller and standard accounts.
    • Added capabilities for signer interactivity within the SozoAccount enum.
    • Transitioned to specific revisions for dependencies to boost stability and predictability.
    • Introduced new dependencies for improved functionality within the project.
    • Updated libp2p dependencies to ensure consistency and incorporate recent improvements.
  • Bug Fixes

    • Streamlined session handling logic to reduce unnecessary session creations.
  • Documentation

    • Improved import organization for clarity and maintainability across several files.
  • Chores

    • Reordered and reorganized import statements for better readability in multiple modules.

Copy link

coderabbitai bot commented Aug 15, 2024

Walkthrough

Ohayo, sensei! Recent updates refine the Rust project's structure with significant enhancements to dependency management, session handling, account representations, and import organization. Key modifications include transitioning to precise dependency revisions, improving session management logic for efficiency, and clarifying account type distinctions. Additionally, a new constant for the controller account contract class hash has been introduced, along with corresponding tests to ensure its correctness.

Changes

Files Change Summary
Cargo.toml, bin/sozo/Cargo.toml, crates/torii/libp2p/Cargo.toml Updated dependency specifications, switched to specific revisions, added new dependencies like hashlink, and revised versions for existing dependencies.
bin/sozo/src/commands/options/account/controller.rs, bin/sozo/src/commands/options/account/mod.rs, bin/sozo/src/commands/options/account/type.rs Modified ControllerSessionAccount to use Arc<P>, refined session handling logic, and updated policy types for better clarity and functionality.
crates/dojo-world/src/contracts/abi/model.rs, crates/dojo-world/src/contracts/abi/world.rs Enhanced abigen! macro by adding derive traits for serialization and equality checks, improving type usability.
crates/katana/primitives/src/genesis/constant.rs Updated CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH and added tests to verify its correctness.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant SessionManager

    User->>Controller: Request session
    Controller->>SessionManager: Check existing session
    alt Session exists
        SessionManager->>Controller: Return existing session
    else New session
        Controller->>SessionManager: Create new session
        SessionManager->>Controller: Return new session
    end
    Controller-->>User: Provide session
Loading

Possibly related PRs

  • opt(torii): avoid calculating poseidon hash where possible #2394: The changes in the main PR involve updates to the Cargo.toml file for dependency management, which is relevant to the dependency updates in the sozo project as seen in the retrieved PRs.
  • chore(walnut): put under walnut feature flag #2407: The modifications in the main PR regarding the Cargo.toml file and the introduction of a new feature flag align with the changes in the retrieved PR that encapsulates the walnut functionality under a feature flag, indicating a related focus on dependency and feature management.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 19d4324 and 7077062.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (1)
  • crates/torii/libp2p/Cargo.toml (1 hunks)
Additional comments not posted (1)
crates/torii/libp2p/Cargo.toml (1)

37-38: Ohayo sensei! The dependency updates look great!

Aligning all the libp2p related dependencies to the newer commit cdc9638 is a smart move. It ensures consistency across the project and potentially brings in bug fixes and improvements from the updated version.

The features specified for the dependencies remain the same, which is perfect for maintaining the desired functionality.

Overall, these changes enhance the project's dependency management. Nicely done!

Also applies to: 45-47


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 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: 1

Outside diff range, codebase verification and nitpick comments (1)
crates/torii/graphql/src/tests/mod.rs (1)

22-23: Ohayo, sensei! The Call type is still in use.

The Call type is used in the execute_v1 function calls within this module. Its removal from the imports will lead to errors. Please ensure the import statement for Call is retained.

  • Lines using Call:
    • execute_v1(vec![Call { ... }]).send()
Analysis chain

Removal of Call type from imports.

The Call type has been removed from the imports. Make sure that this change does not impact any existing functionality that relied on Call. Verify that the code no longer requires this type.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `Call` type is no longer needed in this module.

# Test: Search for `Call` usage in this module. Expect: No usage of `Call`.
rg --type rust -A 5 $'Call' crates/torii/graphql/src/tests/mod.rs

Length of output: 760

crates/katana/controller/src/lib.rs Outdated Show resolved Hide resolved
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 (4)
bin/sozo/src/commands/options/account/type.rs (1)

5-5: Consolidate import statements for better clarity.

The import statements could be grouped by their source or functionality to improve readability.

use starknet::accounts::{
    single_owner, Account, ConnectedAccount, DeclarationV2, DeclarationV3, ExecutionEncoder,
    ExecutionV1, ExecutionV3, LegacyDeclaration, RawDeclarationV2, RawDeclarationV3,
    RawExecutionV1, RawExecutionV3, RawLegacyDeclaration, SingleOwnerAccount,
};
use starknet::core::types::{
    contract::legacy::LegacyContractClass, BlockId, Call, Felt, FlattenedSierraClass,
};
use starknet::providers::Provider;
use starknet::signers::{local_wallet, LocalWallet, SignerInteractivityContext};

Also applies to: 10-10, 12-12

crates/katana/controller/src/lib.rs (1)

4-5: Remove unused import statements.

The commented-out imports should be removed to keep the code clean.

-// use account_sdk::signers::webauthn::{DeviceSigner, WebauthnAccountSigner};
// use account_sdk::wasm_webauthn::CredentialID;

Also applies to: 7-7

Cargo.toml (1)

227-230: Local paths for account_sdk and slot are missing.

Ohayo, sensei! The local paths specified for account_sdk and slot in the Cargo.toml file do not exist in the expected locations. This might affect the build process, so please ensure these paths are correct or update them accordingly.

  • account_sdk path: ../../cartridge/controller/packages/account_sdk
  • slot path: ../../cartridge/slot/slot
Analysis chain

Local path usage for account_sdk and slot.

Using local paths can enhance build performance but ensure that these local versions are up-to-date and compatible with the rest of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the local path usage for `account_sdk` and `slot`.

# Test: Check the existence of the local paths.
if [[ -d "../../cartridge/controller/packages/account_sdk" && -d "../../cartridge/slot/slot" ]]; then
  echo "Local paths exist."
else
  echo "Local paths are missing."
fi

Length of output: 117

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

39-39: Ohayo, sensei! Using Arc for shared ownership is a smart move.

Switching to Arc<P> resolves the Clone trait bound issue, enabling shared ownership of the provider. This change enhances flexibility and adheres to Rust's ownership model.

Consider evaluating the performance implications of using Arc if the provider is accessed frequently in a multi-threaded context.

@glihm glihm changed the title Update Controller dependencies fix(sozo): update Controller dependencies Aug 16, 2024
@glihm glihm added the sozo label Aug 16, 2024
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 (2)
examples/spawn-and-move/dojo_release.toml (1)

22-23: Acknowledged: Improved formatting in skip_contracts.

The indentation changes improve the readability of the skip_contracts list. Nice touch!

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

32-35: Clarify the use of Arc in comments.

The comments explain the reason for using Arc due to Clone bounds. Ensure that this explanation is clear to maintainers and future developers.

- // Why the Arc? becaues the Controller account implementation over on `account_sdk` crate is
+ // Why the Arc? Because the Controller account implementation in the `account_sdk` crate is

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 (4)
crates/katana/executor/tests/fixtures/transaction.rs (2)

9-12: Update import statements.

The import of BroadcastedInvokeTransactionV1 is necessary for the new transaction structure. Ensure that BroadcastedInvokeTransaction is still required; otherwise, consider removing it to keep imports clean.


49-49: Clarify the is_query flag usage.

The is_query flag is set to false, indicating this transaction is not a query. Consider documenting its purpose for future maintainers.

crates/katana/controller/src/lib.rs (1)

4-5: Evaluate the commented-out imports.

The imports for DeviceSigner and WebauthnAccountSigner are commented out. Determine if they are still needed or if they can be removed to clean up the code.

crates/torii/graphql/src/tests/mod.rs (1)

21-22: Ohayo, sensei! The Call type is still in use.

The Call type is still being used in crates/torii/graphql/src/tests/mod.rs, and its removal from the imports will likely cause compilation errors. Please ensure that the import is retained or that the usage of Call is refactored if it is no longer needed.

  • crates/torii/graphql/src/tests/mod.rs: Lines showing usage of Call.
Analysis chain

Ohayo, sensei! Verify the impact of removing Call.

The Call type has been removed from the imports. Ensure that any functionality that previously depended on Call is not affected by this change.

Run the following script to check for any remaining usages of Call:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `Call` is still used in the codebase.

# Test: Search for occurrences of `Call`. Expect: No occurrences.
rg --type rust 'Call' 

Length of output: 25055

@kariy kariy marked this pull request as draft September 3, 2024 17:33
@kariy kariy marked this pull request as ready for review September 13, 2024 16:13
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: 1

Outside diff range and nitpick comments (2)
Cargo.toml (2)

120-120: The async-trait dependency update is a minor version bump.

Upgrading from version 0.1.77 to 0.1.82 should not introduce any breaking changes, but it's always a good idea to review the changelog and test thoroughly.


241-241: The starknet-crypto dependency has a minor version downgrade.

Downgrading from version 0.7.0 to 0.7.1 should not introduce any issues, but please double-check the changelog to ensure compatibility.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 13ae133 and a516b5e.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (23)
  • Cargo.toml (6 hunks)
  • bin/sozo/Cargo.toml (1 hunks)
  • bin/sozo/src/commands/options/account/controller.rs (10 hunks)
  • bin/sozo/src/commands/options/account/mod.rs (2 hunks)
  • bin/sozo/src/commands/options/account/type.rs (4 hunks)
  • crates/dojo-world/src/contracts/abi/model.rs (1 hunks)
  • crates/dojo-world/src/migration/mod.rs (1 hunks)
  • crates/katana/controller/Cargo.toml (1 hunks)
  • crates/katana/controller/src/lib.rs (5 hunks)
  • crates/katana/controller/src/webauthn.rs (1 hunks)
  • crates/katana/core/src/service/messaging/starknet.rs (1 hunks)
  • crates/katana/executor/Cargo.toml (1 hunks)
  • crates/katana/executor/tests/fixtures/transaction.rs (3 hunks)
  • crates/katana/rpc/rpc/tests/common/mod.rs (1 hunks)
  • crates/katana/rpc/rpc/tests/starknet.rs (2 hunks)
  • crates/katana/rpc/rpc/tests/torii.rs (1 hunks)
  • crates/saya/core/src/dojo_os/mod.rs (1 hunks)
  • crates/saya/core/src/verifier/starknet.rs (1 hunks)
  • crates/sozo/ops/src/execute.rs (1 hunks)
  • crates/sozo/ops/src/migration/mod.rs (1 hunks)
  • crates/torii/core/src/sql_test.rs (1 hunks)
  • crates/torii/graphql/src/tests/mod.rs (1 hunks)
  • crates/torii/grpc/src/server/tests/entities_test.rs (1 hunks)
Files skipped from review due to trivial changes (8)
  • crates/katana/core/src/service/messaging/starknet.rs
  • crates/katana/executor/Cargo.toml
  • crates/katana/rpc/rpc/tests/common/mod.rs
  • crates/saya/core/src/dojo_os/mod.rs
  • crates/saya/core/src/verifier/starknet.rs
  • crates/sozo/ops/src/migration/mod.rs
  • crates/torii/core/src/sql_test.rs
  • crates/torii/graphql/src/tests/mod.rs
Files skipped from review as they are similar to previous changes (12)
  • bin/sozo/Cargo.toml
  • bin/sozo/src/commands/options/account/controller.rs
  • bin/sozo/src/commands/options/account/mod.rs
  • bin/sozo/src/commands/options/account/type.rs
  • crates/dojo-world/src/contracts/abi/model.rs
  • crates/dojo-world/src/migration/mod.rs
  • crates/katana/controller/src/webauthn.rs
  • crates/katana/executor/tests/fixtures/transaction.rs
  • crates/katana/rpc/rpc/tests/starknet.rs
  • crates/katana/rpc/rpc/tests/torii.rs
  • crates/sozo/ops/src/execute.rs
  • crates/torii/grpc/src/server/tests/entities_test.rs
Additional comments not posted (13)
crates/katana/controller/Cargo.toml (3)

12-12: Ohayo sensei! The async-trait dependency is a great addition.

The async-trait crate is a popular and stable choice for enabling async methods in traits. It will enhance the module's ability to handle asynchronous programming. Nicely done!


21-23: Verify the reason for using the Git dependency for webauthn-rs-proto.

I see that you've added the webauthn-rs-proto dependency from a specific Git commit to ensure compatibility with account_sdk. While this ensures compatibility, it may make it harder to update the dependency in the future.

Is there a specific reason for using the Git dependency instead of a version from crates.io? If not, consider using a crates.io version for better stability and easier updates.


25-25: The assert_matches dependency is a solid choice for testing, sensei!

Adding the assert_matches crate under [dev-dependencies] is perfect. It will make the tests more expressive and readable. Good thinking!

Cargo.toml (5)

64-64: Ohayo, sensei! The cainome dependency update looks good.

The change from using a version tag to a specific commit hash provides more control over the exact version being used, ensuring compatibility and stability.


161-161: Ohayo! The addition of the hashlink dependency suggests new functionality.

Please ensure that the new functionality introduced by this dependency is properly tested and documented.


230-230: Ohayo! The slot dependency update simplifies the dependency tree.

By using a version tag instead of a commit hash and re-exporting account_sdk, the dependency management becomes cleaner and more maintainable.


240-240: The starknet dependency update to a specific commit hash provides more control.

However, please ensure that the referenced commit (2ddc694) is stable and thoroughly tested.

Also applies to: 249-249


242-246: Ohayo, sensei! The starknet-types-core dependency update is necessary for compatibility.

The strict version requirement of ~0.1.4 ensures that the project uses a version that includes the necessary changes from the referenced pull request. Updating the dependency to a specific commit hash (f98f048) further ensures compatibility.

Also applies to: 250-250

crates/katana/controller/src/lib.rs (5)

129-192: Ohayo sensei! The get_contract_storage function looks great!

The code segment follows a clear logic to compute the guid using the WebauthnSigner and SlotBackend. The use of these structures improves modularity and testability. The unimplemented functions in SlotBackend are safely handled by returning errors since they are not called during the guid computation. The storage key and value for the owner's credentials are correctly computed.


Line range hint 197-248: Ohayo sensei! The test cases are excellent!

The test cases cover the important aspects of the add_controller_account and get_contract_storage functions using realistic test data. The assertions ensure that the functions behave as expected by checking the genesis allocations and storage values. These test cases improve the overall reliability and maintainability of the codebase. Great job!


162-179: Ohayo sensei! The WebauthnBackend trait implementation for SlotBackend is safe and sound!

The get_assertion and create_credential functions are not implemented and return errors, as indicated by the SAFETY comment. This is safe since these functions are not called during the guid computation. Returning errors avoids unnecessary complexity. The code segment is well-structured and follows the trait implementation guidelines.


151-155: Ohayo sensei! The OriginProvider trait implementation for SlotBackend is perfect!

The origin function returns the WEBAUTHN_ORIGIN constant, which is the expected behavior. The code segment is well-structured and follows the trait implementation guidelines. Keep up the great work!


5-14: Ohayo sensei! The new imports are spot-on!

The added imports for async_trait, CoseKey, WebauthnBackend, WebauthnSigner, and OriginProvider are necessary for the WebAuthn-related functionality introduced in the code changes. The imports are correctly specified and follow the Rust naming conventions. The organization and grouping of the imports improve the readability and maintainability of the code. Excellent work!

Cargo.toml Show resolved Hide resolved
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 67.00000% with 33 lines in your changes missing coverage. Please review.

Project coverage is 67.91%. Comparing base (d64fdae) to head (7077062).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...in/sozo/src/commands/options/account/controller.rs 32.14% 19 Missing ⚠️
crates/katana/controller/src/lib.rs 88.88% 6 Missing ⚠️
bin/sozo/src/commands/options/account/type.rs 0.00% 5 Missing ⚠️
crates/dojo-world/abigen/src/main.rs 0.00% 2 Missing ⚠️
bin/sozo/src/commands/options/account/mod.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2303      +/-   ##
==========================================
- Coverage   67.92%   67.91%   -0.01%     
==========================================
  Files         364      364              
  Lines       47832    47910      +78     
==========================================
+ Hits        32490    32539      +49     
- Misses      15342    15371      +29     

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

@kariy kariy merged commit ed2aa83 into main Sep 14, 2024
14 of 15 checks passed
@kariy kariy deleted the sozo/controller branch September 14, 2024 00:37
@kariy kariy mentioned this pull request Sep 19, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants