-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Make Historical Query on Redial Dynamic #24
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
base: v2
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a dynamic lookback for historical queries when a websocket redial occurs by calculating the average block interval dynamically.
- Introduced a new metric (AverageBlockIntervalGauge) in the metrics package and updated its setter.
- Added functions in the Ethereum module to track the current block height and average block interval.
- Updated the redial logic in cmd/start.go to calculate the dynamic lookback based on the last observed block and average block interval.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| metrics/metrics.go | Added a new gauge metric and setter for the average block interval. |
| ethereum/start.go | Added concurrent routines to track block height and average block interval. |
| ethereum/listener.go | Updated redial handling to capture the last observed block. |
| ethereum/chain.go | Introduced functions for tracking the current height and average block time. |
| docs/prometheus.md | Documented the new gauge metric for the average block interval. |
| cmd/start.go | Modified historical event lookback logic to use the dynamic interval. |
Comments suppressed due to low confidence (1)
docs/prometheus.md:29
- The metric name and type 'average_block_interval_seconds_guage'/'Guage' appear to be misspelled; consider correcting them to 'average_block_interval_seconds_gauge' and 'Gauge'.
| average_block_interval_seconds_guage | The average time it takes for a block to be produced in seconds. Update every hour. | Guage |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Currently, if the websocket becomes disconnect and needs to redial the client, the lookback period, used to catch up on any missed history, is hard coded to query the last 50 blocks.
This PR makes this lookback dynamic based on the last observed block and the average block interval.
This dynamic lookback will be more necessary as we introduce support for more chains with varying block intervals.