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(sozo): remove the need of world_block #2863

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pheobeayo
Copy link

@pheobeayo pheobeayo commented Jan 4, 2025

Description

sozo:remove the need of world-block

Related issue

Fixes #2825.

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

Summary by CodeRabbit

  • Improvements
    • Enhanced code readability through improved formatting and structure.
    • Refined event matching logic for better clarity.

Copy link

coderabbitai bot commented Jan 4, 2025

Walkthrough

Ohayo, sensei! The changes in the events.rs file focus on formatting improvements and logic simplifications. The modifications enhance the readability of function calls and structures, particularly in the run method of the EventsArgs struct. The handling of the from_block variable has been streamlined, and the formatting of match arms for WorldEvent variants has been made consistent. These adjustments aim to improve code clarity and maintainability without altering the underlying logic or functionality.

Changes

File Change Summary
bin/sozo/src/commands/events.rs - Improved formatting for function calls and structures
- Simplified handling of from_block variable
- Reformatted match arms for WorldEvent variants
- Enhanced readability of variable assignments

Assessment against linked issues

Objective Addressed Explanation
Remove the need for world_block (#[2825]) The changes do not implement a dynamic block range handling mechanism or remove the world_block dependency as required.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 318ab16 and f381d53.

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

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.

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

🧹 Nitpick comments (4)
bin/sozo/src/commands/events.rs (4)

68-70: Ohayo sensei, consider documenting MAX_BLOCK_RANGE.
Defining MAX_BLOCK_RANGE at 50,000 is good, but a quick doc comment explaining the rationale would help maintainers.

+/// Maximum number of blocks to query in a single request
 const MAX_BLOCK_RANGE: u64 = 50_000;

302-303: Ohayo sensei, verify error handling for model_get.
Consider how you’ll handle potential model retrieval failures. Right now, it looks good, but if an error occurs, it might be good to log it or bubble it up.


338-338: Ohayo sensei, keep watch on the comment.
Looks like a placeholder comment for printing. If you need more data, consider implementing it soon.


357-357: Ohayo sensei, next steps for pretty print.
Same as above, a placeholder comment for printing the value. Let me know if you want some help implementing it.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07bb880 and 318ab16.

📒 Files selected for processing (1)
  • bin/sozo/src/commands/events.rs (13 hunks)
🔇 Additional comments (21)
bin/sozo/src/commands/events.rs (21)

7-7: Ohayo sensei, nice import!
This import for Event as WorldEvent is straightforward and helps bring clarity to event usage.


12-12: Ohayo sensei, imports look good!
These additional imports help streamline access to Starknet types.


60-64: Ohayo sensei, great job retrieving the provider!
The call to utils::get_world_diff_and_provider is well-structured and keeps the code clean.


71-79: Ohayo sensei, watch out for the placeholder call.
self.get_current_block() is commented as a placeholder. Ensure the actual logic to fetch the current block is implemented.


81-81: Ohayo sensei, explicit None is clear.
Returning None when from_block is not set is straightforward and matches expectations.


84-91: Ohayo sensei, check the shape of generated keys.
Wrapping the event map call in an extra vector dimension might be intentional, but validate if your event filtering logic expects Vec<Vec<Felt>> or a single level.


100-104: Ohayo sensei, good usage of pagination.
Leveraging chunk_size and continuation_token will help handle large event sets gracefully.


114-115: Ohayo sensei, good error handling.
Unwrapping the result with a log statement ensures we get immediate feedback if something fails.


144-144: Ohayo sensei, generic constraints look neat!
Specifying P: Provider + Send + Sync is precise for async contexts.


149-153: Ohayo sensei, convenient reverse mapping.
Storing contract_selectors_from_address is a great optimization for quick lookups.


166-174: Ohayo sensei, consistent format for WorldSpawned.
Displaying creator and class_hash in a single format block is clear.


181-190: Ohayo sensei, strong clarity for ModelRegistered.
Nicely done listing namespace, name, class hash, and address.


192-201: Ohayo sensei, uniform approach for EventRegistered.
Mirroring the ModelRegistered format keeps events consistent.


203-213: Ohayo sensei, good detail for ContractRegistered.
Providing namespace, name, and salt helps with debugging.


222-225: Ohayo sensei, graceful logging in ModelUpgraded.
Including both the new and previous addresses is crucial for version tracking.


236-239: Ohayo sensei, consistent pattern in EventUpgraded.
Matches the structure used for other upgraded event logs.


247-247: Ohayo sensei, succinct formatting for ContractUpgraded.
Concise yet informative about the updated class hash.


267-273: Ohayo sensei, good fallback for unknown writer grantee.
If the address is not recognized, showing the raw hex string is a helpful fallback.


282-288: Ohayo sensei, consistent fallback for unknown owner grantee.
Reusing the same approach for owner updates is a nice parallel to writer updates.


365-365: Ohayo sensei, minimal but informative for StoreDelRecord.
The message is short and sweet, though consider adding context if needed.


Line range hint 370-395: Ohayo sensei, inclusive approach for EventEmitted.
The usage of contract tags or fallback hex displays is consistent with the rest of the event handling. Nicely done!

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution here, however this is not solving the issue.

In the current fixed proposed, we only set the from_block, but then the get_event function will still be called once, and not iteratively.

So having a max block range is good approach, but now this must be done iteratively for all the chunks that will be generated.

Also, please check the scripts into scripts folder to format correctly the code and avoid diffs related to linters. 👍

@glihm glihm changed the title sozo: remove the need of world_block #2825 feat(sozo): remove the need of world_block Jan 5, 2025
@pheobeayo
Copy link
Author

Thanks for the contribution here, however this is not solving the issue.

In the current fixed proposed, we only set the from_block, but then the get_event function will still be called once, and not iteratively.

So having a max block range is good approach, but now this must be done iteratively for all the chunks that will be generated.

Also, please check the scripts into scripts folder to format correctly the code and avoid diffs related to linters. 👍

Okay, I will fix it

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.

sozo: remove the need of world_block
2 participants