Skip to content

feat: add logs to track tx and block propagation delay #1184

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

colinlyguo
Copy link
Member

@colinlyguo colinlyguo commented May 12, 2025

1. Purpose or design rationale of this PR

Notion task: https://www.notion.so/scrollzkp/N1-Benchmark-monitor-network-latency-1eb7792d22af801dacbdc86ea433199d

This PR adds logs to track the following metrics:

  • transaction propagation delay (how long does it from receiving a tx to forward it to the next node).
  • block propagation delay (how long does it from receiving a tx to forward it to the next node).

This PR also decreases some debug logs to trace logs since they are not used anymore, so that when enabling the "tracing logs" to track the above delay metrics in sampled nodes. The logs won't flood.

The remaining tasks to build Grafana dashboards: some scripts to aggregate and calculate timestamp diffs based on Loki logs, grouped by transaction hash and block hash.

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change

Summary by CodeRabbit

  • Style

    • Improved and standardized logging output for block and transaction broadcasting, as well as protocol handlers.
    • Adjusted log levels for various messages to reduce verbosity and provide clearer debug information.
  • Chores

    • Updated patch version number.

Copy link

coderabbitai bot commented May 12, 2025

Walkthrough

This change set primarily updates logging levels and adds new debug log statements across several Ethereum protocol handler files to improve log granularity and consistency. Additionally, the patch version constant is incremented. There are no changes to the core logic, control flow, or exported interfaces.

Changes

File(s) Change Summary
eth/fetcher/tx_fetcher.go Changed log level for "Scheduling transaction retrieval" from Debug to Trace in TxFetcher.scheduleFetches.
eth/handler.go Added debug logs for block and transaction broadcasts; changed some logs from Debug to Trace for consistency.
eth/protocols/eth/handlers.go Lowered log levels from Debug to Trace for decoding failures and message processing; added new debug logs for received blocks and pooled transactions.
eth/protocols/eth/peer.go Changed log level for transaction request from Debug to Trace in Peer.RequestTxs.
params/version.go Incremented VersionPatch constant from 44 to 45.

Sequence Diagram(s)

sequenceDiagram
    participant Handler
    participant Peer
    participant Logger

    Handler->>Logger: Debug log (block/tx broadcast info)
    Handler->>Peer: Broadcast block/transactions
    Peer->>Logger: Trace log (transaction request)
    Handler->>Logger: Trace log (broadcast/announce events)
Loading
sequenceDiagram
    participant ProtocolHandler
    participant Logger
    participant Peer

    ProtocolHandler->>Logger: Trace log (decoding failures, nil txs)
    ProtocolHandler->>Logger: Debug log (received block info)
    ProtocolHandler->>Logger: Debug log (received pooled tx info)
    ProtocolHandler->>Peer: Process message
Loading

Suggested reviewers

  • omerfirmak
  • yiweichi

Poem

Logs now whisper, logs now shout,
Debug and Trace have swapped about!
Blocks and transactions, clearly seen,
In hex and hashes, crisp and clean.
Patch bumped up, the code’s refined—
🐇 Cheers to logs, so well aligned!

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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

@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 (2)
eth/handler.go (2)

524-524: Refine transaction broadcast log phrasing
The message "Transactions being broadcasted to" is a bit awkward. Consider simplifying to:

- log.Trace("Transactions being broadcasted to", "peer", peer.String(), "len", len(hashes))
+ log.Trace("Transactions broadcast to", "peer", peer.String(), "len", len(hashes))

530-530: Refine transaction announcement log phrasing
Similarly, update:

- log.Trace("Transactions being announced to", "peer", peer.String(), "len", len(hashes))
+ log.Trace("Transactions announced to", "peer", peer.String(), "len", len(hashes))
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3edb331 and f908e5d.

📒 Files selected for processing (5)
  • eth/fetcher/tx_fetcher.go (1 hunks)
  • eth/handler.go (4 hunks)
  • eth/protocols/eth/handlers.go (5 hunks)
  • eth/protocols/eth/peer.go (1 hunks)
  • params/version.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)
🔇 Additional comments (17)
params/version.go (1)

27-27: Version increment for logging enhancements

The patch version is incremented from 44 to 45, which is appropriate for the non-breaking changes being introduced in this PR to enhance logging for transaction and block propagation delay tracking.

eth/protocols/eth/peer.go (1)

439-439: Reduced log verbosity for transaction requests

The log level has been appropriately changed from Debug to Trace, aligning with the PR objective to reduce the verbosity of existing debug logs to prevent log flooding when tracing is enabled on sampled nodes.

eth/fetcher/tx_fetcher.go (1)

797-797: Reduced log verbosity for transaction scheduling

The log level has been appropriately changed from Debug to Trace, aligning with the PR objective to reduce the verbosity of existing debug logs to prevent log flooding when tracing is enabled on sampled nodes.

eth/protocols/eth/handlers.go (11)

297-297: Added debug log for tracking block propagation

This new debug log is useful for tracking block propagation delay, directly addressing one of the main objectives of the PR to add logging functionality that tracks network latency metrics.


366-366: Reduced log verbosity for decoding failures

The log level has been appropriately changed from Debug to Trace for decoding failures, aligning with the PR objective to reduce the verbosity of existing debug logs.


371-371: Reduced log verbosity for transaction handling

The log level has been appropriately changed from Debug to Trace for transaction handling, aligning with the PR objective to reduce the verbosity of existing debug logs.


383-383: Reduced log verbosity for decoding failures

The log level has been appropriately changed from Debug to Trace for decoding failures, aligning with the PR objective to reduce the verbosity of existing debug logs.


388-391: Added detailed logging for transaction propagation

The new debug logs for transaction propagation will help track the transaction propagation delay (a key objective of this PR). The detailed logging includes both trace and debug level entries to provide comprehensive tracking while minimizing log flooding.


434-434: Reduced log verbosity for transaction decoding failures

The log level has been appropriately changed from Debug to Trace for transaction decoding failures, consistent with the PR objective to reduce verbosity.


437-437: Reduced log verbosity for transaction handling

The log level has been appropriately changed from Debug to Trace for transaction handling, consistent with the PR objective to reduce verbosity.


443-443: Reduced log verbosity for nil transaction handling

The log level has been appropriately changed from Debug to Trace for nil transaction handling, consistent with the PR objective to reduce verbosity.


460-460: Reduced log verbosity for decoding failures

The log level has been appropriately changed from Debug to Trace for decoding failures, consistent with the PR objective to reduce verbosity.


463-463: Reduced log verbosity for pooled transaction handling

The log level has been appropriately changed from Debug to Trace for pooled transaction handling, consistent with the PR objective to reduce verbosity.


469-469: Reduced log verbosity for nil transaction handling

The log level has been appropriately changed from Debug to Trace for nil transaction handling, consistent with the PR objective to reduce verbosity.

eth/handler.go (3)

458-458: Block broadcast start logging added
The new debug log in BroadcastBlock records the block hash, number, and size before propagation—this is a useful instrumentation for measuring propagation latency.


475-475: Verify block.ReceivedAt is populated
The trace log calculates delay with time.Since(block.ReceivedAt). Please confirm that block.ReceivedAt is consistently set when the block is received from peers so that the measured propagation delay is accurate.


483-483: Verify block.ReceivedAt on announcement
Similarly, the announcement trace log relies on block.ReceivedAt. Ensure that ReceivedAt remains valid through both propagation and announcement phases.

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