-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(katana): merge ServerOptions #3047
Conversation
WalkthroughOhayo sensei! This PR revises the configuration merging process for the Katana CLI. In the Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as "CLI (Caller)"
participant NA as "NodeArgs"
participant SO as "ServerOptions"
participant CF as "ConfigFile"
CLI->>NA: with_config_file(config)
NA->>SO: merge(config.server)
NA->>NA: update(metrics) if default
SO-->>NA: Merged server options
NA-->>CLI: Return updated NodeArgs
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 (1)
crates/katana/cli/src/options.rs (1)
157-192
: Ohayo sensei! The merge logic looks good, but let's optimize those clones!The merge implementation correctly updates fields only when they have default values, maintaining the precedence of CLI arguments over config file values. However, we can optimize it by removing unnecessary
clone()
calls on primitive types.Here's the optimized version:
pub fn merge(&mut self, other: Option<&Self>){ if let Some(other) = other { if self.http_addr == DEFAULT_RPC_ADDR { - self.http_addr = other.http_addr.clone(); + self.http_addr = other.http_addr; } if self.http_port == DEFAULT_RPC_PORT { - self.http_port = other.http_port.clone(); + self.http_port = other.http_port; } if self.http_cors_origins.len() == 0 { self.http_cors_origins = other.http_cors_origins.clone(); } if self.http_modules.is_none() { self.http_modules = other.http_modules.clone(); } if self.max_event_page_size == DEFAULT_RPC_MAX_EVENT_PAGE_SIZE { - self.max_event_page_size = other.max_event_page_size.clone(); + self.max_event_page_size = other.max_event_page_size; } if self.max_proof_keys == DEFAULT_RPC_MAX_PROOF_KEYS { - self.max_proof_keys = other.max_proof_keys.clone(); + self.max_proof_keys = other.max_proof_keys; } if self.max_connections.is_none() { - self.max_connections = other.max_connections.clone(); + self.max_connections = other.max_connections; } if self.max_request_body_size.is_none() { - self.max_request_body_size = other.max_request_body_size.clone(); + self.max_request_body_size = other.max_request_body_size; } if self.max_response_body_size.is_none() { - self.max_response_body_size = other.max_response_body_size.clone(); + self.max_response_body_size = other.max_response_body_size; } if self.max_call_gas == DEFAULT_RPC_MAX_CALL_GAS { - self.max_call_gas = other.max_call_gas.clone(); + self.max_call_gas = other.max_call_gas; } } }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
crates/katana/cli/src/args.rs
(1 hunks)crates/katana/cli/src/options.rs
(1 hunks)
🔇 Additional comments (1)
crates/katana/cli/src/args.rs (1)
389-389
: LGTM! Clean and consistent with other merge calls.The change simplifies the server options merging by using the new
merge
method, making it consistent with how other options are merged in this file.
4343649
to
7fb3fcf
Compare
There was a problem hiding this 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 (1)
crates/katana/cli/src/options.rs (1)
157-192
: Ohayo sensei! The merge implementation looks good with minor improvements possible.The merge logic is well-implemented, preserving user-specified values and following a consistent pattern. Consider these minor refinements:
- if self.http_cors_origins.len() == 0 { + if self.http_cors_origins.is_empty() {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
crates/katana/cli/src/args.rs
(1 hunks)crates/katana/cli/src/options.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/katana/cli/src/args.rs
🧰 Additional context used
🪛 GitHub Actions: ci
crates/katana/cli/src/options.rs
[error] 155-155: Rust formatting check failed. Please run 'rustfmt' to format the code.
} | ||
|
||
impl ServerOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix formatting: Add newline after closing brace.
The pipeline indicates a formatting issue. Please run rustfmt
or add a newline after the closing brace of the Default
implementation.
}
}
+
impl ServerOptions {
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
} | |
impl ServerOptions { | |
} | |
} | |
impl ServerOptions { |
🧰 Tools
🪛 GitHub Actions: ci
[error] 155-155: Rust formatting check failed. Please run 'rustfmt' to format the code.
Will close since done in #3044. 👍 |
closes #2968
Summary by CodeRabbit
New Features
Refactor