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

feat: Torii upgrade #303

Merged
merged 4 commits into from
Oct 17, 2024
Merged

feat: Torii upgrade #303

merged 4 commits into from
Oct 17, 2024

Conversation

ponderingdemocritus
Copy link
Contributor

@ponderingdemocritus ponderingdemocritus commented Oct 17, 2024

  • bumps torii

Summary by CodeRabbit

  • New Features

    • Updated the Continuous Integration workflow for improved performance.
    • Enhanced API calls to exclude hashed keys from results.
  • Dependency Updates

    • Changed dependency for @dojoengine/torii-client to a dynamic workspace reference.
    • Updated @dojoengine/torii-wasm dependency to a specific version.
  • Bug Fixes

    • Adjusted the repository cloning process in the build script to target the correct branch.
  • Subproject Update

    • Updated commit reference for the dojo-starter subproject to a newer version.

Copy link

coderabbitai bot commented Oct 17, 2024

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on updates to the Continuous Integration (CI) workflow and package dependencies. The CI configuration in .github/workflows/ci.yaml has been modified to update the dojoup command version and include a step for updating submodules. The package.json files for both @dojoengine/state and @dojoengine/torii-client reflect changes in dependency specifications. Additionally, modifications in the packages/state/src/recs/index.ts file include the addition of a parameter to API calls, while the build.sh script in packages/torii-wasm specifies a new branch for cloning. Lastly, a commit identifier in worlds/dojo-starter has been updated.

Changes

File Change Summary
.github/workflows/ci.yaml Updated dojoup command version to v1.0.0-alpha.16 and added a step for updating submodules.
packages/state/package.json Changed dependency for @dojoengine/torii-client from "1.0.0-alpha.20" to "workspace:*".
packages/state/src/recs/index.ts Added dont_include_hashed_keys: true parameter to getEntities, getEvents, and getEntitiesQuery functions.
packages/torii-client/package.json Updated dependency version for @dojoengine/torii-wasm from "workspace:*" to "1.0.0-alpha.20".
packages/torii-wasm/build.sh Changed git clone command to specify the grpc-update branch.
worlds/dojo-starter Updated subproject commit identifier from 5410f2290df9872d86bdb433443b04ca8cec3308 to 42b56b04436d895d7e76e16bfe50d3f1796cbd27.

Possibly related PRs

🐇 In a land where code does flow,
A rabbit hops with joy, you know!
With dojoup now up to speed,
And submodules updated, indeed!
Dependencies shift, a dance so fine,
In the world of code, all will align!
🐰✨


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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 and nitpick comments (7)
packages/state/package.json (1)

Line range hint 3-3: Consider updating the package version

Given that a significant dependency has been updated, it might be appropriate to increment the version number of the @dojoengine/state package itself. This helps in tracking changes and maintaining semantic versioning.

Consider updating the version from "1.0.0-alpha.20" to the next appropriate version (e.g., "1.0.0-alpha.21" or "1.0.0-beta.1", depending on the nature of the changes).

.github/workflows/ci.yaml (2)

Line range hint 16-17: Good addition of submodule update step.

Adding a step to update submodules is a good practice. It ensures that all submodules are properly initialized and up-to-date before the build process, preventing potential issues with missing or outdated submodule content.

Consider optimizing this step by adding the --depth 1 flag to the git submodule update command, which can speed up the process by fetching only the latest commit for each submodule:

- run: git submodule update --init --recursive
+ run: git submodule update --init --recursive --depth 1

This can significantly reduce the checkout time, especially for repositories with large submodules or a long history.


Line range hint 44-47: Consider addressing the commented-out Codecov section.

There's a commented-out section for uploading coverage reports to Codecov. If code coverage is important for your project, consider either:

  1. Uncommenting and configuring this step if you want to start using Codecov.
  2. Removing this commented-out section if there are no plans to use Codecov in the near future.

This will help maintain a cleaner and more intentional CI configuration.

packages/state/src/recs/index.ts (4)

125-130: LGTM. Consider adding a comment explaining the purpose of dont_include_hashed_keys.

The addition of dont_include_hashed_keys: true to the client.getEntities call is consistent with the Torii upgrade. This change likely optimizes performance or addresses data privacy concerns by excluding hashed keys from the returned entities.

Consider adding a brief comment explaining the purpose and impact of setting dont_include_hashed_keys to true, to improve code maintainability and clarity for future developers.


168-168: LGTM. Ensure consistent documentation across similar changes.

The addition of dont_include_hashed_keys: true to the client.getEventMessages call is consistent with the earlier change in the getEntities function and aligns with the Torii upgrade.

For consistency, if you add a comment explaining dont_include_hashed_keys in the getEntities function as suggested earlier, consider adding a similar comment here or referencing the explanation in getEntities.


235-235: LGTM. Consider adding global documentation for dont_include_hashed_keys.

The addition of dont_include_hashed_keys: true to this client.getEntities call in getEntitiesQuery is consistent with the previous changes and aligns with the Torii upgrade.

Given that this parameter has been added to multiple functions, consider adding a global comment or updating the documentation to explain the purpose and impact of dont_include_hashed_keys across all affected API calls. This would improve overall code clarity and maintainability.


Line range hint 125-235: Overall LGTM. Consider improving documentation for the Torii upgrade changes.

The consistent addition of dont_include_hashed_keys: true across multiple API calls (getEntities, getEvents, getEntitiesQuery) aligns well with the Torii upgrade objective. These changes likely represent a significant update in how the Torii library handles hashed keys.

To improve code maintainability and clarity:

  1. Add a global comment or update the module documentation to explain the purpose and impact of dont_include_hashed_keys.
  2. Consider updating the function documentation for getEntities, getEvents, and getEntitiesQuery to mention this new behavior.
  3. If there are any performance implications or use cases where developers might want to include hashed keys, document these considerations.

These documentation improvements will help future developers understand the rationale behind these changes and use the updated API effectively.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e7d6f1f and 8d54401.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • .github/workflows/ci.yaml (1 hunks)
  • packages/state/package.json (1 hunks)
  • packages/state/src/recs/index.ts (3 hunks)
  • packages/torii-client/package.json (1 hunks)
  • packages/torii-wasm/build.sh (1 hunks)
  • worlds/dojo-starter (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • worlds/dojo-starter
🧰 Additional context used
🔇 Additional comments (4)
packages/torii-wasm/build.sh (2)

Line range hint 1-24: LGTM for the rest of the script

The remainder of the script follows good practices:

  • It uses set -ex for improved error handling and debugging.
  • It builds for both web and Node.js targets.
  • It cleans up after the build process by removing the cloned repository.

These aspects contribute to a robust and maintainable build process.


7-7: 🛠️ Refactor suggestion

Consider the implications of specifying a feature branch for cloning

The change to clone from the grpc-update branch instead of the default branch has several implications:

  1. It ensures consistency by targeting a specific branch, which can be beneficial for reproducible builds.
  2. However, feature branches like grpc-update are often less stable than main branches, potentially introducing instability into the build process.
  3. The build now depends on the state of this specific branch, which may not always be up-to-date or could be deleted in the future.
  4. This change might impact CI/CD pipelines that rely on this script, especially if the specified branch is not always available.

Consider the following improvements:

  1. Use an environment variable or script parameter to specify the branch, allowing for easier switching between branches:
-git clone --depth 1 --branch grpc-update https://github.com/dojoengine/dojo.c dojo.c
+BRANCH=${DOJO_BRANCH:-main}
+git clone --depth 1 --branch $BRANCH https://github.com/dojoengine/dojo.c dojo.c
  1. Add error handling to deal with cases where the specified branch doesn't exist:
if ! git clone --depth 1 --branch $BRANCH https://github.com/dojoengine/dojo.c dojo.c; then
  echo "Failed to clone branch $BRANCH, falling back to main"
  git clone --depth 1 https://github.com/dojoengine/dojo.c dojo.c
fi
  1. Consider using a specific commit hash or tag instead of a branch name for even more reproducible builds:
COMMIT_HASH=abc123...  # Replace with the desired commit hash
git clone https://github.com/dojoengine/dojo.c dojo.c
cd dojo.c
git checkout $COMMIT_HASH

These changes would make the script more flexible and robust while maintaining the ability to target specific versions when needed.

To ensure that the grpc-update branch exists and is up-to-date, you can run the following check:

This will help verify the current state of the specified branch.

packages/state/package.json (1)

28-28: Dependency update to workspace reference

The dependency for @dojoengine/torii-client has been changed from a fixed version "1.0.0-alpha.20" to a workspace reference "workspace:*". This change aligns with the PR objective of upgrading the Torii library.

Pros:

  1. Allows for easier local development and testing of interdependent packages.
  2. Ensures that the latest compatible version of the torii-client is always used within the workspace.

Cons:

  1. May introduce potential instability if the torii-client package undergoes breaking changes.
  2. Could make the build less reproducible across different environments.

To ensure consistency and identify potential issues, let's check for other workspace references and the overall dependency structure:

✅ Verification successful

Workspace reference for @dojoengine/torii-client is consistent across the monorepo.

No issues found with the dependency change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other workspace references and overall dependency structure
jq '.dependencies + .devDependencies + .peerDependencies' packages/state/package.json

# Check if other packages in the monorepo use workspace references
fd package.json | xargs jq -c 'select(.dependencies."@dojoengine/torii-client" | type == "string" and startswith("workspace:")) | {file: input_filename, dep: .dependencies."@dojoengine/torii-client"}'

Length of output: 1280

.github/workflows/ci.yaml (1)

23-23: Verify compatibility with the updated dojoup version.

The dojoup command has been updated to v1.0.0-alpha.16, which aligns with the PR objective of upgrading the Torii library. This change likely brings improvements or fixes to the Dojo toolchain.

To ensure compatibility, please run the following script to check if there are any version-specific dependencies or configurations in the project:

@@ -17,7 +17,7 @@
}
},
"dependencies": {
"@dojoengine/torii-wasm": "workspace:*"
"@dojoengine/torii-wasm": "1.0.0-alpha.20"
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Issues Found:

  1. The specified version @dojoengine/[email protected] is not published. This will prevent the torii-client package from resolving its dependency correctly.
  2. There are remaining workspace dependencies for @dojoengine/torii-wasm in other packages:
    • examples/example-vite-react-phaser-recs/package.json
    • examples/example-vite-kitchen-sink/package.json
    • examples/example-vite-react-sdk/package.json

Please address these issues to ensure consistent dependency management and a successful build process.

🔗 Analysis chain

Verify the impact of switching from workspace dependency to a specific version.

The dependency @dojoengine/torii-wasm has been updated from a workspace dependency ("workspace:*") to a specific version ("1.0.0-alpha.20"). This change has several implications:

  1. It suggests that torii-wasm is now being published as a separate package rather than being used as a local workspace dependency.
  2. The version matches the current version of torii-client, which is good for consistency but may require manual updates in the future to keep them in sync.
  3. This change might affect the build process and development workflow, as it's no longer automatically using the latest local version.

To ensure this change doesn't introduce any issues, please run the following checks:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the specified version of torii-wasm is published
npm view @dojoengine/[email protected]

# Verify that the build process still works with the new dependency
npm run build

# Check for any scripts or documentation that might need updating due to this change
grep -R "workspace:\*" .

Length of output: 8214


Script:

#!/bin/bash
# Check if the specific version of torii-wasm is published using GitHub CLI
gh api repos/CodeRabbitInc/torii-wasm/releases/tags/v1.0.0-alpha.20

# Search for any remaining workspace dependencies for @dojoengine/torii-wasm in the codebase
rg '"@dojoengine/torii-wasm":\s*"workspace:\*"' .

Length of output: 578

@ponderingdemocritus ponderingdemocritus changed the title Torii upgrade feat: Torii upgrade Oct 17, 2024
@ponderingdemocritus ponderingdemocritus merged commit b3339ce into main Oct 17, 2024
2 checks passed
@ponderingdemocritus ponderingdemocritus deleted the torii-upgrade branch October 17, 2024 23:32
@coderabbitai coderabbitai bot mentioned this pull request Oct 21, 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