-
Notifications
You must be signed in to change notification settings - Fork 11
refactor(katana): remove starknet crate dependency from RPC client #268
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replace starknet crate types with Katana's own RPC types and use reqwest directly for HTTP client. Changes: - Remove starknet dependency from bin/katana/Cargo.toml - Add katana-rpc-api and reqwest dependencies - Rewrite RPC client to use reqwest instead of HttpTransport - Replace all starknet types with Katana equivalents: - BlockId → BlockIdOrTag - ConfirmedBlockId → ConfirmedBlockIdOrTag - Use katana_rpc_types::FunctionCall - Use katana_rpc_api::error::starknet::StarknetApiError - Return raw JSON responses for debugging purposes - Update tests to use new types This change removes external dependencies and uses Katana's native types throughout the RPC debugging client. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Apply formatting fixes from cargo +nightly-2025-02-20 fmt --all 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace manual JSON-RPC implementation with jsonrpsee's built-in functionality. Changes: - Use jsonrpsee HttpClient instead of manual reqwest + JSON-RPC handling - Replace manual JSON-RPC request/response structs with jsonrpsee's ClientT::request - Use ArrayParams for parameter handling - Remove reqwest and katana-rpc-api dependencies - Add jsonrpsee with http-client feature - Simpler, more maintainable implementation (~30% less code) This provides proper JSON-RPC 2.0 compliance and better error handling while still returning raw JSON values for debugging purposes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Update the debugging RPC client to match the starknet client method signatures while returning raw JSON values for debugging purposes. Changes: - Remove to_json() methods from BlockIdArg/ConfirmedBlockIdArg (BlockIdOrTag already implements Serialize/Deserialize) - Update all client method signatures to match starknet client exactly: - Use typed arguments (BlockIdOrTag, ContractAddress, StorageKey, etc.) - Maintain raw Value return types for debugging - Update imports to include all necessary types - Remove manual JSON construction for FunctionCall - Let serialization happen automatically via Serialize trait This provides better type safety while maintaining the raw JSON output needed for debugging RPC servers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
59b4b26 to
85ef74a
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
==========================================
+ Coverage 73.32% 75.26% +1.93%
==========================================
Files 209 230 +21
Lines 23132 27127 +3995
==========================================
+ Hits 16961 20416 +3455
- Misses 6171 6711 +540 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Dec 25, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Removed dependency on the
starknetcrate from the Katana RPC debugging client and replaced it with Katana's native types, usingjsonrpseefor proper JSON-RPC handling.This new implementation will also help us better validate our own RPC types.
Original Instructions
The user requested the following changes to the Katana RPC client:
starknetcrate - The RPC client implementation inbin/katana/src/cli/rpc/client.rswas based solely on types from thestarknetcratecrates/rpc/rpc-types/srcHttpTransportfrom starknet cratecrates/rpc/rpc-api/src/error/starknet.rsEvolution of Implementation
Initial Implementation (First Commit)
Initially implemented a manual JSON-RPC client using
reqwest:reqwest::Clientdirectly for HTTP requestsStarknetApiErrorImproved Implementation (Second Commit)
After discussion, refactored to use
jsonrpseefor cleaner JSON-RPC handling:jsonrpsee::http_client::HttpClient- Proper JSON-RPC client with built-in protocol handlingClientT::requestmethod - Returns rawserde_json::Valuefor debuggingArrayParams- Type-safe parameter handling from jsonrpseeFinal Refinement (Latest Commit)
Aligned the client method signatures with the existing starknet client:
to_json()methods - BlockIdOrTag/ConfirmedBlockIdOrTag already implement Serialize/Deserializecrates/rpc/rpc-client/src/starknet.rsexactly:Valuereturn types for debugging purposesThought Process & Alternatives Considered
Initial Approach
Initially planned to simply replace the
starknetcrate types with Katana types while maintaining the same client structure.Alternative Considered: Reusing
katana-rpc-clientDuring implementation, we considered reusing the existing
katana-rpc-client(atcrates/rpc/rpc-client/src/starknet.rs) instead of maintaining two separate client implementations. This client:jsonrpseewith the trait-based API fromkatana-rpc-apiStarknetApiErrorWhy We Kept a Separate Implementation
After discussion, we decided to maintain a separate client implementation for the CLI debugging tool because:
katana-rpc-clientis for programmatic useFinal Improvement: Using jsonrpsee
Realized that using
jsonrpsee(already in the project dependencies) would provide:Final Implementation
starknetandreqwest, addedjsonrpseewithhttp-clientfeature tobin/katana/Cargo.tomljsonrpseewith proper typed method signatures matching the starknet clientstarknet::core::types::BlockId→katana_primitives::block::BlockIdOrTagstarknet::core::types::ConfirmedBlockId→katana_primitives::block::ConfirmedBlockIdOrTagstarknet::core::types::BlockTag→ Direct enum variantsstarknet::core::types::FunctionCall→katana_rpc_types::FunctionCallstarknet::providers::jsonrpc::HttpTransport→jsonrpsee::http_client::HttpClientstarknet.rs:to_json()methods since types already implement SerializeMotivation
The RPC client in the Katana binary is primarily used as a debugging tool to validate RPC server responses. By removing the external
starknetcrate dependency and using Katana's own types with proper JSON-RPC handling viajsonrpsee, we:Test Plan
🤖 Generated with Claude Code