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(katana): configurable max gas for rpc call #3043

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Feb 17, 2025

#2969

Summary by CodeRabbit

  • New Features

    • Now allows you to set a custom maximum gas limit for contract calls made via the RPC interface.
    • Introduced a new command-line option to specify this gas cap, offering more control over RPC execution.
    • Updated default settings ensure optimal initial gas limits.
  • Refactor

    • Enhanced the internal configuration process to seamlessly incorporate the new gas limit option.

Copy link

coderabbitai bot commented Feb 17, 2025

Ohayo, sensei! Here’s the detailed breakdown of the changes:

Walkthrough

The pull request adds a new configuration option for setting gas limits on RPC calls. A max_call_gas field is introduced across several modules including CLI arguments, server options, block execution, and node bindings. This field is conditionally applied in RPC configurations, passed through factory setups, and ultimately used in contract execution. The update consistently integrates the new gas limit parameter into different components without altering existing logic.

Changes

File(s) Change Summary
crates/katana/cli/src/args.rs Added max_call_gas field to the RPC configuration within NodeArgs to propagate the user-defined gas limit.
crates/katana/cli/src/options.rs Introduced max_call_gas in ServerOptions with command-line parsing attributes, default function default_max_call_gas, and updates in the Default implementation.
crates/katana/executor/src/implementation/blockifier/mod.rs Added max_call_gas to BlockifierFactory and StarknetVMProcessor; introduced set_max_call_gas method, and modified the call method to utilize this field.
crates/katana/node-bindings/src/lib.rs Added an optional rpc_max_call_gas field to the Katana struct and a builder method to configure it via CLI arguments.
crates/katana/node/src/config/rpc.rs Added constant DEFAULT_RPC_MAX_CALL_GAS and integrated an optional max_call_gas field into RpcConfig, with the default implementation initializing this field to the default value.
crates/katana/node/src/lib.rs Modified the executor factory creation to configure BlockifierFactory with the max_call_gas setting from config.rpc, using the new set_max_call_gas method.

Possibly related PRs

  • feat: gas price oracle v2 #2766: The changes in the main PR, which add a max_call_gas field to the RpcConfig structure and update the rpc_config method, are related to this PR as both involve modifications to the NodeArgs struct in args.rs, specifically enhancing RPC configurations.
  • fix: katana granular config for starknet #2677: The changes in the main PR are related to the addition of the max_call_gas field in the RpcConfig structure, which is directly influenced by the modifications made to the ServerOptions struct in this PR, as both involve configuring gas limits for RPC calls.
  • feat(katana): new command line interface (breaking) #2663: The changes in the main PR, which involve adding a max_call_gas field to the RpcConfig structure and updating the rpc_config method in NodeArgs, are related to the modifications in this PR that also introduce a max_call_gas field in the ServerOptions struct, as both changes directly affect the configuration of RPC calls.

Suggested labels

katana, contributor

Suggested reviewers

  • glihm

📜 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 44c2570 and 3b17ae0.

📒 Files selected for processing (1)
  • crates/katana/cli/src/options.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/cli/src/options.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt

🪧 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 (2)
crates/katana/executor/src/implementation/blockifier/mod.rs (2)

47-47: Ohayo! Let's add some documentation here, sensei!

Consider adding documentation for the max_call_gas field to explain its purpose and constraints.

+    /// Maximum gas limit for contract calls.
+    /// This value is used to limit the gas consumption of the `starknet_call` RPC method.
     max_call_gas: u64,

53-54: Consider extracting the default value as a constant, sensei!

The default value of 1_000_000_000 should be extracted as a named constant for better maintainability.

+    /// Default maximum gas limit for contract calls.
+    const DEFAULT_MAX_CALL_GAS: u64 = 1_000_000_000;
+
     pub fn new(cfg: CfgEnv, flags: ExecutionFlags, limits: BlockLimits) -> Self {
-        Self { cfg, flags, limits, max_call_gas: 1_000_000_000 }
+        Self { cfg, flags, limits, max_call_gas: Self::DEFAULT_MAX_CALL_GAS }
     }

+    /// Sets the maximum gas limit for contract calls.
     pub fn set_max_call_gas(&mut self, max_call_gas: u64) {
         self.max_call_gas = max_call_gas;
     }

Also applies to: 56-58

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74c7c8c and 44c2570.

📒 Files selected for processing (4)
  • crates/katana/cli/src/options.rs (4 hunks)
  • crates/katana/executor/src/implementation/blockifier/mod.rs (6 hunks)
  • crates/katana/node/src/config/rpc.rs (3 hunks)
  • crates/katana/node/src/lib.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/node/src/config/rpc.rs
🔇 Additional comments (2)
crates/katana/node/src/lib.rs (1)

185-194: Ohayo! Clean implementation of configurable max gas, sensei!

The executor factory initialization properly handles the optional max_call_gas configuration, maintaining clean error handling and consistent configuration patterns.

crates/katana/cli/src/options.rs (1)

133-137: Ohayo! Well-structured CLI option implementation, sensei!

The max_call_gas option is properly integrated with clear documentation, consistent with the existing CLI patterns, and correctly uses feature flags.

Copy link
Member

@kariy kariy left a comment

Choose a reason for hiding this comment

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

I took the liberty to change how the limit is passed to the executor. Other than that, looks good overall.

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 75.67568% with 9 lines in your changes missing coverage. Please review.

Project coverage is 57.69%. Comparing base (ce8c3f7) to head (3b17ae0).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/node-bindings/src/lib.rs 28.57% 5 Missing ⚠️
crates/katana/cli/src/options.rs 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3043      +/-   ##
==========================================
+ Coverage   56.19%   57.69%   +1.49%     
==========================================
  Files         437      437              
  Lines       58821    59231     +410     
==========================================
+ Hits        33057    34173    +1116     
+ Misses      25764    25058     -706     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kariy kariy merged commit 040c1d6 into dojoengine:main Feb 17, 2025
15 checks passed
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.

2 participants