dojo icon indicating copy to clipboard operation
dojo copied to clipboard

feat: added warning messages for when sierra file is too big or too many felts

Open PoulavBhowmick03 opened this issue 6 months ago • 7 comments
trafficstars

Description

Related issue

Fixes #3149

Tests

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

Added to documentation?

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

Checklist

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

Summary by CodeRabbit

  • New Features
    • Added automatic warnings during every build if the Sierra file size or CASM bytecode size exceeds recommended limits, with clear colored messages.
  • Enhancements
    • Statistics for the world and its resources are now always collected during compilation, regardless of options selected.

PoulavBhowmick03 avatar Apr 23 '25 05:04 PoulavBhowmick03

@glihm is this the intended solution?

PoulavBhowmick03 avatar Apr 23 '25 05:04 PoulavBhowmick03

Walkthrough

Ohayo sensei! This change updates the build command in the Sozo CLI to always load world statistics and check contract size limits during every compilation, regardless of whether the --stats flag is used. The code now emits warnings to stderr if the Sierra file exceeds 4,089,446 bytes or if the CASM bytecode exceeds 81,920 felts. The statistics table is only displayed when the --stats option is enabled, but the limit checks and warnings are always performed.

Changes

Files/Paths Change Summary
bin/sozo/src/commands/build.rs Refactored to always load and check world statistics for Sierra and CASM size limits, emitting warnings unconditionally; stats table display remains conditional on the --stats flag.

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Emit warning during compilation if Sierra file > 4MB or CASM bytecode > 81,920 felts (#3149)
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

coderabbitai[bot] avatar Apr 23 '25 05:04 coderabbitai[bot]

I think this should be dynamic based on the network we're migrating the World to. These limits are only being enforced by Starknet Mainnet/Sepolia at the moment, and not on katana-based chains yet. So, ideally, we should first try to determine what chain we may be migrating to, using the rpc url specified in the dojo_*.toml, and show the warnings accordingly.

We should also be very clear about which chain the limits apply to.

I do agree on the dynamism this should have. However at the build time, we may not be aware of the chain.

So we could move those changes into migrate instead of build, which could make more sense and the dynamism you described will be applied more easily. 👍

glihm avatar Apr 23 '25 20:04 glihm

> I do agree on the dynamism this should have. However at the build time, we may not be aware of the chain.

So we could move those changes into migrate instead of build, which could make more sense and the dynamism you described will be applied more easily. 👍

Yes, agree on this. Makes more sense to show the warning at sozo migrate especially at the very start of the migration process. If the migration fails due to exceeding the limits, then the warnings would be more easily accessible and doesn't get lost in the terminal.

The built contracts are agnostic to the chain that it would be migrated to, so let's push this feature over to sozo migrate instead. cc @PoulavBhowmick03

kariy avatar Apr 24 '25 16:04 kariy

@PoulavBhowmick03 if you have any blocker or questions, don't hesitate to ask. 🫡

glihm avatar Apr 28 '25 17:04 glihm

gm @glihm , i was actually at the hospital. getting it done by tonight

PoulavBhowmick03 avatar Apr 30 '25 07:04 PoulavBhowmick03

gm @glihm , i was actually at the hospital. getting it done by tonight

Oh shoot, hopefully you're doing good man.. No pressure, when you have a chance.

glihm avatar Apr 30 '25 14:04 glihm

Any update @PoulavBhowmick03? Hopefully you're feeling better. 🙏

glihm avatar May 12 '25 19:05 glihm

@PoulavBhowmick03 I do hope you're doing better man, and don't hesitate to drop off to recover on your end. 🙏

glihm avatar May 30 '25 22:05 glihm

Will close this since we now rely on Scarb to build files. So it would be a different code, using the stats right after the build to evaluate if some contracts are too big. 👍

Hope you're doing better @PoulavBhowmick03 and things are going well.

glihm avatar Sep 09 '25 21:09 glihm