Skip to content

feat: forward txs to sequencer #1208

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

Conversation

yiweichi
Copy link
Member

@yiweichi yiweichi commented Jun 19, 2025

1. Purpose or design rationale of this PR

This PR add feature to enable RPC node forward transactions directly to sequencer.
txgossip.sequencerhttp: the sequencer's http rpc endpoint

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:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

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

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • Introduced three new CLI flags for transaction gossip control: disable broadcasting, disable receiving, and enable sequencer HTTP interface.
    • Added support for forwarding transactions to a remote sequencer via HTTP.
    • Enabled configuration options to control transaction gossip behavior and sequencer integration.
  • Bug Fixes

    • Transactions of unsupported types are now correctly rejected.
  • Chores

    • Updated the application patch version to 64.

Copy link

coderabbitai bot commented Jun 19, 2025

Walkthrough

This update introduces three new CLI flags for controlling transaction gossip broadcasting, receiving, and sequencer HTTP endpoint configuration. Corresponding fields are added to configuration structs and wiring logic. The transaction submission flow is extended to optionally forward transactions to a remote sequencer and conditionally bypass the local transaction pool based on these flags.

Changes

File(s) Change Summary
cmd/geth/main.go, cmd/geth/usage.go Added three new transaction gossip-related CLI flags to node flags and help usage groups.
cmd/utils/flags.go Defined new CLI flag for sequencer HTTP; updated SetEthConfig to set config fields conditionally based on mining flag.
eth/ethconfig/config.go Added TxGossipBroadcastDisabled, TxGossipReceivingDisabled, and TxGossipSequencerHTTP fields to the Config struct.
eth/backend.go Added sequencer RPC client field; updated constructor to initialize gossip flags and sequencer client; updated Stop to close RPC.
eth/api_backend.go Added disableTxPool field; revised SendTx to support forwarding to sequencer and conditional pool addition; added helper method.
params/version.go Incremented patch version constant from 63 to 64.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Node
    participant EthAPIBackend
    participant SequencerRPC
    participant TxPool

    User->>CLI: Start node with gossip flags
    CLI->>Node: Initialize with config
    Node->>EthAPIBackend: Pass gossip flags and sequencer endpoint

    User->>EthAPIBackend: SendTx(signedTx)
    EthAPIBackend->>EthAPIBackend: Check tx type
    alt BlobTxType
        EthAPIBackend-->>User: Return error
    else sequencerRPC configured
        EthAPIBackend->>SequencerRPC: Forward tx via eth_sendRawTransaction
        alt disableTxPool
            EthAPIBackend-->>User: Return (do not add to local pool)
        else
            EthAPIBackend->>TxPool: AddLocal(tx)
            alt AddLocal fails but sequencer ok
                EthAPIBackend-->>User: Return success (log warning)
            else
                EthAPIBackend-->>User: Return result/error
            end
        end
    else
        EthAPIBackend->>TxPool: AddLocal(tx)
        EthAPIBackend-->>User: Return result/error
    end
Loading

Possibly related PRs

Suggested reviewers

  • Thegaram
  • colinlyguo

Poem

Three new flags hop into view,
Gossip’s path now up to you!
Broadcast, receive, or sequencer send,
Control flows twist, but never bend.
Patch bumps up, the code’s refreshed—
A rabbit’s work, thoroughly enmeshed!
🐇✨


📜 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 9dd67ec and 7d6f953.

📒 Files selected for processing (1)
  • params/version.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • params/version.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)
✨ 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

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

🔭 Outside diff range comments (1)
eth/handler.go (1)

442-444: Fix potential nil pointer dereference in Stop method.

The Stop method unconditionally calls h.txsSub.Unsubscribe(), but h.txsSub will be nil when disableTxBroadcast is true since the subscription is not created in that case.

Add a nil check to prevent panic:

 func (h *handler) Stop() {
-	h.txsSub.Unsubscribe()        // quits txBroadcastLoop
+	if h.txsSub != nil {
+		h.txsSub.Unsubscribe()    // quits txBroadcastLoop
+	}
 	h.minedBlockSub.Unsubscribe() // quits blockBroadcastLoop
🧹 Nitpick comments (1)
eth/backend.go (1)

311-319: Consider making the connection timeout configurable.

The hardcoded 5-second timeout for the sequencer RPC connection may be insufficient for high-latency networks or during network congestion.

Consider adding a configuration option for the timeout:

-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	timeout := 5 * time.Second
+	if config.TxGossipSequencerTimeout > 0 {
+		timeout = config.TxGossipSequencerTimeout
+	}
+	ctx, cancel := context.WithTimeout(context.Background(), timeout)

Additionally, consider validating the HTTP endpoint format before attempting the connection to provide better error messages.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a43881d and 7f3ae1d.

📒 Files selected for processing (8)
  • cmd/geth/main.go (1 hunks)
  • cmd/geth/usage.go (1 hunks)
  • cmd/utils/flags.go (2 hunks)
  • eth/api_backend.go (4 hunks)
  • eth/backend.go (5 hunks)
  • eth/ethconfig/config.go (1 hunks)
  • eth/handler.go (4 hunks)
  • eth/handler_eth.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test
  • GitHub Check: check
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (go)
🔇 Additional comments (16)
eth/ethconfig/config.go (1)

234-236: LGTM! Clean configuration additions.

The new configuration fields for transaction gossip control are well-named, properly typed, and appropriately placed in the Config struct.

eth/handler_eth.go (1)

59-61: LGTM! Correct implementation of transaction receiving control.

The early return when disableTxReceiving is true ensures that transaction receiving can be completely disabled, which aligns with the PR objective.

cmd/geth/main.go (1)

179-181: LGTM! Proper CLI flag integration.

The three transaction gossip control flags are correctly added to the node configuration flags, making them available as command-line options.

eth/handler.go (4)

97-98: LGTM! Clean configuration structure additions.

The new fields for controlling transaction gossip behavior are properly added to the handler configuration.


138-139: LGTM! Proper field additions to handler struct.

The transaction gossip control fields are correctly added to the handler struct.


159-160: LGTM! Correct field initialization.

The configuration fields are properly initialized in the handler constructor.


425-430: LGTM! Proper conditional initialization of transaction broadcast.

The transaction broadcast loop initialization is correctly guarded by the disableTxBroadcast flag, preventing unnecessary resource allocation when broadcasting is disabled.

eth/backend.go (4)

112-114: LGTM: Sequencer RPC service field addition.

The new seqRPCService field is properly typed and documented. The placement within the "Scroll additions" section is appropriate.


289-290: LGTM: Handler configuration for transaction gossip control.

The new configuration flags for disabling transaction broadcast and receiving are properly integrated into the handler configuration.


300-300: LGTM: EthAPIBackend initialization with transaction gossip flag.

The addition of config.TxGossipReceivingDisabled parameter properly integrates the new transaction pool control functionality.


693-695: LGTM: Proper resource cleanup for sequencer RPC service.

The cleanup logic correctly checks for nil and closes the RPC client to prevent resource leaks.

eth/api_backend.go (3)

28-28: LGTM: Required imports for sequencer functionality.

The added imports for hexutil and log are necessary for transaction encoding and logging in the new sequencer forwarding logic.

Also applies to: 39-39


49-49: LGTM: Transaction pool control field addition.

The disableTxPool field provides clear control over local transaction pool behavior.


295-298: LGTM: Clean encapsulation of local transaction pool logic.

The sendTx helper method properly encapsulates the transaction pool addition logic with appropriate validation.

cmd/utils/flags.go (2)

896-909: LGTM: Well-structured flag definitions.

The three new transaction gossip flags are properly defined with clear names, appropriate types, and descriptive usage strings. The flag naming follows the established conventions in the codebase.


1807-1814: LGTM: Correct flag-to-config mapping with appropriate logging.

The boolean flag assignments are implemented correctly, following the established pattern of other flags in this function. The informational logging provides useful visibility into the configuration state.

@yiweichi yiweichi changed the title Feat/forward txs to sequencer feat: forward txs to sequencer Jun 19, 2025
colinlyguo
colinlyguo previously approved these changes Jun 20, 2025
@colinlyguo colinlyguo self-requested a review June 20, 2025 21:24
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