Skip to content

Configure class size limit#862

Merged
FabijanC merged 10 commits intomainfrom
configure-class-size-limit
Sep 25, 2025
Merged

Configure class size limit#862
FabijanC merged 10 commits intomainfrom
configure-class-size-limit

Conversation

@FabijanC
Copy link
Copy Markdown
Contributor

@FabijanC FabijanC commented Sep 24, 2025

Usage related changes

  • Close Configurable max contract class size #853
  • Introduce new CLI parameters for configuring max class size limit:
    • --maximum-contract-class-size <BYTES>
    • --maximum-contract-bytecode-size <FELTS>
    • --maximum-sierra-length <FELTS>

Development related changes

N/A

Checklist:

  • Checked out the contribution guidelines
  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/clippy_check.sh
  • No unused dependencies - ./scripts/check_unused_deps.sh
  • No spelling errors - ./scripts/check_spelling.sh
  • Performed code self-review
  • Rebased to the latest commit of the target branch (or merged it into my branch)
    • Once you make the PR reviewable, please avoid force-pushing
  • Updated the docs if needed - ./website/README.md
  • Linked the issues resolvable by this PR - linking info
  • Updated the tests if needed; all passing - execution info

Summary by CodeRabbit

  • New Features
    • Added CLI options to configure size limits: --maximum-contract-class-size, --maximum-contract-bytecode-size, and --maximum-sierra-length (also configurable via environment variables). These values are now part of the server configuration.
  • Documentation
    • Updated server configuration docs: renamed “Request size limit” to “Size limit,” added guidance for using new CLI flags, and pointed to default limits.
    • Corrected Sierra length value in versioned docs (updated to 81,920 felts).

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 24, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Introduces configurable class size limits. Adds ClassSizeConfig (u64 fields) to StarknetConfig and wires it through CLI (three new flags) and core logic. check_class_size now consumes limits from config instead of constants. Public constants are retyped from usize to u64. add_declare_transaction passes the new config to checks. Integration tests updated to pass and assert new limits; new unit tests cover each limit. Documentation updated to reflect configurable limits and revised defaults, including Sierra length value in versioned docs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning In addition to the requested class size configurability, the PR also introduces configurability for contract bytecode size and Sierra length limits, which were not part of issue #853 and extend beyond the original scope of making only the class size adjustable. Consider separating the bytecode and Sierra length configurability into a follow-up PR or confirm that these additional features align with stakeholder requirements before merging.
Description Check ⚠️ Warning The PR description uses the required template headings but the usage section only references closing issue #853 without explaining how users are affected by the new CLI flags or default behaviors, and the development section marked as N/A omits any mention of developer-facing changes like new configuration structs and tests. Expand the usage section to describe the new CLI options, default values, and how they affect users, and revise the development section to summarize changes to configuration structures, code paths, and tests.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes that the pull request makes the class size limit configurable, which aligns directly with the primary change of introducing a configurable class size limit via ClassSizeConfig, CLI flags, and configuration updates.
Linked Issues Check ✅ Passed The pull request directly addresses issue #853 by introducing a ClassSizeConfig with a configurable maximum_contract_class_size field, wiring it through StarknetConfig and CLI flags, adding tests, and updating documentation to allow users to override the hardcoded class size limit.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@FabijanC FabijanC force-pushed the configure-class-size-limit branch from 8fe403d to 95acfb4 Compare September 25, 2025 09:09
@FabijanC FabijanC marked this pull request as ready for review September 25, 2025 11:16
@FabijanC
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (4)
website/docs/server-config.md (1)

54-65: Good docs update; add a permalink and minor copy tweak.

  • Prefer a permalink to constants (specific commit) to avoid line drift in main.
  • Consider “Starknet chain info” (lowercase “chain”) for consistency.

Example link style:

tests/integration/general_integration_tests.rs (1)

73-92: to_string() usage for numeric CLI args is fine.

Consistent and readable. Consider expanding env-var parity test to include the three new flags in a follow-up.

Also applies to: 105-111

crates/starknet-devnet/src/cli.rs (1)

288-292: Wiring CLI → config is correct.

Values properly populate ClassSizeConfig.

Consider adding simple validation (e.g., nonzero) if zero has no defined semantics.

crates/starknet-devnet-core/src/starknet/add_declare_transaction.rs (1)

35-37: Avoid narrowing casts when enforcing configurable limits

Casting the u64 limits down to usize loses information on 32-bit targets (and for any caller who configures a value > usize::MAX), effectively shrinking the cap and causing false rejections. Compare in the wider u64 domain instead by lifting the measured lengths to u64 (widening cast) before checking.

-    if serialized_class.len() > config.maximum_contract_class_size as usize
-        || sierra_length > config.maximum_sierra_length as usize
-        || casm_length > config.maximum_contract_bytecode_size as usize
+    let serialized_class_len_u64 = serialized_class.len() as u64;
+    let sierra_length_u64 = sierra_length as u64;
+    let casm_length_u64 = casm_length as u64;
+
+    if serialized_class_len_u64 > config.maximum_contract_class_size
+        || sierra_length_u64 > config.maximum_sierra_length
+        || casm_length_u64 > config.maximum_contract_bytecode_size
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8524f8b and 5934538.

📒 Files selected for processing (7)
  • crates/starknet-devnet-core/src/constants.rs (1 hunks)
  • crates/starknet-devnet-core/src/starknet/add_declare_transaction.rs (4 hunks)
  • crates/starknet-devnet-core/src/starknet/starknet_config.rs (4 hunks)
  • crates/starknet-devnet/src/cli.rs (3 hunks)
  • tests/integration/general_integration_tests.rs (2 hunks)
  • website/docs/server-config.md (1 hunks)
  • website/versioned_docs/version-0.6.0/server-config.md (1 hunks)
🔇 Additional comments (6)
website/versioned_docs/version-0.6.0/server-config.md (1)

60-60: Sierra length default matches code. LGTM.

Value aligns with MAXIMUM_SIERRA_LENGTH = 81,920.

tests/integration/general_integration_tests.rs (1)

64-68: Config round‑trip extended with class_size_config. LGTM.

crates/starknet-devnet-core/src/starknet/starknet_config.rs (3)

45-61: ClassSizeConfig addition looks solid.

Default wires to MAXIMUM_*; serde on StarknetConfig will expose it via devnet_getConfig.


149-149: Field added to StarknetConfig. LGTM.


195-195: Default initialization of class_size_config. LGTM.

crates/starknet-devnet-core/src/constants.rs (1)

121-123: All MAXIMUM_ constants are cast to usize before .len() comparisons; no changes required*

@FabijanC FabijanC requested a review from 3alpha September 25, 2025 11:42
Co-authored-by: 3alpha <lg@shardlabs.io>
@FabijanC FabijanC requested a review from 3alpha September 25, 2025 12:05
@FabijanC FabijanC merged commit f64eabe into main Sep 25, 2025
1 check passed
@FabijanC FabijanC deleted the configure-class-size-limit branch September 25, 2025 12:20
FabijanC added a commit that referenced this pull request Sep 25, 2025
* While cherry-picking, also applied typos-cli fix

Co-authored-by: 3alpha <lg@shardlabs.io>
@3alpha 3alpha added the enhancement New feature or request label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configurable max contract class size

2 participants