dojo icon indicating copy to clipboard operation
dojo copied to clipboard

feat(dojo-core): add fixed array support in models

Open bengineer42 opened this issue 1 year ago • 1 comments

Description

Related issue

Fixes #2785

Tests

  • [ ] Yes
  • [ ] No, because they aren't needed
  • [ ] No, because I need help

Added to documentation?

  • [ ] README.md
  • [ ] Dojo Book
  • [ ] No documentation needed

Checklist

  • [ ] I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • [ ] I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • [ ] I've commented my code
  • [ ] I've requested a review after addressing the comments

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for fixed-size arrays in data models and type introspection.
    • Enhanced type system to handle fixed-size array layouts and representations.
  • Technical Improvements

    • Expanded introspection capabilities for complex data structures.
    • Improved code generation for fixed-size array handling.
    • Added new utility functions for processing fixed-size arrays.
  • Testing

    • Introduced new test cases for fixed-size array models and introspection.
    • Validated fixed-size array functionality across multiple components.

bengineer42 avatar Jan 10 '25 15:01 bengineer42

Walkthrough

Ohayo, sensei! This pull request introduces comprehensive support for fixed-size arrays across the Dojo framework. The changes span multiple components, including core introspection mechanisms, storage layouts, and compilation utilities. The modifications enable fixed-size arrays to be used in models, with new implementations in the type system, layout handling, and derive macros to support this feature seamlessly.

Changes

File Change Summary
core-cairo-test/src/tests/meta/introspect.cairo Added new structs and enums with fixed-size arrays for testing.
core-cairo-test/src/tests/model/model.cairo Introduced ModelWithFixedArray and corresponding test function.
core/src/meta/introspect.cairo Added FixedArray variant to Ty enum and Introspect implementation.
core/src/meta/layout.cairo Introduced FixedArray variant to Layout enum.
core/src/storage/layout.cairo Added methods for handling fixed-array layouts.
lang/Cargo.toml Added regex dependency.
lang/src/derive_macros/introspect/* Enhanced type, layout, and size handling for fixed-size arrays.

Assessment against linked issues

Objective Addressed Explanation
Support fixed-sized arrays in models [#2785]

Possibly related PRs

  • #2874: Potential connection to gas oracle and settlement layer configurations.
  • #2875: Possible indirect relation through ChainSpec configuration refactoring.

Sensei, the pull request comprehensively implements fixed-size array support across the Dojo framework, meeting the primary objective of enabling these arrays in models!


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

coderabbitai[bot] avatar Jan 10 '25 15:01 coderabbitai[bot]

Will remove this since it may be some work to adjust, and it is not the priority at the moment.

@remybar @bengineer42 feel free to reopen or a new one once we have the new proc macros API released.

glihm avatar Jun 11 '25 01:06 glihm