fix: light-client error StateLookuptableNotFound - #1872
Conversation
WalkthroughThe changes update error handling and messaging in the indexer and photon indexer modules, providing more informative error messages. Additionally, the LightClient now includes network detection logic, enabling it to return appropriate state tree information based on the detected network environment, including special handling for localnet and differentiating between mainnet and devnet lookup tables. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LightClient
participant RPC
participant StateTreeTables
User->>LightClient: get_latest_active_state_trees()
LightClient->>LightClient: detect_network()
alt Localnet
LightClient-->>User: Return hardcoded state trees
else Other networks
LightClient->>StateTreeTables: Select mainnet or devnet tables
LightClient->>RPC: get_light_state_tree_infos(lookup_tables)
RPC-->>LightClient: Return state tree infos
LightClient-->>User: Return state tree infos
end
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
sdk-libs/client/src/indexer/photon_indexer.rs (1)
135-135: Consider the impact of empty error messages on debuggability.While this change aligns with the broader error handling improvements mentioned in the AI summary, replacing
"Unknown API error"with an empty string viaunwrap_or_default()could potentially make debugging more difficult when the API doesn't provide an error message.Ensure that the coordinated changes in
error.rs(specifically the enhanced debug representation in unknown API error handling) compensate for this potential loss of context.sdk-libs/client/src/rpc/client.rs (1)
132-148: Good network detection implementation with minor robustness considerations.The network detection logic is clean and covers the main network types. The string-based URL matching approach is pragmatic and should work for most standard configurations.
Consider making the detection more robust by potentially using URL parsing to extract hostnames, which would be less sensitive to URL variations (e.g., different ports, protocols, or subdomains).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
sdk-libs/client/src/indexer/error.rs(2 hunks)sdk-libs/client/src/indexer/photon_indexer.rs(1 hunks)sdk-libs/client/src/rpc/client.rs(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: cli-v1
- GitHub Check: Test program-libs-slow
- GitHub Check: Test sdk-libs
- GitHub Check: Test batched-merkle-tree-simulate
- GitHub Check: Test concurrent-merkle-tree
- GitHub Check: Test program-libs-fast
- GitHub Check: stateless-js-v1
- GitHub Check: cli-v2
- GitHub Check: system-programs (sdk-anchor-test-program, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -...
- GitHub Check: system-programs (token-escrow-test, [ "cargo test-sbf -p token-escrow" ])
- GitHub Check: system-programs (sdk-test-program, ["cargo-test-sbf -p sdk-test"])
- GitHub Check: system-programs (counter-test, ["cargo test-sbf -p counter"])
- GitHub Check: stateless-js-v2
- GitHub Check: lint
🔇 Additional comments (4)
sdk-libs/client/src/indexer/error.rs (2)
49-51: Excellent improvement to error message specificity.The expanded error message now provides clear, actionable guidance by specifying exactly what needs to be configured (
photon_urlinLightClientConfig) to resolve the initialization issue. This significantly improves the developer experience.
96-96: Good enhancement of unknown API error reporting.This change replaces the generic
"Unknown API error"message with the actual debug representation of the error, providing much more useful diagnostic information. This improvement works well with the coordinated change inphoton_indexer.rswhere empty error messages are now used as fallbacks.sdk-libs/client/src/rpc/client.rs (2)
685-712: Excellent localnet handling with appropriate feature flag differentiation.The localnet-specific logic provides sensible default test values and properly handles the difference between v2 and v1 configurations using feature flags. This eliminates unnecessary network calls during local development and testing.
The hardcoded pubkeys are appropriately differentiated by feature flags, ensuring the correct tree types are used.
714-729: Well-implemented network-aware lookup table selection.The logic correctly maps network types to appropriate lookup tables:
- Development networks (Devnet, Testnet, ZKTestnet) use devnet tables
- Production and custom URLs default to mainnet tables
This provides a sensible fallback strategy and maintains backward compatibility while adding network awareness.
* fix: unknown api error, and StateLookuptable not found * fix: get_latest_active_state_trees for localnet with hardcoded values * fix: lint
Summary by CodeRabbit
Bug Fixes
New Features