Skip to content

Conversation

@smypmsa
Copy link
Member

@smypmsa smypmsa commented Jun 28, 2025

Summary by CodeRabbit

  • New Features

    • Added latency metrics to monitor the performance of the eth_getLogs method for Arbitrum, Base, BNB Smart Chain, and Ethereum networks.
  • Improvements

    • Enhanced robustness of block latency tracking on Ethereum by improving subscription logic for new block events.
  • Removals

    • Removed the WebSocket-based log latency metric for Ethereum, simplifying latency monitoring.

@vercel
Copy link

vercel bot commented Jun 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
chainstack-rpc-dashboard-germany ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2025 2:36pm
chainstack-rpc-dashboard-singapore ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2025 2:36pm
chainstack-rpc-dashboard-us-west ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2025 2:36pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 28, 2025

Walkthrough

This update introduces the HTTPGetLogsLatencyMetric class to the Arbitrum, Base, BNB Smart Chain, and Ethereum metric modules, enabling latency measurement for the eth_getLogs RPC method on each network. The new metric is registered in the corresponding API read handlers. Additionally, the complex WSLogLatencyMetric for Ethereum is removed, and the block subscription logic is improved.

Changes

File(s) Change Summary
metrics/arbitrum.py, metrics/base.py, metrics/bnbsc.py, metrics/ethereum.py Added HTTPGetLogsLatencyMetric class for eth_getLogs latency; parameters target USDC (Arbitrum, Base, Ethereum) or WBNB (BNBSC) transfers.
api/read/arbitrum.py, api/read/base.py, api/read/bnbsc.py, api/read/ethereum.py Imported and registered the new HTTPGetLogsLatencyMetric in the METRICS list for each network’s API handler.
metrics/ethereum.py Removed WSLogLatencyMetric class; improved WSBlockLatencyMetric.subscribe method with fallback logic for subscription.
metrics/ethereum.py Removed unused imports (aiohttp, Any, Optional) related to the deleted class.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Read_Handler
    participant HTTPGetLogsLatencyMetric
    participant RPC_Node

    Client->>API_Read_Handler: Make request
    API_Read_Handler->>HTTPGetLogsLatencyMetric: Collect latency metric
    HTTPGetLogsLatencyMetric->>RPC_Node: Send eth_getLogs (with fixed params)
    RPC_Node-->>HTTPGetLogsLatencyMetric: Respond with logs
    HTTPGetLogsLatencyMetric-->>API_Read_Handler: Report latency
    API_Read_Handler-->>Client: Return response
Loading

Possibly related PRs

Poem

In the meadow of metrics, a new log hops in,
HTTPGetLogsLatencyMetric begins its spin.
Out with the WebSocket, in with the call,
Measuring transfer logs—no hassle at all!
With each new hop, latency’s tracked—
The rabbit’s code garden is neatly packed.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need 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)

  • @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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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
Contributor

@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: 1

🧹 Nitpick comments (8)
metrics/base.py (2)

109-110: Add missing docstring for the method property.

The static analysis correctly identifies a missing docstring for the public method property.

 @property
 def method(self) -> str:
+    """Return the JSON-RPC method name for this metric."""
     return "eth_getLogs"

118-121: Fix line length violations.

Lines 118 and 120 exceed the 88-character limit flagged by static analysis.

-                "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",  # USDC on Base
+                "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",  # USDC
                 "topics": [
-                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"  # Transfer event
+                    # Transfer event signature
+                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                 ],
metrics/bnbsc.py (2)

109-110: Add missing docstring for the method property.

Static analysis correctly identifies the missing docstring.

 @property
 def method(self) -> str:
+    """Return the JSON-RPC method name for this metric."""
     return "eth_getLogs"

118-120: Fix line length violations.

Lines 118 and 120 exceed the 88-character limit.

-                "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",  # Wrapped BNB on BSC
+                "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",  # WBNB
                 "topics": [
-                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"  # Transfer event
+                    # Transfer event signature  
+                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                 ],
metrics/arbitrum.py (2)

108-110: Add missing docstring for the method property.

The public property needs a docstring for consistency with other methods in the codebase.

 @property
 def method(self) -> str:
+    """Return the RPC method name for eth_getLogs."""
     return "eth_getLogs"

118-121: Fix line length violations.

Lines exceed the 88-character limit set by the project's style guide.

-                "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",  # USDC on Arbitrum
+                # USDC on Arbitrum
+                "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
                 "topics": [
-                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"  # Transfer event
+                    # Transfer event
+                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                 ],
metrics/ethereum.py (2)

116-118: Add missing docstring for the method property.

Maintain consistency with other methods in the codebase.

 @property
 def method(self) -> str:
+    """Return the RPC method name for eth_getLogs."""
     return "eth_getLogs"

126-129: Fix line length violation.

Line 128 exceeds the 88-character limit.

                 "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",  # USDC
                 "topics": [
-                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"  # Transfer event
+                    # Transfer event
+                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                 ],
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d3b244 and 47a4f49.

📒 Files selected for processing (8)
  • api/read/arbitrum.py (1 hunks)
  • api/read/base.py (1 hunks)
  • api/read/bnbsc.py (1 hunks)
  • api/read/ethereum.py (1 hunks)
  • metrics/arbitrum.py (1 hunks)
  • metrics/base.py (1 hunks)
  • metrics/bnbsc.py (1 hunks)
  • metrics/ethereum.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
api/read/ethereum.py (2)
metrics/ethereum.py (1)
  • HTTPGetLogsLatencyMetric (113-131)
config/defaults.py (1)
  • MetricsServiceConfig (6-42)
api/read/bnbsc.py (2)
metrics/bnbsc.py (1)
  • HTTPGetLogsLatencyMetric (105-123)
config/defaults.py (1)
  • MetricsServiceConfig (6-42)
metrics/arbitrum.py (2)
metrics/base.py (5)
  • HTTPGetLogsLatencyMetric (105-123)
  • method (10-11)
  • method (29-30)
  • get_params_from_state (14-22)
  • get_params_from_state (38-40)
common/metric_types.py (1)
  • HttpCallLatencyMetricBase (112-235)
metrics/bnbsc.py (2)
metrics/base.py (5)
  • HTTPGetLogsLatencyMetric (105-123)
  • method (10-11)
  • method (29-30)
  • get_params_from_state (14-22)
  • get_params_from_state (38-40)
common/metric_types.py (1)
  • HttpCallLatencyMetricBase (112-235)
🪛 Ruff (0.11.9)
metrics/base.py

109-109: Missing docstring in public method

(D102)


120-120: Line too long (106 > 88)

(E501)

metrics/arbitrum.py

109-109: Missing docstring in public method

(D102)


118-118: Line too long (92 > 88)

(E501)


120-120: Line too long (106 > 88)

(E501)

metrics/bnbsc.py

109-109: Missing docstring in public method

(D102)


118-118: Line too long (94 > 88)

(E501)


120-120: Line too long (106 > 88)

(E501)

metrics/ethereum.py

117-117: Missing docstring in public method

(D102)


128-128: Line too long (106 > 88)

(E501)

🔇 Additional comments (9)
metrics/base.py (1)

105-123: Well-implemented metric class following established patterns.

The HTTPGetLogsLatencyMetric class correctly implements the required interface and provides appropriate parameters for monitoring USDC transfers on Base network.

metrics/bnbsc.py (1)

105-123: Solid implementation once documentation is corrected.

The metric class correctly implements the required interface for BNB Smart Chain monitoring.

api/read/base.py (1)

9-9: Correctly registers the new HTTPGetLogsLatencyMetric.

The import and metric registration follow the established pattern and integrate the new eth_getLogs latency monitoring for Base network.

Also applies to: 26-26

api/read/arbitrum.py (1)

9-9: Correctly registers the HTTPGetLogsLatencyMetric for Arbitrum.

The changes follow the same pattern as other networks and properly integrate eth_getLogs latency monitoring.

Also applies to: 26-26

api/read/bnbsc.py (1)

9-9: Correctly registers the HTTPGetLogsLatencyMetric for BNB Smart Chain.

The changes maintain consistency with the pattern used across all network-specific API handlers, properly enabling eth_getLogs latency monitoring.

Also applies to: 26-26

api/read/ethereum.py (1)

9-9: LGTM! Clean integration of the new eth_getLogs metric.

The HTTPGetLogsLatencyMetric is properly imported and registered following the established pattern.

Also applies to: 24-24

metrics/arbitrum.py (1)

118-118: Confirmed native USDC address on Arbitrum One is correct

  • File metrics/arbitrum.py, line 118:
    “0xaf88d065e77c8cC2239327C5EDb3A432268e5831” is the official native USDC contract deployed by Circle on Arbitrum One.
metrics/ethereum.py (2)

191-240: Great improvement to WebSocket subscription compatibility!

The fallback logic elegantly handles providers that don't support the False flag parameter in eth_subscribe, improving compatibility across different RPC providers.


126-126: USDC contract address verified

The USDC contract address in metrics/ethereum.py (line 126) –
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 – matches the official Ethereum mainnet address confirmed by Circle and Etherscan. No changes required.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@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 (1)
metrics/bnbsc.py (1)

105-123: LGTM! Address formatting and documentation issues.

The implementation correctly adds eth_getLogs latency measurement for BNB Smart Chain. The contract address and Transfer event topic are accurate for Wrapped BNB on BSC.

Apply this diff to fix formatting and add missing docstring:

 class HTTPGetLogsLatencyMetric(HttpCallLatencyMetricBase):
     """Collects call latency for the eth_getLogs method."""

     @property
     def method(self) -> str:
+        """Return the JSON-RPC method name."""
         return "eth_getLogs"

     @staticmethod
     def get_params_from_state(state_data: dict) -> list:
         """Get parameters for Wrapped BNB transfer logs from latest block."""
         return [
             {
                 "fromBlock": "latest",
-                "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",  # Wrapped BNB on BSC
+                "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",  # Wrapped BNB
                 "topics": [
-                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"  # Transfer event
+                    # Transfer event signature
+                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                 ],
             }
         ]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47a4f49 and a53c317.

📒 Files selected for processing (1)
  • metrics/bnbsc.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
metrics/bnbsc.py

109-109: Missing docstring in public method

(D102)


118-118: Line too long (94 > 88)

(E501)


120-120: Line too long (106 > 88)

(E501)

@smypmsa smypmsa merged commit a8da5b8 into master Jun 28, 2025
5 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