dojo
dojo copied to clipboard
feat: added warning messages for when sierra file is too big or too many felts
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.
@glihm is this the intended solution?
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.
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
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 thedojo_*.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. 👍
> 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
migrateinstead ofbuild, 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
@PoulavBhowmick03 if you have any blocker or questions, don't hesitate to ask. 🫡
gm @glihm , i was actually at the hospital. getting it done by tonight
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.
Any update @PoulavBhowmick03? Hopefully you're feeling better. 🙏
@PoulavBhowmick03 I do hope you're doing better man, and don't hesitate to drop off to recover on your end. 🙏
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.