-
Notifications
You must be signed in to change notification settings - Fork 189
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): chain spec file management tools #2945
Conversation
Pull Request Analysis 🚀Ohayo, sensei! Let's dive into the details of this comprehensive pull request that introduces significant changes to the Katana project's architecture and dependencies. WalkthroughThis pull request introduces a new crate called Changes
Sequence DiagramsequenceDiagram
participant CLI as Katana CLI
participant ChainSpec as Chain Specification
participant SettlementLayer as Settlement Layer
participant Backend as Node Backend
CLI->>ChainSpec: Initialize Chain Configuration
ChainSpec->>SettlementLayer: Determine Settlement Type
SettlementLayer-->>ChainSpec: Configure Parameters
ChainSpec->>Backend: Provide Chain Specification
Backend->>Backend: Configure Node Settings
Possibly related PRs
Sensei, this PR represents a significant architectural refactoring that improves the modularity and flexibility of the Katana blockchain implementation! 🌟 🪧 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.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.
Actionable comments posted: 2
🧹 Nitpick comments (5)
bin/katana/src/cli/init/mod.rs (2)
54-65
: Enhance Validation for Chain ID InputOhayo sensei, the chain ID parser currently only checks for ASCII characters. Consider adding additional validation to ensure the chain ID meets the expected format and avoids invalid or potentially harmful inputs.
Apply this diff to improve the validation:
let chain_id = CustomType::<String>::new("Id") .with_help_message("This will be the id of your rollup chain.") - // checks that the input is a valid ascii string. + // Validates that the input is alphanumeric and within expected length. .with_parser(&|input| { - if input.is_ascii() { + if input.chars().all(|c| c.is_alphanumeric() || c == '_') && input.len() <= 32 { Ok(input.to_string()) } else { Err(()) } }) - .with_error_message("Must be valid ASCII characters") + .with_error_message("Chain ID must be alphanumeric (including underscores), up to 32 characters") .prompt()?;
128-133
: Consider Removing Commented-Out CodeOhayo sensei, it's generally good practice to avoid keeping commented-out code in the codebase. Since there's already a TODO note, consider removing this section to keep the code clean and maintainable.
crates/katana/primitives/src/contract.rs (1)
25-28
: Sugoi constant additions, sensei! 🎋The new predefined contract address constants will be helpful for testing and default configurations. The implementation is clean and follows Rust naming conventions.
However, consider adding documentation to explain the purpose and typical usage of these constants.
+ /// The zero address (0x0) pub const ZERO: Self = Self(Felt::ZERO); + /// The one address (0x1) pub const ONE: Self = Self(Felt::ONE); + /// The two address (0x2) pub const TWO: Self = Self(Felt::TWO); + /// The three address (0x3) pub const THREE: Self = Self(Felt::THREE);crates/katana/core/src/backend/gas_oracle.rs (1)
62-68
: Nice addition of Starknet support, sensei!The placeholder implementation for Starknet gas prices is well-documented and provides a clear path for future implementation.
Consider adding a TODO comment with tracking issue number for implementing actual Starknet gas price sampling in the future.
crates/katana/executor/Cargo.toml (1)
24-27
: Consider grouping related dependencies.Ohayo! The dependencies could be better organized by grouping katana-related dependencies together.
-katana-cairo.workspace = true -katana-chain-spec.workspace = true -katana-provider = { workspace = true, features = [ "test-utils" ] } -katana-rpc-types.workspace = true +katana-cairo.workspace = true +katana-provider = { workspace = true, features = [ "test-utils" ] } +katana-rpc-types.workspace = true +katana-chain-spec.workspace = true
🛑 Comments failed to post (2)
crates/katana/chain-spec/src/file.rs (1)
58-59: 🛠️ Refactor suggestion
Remove Debugging Statement
Ohayo sensei, the
dbg!
macro is used for debugging purposes and should be removed from production code to prevent unnecessary console output.Apply this diff to remove the debug statement:
let dir = ChainConfigDir::create(&chain_spec.id)?; - dbg!(&dir);
📝 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.let dir = ChainConfigDir::create(&chain_spec.id)?;
crates/katana/core/src/backend/gas_oracle.rs (1)
300-305: 💡 Codebase verification
Ohayo! Test coverage needed for sampled_starknet, sensei!
The
sampled_starknet()
function is implemented but currently lacks test coverage. Since it's a simple implementation returning fixed gas prices, adding tests would help ensure interface consistency as the implementation evolves.🔗 Analysis chain
Test case update looks good, sensei!
The test has been updated to use the new
GasOracle
enum and properly handle the sampled variant.Consider adding test coverage for the new
sampled_starknet
functionality:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check test coverage for sampled_starknet rg -l "sampled_starknet.*test" .Length of output: 34
Script:
#!/bin/bash # Find the implementation of sampled_starknet ast-grep --pattern 'fn sampled_starknet' # Find test files in the gas oracle directory fd test\.rs$ crates/katana/core/src/backend/ # Look for any gas oracle related tests rg -l "GasOracle.*test" .Length of output: 118
Script:
#!/bin/bash # Look for any Starknet-related code in gas oracle rg -l "starknet" crates/katana/core/src/backend/gas_oracle.rs # Find all test files in the project fd "test\.rs$" # Look for any gas-related tests rg -l "gas.*test" .Length of output: 907
Script:
#!/bin/bash # Check the content of gas oracle file focusing on tests and Starknet rg "mod test|starknet" -A 5 crates/katana/core/src/backend/gas_oracle.rsLength of output: 390
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## katana/chainspec #2945 +/- ##
===================================================
Coverage ? 55.95%
===================================================
Files ? 445
Lines ? 57592
Branches ? 0
===================================================
Hits ? 32226
Misses ? 25366
Partials ? 0 ☔ View full report in Codecov by Sentry. |
Summary by CodeRabbit
Here are the release notes for this pull request:
New Features
katana-chain-spec
crate to manage chain configuration and specificationImprovements
Dependencies
katana-chain-spec
as a workspace dependency across multiple cratesdirs
andtoml
Breaking Changes