Skip to content
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

[EASY] Improve mempool submission expired logs #3272

Merged
merged 4 commits into from
Feb 11, 2025

Conversation

squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Feb 7, 2025

Currently, it is not really convenient to debug mempool submission errors, especially when a tx has expired. This PR adds current block number info, when the submission started and the deadline. The expired tx hash would help search for the logs associated with it without looking into the code to find the required messages to filter in.

Summary by CodeRabbit

  • New Features
    • Enhanced error reporting for transactions that fail due to timing, now providing additional context such as transaction identifiers and associated timing details.
    • Improved logging during transaction submission and verification by including current block information, aiding in better traceability and monitoring.
  • Bug Fixes
    • Updated error handling logic to accommodate additional data for the Expired error variant, allowing for more detailed future handling.

@squadgazzz squadgazzz requested a review from a team as a code owner February 7, 2025 14:38
Copy link

coderabbitai bot commented Feb 7, 2025

Walkthrough

This pull request enhances error handling and logging across several modules. The main change is in the Mempools' submit method, where the Expired error variant now carries additional information (transaction ID, submission block, and deadline). Logging has been updated to include the current block number at key points. Similarly, the notify and observe modules have been updated to pattern match on the enriched Expired error without altering the overall logic.

Changes

File(s) Change Summary
crates/driver/src/domain/mempools.rs Modified the submit method to enrich the Expired error variant with tx_id, submitted_at_block, and submission_deadline; added logging of the current block number.
crates/driver/src/infra/notify/mod.rs,
crates/driver/src/infra/observe/mod.rs
Updated error handling to use pattern matching with destructuring for the Expired error variant, accommodating the additional contextual data.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant M as Mempool
    participant L as Logger

    C->>M: submit(transaction)
    M->>L: Log submission (tx hash, current block)
    M->>M: Check transaction expiration
    alt Transaction expired
        M->>L: Log error (tx_id, submitted_at_block, submission_deadline, current block)
        M-->>C: Return Expired Error {tx_id, submitted_at_block, submission_deadline}
    else Transaction valid
        M->>L: Log confirmation check (current block)
        M-->>C: Return success
    end
Loading

Poem

I'm a happy bunny on the run,
Logging each block, oh what fun!
Errors now tell a tale so clear,
With tx details hopping near,
A code chanson to brighten the sun!
🐰✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 41c644c and 1267209.

📒 Files selected for processing (1)
  • crates/driver/src/domain/mempools.rs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: unit-tests
  • GitHub Check: test-local-node
  • GitHub Check: test-forked-node
  • GitHub Check: test-driver
🔇 Additional comments (3)
crates/driver/src/domain/mempools.rs (3)

129-130: LGTM! Enhanced logging provides valuable context.

The addition of the current block number in the debug log helps track transaction lifecycle, which aligns well with the PR's objective of improving debugging for expired transactions.

Note: As discussed in a past review, while this block number might not be the exact block where the transaction gets minted, it correctly represents the submission time and works well with the transaction monitoring mechanism below.


135-135: LGTM! Improved transaction monitoring.

The addition of the current block number in the confirmation check log creates a clear trail of the transaction's progress through blocks.


166-170: LGTM! Enhanced error context improves debugging.

The enriched Expired error variant and message now include all relevant information (transaction ID, submission block, and deadline) which significantly improves the ability to debug expired transactions.

Note: This addresses the past review comment about showing fields in the error message.

Also applies to: 255-263


🪧 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.

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. (Beta)
  • @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

@m-lord-renkse m-lord-renkse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that rabbit thing? 😅

crates/driver/src/domain/mempools.rs Show resolved Hide resolved
crates/driver/src/domain/mempools.rs Show resolved Hide resolved
@squadgazzz squadgazzz added the hotfix Labels PRs that should be applied into production right away label Feb 10, 2025
@squadgazzz squadgazzz removed the hotfix Labels PRs that should be applied into production right away label Feb 11, 2025
@squadgazzz squadgazzz enabled auto-merge (squash) February 11, 2025 12:54
@squadgazzz squadgazzz merged commit ce951e3 into main Feb 11, 2025
11 checks passed
@squadgazzz squadgazzz deleted the improve-mempool-submission-logs branch February 11, 2025 13:00
@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants