Skip to content

refactor: make tx forwarding to sequencer non-blocking if tx pool is enabled #1227

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 6 commits into
base: develop
Choose a base branch
from

Conversation

jonastheis
Copy link

@jonastheis jonastheis commented Jul 25, 2025

This PR makes tx forwarding non-blocking if the tx pool is enabled. If the tx pool is disabled (private mempool mode) then the forwarding is done synchronously to notify the user. In the additional case this is not necessary as it is optional and in the failure case the transaction will simply be broadcast like usual via gossip (public mempool).

Summary by CodeRabbit

  • Refactor
    • Enhanced transaction sending to handle synchronous and asynchronous modes based on transaction pool status, improving reliability.
    • Improved HTTP request handling with context support for better request management.
  • Chores
    • Updated the patch version number.

Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

The SendTx method in EthAPIBackend was refactored to move sequencer RPC logic into a new helper method, sendToSequencer, improving code organization and adjusting control flow for synchronous or asynchronous sending based on the transaction pool state. Additionally, the patch version in the params package was incremented. The HTTP request in BeaconNodeClient was changed to use explicit request creation with context propagation.

Changes

File(s) Change Summary
EthAPIBackend refactor
eth/api_backend.go
Refactored SendTx to delegate sending transactions to new helper sendToSequencer; adjusted control flow for synchronous vs asynchronous sending based on disableTxPool.
Version update
params/version.go
Incremented VersionPatch constant from 74 to 76.
HTTP request context addition
rollup/da_syncer/blob_client/beacon_node_client.go
Changed HTTP request in GetBlobByVersionedHashAndBlockTime from http.Client.Get to explicit http.NewRequestWithContext and client.Do for context propagation and added error handling for request creation.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant EthAPIBackend
    participant SequencerRPC

    Client->>EthAPIBackend: SendTx(signedTx)
    alt TxPool Disabled
        EthAPIBackend->>EthAPIBackend: sendToSequencer(ctx, signedTx)
        EthAPIBackend->>SequencerRPC: eth_sendRawTransaction
        SequencerRPC-->>EthAPIBackend: Response/Error
        EthAPIBackend-->>Client: Error or nil
    else TxPool Enabled
        EthAPIBackend->>EthAPIBackend: goroutine sendToSequencer(ctx, signedTx)
        EthAPIBackend-->>Client: nil
        EthAPIBackend->>SequencerRPC: eth_sendRawTransaction (async)
        SequencerRPC-->>EthAPIBackend: Response/Error (logged)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • feat: forward txs to sequencer #1208: Refactors EthAPIBackend.SendTx to delegate sending transactions to a helper with sync/async behavior; related as it modifies the same method and sequencer forwarding logic.

Suggested reviewers

  • yiweichi
  • georgehao

Poem

🐇 In the warren, code refines its tune,
Transactions now sent by the light of the moon.
Helpers emerge, async flows bloom,
Patch seventy-six hops into the room!
With sequencer calls neat and clear,
The rabbits code on, full of cheer.
✨🐰

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 06c07b6 and 48f88e3.

📒 Files selected for processing (1)
  • rollup/da_syncer/blob_client/beacon_node_client.go (1 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). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
rollup/da_syncer/blob_client/beacon_node_client.go (1)

117-121: LGTM! Excellent improvement to context handling.

The change from using c.client.Get() to explicitly creating a request with http.NewRequestWithContext() provides proper context propagation for request cancellation and timeouts. This also adds necessary error handling for request creation that was previously missing.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/sequencer-forward-non-blocking

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 generate unit tests to generate unit tests for 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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2f379 and 85222a9.

📒 Files selected for processing (2)
  • eth/api_backend.go (2 hunks)
  • params/version.go (1 hunks)
🔇 Additional comments (3)
params/version.go (1)

27-27: Version increment looks appropriate.

The patch version bump from 74 to 75 correctly reflects the refactoring changes in this PR.

eth/api_backend.go (2)

22-22: Import addition is correct.

The fmt import is properly added to support error formatting in the new sendToSequencer method.


297-307: Well-implemented helper method.

The sendToSequencer method properly extracts the sequencer RPC logic with appropriate error handling and clear separation of concerns. The error messages are descriptive and the method follows the single responsibility principle.

return err
// If the transaction pool is disabled, then we need to make sure that we send the transaction to the sequencer RPC synchronously.
if b.disableTxPool {
return b.sendToSequencer(ctx, signedTx)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return b.sendToSequencer(ctx, signedTx)
err := b.sendToSequencer(ctx, signedTx)
if err != nil {
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
}
return err

Copy link
Author

Choose a reason for hiding this comment

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

done in f0362d4

// If the transaction pool is enabled, we send the transaction to the sequencer RPC asynchronously as this is
// additional to the public mempool.
go func() {
err := b.sendToSequencer(ctx, signedTx)
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
if err != nil {
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err)
}

Copy link
Author

Choose a reason for hiding this comment

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

done in f0362d4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants